source: trunk/src/kernel32/winexepe2lx.cpp@ 1306

Last change on this file since 1306 was 1274, checked in by bird, 26 years ago

New Pe2Lx implementation.

File size: 4.2 KB
Line 
1/* $Id: winexepe2lx.cpp,v 1.2 1999-10-14 01:37:56 bird Exp $ */
2
3/*
4 * Win32 PE2LX Exe class
5 *
6 * Copyright 1998-1999 Sander van Leeuwen (sandervl@xs4all.nl)
7 * Copyright 1999 knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
8 *
9 * Project Odin Software License can be found in LICENSE.TXT
10 *
11 */
12
13/*******************************************************************************
14* Defined Constants And Macros *
15*******************************************************************************/
16#define INCL_DOSERRORS /* DOS Error values */
17
18
19/*******************************************************************************
20* Header Files *
21*******************************************************************************/
22#include <os2wrap.h> //Odin32 OS/2 api wrappers
23
24#include <stdlib.h> //getenv
25
26#include <misc.h>
27#include <win32type.h>
28#include <winexepe2lx.h>
29
30#include "cio.h" // I/O
31#include "oslibmisc.h" // OSLibGetDllName
32#include "conwin.h" // Windows Header for console only
33#include "console.h"
34
35
36/**
37 * Register a Pe2Lx Executable module.
38 * This is called from the TIBFix code in the Pe2Lx exe. It creates the WinExe object from
39 * the instance handle passed in.
40 * @param ulPe2LxVersion Pe2Lx version number.
41 * @param hinstance Module handle.
42 * @param ulReserved Reserved.
43 * @sketch I/O init.
44 * Check that pe2lx version matches the version of kernel32.dll.
45 * Frees WinExe if is not NULL - should never happen!
46 * Write info to the log.
47 * Create Pe2Lx Exe object.
48 * Call start (which calls the entry point).
49 * @status completely implemented.
50 * @author Sander van Leeuwen, knut st. osmundsen
51 */
52void WIN32API RegisterPe2LxExe(ULONG ulPe2LxVersion, HINSTANCE hinstance, ULONG ulReserved)
53{
54 /* I/O init. */
55 if (getenv("WIN32_IOPL2"))
56 io_init1();
57
58 /* Check that pe2lx version matches the version of kernel32.dll. */
59 CheckVersion(ulPe2LxVersion & ~0x80000000UL, OSLibGetDllName(hinstance));
60
61 /* Frees WinExe if is not NULL - should never happen! */
62 if (WinExe != NULL)
63 {
64 dprintf(("RegisterPe2LxExe: WinExe != NULL\n"));
65 delete(WinExe);
66 }
67
68 /* Write info to the log. */
69 dprintf(("RegisterPe2LxExe: ulPe2LxVersion = %#x\n", ulPe2LxVersion));
70 dprintf(("RegisterPe2LxExe: hinstance = %#x\n", hinstance));
71 dprintf(("RegisterPe2LxExe: ulReserved = %#x\n", ulReserved));
72 dprintf(("RegisterPe2LxExe: name = %s\n", OSLibGetDllName(hinstance)));
73
74 /* Create Pe2Lx Exe object. */
75 try
76 {
77 Win32Pe2LxExe *pWinPe2LxExe;
78 pWinPe2LxExe = new Win32Pe2LxExe(hinstance, (ulPe2LxVersion & 0x80000000UL) == 0x80000000UL);
79 if (pWinPe2LxExe == NULL)
80 throw ((ULONG)ERROR_NOT_ENOUGH_MEMORY);
81
82 /* Call start (which calls the entry point). */
83 /*DebugInt3();*/
84 pWinPe2LxExe->start();
85 }
86 catch (ULONG ul)
87 {
88 eprintf(("Win32Pe2LxExe creation failed! ul=%d\n", ul));
89 DebugInt3();
90 return;
91 }
92}
93
94
95/**
96 * Constructor - creates an pe2lx exe object from a module handle to a pe2lx exe module.
97 * @param hinstance Module handle.
98 * @param fWin32k TRUE: Win32k module.
99 * FALSE: Pe2Lx module.
100 * @status completely implmented.
101 * @author Sander van Leeuwen, knut st. osmundsen
102 * @remark Win32Pe2LxImage may throw an exception!
103 */
104Win32Pe2LxExe::Win32Pe2LxExe(HINSTANCE hinstance, BOOL fWin32k) throw(ULONG):
105 Win32ImageBase(hinstance),
106 Win32ExeBase(hinstance),
107 Win32Pe2LxImage(hinstance, fWin32k)
108{
109 fConsoleApp = pNtHdrs->OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CUI;
110
111 /* console app? */
112 if (fConsoleApp)
113 {
114 APIRET rc;
115
116 dprintf(("Console application!\n"));
117
118 rc = iConsoleInit(); /* initialize console subsystem */
119 if (rc != NO_ERROR) /* check for errors */
120 dprintf(("KERNEL32:Win32Image:Init ConsoleInit failed with %u.\n", rc));
121 }
122}
123
124
125/**
126 * Destructor - does nothing.
127 * @status completely implemented.
128 * @author Sander van Leeuwen
129 */
130Win32Pe2LxExe::~Win32Pe2LxExe()
131{
132}
Note: See TracBrowser for help on using the repository browser.