source: trunk/src/kernel32/winexebase.cpp@ 4310

Last change on this file since 4310 was 4244, checked in by sandervl, 25 years ago

LX exe command line fix

File size: 3.8 KB
Line 
1/* $Id: winexebase.cpp,v 1.11 2000-09-12 19:01:59 sandervl Exp $ */
2
3/*
4 * Win32 exe base class
5 *
6 * Copyright 1998-1999 Sander van Leeuwen (sandervl@xs4all.nl)
7 *
8 *
9 * Project Odin Software License can be found in LICENSE.TXT
10 *
11 */
12#define INCL_DOSFILEMGR /* File Manager values */
13#define INCL_DOSERRORS /* DOS Error values */
14#define INCL_DOSPROCESS /* DOS Process values */
15#define INCL_DOSMISC /* DOS Miscellanous values */
16#define INCL_WIN
17#include <os2wrap.h> //Odin32 OS/2 api wrappers
18#include <stdio.h>
19#include <string.h>
20#include <stdlib.h>
21#include <iostream.h>
22#include <fstream.h>
23#include <misc.h>
24#include <win32type.h>
25#include <winexebase.h>
26#include <windllbase.h>
27#include <wprocess.h>
28#include <pefile.h>
29#include "exceptions.h"
30#include "exceptutil.h"
31#include "cio.h"
32
33#include "conwin.h" // Windows Header for console only
34#include "console.h"
35
36#define DBG_LOCALLOG DBG_winexebase
37#include "dbglocal.h"
38
39BOOL fExeStarted = FALSE;
40Win32ExeBase *WinExe = NULL;
41
42//******************************************************************************
43//******************************************************************************
44BOOL IsExeStarted()
45{
46 return fExeStarted;
47}
48//******************************************************************************
49//******************************************************************************
50Win32ExeBase::Win32ExeBase(HINSTANCE hInstance)
51 : Win32ImageBase(hInstance),
52 fConsoleApp(FALSE)
53{
54 WinExe = this;
55}
56//******************************************************************************
57//******************************************************************************
58Win32ExeBase::~Win32ExeBase()
59{
60 QueueItem *item;
61 Win32DllBase *dll;
62
63 //First delete all dlls loaded by LoadLibrary
64 //Then delete all dlls that were loaded by the exe
65 //(NOTE: This is what NT does; first delete loadlib dlls in LIFO order and
66 // then the exe dlls)
67 Win32DllBase::deleteDynamicLibs();
68
69 dprintf(("Win32ExeBase::~Win32ExeBase"));
70#ifdef DEBUG_ENABLELOG_LEVEL2
71 item = loadedDlls.Head();
72 dll = (Win32DllBase *)loadedDlls.getItem(item);
73 dll->printListOfDlls();
74#endif
75
76 item = loadedDlls.Head();
77 while(item) {
78 dll = (Win32DllBase *)loadedDlls.getItem(item);
79 if(dll == NULL) {
80 dprintf(("ERROR: Win32ExeBase::~Win32ExeBase: dll item == NULL!!"));
81 DebugInt3();
82 break;
83 }
84 dll->Release();
85 item = loadedDlls.getNext(item);
86 }
87
88 Win32DllBase::deleteAll();
89
90 WinExe = NULL;
91}
92//******************************************************************************
93//******************************************************************************
94ULONG Win32ExeBase::start()
95{
96 WINEXCEPTION_FRAME exceptFrame;
97 ULONG rc;
98
99 if(getenv("WIN32_IOPL2")) {
100 io_init1();
101 }
102 dprintf(("Start executable %X\n", WinExe));
103
104 fExeStarted = TRUE;
105
106 //Note: The Win32 exception structure references by FS:[0] is the same
107 // in OS/2
108 OS2SetExceptionHandler((void *)&exceptFrame);
109 SetWin32TIB();
110
111 //Allocate TLS index for this module
112 tlsAlloc();
113 tlsAttachThread(); //setup TLS (main thread)
114
115 //Set default FPU control word (no exceptions); same as in NT
116 _control87(0x27F, 0xFFF);
117 ULONG Size = 16, Attr;
118 rc = DosQueryMem((PVOID) (entryPoint), &Size, &Attr);
119 dprintf(("Start exe; Attr = %x, rc = %d", Attr, rc));
120 rc = ((WIN32EXEENTRY)entryPoint)(NULL);
121 RestoreOS2TIB();
122
123 OS2UnsetExceptionHandler((void *)&exceptFrame);
124
125 return rc;
126}
127//******************************************************************************
128//******************************************************************************
129BOOL Win32ExeBase::isDll()
130{
131 return FALSE;
132}
133//******************************************************************************
134//******************************************************************************
Note: See TracBrowser for help on using the repository browser.