source: trunk/src/kernel32/winexe.cpp@ 596

Last change on this file since 596 was 506, checked in by sandervl, 26 years ago

* empty log message *

File size: 3.5 KB
Line 
1/* $Id: winexe.cpp,v 1.9 1999-08-16 13:54:32 sandervl Exp $ */
2
3/*
4 * Win32 exe class
5 *
6 * Copyright 1998 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 <nameid.h>
25#include <win32type.h>
26#include <winexe.h>
27#include <wprocess.h>
28#include <pefile.h>
29#include "cio.h"
30
31#include "conwin.h" // Windows Header for console only
32#include "console.h"
33
34Win32Exe *WinExe = NULL;
35
36//******************************************************************************
37//Called by ring 3 pe loader to create win32 executable
38//******************************************************************************
39Win32Exe* WIN32API CreateWin32Exe(char *szFileName)
40{
41 return new Win32Exe(szFileName);
42}
43//******************************************************************************
44//******************************************************************************
45Win32Exe::Win32Exe(char *szFileName) : Win32Image(szFileName), fConsoleApp(FALSE),
46 cmdline(NULL), OS2InstanceHandle(-1)
47{
48 fConsoleApp = (oh.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CUI);
49 WinExe = this;
50
51 dprintf(("Win32Exe ctor: %s", szFileName));
52
53 if(fConsoleApp) {
54 dprintf(("Console application!\n"));
55
56 APIRET rc = iConsoleInit(); /* initialize console subsystem */
57 if (rc != NO_ERROR) /* check for errors */
58 dprintf(("KERNEL32:Win32Image:Init ConsoleInit failed with %u.\n", rc));
59 }
60}
61//******************************************************************************
62//******************************************************************************
63Win32Exe::Win32Exe(HINSTANCE hinstance, int NameTableId, int Win32TableId) :
64 Win32Image(hinstance, NameTableId, Win32TableId),
65 fConsoleApp(FALSE), cmdline(NULL), OS2InstanceHandle(-1)
66{
67 if(GET_CONSOLE(Win32TableId) == 1) {//console app
68 dprintf(("Console application!\n"));
69
70 fConsoleApp = TRUE;
71 APIRET rc = iConsoleInit(); /* initialize console subsystem */
72 if (rc != NO_ERROR) /* check for errors */
73 dprintf(("KERNEL32:Win32Image:Init ConsoleInit failed with %u.\n", rc));
74 }
75 WinExe = this;
76}
77//******************************************************************************
78//******************************************************************************
79Win32Exe::~Win32Exe()
80{
81 Win32Dll::deleteAll();
82 WinExe = NULL;
83}
84//******************************************************************************
85//******************************************************************************
86ULONG Win32Exe::start()
87{
88 ULONG rc;
89
90 if(getenv("WIN32_IOPL2")) {
91 io_init1();
92 }
93 dprintf(("Start executable %X\n", WinExe));
94
95 fExeStarted = TRUE;
96
97 //Allocate TLS index for this module
98 tlsAlloc();
99 tlsAttachThread(); //setup TLS (main thread)
100
101 SetWin32TIB();
102 rc = ((WIN32EXEENTRY)entryPoint)();
103 RestoreOS2TIB();
104 return rc;
105}
106//******************************************************************************
107//******************************************************************************
108
Note: See TracBrowser for help on using the repository browser.