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

Last change on this file since 2893 was 2802, checked in by sandervl, 26 years ago

Added new logging feature

File size: 3.4 KB
Line 
1/* $Id: winexebase.cpp,v 1.5 2000-02-16 14:22:11 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 cmdLineA(NULL), cmdLineW(NULL)
54{
55 WinExe = this;
56}
57//******************************************************************************
58//******************************************************************************
59Win32ExeBase::~Win32ExeBase()
60{
61 Win32DllBase::deleteAll();
62 WinExe = NULL;
63 if(cmdLineA)
64 free(cmdLineA);
65 if(cmdLineW)
66 free(cmdLineW);
67}
68//******************************************************************************
69//******************************************************************************
70ULONG Win32ExeBase::start()
71{
72 WINEXCEPTION_FRAME exceptFrame;
73 ULONG rc;
74
75 if(getenv("WIN32_IOPL2")) {
76 io_init1();
77 }
78 dprintf(("Start executable %X\n", WinExe));
79
80 fExeStarted = TRUE;
81
82 //Note: The Win32 exception structure references by FS:[0] is the same
83 // in OS/2
84 OS2SetExceptionHandler((void *)&exceptFrame);
85 SetWin32TIB();
86
87 //Allocate TLS index for this module
88 tlsAlloc();
89 tlsAttachThread(); //setup TLS (main thread)
90
91 rc = ((WIN32EXEENTRY)entryPoint)(NULL);
92 RestoreOS2TIB();
93
94 OS2UnsetExceptionHandler((void *)&exceptFrame);
95
96 return rc;
97}
98//******************************************************************************
99//******************************************************************************
100BOOL Win32ExeBase::isDll()
101{
102 return FALSE;
103}
104//******************************************************************************
105//******************************************************************************
106void Win32ExeBase::setCommandLine(char *cline)
107{
108 ULONG cmdlength = strlen(cline) + 1;
109
110 cmdLineA = (LPSTR)malloc(cmdlength);
111 strcpy(cmdLineA, cline);
112 cmdLineW = (LPWSTR)malloc(cmdlength*sizeof(WCHAR));
113 AsciiToUnicode(cmdLineA, cmdLineW);
114}
115//******************************************************************************
116//******************************************************************************
Note: See TracBrowser for help on using the repository browser.