source: trunk/src/kernel32/winexelx.cpp@ 2007

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

Exception changes + fixes; don't switch FS selectors for Odin32 OS/2 apps

File size: 3.5 KB
Line 
1/* $Id: winexelx.cpp,v 1.3 1999-10-09 13:33:24 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 pResData)
39{
40 APIRET rc;
41 PPIB ppib;
42 PTIB ptib;
43
44 //Signal to TEB management that we're a real OS/2 app and don't
45 //require setting FS to our special win32 selector
46 fIsOS2Image = TRUE;
47
48 if(WinExe != NULL) //should never happen
49 delete(WinExe);
50
51 if(getenv("WIN32_IOPL2")) {
52 io_init1();
53 }
54
55 rc = DosGetInfoBlocks(&ptib, &ppib);
56 if(rc) {
57 return FALSE;
58 }
59
60 Win32LxExe *winexe;
61
62 winexe = new Win32LxExe(ppib->pib_hmte, pResData);
63
64 if(winexe) {
65 winexe->setCommandLine(ppib->pib_pchcmd);
66 winexe->setEntryPoint((ULONG)EntryPoint);
67 winexe->start();
68 }
69 else {
70 eprintf(("Win32LxExe creation failed!\n"));
71 DebugInt3();
72 return FALSE;
73 }
74 return TRUE;
75}
76//******************************************************************************
77//******************************************************************************
78Win32LxExe::Win32LxExe(HINSTANCE hInstance, PVOID pResData)
79 : Win32ImageBase(hInstance),
80 Win32LxImage(hInstance, pResData),
81 Win32ExeBase(hInstance)
82{
83 dprintf(("Win32LxExe ctor: %s", szModule));
84}
85//******************************************************************************
86//******************************************************************************
87//******************************************************************************
88//******************************************************************************
89Win32LxExe::~Win32LxExe()
90{
91}
92//******************************************************************************
93//******************************************************************************
94ULONG Win32LxExe::start()
95{
96 WINEXCEPTION_FRAME exceptFrame;
97 ULONG rc;
98
99 if(getenv("WIN32_IOPL2")) {
100 io_init1();
101 }
102 dprintf(("Start executable %X\n", WinExe));
103
104 fExeStarted = TRUE;
105
106 //Allocate TLS index for this module
107 tlsAlloc();
108 tlsAttachThread(); //setup TLS (main thread)
109
110 //Note: The Win32 exception structure references by FS:[0] is the same
111 // in OS/2
112 OS2SetExceptionHandler((void *)&exceptFrame);
113
114 SetWin32TIB();
115 rc = ((WINMAIN)entryPoint)(hinstance, 0, cmdline, SW_SHOWNORMAL_W);
116 RestoreOS2TIB();
117
118 OS2UnsetExceptionHandler((void *)&exceptFrame);
119
120 return rc;
121}
122//******************************************************************************
123//******************************************************************************
Note: See TracBrowser for help on using the repository browser.