source: trunk/src/kernel32/winexedummy.cpp@ 9971

Last change on this file since 9971 was 9971, checked in by sandervl, 22 years ago

PF: Corrected HFILE definition as it is in Wine and in Win2k

File size: 5.7 KB
Line 
1/* $Id: winexedummy.cpp,v 1.4 2003-04-02 11:03:32 sandervl Exp $ */
2
3/*
4 * Win32 Dummy Exe class
5 *
6 * Copyright 2001 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 <misc.h>
22#include <win32type.h>
23#include <winexedummy.h>
24#include <winconst.h>
25#include <win32api.h>
26#include <wprocess.h>
27#include "initterm.h"
28
29//******************************************************************************
30//Create Dummy Exe object
31//******************************************************************************
32BOOL WIN32API RegisterDummyExe(LPSTR pszExeName)
33{
34 if(WinExe != NULL) //should never happen
35 delete(WinExe);
36
37 Win32DummyExe *winexe;
38
39 winexe = new Win32DummyExe(pszExeName);
40
41 if(winexe) {
42 InitCommandLine(FALSE);
43 winexe->start();
44 }
45 else {
46 eprintf(("Win32DummyExe creation failed!\n"));
47 DebugInt3();
48 return FALSE;
49 }
50 return TRUE;
51}
52//******************************************************************************
53//******************************************************************************
54Win32DummyExe::Win32DummyExe(LPSTR pszExeName)
55 : Win32ImageBase(-1),
56 Win32ExeBase(-1), header(0)
57{
58 dprintf(("Win32DummyExe ctor: %s", pszExeName));
59 hinstance = (HINSTANCE)buildHeader(1, 0, IMAGE_SUBSYSTEM_WINDOWS_GUI);
60 strcpy(szModule, pszExeName);
61 strcpy(szFileName, pszExeName);
62 setFullPath(pszExeName);
63}
64//******************************************************************************
65//******************************************************************************
66Win32DummyExe::~Win32DummyExe()
67{
68 if(header) {
69 DosFreeMem(header);
70 }
71}
72//******************************************************************************
73//******************************************************************************
74ULONG Win32DummyExe::start()
75{
76 return 0;
77}
78//******************************************************************************
79//******************************************************************************
80ULONG Win32DummyExe::getApi(char *name)
81{
82 return 0;
83}
84//******************************************************************************
85//******************************************************************************
86ULONG Win32DummyExe::getApi(int ordinal)
87{
88 return 0;
89}
90//******************************************************************************
91//******************************************************************************
92LPVOID Win32DummyExe::buildHeader(DWORD MajorImageVersion, DWORD MinorImageVersion,
93 DWORD Subsystem)
94{
95 APIRET rc;
96 IMAGE_DOS_HEADER *pdosheader;
97 PIMAGE_OPTIONAL_HEADER poh;
98 PIMAGE_FILE_HEADER pfh;
99 DWORD *ntsig;
100
101 // AH TODO: we are wasting 60kb address space here (unless using high memory)!!!
102 rc = DosAllocMem(&header, 4096, PAG_READ | PAG_WRITE | PAG_COMMIT | flAllocMem);
103 if(rc) {
104 dprintf(("ERROR: buildHeader DosAllocMem failed!! (rc=%x)", rc));
105 DebugInt3();
106 return NULL;
107 }
108 memcpy(header, dosHeader, sizeof(dosHeader));
109 ntsig = (DWORD *)((LPBYTE)header + sizeof(dosHeader));
110 *ntsig = IMAGE_NT_SIGNATURE;
111 pfh = (PIMAGE_FILE_HEADER)(ntsig+1);
112 pfh->Machine = IMAGE_FILE_MACHINE_I386;
113 pfh->NumberOfSections = 0;
114 pfh->TimeDateStamp = 0x3794f60f;
115 pfh->PointerToSymbolTable = 0;
116 pfh->NumberOfSymbols = 0;
117 pfh->SizeOfOptionalHeader = sizeof(IMAGE_OPTIONAL_HEADER);
118 pfh->Characteristics = IMAGE_FILE_DLL | IMAGE_FILE_32BIT_MACHINE |
119 IMAGE_FILE_DEBUG_STRIPPED | IMAGE_FILE_EXECUTABLE_IMAGE |
120 IMAGE_FILE_RELOCS_STRIPPED;
121 poh = (PIMAGE_OPTIONAL_HEADER)(pfh+1);
122 poh->Magic = IMAGE_NT_OPTIONAL_HDR_MAGIC;
123 poh->MajorLinkerVersion = 0x3;
124 poh->MinorLinkerVersion = 0xA;
125 poh->SizeOfCode = 0;
126 poh->SizeOfInitializedData = 0;
127 poh->SizeOfUninitializedData = 0;
128 poh->AddressOfEntryPoint = 0;
129 poh->BaseOfCode = 0;
130 poh->BaseOfData = 0;
131 poh->ImageBase = 0;
132 poh->SectionAlignment = 4096;
133 poh->FileAlignment = 512;
134 poh->MajorOperatingSystemVersion = MajorImageVersion;
135 poh->MinorOperatingSystemVersion = MinorImageVersion;
136 poh->MajorImageVersion = MajorImageVersion;
137 poh->MinorImageVersion = MinorImageVersion;
138 poh->MajorSubsystemVersion = ODINNT_MAJOR_VERSION;
139 poh->MinorSubsystemVersion = ODINNT_MINOR_VERSION;
140 poh->Win32VersionValue = 0;
141 poh->SizeOfImage = 0;
142 poh->SizeOfHeaders = 1024;
143 poh->CheckSum = 0;
144 poh->Subsystem = Subsystem;
145 poh->DllCharacteristics = 0;
146 poh->SizeOfStackReserve = 1*1024*1024;
147 poh->SizeOfStackCommit = 4096;
148 poh->SizeOfHeapReserve = 1*1024*1024;
149 poh->SizeOfHeapCommit = 4096;
150 poh->LoaderFlags = 0;
151 poh->NumberOfRvaAndSizes = 0;
152// poh->DataDirectory[0]
153
154 return header;
155}
156//******************************************************************************
157//******************************************************************************
Note: See TracBrowser for help on using the repository browser.