1 | /* $Id: winexebase.cpp,v 1.3 1999-11-24 19:31:23 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 | BOOL fExeStarted = FALSE;
|
---|
37 | Win32ExeBase *WinExe = NULL;
|
---|
38 |
|
---|
39 | //******************************************************************************
|
---|
40 | //******************************************************************************
|
---|
41 | BOOL IsExeStarted()
|
---|
42 | {
|
---|
43 | return fExeStarted;
|
---|
44 | }
|
---|
45 | //******************************************************************************
|
---|
46 | //******************************************************************************
|
---|
47 | Win32ExeBase::Win32ExeBase(HINSTANCE hInstance)
|
---|
48 | : Win32ImageBase(hInstance),
|
---|
49 | fConsoleApp(FALSE),
|
---|
50 | cmdline(NULL)
|
---|
51 | {
|
---|
52 | WinExe = this;
|
---|
53 | }
|
---|
54 | //******************************************************************************
|
---|
55 | //******************************************************************************
|
---|
56 | Win32ExeBase::~Win32ExeBase()
|
---|
57 | {
|
---|
58 | Win32DllBase::deleteAll();
|
---|
59 | WinExe = NULL;
|
---|
60 | }
|
---|
61 | //******************************************************************************
|
---|
62 | //******************************************************************************
|
---|
63 | ULONG Win32ExeBase::start()
|
---|
64 | {
|
---|
65 | WINEXCEPTION_FRAME exceptFrame;
|
---|
66 | ULONG rc;
|
---|
67 |
|
---|
68 | if(getenv("WIN32_IOPL2")) {
|
---|
69 | io_init1();
|
---|
70 | }
|
---|
71 | dprintf(("Start executable %X\n", WinExe));
|
---|
72 |
|
---|
73 | fExeStarted = TRUE;
|
---|
74 |
|
---|
75 | //Note: The Win32 exception structure references by FS:[0] is the same
|
---|
76 | // in OS/2
|
---|
77 | OS2SetExceptionHandler((void *)&exceptFrame);
|
---|
78 | SetWin32TIB();
|
---|
79 |
|
---|
80 | //Allocate TLS index for this module
|
---|
81 | tlsAlloc();
|
---|
82 | tlsAttachThread(); //setup TLS (main thread)
|
---|
83 |
|
---|
84 | rc = ((WIN32EXEENTRY)entryPoint)(NULL);
|
---|
85 | RestoreOS2TIB();
|
---|
86 |
|
---|
87 | OS2UnsetExceptionHandler((void *)&exceptFrame);
|
---|
88 |
|
---|
89 | return rc;
|
---|
90 | }
|
---|
91 | //******************************************************************************
|
---|
92 | //******************************************************************************
|
---|
93 | BOOL Win32ExeBase::isDll()
|
---|
94 | {
|
---|
95 | return FALSE;
|
---|
96 | }
|
---|
97 | //******************************************************************************
|
---|
98 | //******************************************************************************
|
---|