This commit is contained in:
Aaron Robinson 2003-02-10 04:51:49 +00:00
parent 09eb8150a2
commit d7900d016e
4 changed files with 71 additions and 18 deletions

View File

@ -1,3 +1,54 @@
disassemble
// ******************************************************************
// * disassemble entry point 0x50 bytes
// ******************************************************************
{
const int BUF_SIZE = 0x50;
disassemble_init(0, INTEL_SYNTAX);
char buf[BUF_SIZE]; /* buffer of bytes to disassemble */
int pos = 0; /* current position in buffer */
int size = 0; /* size of instruction */
struct instr i; /* representation of the code instruction */
while(pos > BUF_SIZE)
{
disassemble_address(buf + pos, &i);
if(size)
{
printf("%.08X: %s", pos, i.mnemonic);
if(i.destType)
{
printf(" %s", i.dest);
if(i.srcType)
{
printf(", %s", i.src);
if(i.auxType)
{
printf(", %s", i.aux);
}
}
}
printf("\n");
pos += size;
}
else
{
pos++;
}
}
disassemble_cleanup();
}
xboxkrnl::NtOpenFile :
/*

View File

@ -2,6 +2,9 @@ Cxbx Todo:
Recent files (for .exe and .xbe) in menu. (Use registry)
Attempt to add compatibility with ME by using LLDT assembly. This
may not even work, but might as well try it.
Xbe files should associate with Cxbx (by user configuration). There
should be configuration allowing the Xbe to execute automatically
without a GUI at all, or for the Xbe to open in the Cxbx GUI. This

View File

@ -64,7 +64,7 @@ extern "C"
// ******************************************************************
// * func: EmuXInit
// ******************************************************************
CXBXKRNL_API void NTAPI EmuXInit(DebugMode DebugConsole, char *DebugFilename, uint08 *XBEHeader, uint32 XBEHeaderSize, void (*Entry)());
CXBXKRNL_API void NTAPI EmuXInit(DebugMode DebugConsole, char *DebugFilename, Xbe::Header *XbeHeader, uint32 XbeHeaderSize, void (*Entry)());
// ******************************************************************
// * func: EmuXDummy

View File

@ -51,12 +51,12 @@ namespace xntdll
// ******************************************************************
// * static functions
// ******************************************************************
static void EmuXInstallWrappers(void (*Entry)());
static void EmuXInstallWrappers(void (*Entry)(), Xbe::Header *XbeHeader);
// ******************************************************************
// * func: EmuXInit
// ******************************************************************
CXBXKRNL_API void NTAPI EmuXInit(DebugMode DebugConsole, char *DebugFilename, uint08 *XBEHeader, uint32 XBEHeaderSize, void (*Entry)())
CXBXKRNL_API void NTAPI EmuXInit(DebugMode DebugConsole, char *DebugFilename, Xbe::Header *XbeHeader, uint32 XbeHeaderSize, void (*Entry)())
{
// ******************************************************************
// * debug console allocation (if configured)
@ -95,38 +95,35 @@ CXBXKRNL_API void NTAPI EmuXInit(DebugMode DebugConsole, char *DebugFilename, ui
" XBEHeaderSize : 0x%.08X\n"
" Entry : 0x%.08X\n"
");\n",
DebugConsole, DebugFilename, XBEHeader, XBEHeaderSize, Entry);
DebugConsole, DebugFilename, XbeHeader, XbeHeaderSize, Entry);
}
// ******************************************************************
// * Locate functions and install wrapper vectors
// ******************************************************************
{
EmuXInstallWrappers(Entry);
EmuXInstallWrappers(Entry, XbeHeader);
}
// ******************************************************************
// * Load the necessary pieces of XBEHeader
// ******************************************************************
{
Xbe::Header *MemXbeHeader = (Xbe::Header*)0x00010000;
uint32 old_protection = 0;
VirtualProtect((void*)0x00010000, 0x1000, PAGE_READWRITE, &old_protection);
VirtualProtect(MemXbeHeader, 0x1000, PAGE_READWRITE, &old_protection);
// we sure hope we aren't corrupting anything necessary for an .exe to survive :]
uint32 dwSizeofHeaders = *(uint32*)&XBEHeader[0x0108];
uint32 dwCertificateAddr = *(uint32*)&XBEHeader[0x0118];
uint32 dwInitFlags = *(uint32*)&XBEHeader[0x0124];
uint32 dwPeHeapReserve = *(uint32*)&XBEHeader[0x0134];
uint32 dwPeHeapCommit = *(uint32*)&XBEHeader[0x0138];
MemXbeHeader->dwSizeofHeaders = XbeHeader->dwSizeofHeaders;
MemXbeHeader->dwCertificateAddr = XbeHeader->dwCertificateAddr;
MemXbeHeader->dwPeHeapReserve = XbeHeader->dwPeHeapReserve;
MemXbeHeader->dwPeHeapCommit = XbeHeader->dwPeHeapCommit;
*(uint32 *)0x00010108 = dwSizeofHeaders;
*(uint32 *)0x00010118 = dwCertificateAddr;
*(uint32 *)0x00010124 = dwInitFlags;
*(uint32 *)0x00010134 = dwPeHeapReserve;
*(uint32 *)0x00010138 = dwPeHeapCommit;
memcpy(&MemXbeHeader->dwInitFlags, &XbeHeader->dwInitFlags, sizeof(XbeHeader->dwInitFlags));
memcpy((void*)dwCertificateAddr, &XBEHeader[dwCertificateAddr - 0x00010000], sizeof(Xbe::Certificate));
memcpy((void*)XbeHeader->dwCertificateAddr, &((uint08*)XbeHeader)[XbeHeader->dwCertificateAddr - 0x00010000], sizeof(Xbe::Certificate));
}
// ******************************************************************
@ -229,7 +226,7 @@ inline void EmuXInstallWrapper(void *FunctionAddr, void *WrapperAddr)
// ******************************************************************
// * func: EmuXInstallWrappers
// ******************************************************************
void EmuXInstallWrappers(void (*Entry)())
void EmuXInstallWrappers(void (*Entry)(), Xbe::Header *XbeHeader)
{
// ******************************************************************
// * debug trace
@ -250,6 +247,8 @@ void EmuXInstallWrappers(void (*Entry)())
printf("EmuXInstallWrappers: mainXapiStartup -> 0x%.08X\n", RealmainXapiStartup);
// Known to work on : XAPILIB Version 1.0.4627
// ******************************************************************
// * install CreateThread vector
// ******************************************************************