source: trunk/src/kernel32/winexepeldr.cpp@ 1036

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

Rewrite for new win32 image classes

File size: 3.1 KB
Line 
1/* $Id: winexepeldr.cpp,v 1.1 1999-09-15 23:39:07 sandervl Exp $ */
2
3/*
4 * Win32 PE loader 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 <winexepeldr.h>
26#include <wprocess.h>
27#include <pefile.h>
28
29#include "conwin.h" // Windows Header for console only
30#include "console.h"
31
32#include "exceptions.h"
33#include "exceptutil.h"
34
35#include "cio.h"
36
37//******************************************************************************
38//Called by ring 3 pe loader to create win32 executable
39//******************************************************************************
40BOOL WIN32API CreateWin32PeLdrExe(char *szFileName, ULONG reservedMem)
41{
42 APIRET rc;
43 PPIB ppib;
44 PTIB ptib;
45 WINEXCEPTION_FRAME exceptFrame;
46 Win32PeLdrExe *WinExe;
47 char *szCmdLine;
48
49 WinExe = new Win32PeLdrExe(szFileName);
50
51 rc = DosGetInfoBlocks(&ptib, &ppib);
52 if(rc) {
53 WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, szInteralErrorMsg, szErrorTitle, 0, MB_OK | MB_ERROR | MB_MOVEABLE);
54 delete WinExe;
55 return FALSE;
56 }
57 //TODO: Create full path for executable?
58 szCmdLine = ppib->pib_pchcmd + strlen(ppib->pib_pchcmd) + 1;
59
60 WinExe->setCommandLine(szCmdLine);
61
62 if(getenv("WIN32_IOPL2")) {
63 io_init1();
64 }
65
66 OS2SetExceptionHandler(&exceptFrame);
67 if(WinExe->init(reservedMem) == FALSE) {
68 delete WinExe;
69 return FALSE;
70 }
71 OS2UnsetExceptionHandler(&exceptFrame);
72 WinExe->start();
73
74 delete WinExe;
75
76 return TRUE;
77}
78//******************************************************************************
79//******************************************************************************
80Win32PeLdrExe::Win32PeLdrExe(char *szFileName) :
81 Win32ImageBase(-1),
82 Win32ExeBase(-1),
83 Win32PeLdrImage(szFileName)
84{
85 fConsoleApp = (oh.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CUI);
86
87 dprintf(("Win32PeLdrExe ctor: %s", szFileName));
88
89 if(fConsoleApp) {
90 dprintf(("Console application!\n"));
91
92 APIRET rc = iConsoleInit(); /* initialize console subsystem */
93 if (rc != NO_ERROR) /* check for errors */
94 dprintf(("KERNEL32:Win32Image:Init ConsoleInit failed with %u.\n", rc));
95 }
96}
97//******************************************************************************
98//******************************************************************************
99Win32PeLdrExe::~Win32PeLdrExe()
100{
101}
102//******************************************************************************
103//******************************************************************************
Note: See TracBrowser for help on using the repository browser.