Kernel
This commit is contained in:
parent
1ca5885543
commit
05afe9b15a
|
@ -83,18 +83,18 @@ class Xbe : public Error
|
|||
#include "AlignPrefix1.h"
|
||||
struct Header
|
||||
{
|
||||
uint32 dwMagic; // magic number [should be "XBEH"]
|
||||
uint08 pbDigitalSignature[256]; // digital signature
|
||||
uint32 dwBaseAddr; // base address
|
||||
uint32 dwSizeofHeaders; // size of headers
|
||||
uint32 dwSizeofImage; // size of image
|
||||
uint32 dwSizeofImageHeader; // size of image header
|
||||
uint32 dwTimeDate; // timedate stamp
|
||||
uint32 dwCertificateAddr; // certificate address
|
||||
uint32 dwSections; // number of sections
|
||||
uint32 dwSectionHeadersAddr; // section headers address
|
||||
uint32 dwMagic; // 0x0000 - magic number [should be "XBEH"]
|
||||
uint08 pbDigitalSignature[256]; // 0x0004 - digital signature
|
||||
uint32 dwBaseAddr; // 0x0104 - base address
|
||||
uint32 dwSizeofHeaders; // 0x0108 - size of headers
|
||||
uint32 dwSizeofImage; // 0x010C - size of image
|
||||
uint32 dwSizeofImageHeader; // 0x0110 - size of image header
|
||||
uint32 dwTimeDate; // 0x0114 - timedate stamp
|
||||
uint32 dwCertificateAddr; // 0x0118 - certificate address
|
||||
uint32 dwSections; // 0x011C - number of sections
|
||||
uint32 dwSectionHeadersAddr; // 0x0120 - section headers address
|
||||
|
||||
struct InitFlags
|
||||
struct InitFlags // 0x0124 - initialization flags
|
||||
{
|
||||
uint32 bMountUtilityDrive : 1; // mount utility drive flag
|
||||
uint32 bFormatUtilityDrive : 1; // format utility drive flag
|
||||
|
@ -107,26 +107,26 @@ class Xbe : public Error
|
|||
}
|
||||
dwInitFlags;
|
||||
|
||||
uint32 dwEntryAddr; // entry point address
|
||||
uint32 dwTLSAddr; // thread local storage directory address
|
||||
uint32 dwPeStackCommit; // size of stack commit
|
||||
uint32 dwPeHeapReserve; // size of heap reserve
|
||||
uint32 dwPeHeapCommit; // size of heap commit
|
||||
uint32 dwPeBaseAddr; // original base address
|
||||
uint32 dwPeSizeofImage; // size of original image
|
||||
uint32 dwPeChecksum; // original checksum
|
||||
uint32 dwPeTimeDate; // original timedate stamp
|
||||
uint32 dwDebugPathnameAddr; // debug pathname address
|
||||
uint32 dwDebugFilenameAddr; // debug filename address
|
||||
uint32 dwDebugUnicodeFilenameAddr; // debug unicode filename address
|
||||
uint32 dwKernelImageThunkAddr; // kernel image thunk address
|
||||
uint32 dwNonKernelImportDirAddr; // non kernel import directory address
|
||||
uint32 dwLibraryVersions; // number of library versions
|
||||
uint32 dwLibraryVersionsAddr; // library versions address
|
||||
uint32 dwKernelLibraryVersionAddr; // kernel library version address
|
||||
uint32 dwXAPILibraryVersionAddr; // xapi library version address
|
||||
uint32 dwLogoBitmapAddr; // logo bitmap address
|
||||
uint32 dwSizeofLogoBitmap; // logo bitmap size
|
||||
uint32 dwEntryAddr; // 0x0128 - entry point address
|
||||
uint32 dwTLSAddr; // 0x012C - thread local storage directory address
|
||||
uint32 dwPeStackCommit; // 0x0130 - size of stack commit
|
||||
uint32 dwPeHeapReserve; // 0x0134 - size of heap reserve
|
||||
uint32 dwPeHeapCommit; // 0x0138 - size of heap commit
|
||||
uint32 dwPeBaseAddr; // 0x013C - original base address
|
||||
uint32 dwPeSizeofImage; // 0x0140 - size of original image
|
||||
uint32 dwPeChecksum; // 0x0144 - original checksum
|
||||
uint32 dwPeTimeDate; // 0x0148 - original timedate stamp
|
||||
uint32 dwDebugPathnameAddr; // 0x014C - debug pathname address
|
||||
uint32 dwDebugFilenameAddr; // 0x0150 - debug filename address
|
||||
uint32 dwDebugUnicodeFilenameAddr; // 0x0154 - debug unicode filename address
|
||||
uint32 dwKernelImageThunkAddr; // 0x0158 - kernel image thunk address
|
||||
uint32 dwNonKernelImportDirAddr; // 0x015C - non kernel import directory address
|
||||
uint32 dwLibraryVersions; // 0x0160 - number of library versions
|
||||
uint32 dwLibraryVersionsAddr; // 0x0164 - library versions address
|
||||
uint32 dwKernelLibraryVersionAddr; // 0x0168 - kernel library version address
|
||||
uint32 dwXAPILibraryVersionAddr; // 0x016C - xapi library version address
|
||||
uint32 dwLogoBitmapAddr; // 0x0170 - logo bitmap address
|
||||
uint32 dwSizeofLogoBitmap; // 0x0174 - logo bitmap size
|
||||
}
|
||||
#include "AlignPosfix1.h"
|
||||
m_Header;
|
||||
|
@ -142,19 +142,19 @@ class Xbe : public Error
|
|||
#include "AlignPrefix1.h"
|
||||
struct Certificate
|
||||
{
|
||||
uint32 dwSize; // size of certificate
|
||||
uint32 dwTimeDate; // timedate stamp
|
||||
uint32 dwTitleId; // title id
|
||||
wchar_t wszTitleName[40]; // title name (unicode)
|
||||
uint32 dwAlternateTitleId[0x10]; // alternate title ids
|
||||
uint32 dwAllowedMedia; // allowed media types
|
||||
uint32 dwGameRegion; // game region
|
||||
uint32 dwGameRatings; // game ratings
|
||||
uint32 dwDiskNumber; // disk number
|
||||
uint32 dwVersion; // version
|
||||
uint08 bzLanKey[16]; // lan key
|
||||
uint08 bzSignatureKey[16]; // signature key
|
||||
uint08 bzTitleAlternateSignatureKey[16][16]; // alternate signature keys
|
||||
uint32 dwSize; // 0x0000 - size of certificate
|
||||
uint32 dwTimeDate; // 0x0004 - timedate stamp
|
||||
uint32 dwTitleId; // 0x0008 - title id
|
||||
wchar_t wszTitleName[40]; // 0x000C - title name (unicode)
|
||||
uint32 dwAlternateTitleId[0x10]; // 0x005C - alternate title ids
|
||||
uint32 dwAllowedMedia; // 0x009C - allowed media types
|
||||
uint32 dwGameRegion; // 0x00A0 - game region
|
||||
uint32 dwGameRatings; // 0x00A4 - game ratings
|
||||
uint32 dwDiskNumber; // 0x00A8 - disk number
|
||||
uint32 dwVersion; // 0x00AC - version
|
||||
uint08 bzLanKey[16]; // 0x00B0 - lan key
|
||||
uint08 bzSignatureKey[16]; // 0x00C0 - signature key
|
||||
uint08 bzTitleAlternateSignatureKey[16][16]; // 0x00D0 - alternate signature keys
|
||||
}
|
||||
#include "AlignPosfix1.h"
|
||||
m_Certificate;
|
||||
|
|
|
@ -206,11 +206,16 @@ CXBXKRNL_API void NTAPI EmuXInit(DebugMode DebugConsole, char *DebugFilename, ui
|
|||
|
||||
VirtualProtect((void*)0x00010000, 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 dwPeHeapReserve = *(uint32*)&XBEHeader[0x0134];
|
||||
uint32 dwPeHeapCommit = *(uint32*)&XBEHeader[0x0138];
|
||||
|
||||
*(uint32 *)0x00010108 = dwSizeofHeaders;
|
||||
*(uint32 *)0x00010118 = dwCertificateAddr;
|
||||
*(uint32 *)0x00010134 = dwPeHeapReserve;
|
||||
*(uint32 *)0x00010138 = dwPeHeapCommit;
|
||||
|
||||
memcpy((void*)dwCertificateAddr, &XBEHeader[dwCertificateAddr - 0x00010000], sizeof(Xbe::Certificate));
|
||||
}
|
||||
|
@ -507,6 +512,76 @@ XBSYSAPI EXPORTNUM(113) VOID NTAPI xboxkrnl::KeInitializeTimerEx
|
|||
return;
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * 0x0095 - KeSetTimer
|
||||
// ******************************************************************
|
||||
XBSYSAPI EXPORTNUM(149) xboxkrnl::BOOLEAN NTAPI xboxkrnl::KeSetTimer
|
||||
(
|
||||
IN PKTIMER Timer,
|
||||
IN LARGE_INTEGER DueTime,
|
||||
IN PKDPC Dpc OPTIONAL
|
||||
)
|
||||
{
|
||||
EmuXSwapFS(); // Win2k/XP FS
|
||||
|
||||
// ******************************************************************
|
||||
// * debug trace
|
||||
// ******************************************************************
|
||||
#ifdef _DEBUG
|
||||
{
|
||||
printf("CxbxKrnl [0x%.08X]: KeSetTimer\n"
|
||||
" (\n"
|
||||
" Timer : 0x%.08X\n"
|
||||
" DueTime : 0x%I64X\n"
|
||||
" Dpc : 0x%.08X\n"
|
||||
" );\n",
|
||||
GetCurrentThreadId(), Timer, DueTime, Dpc);
|
||||
}
|
||||
#endif
|
||||
|
||||
EmuXSwapFS(); // XBox FS
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * 0x00B8 - NtAllocateVirtualMemory
|
||||
// ******************************************************************
|
||||
XBSYSAPI EXPORTNUM(184) NTSTATUS xboxkrnl::NtAllocateVirtualMemory
|
||||
(
|
||||
IN OUT PVOID *BaseAddress,
|
||||
IN ULONG ZeroBits,
|
||||
IN OUT SIZE_T AllocationSize,
|
||||
IN DWORD AllocationType,
|
||||
IN DWORD Protect
|
||||
)
|
||||
{
|
||||
EmuXSwapFS(); // Win2k/XP FS
|
||||
|
||||
// ******************************************************************
|
||||
// * debug trace
|
||||
// ******************************************************************
|
||||
#ifdef _DEBUG
|
||||
{
|
||||
printf("CxbxKrnl [0x%.08X]: NtAllocateVirtualMemory\n"
|
||||
" (\n"
|
||||
" BaseAddress : 0x%.08X\n"
|
||||
" ZeroBits : 0x%.08X\n"
|
||||
" AllocationSize : 0x%.08X\n"
|
||||
" AllocationType : 0x%.08X\n"
|
||||
" Protect : 0x%.08X\n"
|
||||
" );\n",
|
||||
GetCurrentThreadId(), BaseAddress, ZeroBits, AllocationSize, AllocationType, Protect);
|
||||
}
|
||||
#endif
|
||||
|
||||
*BaseAddress = VirtualAlloc(*BaseAddress, AllocationSize, AllocationType, Protect);
|
||||
|
||||
EmuXSwapFS(); // XBox FS
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * 0x00BB - NtClose
|
||||
// ******************************************************************
|
||||
|
@ -538,6 +613,82 @@ XBSYSAPI EXPORTNUM(187) NTSTATUS NTAPI xboxkrnl::NtClose
|
|||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * 0x00CA - NtOpenFile
|
||||
// ******************************************************************
|
||||
XBSYSAPI EXPORTNUM(202) NTSTATUS xboxkrnl::NtOpenFile
|
||||
(
|
||||
OUT PHANDLE FileHandle,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||
IN ULONG ShareAccess,
|
||||
IN ULONG OpenOptions
|
||||
)
|
||||
{
|
||||
EmuXSwapFS(); // Win2k/XP FS
|
||||
|
||||
// ******************************************************************
|
||||
// * debug trace
|
||||
// ******************************************************************
|
||||
#ifdef _DEBUG
|
||||
{
|
||||
printf("CxbxKrnl [0x%.08X]: NtOpenFile\n"
|
||||
" (\n"
|
||||
" FileHandle : 0x%.08X\n"
|
||||
" DesiredAccess : 0x%.08X\n"
|
||||
" ObjectAttributes : 0x%.08X\n"
|
||||
" IoStatusBlock : 0x%.08X\n"
|
||||
" ShareAccess : 0x%.08X\n"
|
||||
" OpenOptions : 0x%.08X\n"
|
||||
" );\n",
|
||||
GetCurrentThreadId(), FileHandle, DesiredAccess, ObjectAttributes,
|
||||
IoStatusBlock, ShareAccess, OpenOptions);
|
||||
}
|
||||
#endif
|
||||
|
||||
EmuXSwapFS(); // XBox FS
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * 0x00DA - NtQueryVolumeInformationFile
|
||||
// ******************************************************************
|
||||
XBSYSAPI EXPORTNUM(218) NTSTATUS NTAPI xboxkrnl::NtQueryVolumeInformationFile
|
||||
(
|
||||
IN HANDLE FileHandle,
|
||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||
OUT PVOID FileInformation,
|
||||
IN ULONG Length,
|
||||
IN FS_INFORMATION_CLASS FileInformationClass
|
||||
)
|
||||
{
|
||||
EmuXSwapFS(); // Win2k/XP FS
|
||||
|
||||
// ******************************************************************
|
||||
// * debug trace
|
||||
// ******************************************************************
|
||||
#ifdef _DEBUG
|
||||
{
|
||||
printf("CxbxKrnl [0x%.08X]: NtQueryVolumeInformationFile\n"
|
||||
" (\n"
|
||||
" FileHandle : 0x%.08X\n"
|
||||
" IoStatusBlock : 0x%.08X\n"
|
||||
" FileInformation : 0x%.08X\n"
|
||||
" Length : 0x%.08X\n"
|
||||
" FileInformationClass: 0x%.08X\n"
|
||||
" );\n",
|
||||
GetCurrentThreadId(), FileHandle, IoStatusBlock, FileInformation,
|
||||
Length, FileInformationClass);
|
||||
}
|
||||
#endif
|
||||
|
||||
EmuXSwapFS(); // XBox FS
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * 0x00FF - PsCreateSystemThreadEx
|
||||
// ******************************************************************
|
||||
|
@ -631,6 +782,36 @@ XBSYSAPI EXPORTNUM(277) VOID NTAPI xboxkrnl::RtlEnterCriticalSection
|
|||
EmuXSwapFS(); // XBox FS
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * 0x0123 - RtlInitializeCriticalSection
|
||||
// ******************************************************************
|
||||
XBSYSAPI EXPORTNUM(291) VOID NTAPI xboxkrnl::RtlInitializeCriticalSection
|
||||
(
|
||||
IN PRTL_CRITICAL_SECTION CriticalSection
|
||||
)
|
||||
{
|
||||
EmuXSwapFS(); // Win2k/XP FS
|
||||
|
||||
// ******************************************************************
|
||||
// * debug trace
|
||||
// ******************************************************************
|
||||
#ifdef _DEBUG
|
||||
{
|
||||
printf("CxbxKrnl [0x%.08X]: RtlInitializeCriticalSection\n"
|
||||
" (\n"
|
||||
" CriticalSection : 0x%.08X\n"
|
||||
" );\n",
|
||||
GetCurrentThreadId(), CriticalSection);
|
||||
}
|
||||
#endif
|
||||
|
||||
InitializeCriticalSection((win32::PRTL_CRITICAL_SECTION)CriticalSection);
|
||||
|
||||
EmuXSwapFS(); // XBox FS
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * 0x0126 RtlEnterCriticalSection
|
||||
// ******************************************************************
|
||||
|
|
|
@ -199,7 +199,7 @@ CXBXKRNL_API uint32 KernelThunkTable[367] =
|
|||
(uint32)PANIC(0x0092), // 0x0092 (146)
|
||||
(uint32)PANIC(0x0093), // 0x0093 (147)
|
||||
(uint32)PANIC(0x0094), // 0x0094 (148)
|
||||
(uint32)PANIC(0x0095), // 0x0095 (149)
|
||||
(uint32)&xboxkrnl::KeSetTimer, // 0x0095 (149)
|
||||
(uint32)PANIC(0x0096), // 0x0096 (150)
|
||||
(uint32)PANIC(0x0097), // 0x0097 (151)
|
||||
(uint32)PANIC(0x0098), // 0x0098 (152)
|
||||
|
@ -234,7 +234,7 @@ CXBXKRNL_API uint32 KernelThunkTable[367] =
|
|||
(uint32)PANIC(0x00B5), // 0x00B5 (181)
|
||||
(uint32)PANIC(0x00B6), // 0x00B6 (182)
|
||||
(uint32)PANIC(0x00B7), // 0x00B7 (183)
|
||||
(uint32)PANIC(0x00B8), // 0x00B8 (184)
|
||||
(uint32)&xboxkrnl::NtAllocateVirtualMemory, // 0x00B8 (184)
|
||||
(uint32)PANIC(0x00B9), // 0x00B9 (185)
|
||||
(uint32)PANIC(0x00BA), // 0x00BA (186)
|
||||
(uint32)&xboxkrnl::NtClose, // 0x00BB (187)
|
||||
|
@ -252,7 +252,7 @@ CXBXKRNL_API uint32 KernelThunkTable[367] =
|
|||
(uint32)PANIC(0x00C7), // 0x00C7 (199)
|
||||
(uint32)PANIC(0x00C8), // 0x00C8 (200)
|
||||
(uint32)PANIC(0x00C9), // 0x00C9 (201)
|
||||
(uint32)PANIC(0x00CA), // 0x00CA (202)
|
||||
(uint32)&xboxkrnl::NtOpenFile, // 0x00CA (202)
|
||||
(uint32)PANIC(0x00CB), // 0x00CB (203)
|
||||
(uint32)PANIC(0x00CC), // 0x00CC (204)
|
||||
(uint32)PANIC(0x00CD), // 0x00CD (205)
|
||||
|
@ -268,7 +268,7 @@ CXBXKRNL_API uint32 KernelThunkTable[367] =
|
|||
(uint32)PANIC(0x00D7), // 0x00D7 (215)
|
||||
(uint32)PANIC(0x00D8), // 0x00D8 (216)
|
||||
(uint32)PANIC(0x00D9), // 0x00D9 (217)
|
||||
(uint32)PANIC(0x00DA), // 0x00DA (218)
|
||||
(uint32)&xboxkrnl::NtQueryVolumeInformationFile,// 0x00DA (218)
|
||||
(uint32)PANIC(0x00DB), // 0x00DB (219)
|
||||
(uint32)PANIC(0x00DC), // 0x00DC (220)
|
||||
(uint32)PANIC(0x00DD), // 0x00DD (221)
|
||||
|
@ -341,7 +341,7 @@ CXBXKRNL_API uint32 KernelThunkTable[367] =
|
|||
(uint32)PANIC(0x0120), // 0x0120 (288)
|
||||
(uint32)PANIC(0x0121), // 0x0121 (289)
|
||||
(uint32)PANIC(0x0122), // 0x0122 (290)
|
||||
(uint32)PANIC(0x0123), // 0x0123 (291)
|
||||
(uint32)&xboxkrnl::RtlInitializeCriticalSection,// 0x0123 (291)
|
||||
(uint32)PANIC(0x0124), // 0x0124 (292)
|
||||
(uint32)PANIC(0x0125), // 0x0125 (293)
|
||||
(uint32)xboxkrnl::RtlLeaveCriticalSection, // 0x0126 (294)
|
||||
|
|
Loading…
Reference in New Issue