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

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

Rewrite for new win32 image classes

File size: 3.5 KB
Line 
1/* $Id: winexepe2lx.cpp,v 1.1 1999-09-15 23:39:07 sandervl Exp $ */
2
3/*
4 * Win32 PE2LX Exe class
5 *
6 * Copyright 1998-1999 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 <win32type.h>
25#include <winexepe2lx.h>
26#include <wprocess.h>
27#include <pefile.h>
28#include "cio.h"
29
30#include "oslibmisc.h"
31#include "oslibdos.h"
32
33#include "conwin.h" // Windows Header for console only
34#include "console.h"
35
36/******************************************************************************/
37//******************************************************************************
38void WIN32API RegisterPe2LxExe(WIN32EXEENTRY EntryPoint, PIMAGE_TLS_CALLBACK *TlsCallbackAddr,
39 LPDWORD TlsIndexAddr, ULONG TlsInitSize,
40 ULONG TlsTotalSize, LPVOID TlsAddress,
41 LONG Win32TableId, LONG NameTableId, LONG VersionResId,
42 LONG Pe2lxVersion, HINSTANCE hinstance, ULONG dwReserved)
43{
44 if(WinExe != NULL) //should never happen
45 delete(WinExe);
46
47 CheckVersion(Pe2lxVersion, OSLibGetDllName(hinstance));
48
49 if(getenv("WIN32_IOPL2")) {
50 io_init1();
51 }
52
53 Win32Pe2LxExe *winexe;
54
55 winexe = new Win32Pe2LxExe(hinstance, NameTableId, Win32TableId);
56
57 if(winexe) {
58 dprintf(("RegisterExe Win32TableId = %x", Win32TableId));
59 dprintf(("RegisterExe NameTableId = %x", NameTableId));
60 dprintf(("RegisterExe VersionResId = %x", VersionResId));
61 dprintf(("RegisterExe Pe2lxVersion = %x", Pe2lxVersion));
62
63 winexe->setVersionId(VersionResId);
64 winexe->setEntryPoint((ULONG)EntryPoint);
65 winexe->setTLSAddress(TlsAddress);
66 winexe->setTLSInitSize(TlsInitSize);
67 winexe->setTLSTotalSize(TlsTotalSize);
68 winexe->setTLSIndexAddr(TlsIndexAddr);
69 winexe->setTLSCallBackAddr(TlsCallbackAddr);
70
71 winexe->start();
72 }
73 else {
74 eprintf(("Win32Pe2LxExe creation failed!\n"));
75 DebugInt3();
76 return;
77 }
78}
79//******************************************************************************
80//******************************************************************************
81Win32Pe2LxExe::Win32Pe2LxExe(HINSTANCE hinstance, int NameTableId, int Win32TableId) :
82 Win32ImageBase(hinstance),
83 Win32ExeBase(hinstance),
84 Win32Pe2LxImage(hinstance, NameTableId, Win32TableId)
85{
86 if(GET_CONSOLE(Win32TableId) == 1) {//console app
87 dprintf(("Console application!\n"));
88
89 fConsoleApp = TRUE;
90 APIRET rc = iConsoleInit(); /* initialize console subsystem */
91 if (rc != NO_ERROR) /* check for errors */
92 dprintf(("KERNEL32:Win32Image:Init ConsoleInit failed with %u.\n", rc));
93 }
94 WinExe = this;
95}
96//******************************************************************************
97//******************************************************************************
98Win32Pe2LxExe::~Win32Pe2LxExe()
99{
100}
101//******************************************************************************
102//******************************************************************************
Note: See TracBrowser for help on using the repository browser.