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

Last change on this file since 7029 was 6133, checked in by sandervl, 24 years ago

stack alignment change

File size: 3.7 KB
Line 
1/* $Id: winexebase.cpp,v 1.18 2001-06-27 19:09:36 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 <cpuhlp.h>
30#include "exceptions.h"
31#include "exceptutil.h"
32#include "cio.h"
33
34#include "conwin.h" // Windows Header for console only
35#include "console.h"
36
37#define DBG_LOCALLOG DBG_winexebase
38#include "dbglocal.h"
39
40BOOL fExeStarted = FALSE;
41Win32ExeBase *WinExe = NULL;
42
43//******************************************************************************
44//******************************************************************************
45BOOL IsExeStarted()
46{
47 return fExeStarted;
48}
49//******************************************************************************
50//******************************************************************************
51Win32ExeBase::Win32ExeBase(HINSTANCE hInstance)
52 : Win32ImageBase(hInstance),
53 fConsoleApp(FALSE)
54{
55 WinExe = this;
56}
57//******************************************************************************
58//******************************************************************************
59Win32ExeBase::~Win32ExeBase()
60{
61 QueueItem *item;
62 Win32DllBase *dll;
63
64 //First delete all dlls loaded by LoadLibrary
65 //Then delete all dlls that were loaded by the exe
66 //(NOTE: This is what NT does; first delete loadlib dlls in LIFO order and
67 // then the exe dlls)
68 Win32DllBase::deleteDynamicLibs();
69
70 dprintf(("Win32ExeBase::~Win32ExeBase"));
71#ifdef DEBUG_ENABLELOG_LEVEL2
72 item = loadedDlls.Head();
73 dll = (Win32DllBase *)loadedDlls.getItem(item);
74 dll->printListOfDlls();
75#endif
76
77 item = loadedDlls.Head();
78 while(item) {
79 dll = (Win32DllBase *)loadedDlls.getItem(item);
80 if(dll == NULL) {
81 dprintf(("ERROR: Win32ExeBase::~Win32ExeBase: dll item == NULL!!"));
82 DebugInt3();
83 break;
84 }
85 dll->Release();
86 item = loadedDlls.getNext(item);
87 }
88
89 Win32DllBase::deleteAll();
90
91 WinExe = NULL;
92}
93//******************************************************************************
94//******************************************************************************
95ULONG Win32ExeBase::start()
96{
97 WINEXCEPTION_FRAME exceptFrame;
98 ULONG rc;
99
100 if(getenv("WIN32_IOPL2")) {
101 io_init1();
102 }
103 dprintf(("Start executable %X\n", WinExe));
104
105 fExeStarted = TRUE;
106
107 //Note: The Win32 exception structure references by FS:[0] is the same
108 // in OS/2
109 OS2SetExceptionHandler((void *)&exceptFrame);
110 SetWin32TIB();
111
112 //Set FPU control word to 0x27F (same as in NT)
113 CONTROL87(0x27F, 0xFFF);
114 dprintf(("KERNEL32: Win32ExeBase::start exe at %08xh\n",
115 (void*)entryPoint ));
116 rc = CallEntryPoint(entryPoint, NULL);
117 RestoreOS2TIB();
118
119 OS2UnsetExceptionHandler((void *)&exceptFrame);
120
121 return rc;
122}
123//******************************************************************************
124//******************************************************************************
125BOOL Win32ExeBase::isDll()
126{
127 return FALSE;
128}
129//******************************************************************************
130//******************************************************************************
Note: See TracBrowser for help on using the repository browser.