Changeset 8877 for trunk/src/kernel32/winexedummy.cpp
- Timestamp:
- Jul 15, 2002, 4:28:53 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/winexedummy.cpp
r7797 r8877 1 /* $Id: winexedummy.cpp,v 1. 1 2002-02-03 13:16:22sandervl Exp $ */1 /* $Id: winexedummy.cpp,v 1.2 2002-07-15 14:28:53 sandervl Exp $ */ 2 2 3 3 /* … … 25 25 #include <win32api.h> 26 26 #include <wprocess.h> 27 #include "initterm.h" 27 28 28 29 //****************************************************************************** … … 31 32 BOOL WIN32API RegisterDummyExe(LPSTR pszExeName) 32 33 { 33 if(WinExe != NULL) //should never happen34 if(WinExe != NULL) //should never happen 34 35 delete(WinExe); 35 36 36 Win32DummyExe *winexe;37 Win32DummyExe *winexe; 37 38 38 winexe = new Win32DummyExe(pszExeName);39 winexe = new Win32DummyExe(pszExeName); 39 40 40 if(winexe) {41 if(winexe) { 41 42 InitCommandLine(FALSE); 42 winexe->start();43 }44 else {43 winexe->start(); 44 } 45 else { 45 46 eprintf(("Win32DummyExe creation failed!\n")); 46 47 DebugInt3(); 47 return FALSE;48 }49 return TRUE;48 return FALSE; 49 } 50 return TRUE; 50 51 } 51 52 //****************************************************************************** … … 55 56 Win32ExeBase(-1), header(0) 56 57 { 57 dprintf(("Win32DummyExe ctor: %s", pszExeName));58 hinstance = (HINSTANCE)buildHeader(1, 0, IMAGE_SUBSYSTEM_WINDOWS_GUI);59 strcpy(szModule, pszExeName);60 strcpy(szFileName, pszExeName);61 setFullPath(pszExeName);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); 62 63 } 63 64 //****************************************************************************** … … 65 66 Win32DummyExe::~Win32DummyExe() 66 67 { 67 if(header) {68 DosFreeMem(header);69 }68 if(header) { 69 DosFreeMem(header); 70 } 70 71 } 71 72 //****************************************************************************** … … 92 93 DWORD Subsystem) 93 94 { 94 APIRET rc;95 IMAGE_DOS_HEADER *pdosheader;96 PIMAGE_OPTIONAL_HEADER poh;97 PIMAGE_FILE_HEADER pfh;98 DWORD *ntsig;95 APIRET rc; 96 IMAGE_DOS_HEADER *pdosheader; 97 PIMAGE_OPTIONAL_HEADER poh; 98 PIMAGE_FILE_HEADER pfh; 99 DWORD *ntsig; 99 100 100 rc = DosAllocMem(&header, 4096, PAG_READ | PAG_WRITE | PAG_COMMIT);101 if(rc) {102 dprintf(("ERROR: buildHeader DosAllocMem failed!! (rc=%x)", rc));101 rc = DosAllocMem(&header, 4096, PAG_READ | PAG_WRITE | PAG_COMMIT | flAllocMem); 102 if(rc) { 103 dprintf(("ERROR: buildHeader DosAllocMem failed!! (rc=%x)", rc)); 103 104 DebugInt3(); 104 return NULL;105 }106 memcpy(header, dosHeader, sizeof(dosHeader));107 ntsig = (DWORD *)((LPBYTE)header + sizeof(dosHeader));108 *ntsig = IMAGE_NT_SIGNATURE;109 pfh = (PIMAGE_FILE_HEADER)(ntsig+1);110 pfh->Machine = IMAGE_FILE_MACHINE_I386;111 pfh->NumberOfSections = 0;112 pfh->TimeDateStamp = 0x3794f60f;113 pfh->PointerToSymbolTable = 0;114 pfh->NumberOfSymbols = 0;115 pfh->SizeOfOptionalHeader = sizeof(IMAGE_OPTIONAL_HEADER);116 pfh->Characteristics = IMAGE_FILE_DLL | IMAGE_FILE_32BIT_MACHINE |117 IMAGE_FILE_DEBUG_STRIPPED | IMAGE_FILE_EXECUTABLE_IMAGE |118 IMAGE_FILE_RELOCS_STRIPPED;119 poh = (PIMAGE_OPTIONAL_HEADER)(pfh+1);120 poh->Magic = IMAGE_NT_OPTIONAL_HDR_MAGIC;121 poh->MajorLinkerVersion = 0x3;122 poh->MinorLinkerVersion = 0xA;123 poh->SizeOfCode = 0;124 poh->SizeOfInitializedData = 0;125 poh->SizeOfUninitializedData = 0;126 poh->AddressOfEntryPoint = 0;127 poh->BaseOfCode = 0;128 poh->BaseOfData = 0;129 poh->ImageBase = 0;130 poh->SectionAlignment = 4096;131 poh->FileAlignment = 512;132 poh->MajorOperatingSystemVersion = MajorImageVersion;133 poh->MinorOperatingSystemVersion = MinorImageVersion;134 poh->MajorImageVersion = MajorImageVersion;135 poh->MinorImageVersion = MinorImageVersion;136 poh->MajorSubsystemVersion = ODINNT_MAJOR_VERSION;137 poh->MinorSubsystemVersion = ODINNT_MINOR_VERSION;138 poh->Reserved1 = 0;139 poh->SizeOfImage = 0;140 poh->SizeOfHeaders = 1024;141 poh->CheckSum = 0;142 poh->Subsystem = Subsystem;143 poh->DllCharacteristics = 0;144 poh->SizeOfStackReserve = 1*1024*1024;145 poh->SizeOfStackCommit = 4096;146 poh->SizeOfHeapReserve = 1*1024*1024;147 poh->SizeOfHeapCommit = 4096;148 poh->LoaderFlags = 0;149 poh->NumberOfRvaAndSizes = 0;105 return NULL; 106 } 107 memcpy(header, dosHeader, sizeof(dosHeader)); 108 ntsig = (DWORD *)((LPBYTE)header + sizeof(dosHeader)); 109 *ntsig = IMAGE_NT_SIGNATURE; 110 pfh = (PIMAGE_FILE_HEADER)(ntsig+1); 111 pfh->Machine = IMAGE_FILE_MACHINE_I386; 112 pfh->NumberOfSections = 0; 113 pfh->TimeDateStamp = 0x3794f60f; 114 pfh->PointerToSymbolTable = 0; 115 pfh->NumberOfSymbols = 0; 116 pfh->SizeOfOptionalHeader = sizeof(IMAGE_OPTIONAL_HEADER); 117 pfh->Characteristics = IMAGE_FILE_DLL | IMAGE_FILE_32BIT_MACHINE | 118 IMAGE_FILE_DEBUG_STRIPPED | IMAGE_FILE_EXECUTABLE_IMAGE | 119 IMAGE_FILE_RELOCS_STRIPPED; 120 poh = (PIMAGE_OPTIONAL_HEADER)(pfh+1); 121 poh->Magic = IMAGE_NT_OPTIONAL_HDR_MAGIC; 122 poh->MajorLinkerVersion = 0x3; 123 poh->MinorLinkerVersion = 0xA; 124 poh->SizeOfCode = 0; 125 poh->SizeOfInitializedData = 0; 126 poh->SizeOfUninitializedData = 0; 127 poh->AddressOfEntryPoint = 0; 128 poh->BaseOfCode = 0; 129 poh->BaseOfData = 0; 130 poh->ImageBase = 0; 131 poh->SectionAlignment = 4096; 132 poh->FileAlignment = 512; 133 poh->MajorOperatingSystemVersion = MajorImageVersion; 134 poh->MinorOperatingSystemVersion = MinorImageVersion; 135 poh->MajorImageVersion = MajorImageVersion; 136 poh->MinorImageVersion = MinorImageVersion; 137 poh->MajorSubsystemVersion = ODINNT_MAJOR_VERSION; 138 poh->MinorSubsystemVersion = ODINNT_MINOR_VERSION; 139 poh->Reserved1 = 0; 140 poh->SizeOfImage = 0; 141 poh->SizeOfHeaders = 1024; 142 poh->CheckSum = 0; 143 poh->Subsystem = Subsystem; 144 poh->DllCharacteristics = 0; 145 poh->SizeOfStackReserve = 1*1024*1024; 146 poh->SizeOfStackCommit = 4096; 147 poh->SizeOfHeapReserve = 1*1024*1024; 148 poh->SizeOfHeapCommit = 4096; 149 poh->LoaderFlags = 0; 150 poh->NumberOfRvaAndSizes = 0; 150 151 // poh->DataDirectory[0] 151 152 152 return header;153 return header; 153 154 } 154 155 //******************************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.