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

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

Fix: major restructuring of Open32 handle management, HandleManager

File size: 3.3 KB
Line 
1/* $Id: winexe.cpp,v 1.5 1999-06-17 18:25:22 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#include "conwin.h" // Windows Header for console only
34#include "console.h"
35#include "handlemanager.h"
36
37
38Win32Exe *WinExe = NULL;
39
40//******************************************************************************
41//******************************************************************************
42Win32Exe::Win32Exe(char *szFileName) : Win32Image(szFileName), fConsoleApp(FALSE),
43 cmdline(NULL), OS2InstanceHandle(-1)
44{
45 fConsoleApp = (oh.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CUI);
46 WinExe = this;
47
48 dprintf(("Win32Exe ctor: %s", szFileName));
49
50 HMInitialize(); /* store standard handles within HandleManager */
51 dprintf(("KERNEL32/WINEXE: HandleManager Initialized.\n"));
52 if(fConsoleApp) {
53 dprintf(("Console application!\n"));
54
55 APIRET rc = iConsoleInit(); /* initialize console subsystem */
56 if (rc != NO_ERROR) /* check for errors */
57 dprintf(("KERNEL32:Win32Image:Init ConsoleInit failed with %u.\n", rc));
58 }
59}
60//******************************************************************************
61//******************************************************************************
62Win32Exe::Win32Exe(HINSTANCE hinstance, int NameTableId, int Win32TableId) :
63 Win32Image(hinstance, NameTableId, Win32TableId),
64 fConsoleApp(FALSE), cmdline(NULL), OS2InstanceHandle(-1)
65{
66 HMInitialize(); /* store standard handles within HandleManager */
67 dprintf(("KERNEL32/WINEXE: HandleManager Initialized.\n"));
68
69 if(GET_CONSOLE(Win32TableId) == 1) {//console app
70 dprintf(("Console application!\n"));
71
72 fConsoleApp = TRUE;
73 APIRET rc = iConsoleInit(); /* initialize console subsystem */
74 if (rc != NO_ERROR) /* check for errors */
75 dprintf(("KERNEL32:Win32Image:Init ConsoleInit failed with %u.\n", rc));
76 }
77 WinExe = this;
78}
79//******************************************************************************
80//******************************************************************************
81Win32Exe::~Win32Exe()
82{
83 Win32Dll::deleteAll();
84 WinExe = NULL;
85}
86//******************************************************************************
87//******************************************************************************
88ULONG Win32Exe::start()
89{
90 if(getenv("WIN32_IOPL2")) {
91 io_init1();
92 }
93 dprintf(("Start executable %X\n", WinExe));
94
95 fExeStarted = TRUE;
96 return ((WIN32EXEENTRY)entryPoint)();
97}
98//******************************************************************************
99//******************************************************************************
100
Note: See TracBrowser for help on using the repository browser.