mirror of
https://github.com/advancingdragon/Dirtbox.git
synced 2024-06-01 03:27:24 -04:00
Made large address aware, added command line args.
This commit is contained in:
parent
b2a489ca16
commit
4653d8677e
|
@ -9,8 +9,13 @@
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
Xbe XbeFile("C:\\Projects\\Xbox\\XGraphicsTest\\Release\\XGraphicsTest.xbe");
|
if (argc < 3)
|
||||||
XbeFile.WriteExe("C:\\Projects\\Xbox\\DirtboxKernel\\Debug\\xbe.exe");
|
{
|
||||||
|
printf("Usage: Dirtbox input output\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
Xbe XbeFile(argv[1]);
|
||||||
|
XbeFile.WriteExe(argv[2]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
15
MicroExe.h
15
MicroExe.h
|
@ -101,12 +101,17 @@ struct MICRO_EXE_HEADERS
|
||||||
#include "AlignPosfix1.h"
|
#include "AlignPosfix1.h"
|
||||||
|
|
||||||
|
|
||||||
const uint16 IMAGE_FILE_MACHINE_I386 = 0x014c; // Intel 386.
|
const uint16 IMAGE_FILE_RELOCS_STRIPPED = 0x0001; // Relocation info stripped from file.
|
||||||
|
const uint16 IMAGE_FILE_EXECUTABLE_IMAGE = 0x0002; // File is executable (i.e. no unresolved externel references).
|
||||||
|
const uint16 IMAGE_FILE_LARGE_ADDRESS_AWARE = 0x0020; // App can handle >2gb addresses
|
||||||
|
const uint16 IMAGE_FILE_32BIT_MACHINE = 0x0100; // 32 bit word machine.
|
||||||
|
|
||||||
const uint16 IMAGE_SUBSYSTEM_UNKNOWN = 0;
|
const uint16 IMAGE_FILE_MACHINE_I386 = 0x014c; // Intel 386.
|
||||||
const uint16 IMAGE_SUBSYSTEM_NATIVE = 1;
|
|
||||||
const uint16 IMAGE_SUBSYSTEM_WINDOWS_GUI = 2;
|
const uint16 IMAGE_SUBSYSTEM_UNKNOWN = 0x0000;
|
||||||
const uint16 IMAGE_SUBSYSTEM_WINDOWS_CUI = 3;
|
const uint16 IMAGE_SUBSYSTEM_NATIVE = 0x0001;
|
||||||
|
const uint16 IMAGE_SUBSYSTEM_WINDOWS_GUI = 0x0002;
|
||||||
|
const uint16 IMAGE_SUBSYSTEM_WINDOWS_CUI = 0x0003;
|
||||||
|
|
||||||
const uint32 EXE_ALIGNMENT = 4;
|
const uint32 EXE_ALIGNMENT = 4;
|
||||||
|
|
||||||
|
|
15
Xbe.cpp
15
Xbe.cpp
|
@ -97,7 +97,9 @@ static void __declspec(naked) TrampolineCode()
|
||||||
{
|
{
|
||||||
mov edx, 0x000100EC
|
mov edx, 0x000100EC
|
||||||
call dword ptr [edx]
|
call dword ptr [edx]
|
||||||
ret 0x10
|
ret
|
||||||
|
nop
|
||||||
|
nop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -380,6 +382,11 @@ Xbe::~Xbe()
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
int32 Xbe::PatchXbe()
|
int32 Xbe::PatchXbe()
|
||||||
{
|
{
|
||||||
|
printf("Xbe::PatchExe Patching initialization flags in Xbe...");
|
||||||
|
Header.InitFlags.MountUtilityDrive = 0;
|
||||||
|
Header.InitFlags.FormatUtilityDrive = 0;
|
||||||
|
printf("OK\n");
|
||||||
|
|
||||||
printf("Xbe::PatchExe Patching MapRegisters in Xbe...");
|
printf("Xbe::PatchExe Patching MapRegisters in Xbe...");
|
||||||
|
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
|
@ -463,7 +470,9 @@ int32 Xbe::WriteExe(const char *Filename)
|
||||||
ExeHeaders.Header.PointerToSymbolTable = 0;
|
ExeHeaders.Header.PointerToSymbolTable = 0;
|
||||||
ExeHeaders.Header.NumberOfSymbols = 0;
|
ExeHeaders.Header.NumberOfSymbols = 0;
|
||||||
ExeHeaders.Header.SizeOfOptionalHeader = sizeof(MICRO_EXE_HEADERS::OPTIONAL_HEADER);
|
ExeHeaders.Header.SizeOfOptionalHeader = sizeof(MICRO_EXE_HEADERS::OPTIONAL_HEADER);
|
||||||
ExeHeaders.Header.Characteristics = 0x0103;
|
ExeHeaders.Header.Characteristics =
|
||||||
|
IMAGE_FILE_RELOCS_STRIPPED | IMAGE_FILE_EXECUTABLE_IMAGE |
|
||||||
|
IMAGE_FILE_LARGE_ADDRESS_AWARE | IMAGE_FILE_32BIT_MACHINE;
|
||||||
|
|
||||||
ExeHeaders.OptionalHeader.Magic = 0x010B;
|
ExeHeaders.OptionalHeader.Magic = 0x010B;
|
||||||
ExeHeaders.OptionalHeader.MajorLinkerVersion = 0x06;
|
ExeHeaders.OptionalHeader.MajorLinkerVersion = 0x06;
|
||||||
|
@ -488,7 +497,7 @@ int32 Xbe::WriteExe(const char *Filename)
|
||||||
ExeHeaders.OptionalHeader.SizeOfImage = Header.SizeOfImage; // already aligned at 0x20
|
ExeHeaders.OptionalHeader.SizeOfImage = Header.SizeOfImage; // already aligned at 0x20
|
||||||
ExeHeaders.OptionalHeader.SizeOfHeaders = RoundUp(sizeof(MICRO_EXE_HEADERS), EXE_ALIGNMENT);
|
ExeHeaders.OptionalHeader.SizeOfHeaders = RoundUp(sizeof(MICRO_EXE_HEADERS), EXE_ALIGNMENT);
|
||||||
ExeHeaders.OptionalHeader.CheckSum = 0;
|
ExeHeaders.OptionalHeader.CheckSum = 0;
|
||||||
ExeHeaders.OptionalHeader.Subsystem = IMAGE_SUBSYSTEM_WINDOWS_GUI;
|
ExeHeaders.OptionalHeader.Subsystem = IMAGE_SUBSYSTEM_WINDOWS_CUI;
|
||||||
ExeHeaders.OptionalHeader.DllCharacteristics = 0x400;
|
ExeHeaders.OptionalHeader.DllCharacteristics = 0x400;
|
||||||
ExeHeaders.OptionalHeader.SizeOfStackReserve = 0x100000;
|
ExeHeaders.OptionalHeader.SizeOfStackReserve = 0x100000;
|
||||||
ExeHeaders.OptionalHeader.SizeOfStackCommit = 0x1000;
|
ExeHeaders.OptionalHeader.SizeOfStackCommit = 0x1000;
|
||||||
|
|
Loading…
Reference in a new issue