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

Last change on this file since 111 was 111, checked in by phaller, 26 years ago

Fix: major restructuring of Open32 handle management, HandleManager

File size: 3.4 KB
Line 
1/* $Id: winexe.cpp,v 1.4 1999-06-17 18:21:43 phaller Exp $ */
2
3/*
4 *
5 * Project Odin Software License can be found in LICENSE.TXT
6 *
7 */
8/*
9 * Win32 exe class
10 *
11 * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
12 *
13 */
14#define INCL_DOSFILEMGR /* File Manager values */
15#define INCL_DOSERRORS /* DOS Error values */
16#define INCL_DOSPROCESS /* DOS Process values */
17#define INCL_DOSMISC /* DOS Miscellanous values */
18#define INCL_WIN
19#include <os2.h>
20#include <stdio.h>
21#include <string.h>
22#include <stdlib.h>
23#include <iostream.h>
24#include <fstream.h>
25#include "misc.h"
26#include "nameid.h"
27#include "win32type.h"
28#include <winexe.h>
29#include "wprocess.h"
30#include "pefile.h"
31#include "cio.h"
32
33
34// PH: to soothe the compiler
35#define BY_HANDLE_FILE_INFORMATION void
36#define LPFILETIME void*
37#define OFSTRUCT void
38
39#include "console.h"
40#include "handlemanager.h"
41
42
43Win32Exe *WinExe = NULL;
44
45//******************************************************************************
46//******************************************************************************
47Win32Exe::Win32Exe(char *szFileName) : Win32Image(szFileName), fConsoleApp(FALSE),
48 cmdline(NULL), OS2InstanceHandle(-1)
49{
50 fConsoleApp = (oh.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CUI);
51 WinExe = this;
52
53 dprintf(("Win32Exe ctor: %s", szFileName));
54
55 HMInitialize(); /* store standard handles within HandleManager */
56 dprintf(("KERNEL32/WINEXE: HandleManager Initialized.\n"));
57 if(fConsoleApp) {
58 dprintf(("Console application!\n"));
59
60 APIRET rc = iConsoleInit(); /* initialize console subsystem */
61 if (rc != NO_ERROR) /* check for errors */
62 dprintf(("KERNEL32:Win32Image:Init ConsoleInit failed with %u.\n", rc));
63 }
64}
65//******************************************************************************
66//******************************************************************************
67Win32Exe::Win32Exe(HINSTANCE hinstance, int NameTableId, int Win32TableId) :
68 Win32Image(hinstance, NameTableId, Win32TableId),
69 fConsoleApp(FALSE), cmdline(NULL), OS2InstanceHandle(-1)
70{
71 HMInitialize(); /* store standard handles within HandleManager */
72 dprintf(("KERNEL32/WINEXE: HandleManager Initialized.\n"));
73
74 if(GET_CONSOLE(Win32TableId) == 1) {//console app
75 dprintf(("Console application!\n"));
76
77 fConsoleApp = TRUE;
78 APIRET rc = iConsoleInit(); /* initialize console subsystem */
79 if (rc != NO_ERROR) /* check for errors */
80 dprintf(("KERNEL32:Win32Image:Init ConsoleInit failed with %u.\n", rc));
81 }
82 WinExe = this;
83}
84//******************************************************************************
85//******************************************************************************
86Win32Exe::~Win32Exe()
87{
88 Win32Dll::deleteAll();
89 WinExe = NULL;
90}
91//******************************************************************************
92//******************************************************************************
93ULONG Win32Exe::start()
94{
95 if(getenv("WIN32_IOPL2")) {
96 io_init1();
97 }
98 dprintf(("Start executable %X\n", WinExe));
99
100 fExeStarted = TRUE;
101 return ((WIN32EXEENTRY)entryPoint)();
102}
103//******************************************************************************
104//******************************************************************************
105
Note: See TracBrowser for help on using the repository browser.