source: trunk/src/kernel32/winexelx.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.3 KB
Line 
1/* $Id: winexelx.cpp,v 1.1 1999-09-15 23:39:07 sandervl Exp $ */
2
3/*
4 * Win32 LX Exe class (compiled in OS/2 using Odin32 api)
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 <winexelx.h>
26#include <winconst.h>
27#include <wprocess.h>
28#include <odinlx.h>
29
30#include "exceptions.h"
31#include "exceptutil.h"
32#include "cio.h"
33
34//******************************************************************************
35//Create LX Exe object and call entrypoint
36//System dlls set EntryPoint to 0
37//******************************************************************************
38BOOL WIN32API RegisterLxExe(WINMAIN EntryPoint, PVOID unused)
39{
40 APIRET rc;
41 PPIB ppib;
42 PTIB ptib;
43
44 if(WinExe != NULL) //should never happen
45 delete(WinExe);
46
47 if(getenv("WIN32_IOPL2")) {
48 io_init1();
49 }
50
51 rc = DosGetInfoBlocks(&ptib, &ppib);
52 if(rc) {
53 return FALSE;
54 }
55
56 Win32LxExe *winexe;
57
58 winexe = new Win32LxExe(ppib->pib_hmte);
59
60 if(winexe) {
61 winexe->setCommandLine(ppib->pib_pchcmd);
62 winexe->setEntryPoint((ULONG)EntryPoint);
63 winexe->start();
64 }
65 else {
66 eprintf(("Win32LxExe creation failed!\n"));
67 DebugInt3();
68 return FALSE;
69 }
70 return TRUE;
71}
72//******************************************************************************
73//******************************************************************************
74Win32LxExe::Win32LxExe(HINSTANCE hInstance)
75 : Win32ImageBase(hInstance),
76 Win32LxImage(hInstance),
77 Win32ExeBase(hInstance)
78{
79 dprintf(("Win32LxExe ctor: %s", szModule));
80}
81//******************************************************************************
82//******************************************************************************
83//******************************************************************************
84//******************************************************************************
85Win32LxExe::~Win32LxExe()
86{
87}
88//******************************************************************************
89//******************************************************************************
90ULONG Win32LxExe::start()
91{
92 WINEXCEPTION_FRAME exceptFrame;
93 ULONG rc;
94
95 if(getenv("WIN32_IOPL2")) {
96 io_init1();
97 }
98 dprintf(("Start executable %X\n", WinExe));
99
100 fExeStarted = TRUE;
101
102 //Allocate TLS index for this module
103 tlsAlloc();
104 tlsAttachThread(); //setup TLS (main thread)
105
106 //Note: The Win32 exception structure references by FS:[0] is the same
107 // in OS/2
108 OS2SetExceptionHandler((void *)&exceptFrame);
109
110 SetWin32TIB();
111 rc = ((WINMAIN)entryPoint)(hinstance, 0, cmdline, SW_SHOWNORMAL_W);
112 RestoreOS2TIB();
113
114 OS2UnsetExceptionHandler((void *)&exceptFrame);
115
116 return rc;
117}
118//******************************************************************************
119//******************************************************************************
Note: See TracBrowser for help on using the repository browser.