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

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

Major changes in PE2LX/KERNEL32 for TLS support. DLL VERSION INCREASED TO 3 AS THIS CHANGE MAKES IT INCOMPATIBLE WITH APPS CONVERTED WITH PREVIOUS VERSION OF PE2LX (OR WIN32K)

File size: 3.2 KB
Line 
1/* $Id: winexe.cpp,v 1.8 1999-07-07 08:11:10 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//******************************************************************************
38Win32Exe::Win32Exe(char *szFileName) : Win32Image(szFileName), fConsoleApp(FALSE),
39 cmdline(NULL), OS2InstanceHandle(-1)
40{
41 fConsoleApp = (oh.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CUI);
42 WinExe = this;
43
44 dprintf(("Win32Exe ctor: %s", szFileName));
45
46 if(fConsoleApp) {
47 dprintf(("Console application!\n"));
48
49 APIRET rc = iConsoleInit(); /* initialize console subsystem */
50 if (rc != NO_ERROR) /* check for errors */
51 dprintf(("KERNEL32:Win32Image:Init ConsoleInit failed with %u.\n", rc));
52 }
53}
54//******************************************************************************
55//******************************************************************************
56Win32Exe::Win32Exe(HINSTANCE hinstance, int NameTableId, int Win32TableId) :
57 Win32Image(hinstance, NameTableId, Win32TableId),
58 fConsoleApp(FALSE), cmdline(NULL), OS2InstanceHandle(-1)
59{
60 if(GET_CONSOLE(Win32TableId) == 1) {//console app
61 dprintf(("Console application!\n"));
62
63 fConsoleApp = TRUE;
64 APIRET rc = iConsoleInit(); /* initialize console subsystem */
65 if (rc != NO_ERROR) /* check for errors */
66 dprintf(("KERNEL32:Win32Image:Init ConsoleInit failed with %u.\n", rc));
67 }
68 WinExe = this;
69}
70//******************************************************************************
71//******************************************************************************
72Win32Exe::~Win32Exe()
73{
74 Win32Dll::deleteAll();
75 WinExe = NULL;
76}
77//******************************************************************************
78//******************************************************************************
79ULONG Win32Exe::start()
80{
81 ULONG rc;
82
83 if(getenv("WIN32_IOPL2")) {
84 io_init1();
85 }
86 dprintf(("Start executable %X\n", WinExe));
87
88 fExeStarted = TRUE;
89
90 //Allocate TLS index for this module
91 tlsAlloc();
92 tlsAttachThread(); //setup TLS (main thread)
93
94 SetWin32TIB();
95 rc = ((WIN32EXEENTRY)entryPoint)();
96 RestoreOS2TIB();
97 return rc;
98}
99//******************************************************************************
100//******************************************************************************
101
Note: See TracBrowser for help on using the repository browser.