From 50d449d378678efa00db620c7a985f5a3f052244 Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Sat, 24 Dec 2016 01:04:54 +0100 Subject: [PATCH 01/27] Implemented NtQuerySemaphore --- import/OpenXDK/include/xboxkrnl/nt.h | 10 +++++++- import/OpenXDK/include/xboxkrnl/xboxkrnl.h | 6 +++++ src/CxbxKrnl/EmuKrnlNt.cpp | 27 ++++++++++++++++++++++ src/CxbxKrnl/EmuNtDll.cpp | 1 + src/CxbxKrnl/EmuNtDll.h | 20 ++++++++++++++++ src/CxbxKrnl/KernelThunk.cpp | 2 +- 6 files changed, 64 insertions(+), 2 deletions(-) diff --git a/import/OpenXDK/include/xboxkrnl/nt.h b/import/OpenXDK/include/xboxkrnl/nt.h index 0c1c954ea..1f42747e4 100644 --- a/import/OpenXDK/include/xboxkrnl/nt.h +++ b/import/OpenXDK/include/xboxkrnl/nt.h @@ -298,7 +298,15 @@ XBSYSAPI EXPORTNUM(211) NTSTATUS NTAPI NtQueryInformationFile XBSYSAPI VOID *NtQueryIoCompletion; XBSYSAPI VOID *NtQueryMutant; -XBSYSAPI VOID *NtQuerySemaphore; + +// ****************************************************************** +// * 0x00D6 - NtQuerySemaphore() +// ****************************************************************** +XBSYSAPI EXPORTNUM(214) NTSTATUS NTAPI NtQuerySemaphore +( + IN HANDLE SemaphoreHandle, + OUT PSEMAPHORE_BASIC_INFORMATION SemaphoreInformation +); // ****************************************************************** // * 0x00D7 - NtQuerySymbolicLinkObject() diff --git a/import/OpenXDK/include/xboxkrnl/xboxkrnl.h b/import/OpenXDK/include/xboxkrnl/xboxkrnl.h index c5d1ae740..cb0227ae9 100644 --- a/import/OpenXDK/include/xboxkrnl/xboxkrnl.h +++ b/import/OpenXDK/include/xboxkrnl/xboxkrnl.h @@ -1169,6 +1169,12 @@ typedef struct _KSEMAPHORE } KSEMAPHORE, *PKSEMAPHORE, *RESTRICTED_POINTER PRKSEMAPHORE; +// SEMAPHORE_BASIC_INFORMATION - same as Windows +typedef struct _SEMAPHORE_BASIC_INFORMATION { + LONG CurrentCount; + LONG MaximumCount; +} SEMAPHORE_BASIC_INFORMATION, *PSEMAPHORE_BASIC_INFORMATION; + typedef struct _ERWLOCK { LONG LockCount; diff --git a/src/CxbxKrnl/EmuKrnlNt.cpp b/src/CxbxKrnl/EmuKrnlNt.cpp index 03f6b87eb..d13d0dcb9 100644 --- a/src/CxbxKrnl/EmuKrnlNt.cpp +++ b/src/CxbxKrnl/EmuKrnlNt.cpp @@ -1002,6 +1002,33 @@ XBSYSAPI EXPORTNUM(211) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtQueryInformationFil RETURN(ret); } +// ****************************************************************** +// * 0x00D6 - NtQuerySemaphore() +// ****************************************************************** +XBSYSAPI EXPORTNUM(214) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtQuerySemaphore +( + IN HANDLE SemaphoreHandle, + OUT PSEMAPHORE_BASIC_INFORMATION SemaphoreInformation +) +{ + LOG_FUNC_BEGIN + LOG_FUNC_ARG(SemaphoreHandle) + LOG_FUNC_ARG_OUT(SemaphoreInformation) + LOG_FUNC_END; + + NTSTATUS ret = NtDll::NtQuerySemaphore( + (NtDll::HANDLE)SemaphoreHandle, + /*SemaphoreInformationClass*/NtDll::SEMAPHORE_INFORMATION_CLASS::SemaphoreBasicInformation, + SemaphoreInformation, + sizeof(SEMAPHORE_BASIC_INFORMATION), + /*ReturnLength=*/nullptr); + + if (ret != STATUS_SUCCESS) + EmuWarning("NtQuerySemaphore failed! (%s)", NtStatusToString(ret)); + + RETURN(ret); +} + // ****************************************************************** // * 0x00D7 - NtQuerySymbolicLinkObject() // ****************************************************************** diff --git a/src/CxbxKrnl/EmuNtDll.cpp b/src/CxbxKrnl/EmuNtDll.cpp index c38c455fd..034fee8b5 100644 --- a/src/CxbxKrnl/EmuNtDll.cpp +++ b/src/CxbxKrnl/EmuNtDll.cpp @@ -84,6 +84,7 @@ IMPORT(NtPulseEvent); IMPORT(NtQueryDirectoryFile); IMPORT(NtQueryFullAttributesFile); IMPORT(NtQueryInformationFile); +IMPORT(NtQuerySemaphore); IMPORT(NtQueryTimer); IMPORT(NtQueryVirtualMemory); IMPORT(NtQueryVolumeInformationFile); diff --git a/src/CxbxKrnl/EmuNtDll.h b/src/CxbxKrnl/EmuNtDll.h index dea4b7204..d89aa962f 100644 --- a/src/CxbxKrnl/EmuNtDll.h +++ b/src/CxbxKrnl/EmuNtDll.h @@ -419,6 +419,13 @@ typedef enum _MEMORY_INFORMATION_CLASS } MEMORY_INFORMATION_CLASS; +// ****************************************************************** +// * SEMAPHORE_INFORMATION_CLASS +// ****************************************************************** +typedef enum _SEMAPHORE_INFORMATION_CLASS { + SemaphoreBasicInformation +} SEMAPHORE_INFORMATION_CLASS, *PSEMAPHORE_INFORMATION_CLASS; + // ****************************************************************** // * EVENT_TYPE // ****************************************************************** @@ -1221,6 +1228,18 @@ typedef NTSTATUS (NTAPI *FPTR_NtCreateSemaphore) IN ULONG MaximumCount ); +// ****************************************************************** +// * NtQuerySemaphore +// ****************************************************************** +typedef NTSTATUS(NTAPI *FPTR_NtQuerySemaphore) +( + IN HANDLE SemaphoreHandle, + IN SEMAPHORE_INFORMATION_CLASS SemaphoreInformationClass, + OUT PVOID SemaphoreInformation, + IN ULONG SemaphoreInformationLength, + OUT PULONG ReturnLength OPTIONAL +); + // ****************************************************************** // * NtReleaseSemaphore // ****************************************************************** @@ -1627,6 +1646,7 @@ EXTERN(NtPulseEvent); EXTERN(NtQueryDirectoryFile); EXTERN(NtQueryFullAttributesFile); EXTERN(NtQueryInformationFile); +EXTERN(NtQuerySemaphore); EXTERN(NtQueryTimer); EXTERN(NtQueryVirtualMemory); EXTERN(NtQueryVolumeInformationFile); diff --git a/src/CxbxKrnl/KernelThunk.cpp b/src/CxbxKrnl/KernelThunk.cpp index 69144b952..3779b0183 100644 --- a/src/CxbxKrnl/KernelThunk.cpp +++ b/src/CxbxKrnl/KernelThunk.cpp @@ -279,7 +279,7 @@ extern "C" CXBXKRNL_API uint32 CxbxKrnl_KernelThunkTable[379] = (uint32)FUNC(&xboxkrnl::NtQueryInformationFile), // 0x00D3 (211) (uint32)PANIC(0x00D4), // 0x00D4 (212) NtQueryIoCompletion (uint32)PANIC(0x00D5), // 0x00D5 (213) NtQueryMutant - (uint32)PANIC(0x00D6), // 0x00D6 (214) NtQuerySemaphore + (uint32)FUNC(&xboxkrnl::NtQuerySemaphore), // 0x00D6 (214) (uint32)FUNC(&xboxkrnl::NtQuerySymbolicLinkObject), // 0x00D7 (215) (uint32)FUNC(&xboxkrnl::NtQueryTimer), // 0x00D8 (216) (uint32)FUNC(&xboxkrnl::NtQueryVirtualMemory), // 0x00D9 (217) From 8509e97ed90a2d85ecd1c0c131e0debb31cd3c18 Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Sat, 24 Dec 2016 01:20:26 +0100 Subject: [PATCH 02/27] Implemented NtQueryEvent --- import/OpenXDK/include/xboxkrnl/nt.h | 10 +++++++- import/OpenXDK/include/xboxkrnl/xboxkrnl.h | 9 +++++++- src/CxbxKrnl/EmuKrnlNt.cpp | 27 ++++++++++++++++++++++ src/CxbxKrnl/EmuNtDll.cpp | 1 + src/CxbxKrnl/EmuNtDll.h | 20 ++++++++++++++++ src/CxbxKrnl/KernelThunk.cpp | 2 +- 6 files changed, 66 insertions(+), 3 deletions(-) diff --git a/import/OpenXDK/include/xboxkrnl/nt.h b/import/OpenXDK/include/xboxkrnl/nt.h index 1f42747e4..f584f1849 100644 --- a/import/OpenXDK/include/xboxkrnl/nt.h +++ b/import/OpenXDK/include/xboxkrnl/nt.h @@ -269,7 +269,15 @@ XBSYSAPI EXPORTNUM(207) NTSTATUS NTAPI NtQueryDirectoryFile ); XBSYSAPI VOID *NtQueryDirectoryObject; -XBSYSAPI VOID *NtQueryEvent; + +// ****************************************************************** +// * 0x00D1 - NtQueryEvent() +// ****************************************************************** +XBSYSAPI EXPORTNUM(209) NTSTATUS NTAPI NtQueryEvent +( + IN HANDLE EventHandle, + OUT PEVENT_BASIC_INFORMATION EventInformation +); // ****************************************************************** // * NtQueryFullAttributesFile diff --git a/import/OpenXDK/include/xboxkrnl/xboxkrnl.h b/import/OpenXDK/include/xboxkrnl/xboxkrnl.h index cb0227ae9..d5050a70d 100644 --- a/import/OpenXDK/include/xboxkrnl/xboxkrnl.h +++ b/import/OpenXDK/include/xboxkrnl/xboxkrnl.h @@ -986,7 +986,7 @@ typedef struct _MEMORY_BASIC_INFORMATION MEMORY_BASIC_INFORMATION, *PMEMORY_BASIC_INFORMATION; // ****************************************************************** -// * EVENT_TYPE +// * EVENT_TYPE - same as Windows // ****************************************************************** typedef enum _EVENT_TYPE { @@ -1162,6 +1162,13 @@ typedef struct _KEVENT //KEVENT, *PKEVENT, *RESTRICTED_POINTER PRKEVENT; KEVENT, *PKEVENT, *PRKEVENT; // even with undefined RESTRICTED_POINTER, this doesn't compile +// EVENT_BASIC_INFORMATION - same as Windows +typedef struct _EVENT_BASIC_INFORMATION { + EVENT_TYPE EventType; + LONG EventState; +} EVENT_BASIC_INFORMATION, *PEVENT_BASIC_INFORMATION; + +// KSEMAPHORE typedef struct _KSEMAPHORE { DISPATCHER_HEADER Header; diff --git a/src/CxbxKrnl/EmuKrnlNt.cpp b/src/CxbxKrnl/EmuKrnlNt.cpp index d13d0dcb9..f0c2e47a7 100644 --- a/src/CxbxKrnl/EmuKrnlNt.cpp +++ b/src/CxbxKrnl/EmuKrnlNt.cpp @@ -933,6 +933,33 @@ XBSYSAPI EXPORTNUM(210) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtQueryFullAttributes RETURN(ret); } +// ****************************************************************** +// * 0x00D1 - NtQueryEvent() +// ****************************************************************** +XBSYSAPI EXPORTNUM(209) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtQueryEvent +( + IN HANDLE EventHandle, + OUT PEVENT_BASIC_INFORMATION EventInformation +) +{ + LOG_FUNC_BEGIN + LOG_FUNC_ARG(EventHandle) + LOG_FUNC_ARG_OUT(EventInformation) + LOG_FUNC_END; + + NTSTATUS ret = NtDll::NtQueryEvent( + (NtDll::HANDLE)EventHandle, + /*EventInformationClass*/NtDll::EVENT_INFORMATION_CLASS::EventBasicInformation, + EventInformation, + sizeof(EVENT_BASIC_INFORMATION), + /*ReturnLength=*/nullptr); + + if (ret != STATUS_SUCCESS) + EmuWarning("NtQueryEvent failed! (%s)", NtStatusToString(ret)); + + RETURN(ret); +} + // ****************************************************************** // * 0x00D3 - NtQueryInformationFile() // ****************************************************************** diff --git a/src/CxbxKrnl/EmuNtDll.cpp b/src/CxbxKrnl/EmuNtDll.cpp index 034fee8b5..1830b0809 100644 --- a/src/CxbxKrnl/EmuNtDll.cpp +++ b/src/CxbxKrnl/EmuNtDll.cpp @@ -82,6 +82,7 @@ IMPORT(NtFsControlFile); IMPORT(NtOpenSymbolicLinkObject); IMPORT(NtPulseEvent); IMPORT(NtQueryDirectoryFile); +IMPORT(NtQueryEvent); IMPORT(NtQueryFullAttributesFile); IMPORT(NtQueryInformationFile); IMPORT(NtQuerySemaphore); diff --git a/src/CxbxKrnl/EmuNtDll.h b/src/CxbxKrnl/EmuNtDll.h index d89aa962f..ee3bdce19 100644 --- a/src/CxbxKrnl/EmuNtDll.h +++ b/src/CxbxKrnl/EmuNtDll.h @@ -436,6 +436,13 @@ typedef enum _EVENT_TYPE } EVENT_TYPE; +// ****************************************************************** +// * EVENT_INFORMATION_CLASS +// ****************************************************************** +typedef enum _EVENT_INFORMATION_CLASS { + EventBasicInformation +} EVENT_INFORMATION_CLASS, *PEVENT_INFORMATION_CLASS; + // ****************************************************************** // * TIMER_TYPE // ****************************************************************** @@ -1187,6 +1194,18 @@ typedef NTSTATUS (NTAPI *FPTR_NtCreateEvent) IN BOOLEAN InitialState ); +// ****************************************************************** +// * NtQueryEvent +// ****************************************************************** +typedef NTSTATUS (NTAPI *FPTR_NtQueryEvent) +( + IN HANDLE EventHandle, + IN EVENT_INFORMATION_CLASS EventInformationClass, + OUT PVOID EventInformation, + IN ULONG EventInformationLength, + OUT PULONG ReturnLength OPTIONAL +); + // ****************************************************************** // * NtPulseEvent // ****************************************************************** @@ -1644,6 +1663,7 @@ EXTERN(NtFsControlFile); EXTERN(NtOpenSymbolicLinkObject); EXTERN(NtPulseEvent); EXTERN(NtQueryDirectoryFile); +EXTERN(NtQueryEvent); EXTERN(NtQueryFullAttributesFile); EXTERN(NtQueryInformationFile); EXTERN(NtQuerySemaphore); diff --git a/src/CxbxKrnl/KernelThunk.cpp b/src/CxbxKrnl/KernelThunk.cpp index 3779b0183..f7b0f4610 100644 --- a/src/CxbxKrnl/KernelThunk.cpp +++ b/src/CxbxKrnl/KernelThunk.cpp @@ -274,7 +274,7 @@ extern "C" CXBXKRNL_API uint32 CxbxKrnl_KernelThunkTable[379] = (uint32)FUNC(&xboxkrnl::NtQueueApcThread), // 0x00CE (206) (uint32)FUNC(&xboxkrnl::NtQueryDirectoryFile), // 0x00CF (207) (uint32)PANIC(0x00D0), // 0x00D0 (208) NtQueryDirectoryObject - (uint32)PANIC(0x00D1), // 0x00D1 (209) NtQueryEvent + (uint32)FUNC(&xboxkrnl::NtQueryEvent), // 0x00D1 (209) (uint32)FUNC(&xboxkrnl::NtQueryFullAttributesFile), // 0x00D2 (210) (uint32)FUNC(&xboxkrnl::NtQueryInformationFile), // 0x00D3 (211) (uint32)PANIC(0x00D4), // 0x00D4 (212) NtQueryIoCompletion From dc3d4beaa09d19b6dc21bbfa904da1b538a9cff4 Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Mon, 26 Dec 2016 13:05:56 +0100 Subject: [PATCH 03/27] Implemented RtlEqualUnicodeString --- import/OpenXDK/include/xboxkrnl/rtl.h | 13 +++++++++++-- src/CxbxKrnl/EmuKrnlRtl.cpp | 21 +++++++++++++++++++++ src/CxbxKrnl/EmuNtDll.cpp | 1 + src/CxbxKrnl/EmuNtDll.h | 11 +++++++++++ src/CxbxKrnl/KernelThunk.cpp | 2 +- 5 files changed, 45 insertions(+), 3 deletions(-) diff --git a/import/OpenXDK/include/xboxkrnl/rtl.h b/import/OpenXDK/include/xboxkrnl/rtl.h index 4d7979e07..82b904f60 100644 --- a/import/OpenXDK/include/xboxkrnl/rtl.h +++ b/import/OpenXDK/include/xboxkrnl/rtl.h @@ -171,7 +171,7 @@ XBSYSAPI EXPORTNUM(277) VOID NTAPI RtlEnterCriticalSection XBSYSAPI VOID *RtlEnterCriticalSectionAndRegion; // ****************************************************************** -// * RtlEnterCriticalSection +// * 0x0117 - RtlEqualString() // ****************************************************************** XBSYSAPI EXPORTNUM(279) BOOLEAN NTAPI RtlEqualString ( @@ -180,7 +180,16 @@ XBSYSAPI EXPORTNUM(279) BOOLEAN NTAPI RtlEqualString IN BOOLEAN CaseSensitive ); -XBSYSAPI VOID *RtlEqualUnicodeString; +// ****************************************************************** +// * 0x0118 - RtlEqualUnicodeString() +// ****************************************************************** +XBSYSAPI EXPORTNUM(280) BOOLEAN NTAPI RtlEqualUnicodeString +( + IN PUNICODE_STRING String1, + IN PUNICODE_STRING String2, + IN BOOLEAN CaseSensitive +); + XBSYSAPI VOID *RtlExtendedIntegerMultiply; XBSYSAPI VOID *RtlExtendedLargeIntegerDivide; XBSYSAPI VOID *RtlExtendedMagicDivide; diff --git a/src/CxbxKrnl/EmuKrnlRtl.cpp b/src/CxbxKrnl/EmuKrnlRtl.cpp index 92d88b192..23911f5f0 100644 --- a/src/CxbxKrnl/EmuKrnlRtl.cpp +++ b/src/CxbxKrnl/EmuKrnlRtl.cpp @@ -455,6 +455,27 @@ XBSYSAPI EXPORTNUM(279) xboxkrnl::BOOLEAN NTAPI xboxkrnl::RtlEqualString RETURN(bRet); } +// ****************************************************************** +// * 0x0118 - RtlEqualUnicodeString() +// ****************************************************************** +XBSYSAPI EXPORTNUM(280) xboxkrnl::BOOLEAN NTAPI xboxkrnl::RtlEqualUnicodeString +( + IN PUNICODE_STRING String1, + IN PUNICODE_STRING String2, + IN BOOLEAN CaseSensitive +) +{ + LOG_FUNC_BEGIN + LOG_FUNC_ARG(String1) + LOG_FUNC_ARG(String2) + LOG_FUNC_ARG(CaseSensitive) + LOG_FUNC_END; + + BOOLEAN bRet = NtDll::RtlEqualUnicodeString((NtDll::PUNICODE_STRING)String1, (NtDll::PUNICODE_STRING)String2, (NtDll::BOOLEAN)CaseSensitive); + + RETURN(bRet); +} + // ****************************************************************** // * 0x011E - RtlFreeAnsiString() // ****************************************************************** diff --git a/src/CxbxKrnl/EmuNtDll.cpp b/src/CxbxKrnl/EmuNtDll.cpp index 1830b0809..4bdcc0e47 100644 --- a/src/CxbxKrnl/EmuNtDll.cpp +++ b/src/CxbxKrnl/EmuNtDll.cpp @@ -122,6 +122,7 @@ IMPORT(RtlDowncaseUnicodeChar); IMPORT(RtlDowncaseUnicodeString); IMPORT(RtlEnterCriticalSection); IMPORT(RtlEqualString); +IMPORT(RtlEqualUnicodeString); IMPORT(RtlFreeAnsiString); IMPORT(RtlFreeHeap); IMPORT(RtlInitAnsiString); diff --git a/src/CxbxKrnl/EmuNtDll.h b/src/CxbxKrnl/EmuNtDll.h index ee3bdce19..bbf101d55 100644 --- a/src/CxbxKrnl/EmuNtDll.h +++ b/src/CxbxKrnl/EmuNtDll.h @@ -1054,6 +1054,16 @@ typedef BOOLEAN (NTAPI *FPTR_RtlEqualString) IN BOOLEAN CaseSensitive ); +// ****************************************************************** +// * RtlEqualUnicodeString +// ****************************************************************** +typedef BOOLEAN (NTAPI *FPTR_RtlEqualUnicodeString) +( + IN PUNICODE_STRING String1, + IN PUNICODE_STRING String2, + IN BOOLEAN CaseSensitive +); + // ****************************************************************** // * NtDelayExecution // ****************************************************************** @@ -1703,6 +1713,7 @@ EXTERN(RtlDowncaseUnicodeChar); EXTERN(RtlDowncaseUnicodeString); EXTERN(RtlEnterCriticalSection); EXTERN(RtlEqualString); +EXTERN(RtlEqualUnicodeString); EXTERN(RtlFreeAnsiString); EXTERN(RtlFreeHeap); EXTERN(RtlInitAnsiString); diff --git a/src/CxbxKrnl/KernelThunk.cpp b/src/CxbxKrnl/KernelThunk.cpp index f7b0f4610..3b5675af6 100644 --- a/src/CxbxKrnl/KernelThunk.cpp +++ b/src/CxbxKrnl/KernelThunk.cpp @@ -345,7 +345,7 @@ extern "C" CXBXKRNL_API uint32 CxbxKrnl_KernelThunkTable[379] = (uint32)FUNC(&xboxkrnl::RtlEnterCriticalSection), // 0x0115 (277) (uint32)PANIC(0x0116), // 0x0116 (278) RtlEnterCriticalSectionAndRegion (uint32)FUNC(&xboxkrnl::RtlEqualString), // 0x0117 (279) - (uint32)PANIC(0x0118), // 0x0118 (280) RtlEqualUnicodeString + (uint32)FUNC(&xboxkrnl::RtlEqualUnicodeString), // 0x0118 (280) (uint32)PANIC(0x0119), // 0x0119 (281) RtlExtendedIntegerMultiply (uint32)PANIC(0x011A), // 0x011A (282) RtlExtendedLargeIntegerDivide (uint32)PANIC(0x011B), // 0x011B (283) RtlExtendedMagicDivide From fbd7bfdba5f8b9e33ea54332e9f151cd522f5164 Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Mon, 26 Dec 2016 13:23:00 +0100 Subject: [PATCH 04/27] Implemented RtlExtendedIntegerMultiply --- import/OpenXDK/include/xboxkrnl/rtl.h | 10 +++++++++- src/CxbxKrnl/EmuKrnlRtl.cpp | 27 +++++++++++++++++++++++++++ src/CxbxKrnl/EmuNtDll.cpp | 1 + src/CxbxKrnl/EmuNtDll.h | 24 +++++++++++++++++++++--- src/CxbxKrnl/KernelThunk.cpp | 2 +- 5 files changed, 59 insertions(+), 5 deletions(-) diff --git a/import/OpenXDK/include/xboxkrnl/rtl.h b/import/OpenXDK/include/xboxkrnl/rtl.h index 82b904f60..190ed3f0b 100644 --- a/import/OpenXDK/include/xboxkrnl/rtl.h +++ b/import/OpenXDK/include/xboxkrnl/rtl.h @@ -190,7 +190,15 @@ XBSYSAPI EXPORTNUM(280) BOOLEAN NTAPI RtlEqualUnicodeString IN BOOLEAN CaseSensitive ); -XBSYSAPI VOID *RtlExtendedIntegerMultiply; +// ****************************************************************** +// * 0x0119 - RtlExtendedIntegerMultiply() +// ****************************************************************** +XBSYSAPI EXPORTNUM(281) LARGE_INTEGER NTAPI RtlExtendedIntegerMultiply +( + IN LARGE_INTEGER Multiplicand, + IN LONG Multiplier +); + XBSYSAPI VOID *RtlExtendedLargeIntegerDivide; XBSYSAPI VOID *RtlExtendedMagicDivide; XBSYSAPI VOID *RtlFillMemory; diff --git a/src/CxbxKrnl/EmuKrnlRtl.cpp b/src/CxbxKrnl/EmuKrnlRtl.cpp index 23911f5f0..4615a6e9d 100644 --- a/src/CxbxKrnl/EmuKrnlRtl.cpp +++ b/src/CxbxKrnl/EmuKrnlRtl.cpp @@ -476,6 +476,33 @@ XBSYSAPI EXPORTNUM(280) xboxkrnl::BOOLEAN NTAPI xboxkrnl::RtlEqualUnicodeString RETURN(bRet); } +// ****************************************************************** +// * 0x0119 - RtlExtendedIntegerMultiply() +// ****************************************************************** +XBSYSAPI EXPORTNUM(281) xboxkrnl::LARGE_INTEGER NTAPI xboxkrnl::RtlExtendedIntegerMultiply +( + IN LARGE_INTEGER Multiplicand, + IN LONG Multiplier +) +{ + LOG_FUNC_BEGIN + LOG_FUNC_ARG(Multiplicand) + LOG_FUNC_ARG(Multiplier) + LOG_FUNC_END; + + LARGE_INTEGER ret; + + // As long as there are no type casts for NtDll::LARGE_INTEGER to xboxkrnl::LARGE_INTEGER + // and back, just copy the only member manually : + // TODO : Simplify this by adding typecasts between NtDll and xboxkrnl versions of LARGE_INTEGER + NtDll::LARGE_INTEGER NtMultiplicand; + NtMultiplicand.QuadPart = Multiplicand.QuadPart; + + ret.QuadPart = NtDll::RtlExtendedIntegerMultiply(NtMultiplicand, (NtDll::LONG)Multiplier).QuadPart; + + RETURN(ret); +} + // ****************************************************************** // * 0x011E - RtlFreeAnsiString() // ****************************************************************** diff --git a/src/CxbxKrnl/EmuNtDll.cpp b/src/CxbxKrnl/EmuNtDll.cpp index 4bdcc0e47..c145b9055 100644 --- a/src/CxbxKrnl/EmuNtDll.cpp +++ b/src/CxbxKrnl/EmuNtDll.cpp @@ -123,6 +123,7 @@ IMPORT(RtlDowncaseUnicodeString); IMPORT(RtlEnterCriticalSection); IMPORT(RtlEqualString); IMPORT(RtlEqualUnicodeString); +IMPORT(RtlExtendedIntegerMultiply); IMPORT(RtlFreeAnsiString); IMPORT(RtlFreeHeap); IMPORT(RtlInitAnsiString); diff --git a/src/CxbxKrnl/EmuNtDll.h b/src/CxbxKrnl/EmuNtDll.h index bbf101d55..5370ea4b6 100644 --- a/src/CxbxKrnl/EmuNtDll.h +++ b/src/CxbxKrnl/EmuNtDll.h @@ -115,6 +115,7 @@ typedef CONST WCHAR *LPCWSTR, *PCWSTR; // * NTSTATUS // ****************************************************************** typedef long NTSTATUS; +typedef __int64 LONGLONG; typedef unsigned __int64 ULONGLONG; #define NT_SUCCESS(Status) ((NTSTATUS) (Status) >= 0) @@ -210,10 +211,17 @@ MODE; // ****************************************************************** // * LARGE_INTEGER // ****************************************************************** -typedef struct _LARGE_INTEGER +typedef union _LARGE_INTEGER { - DWORD LowPart; - LONG HighPart; + struct { + DWORD LowPart; + LONG HighPart; + }; + struct { + DWORD LowPart; + LONG HighPart; + } u; + LONGLONG QuadPart; } LARGE_INTEGER, *PLARGE_INTEGER; @@ -1064,6 +1072,15 @@ typedef BOOLEAN (NTAPI *FPTR_RtlEqualUnicodeString) IN BOOLEAN CaseSensitive ); +// ****************************************************************** +// * RtlEqualUnicodeString +// ****************************************************************** +typedef LARGE_INTEGER (NTAPI *FPTR_RtlExtendedIntegerMultiply) +( + IN LARGE_INTEGER Multiplicand, + IN LONG Multiplier +); + // ****************************************************************** // * NtDelayExecution // ****************************************************************** @@ -1714,6 +1731,7 @@ EXTERN(RtlDowncaseUnicodeString); EXTERN(RtlEnterCriticalSection); EXTERN(RtlEqualString); EXTERN(RtlEqualUnicodeString); +EXTERN(RtlExtendedIntegerMultiply); EXTERN(RtlFreeAnsiString); EXTERN(RtlFreeHeap); EXTERN(RtlInitAnsiString); diff --git a/src/CxbxKrnl/KernelThunk.cpp b/src/CxbxKrnl/KernelThunk.cpp index 3b5675af6..39443a920 100644 --- a/src/CxbxKrnl/KernelThunk.cpp +++ b/src/CxbxKrnl/KernelThunk.cpp @@ -346,7 +346,7 @@ extern "C" CXBXKRNL_API uint32 CxbxKrnl_KernelThunkTable[379] = (uint32)PANIC(0x0116), // 0x0116 (278) RtlEnterCriticalSectionAndRegion (uint32)FUNC(&xboxkrnl::RtlEqualString), // 0x0117 (279) (uint32)FUNC(&xboxkrnl::RtlEqualUnicodeString), // 0x0118 (280) - (uint32)PANIC(0x0119), // 0x0119 (281) RtlExtendedIntegerMultiply + (uint32)FUNC(&xboxkrnl::RtlExtendedIntegerMultiply), // 0x0119 (281) (uint32)PANIC(0x011A), // 0x011A (282) RtlExtendedLargeIntegerDivide (uint32)PANIC(0x011B), // 0x011B (283) RtlExtendedMagicDivide (uint32)PANIC(0x011C), // 0x011C (284) RtlFillMemory From bcd6b98764ca5a16a183b306382821b1a8538ed3 Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Mon, 26 Dec 2016 13:28:51 +0100 Subject: [PATCH 05/27] Implemented RtlExtendedLargeIntegerDivide --- import/OpenXDK/include/xboxkrnl/rtl.h | 11 +++++++++- src/CxbxKrnl/EmuKrnlRtl.cpp | 29 +++++++++++++++++++++++++++ src/CxbxKrnl/EmuNtDll.cpp | 1 + src/CxbxKrnl/EmuNtDll.h | 13 +++++++++++- src/CxbxKrnl/KernelThunk.cpp | 2 +- 5 files changed, 53 insertions(+), 3 deletions(-) diff --git a/import/OpenXDK/include/xboxkrnl/rtl.h b/import/OpenXDK/include/xboxkrnl/rtl.h index 190ed3f0b..ea9f30706 100644 --- a/import/OpenXDK/include/xboxkrnl/rtl.h +++ b/import/OpenXDK/include/xboxkrnl/rtl.h @@ -199,7 +199,16 @@ XBSYSAPI EXPORTNUM(281) LARGE_INTEGER NTAPI RtlExtendedIntegerMultiply IN LONG Multiplier ); -XBSYSAPI VOID *RtlExtendedLargeIntegerDivide; +// ****************************************************************** +// * 0x011A - RtlExtendedLargeIntegerDivide() +// ****************************************************************** +XBSYSAPI EXPORTNUM(282) LARGE_INTEGER NTAPI RtlExtendedLargeIntegerDivide +( + IN LARGE_INTEGER Dividend, + IN ULONG Divisor, + IN PULONG Remainder // OUT? OPTIONAL? +); + XBSYSAPI VOID *RtlExtendedMagicDivide; XBSYSAPI VOID *RtlFillMemory; XBSYSAPI VOID *RtlFillMemoryUlong; diff --git a/src/CxbxKrnl/EmuKrnlRtl.cpp b/src/CxbxKrnl/EmuKrnlRtl.cpp index 4615a6e9d..0393250d5 100644 --- a/src/CxbxKrnl/EmuKrnlRtl.cpp +++ b/src/CxbxKrnl/EmuKrnlRtl.cpp @@ -503,6 +503,35 @@ XBSYSAPI EXPORTNUM(281) xboxkrnl::LARGE_INTEGER NTAPI xboxkrnl::RtlExtendedInteg RETURN(ret); } +// ****************************************************************** +// * 0x011A - RtlExtendedLargeIntegerDivide() +// ****************************************************************** +XBSYSAPI EXPORTNUM(282) xboxkrnl::LARGE_INTEGER NTAPI xboxkrnl::RtlExtendedLargeIntegerDivide +( + IN LARGE_INTEGER Dividend, + IN ULONG Divisor, + IN PULONG Remainder // OUT? OPTIONAL? +) +{ + LOG_FUNC_BEGIN + LOG_FUNC_ARG(Dividend) + LOG_FUNC_ARG(Divisor) + LOG_FUNC_ARG(Remainder) + LOG_FUNC_END; + + LARGE_INTEGER ret; + + // As long as there are no type casts for NtDll::LARGE_INTEGER to xboxkrnl::LARGE_INTEGER + // and back, just copy the only member manually : + // TODO : Simplify this by adding typecasts between NtDll and xboxkrnl versions of LARGE_INTEGER + NtDll::LARGE_INTEGER NtDividend; + NtDividend.QuadPart = Dividend.QuadPart; + + ret.QuadPart = NtDll::RtlExtendedLargeIntegerDivide(NtDividend, (NtDll::ULONG)Divisor, (NtDll::PULONG)Remainder).QuadPart; + + RETURN(ret); +} + // ****************************************************************** // * 0x011E - RtlFreeAnsiString() // ****************************************************************** diff --git a/src/CxbxKrnl/EmuNtDll.cpp b/src/CxbxKrnl/EmuNtDll.cpp index c145b9055..c84efb43d 100644 --- a/src/CxbxKrnl/EmuNtDll.cpp +++ b/src/CxbxKrnl/EmuNtDll.cpp @@ -124,6 +124,7 @@ IMPORT(RtlEnterCriticalSection); IMPORT(RtlEqualString); IMPORT(RtlEqualUnicodeString); IMPORT(RtlExtendedIntegerMultiply); +IMPORT(RtlExtendedLargeIntegerDivide); IMPORT(RtlFreeAnsiString); IMPORT(RtlFreeHeap); IMPORT(RtlInitAnsiString); diff --git a/src/CxbxKrnl/EmuNtDll.h b/src/CxbxKrnl/EmuNtDll.h index 5370ea4b6..7e6ae6790 100644 --- a/src/CxbxKrnl/EmuNtDll.h +++ b/src/CxbxKrnl/EmuNtDll.h @@ -1073,12 +1073,22 @@ typedef BOOLEAN (NTAPI *FPTR_RtlEqualUnicodeString) ); // ****************************************************************** -// * RtlEqualUnicodeString +// * RtlExtendedIntegerMultiply // ****************************************************************** typedef LARGE_INTEGER (NTAPI *FPTR_RtlExtendedIntegerMultiply) ( IN LARGE_INTEGER Multiplicand, IN LONG Multiplier + ); + +// ****************************************************************** +// * RtlExtendedLargeIntegerDivide +// ****************************************************************** +typedef LARGE_INTEGER (NTAPI *FPTR_RtlExtendedLargeIntegerDivide) +( + IN LARGE_INTEGER Dividend, + IN ULONG Divisor, + OUT PULONG Remainder ); // ****************************************************************** @@ -1732,6 +1742,7 @@ EXTERN(RtlEnterCriticalSection); EXTERN(RtlEqualString); EXTERN(RtlEqualUnicodeString); EXTERN(RtlExtendedIntegerMultiply); +EXTERN(RtlExtendedLargeIntegerDivide); EXTERN(RtlFreeAnsiString); EXTERN(RtlFreeHeap); EXTERN(RtlInitAnsiString); diff --git a/src/CxbxKrnl/KernelThunk.cpp b/src/CxbxKrnl/KernelThunk.cpp index 39443a920..597a8ef4e 100644 --- a/src/CxbxKrnl/KernelThunk.cpp +++ b/src/CxbxKrnl/KernelThunk.cpp @@ -347,7 +347,7 @@ extern "C" CXBXKRNL_API uint32 CxbxKrnl_KernelThunkTable[379] = (uint32)FUNC(&xboxkrnl::RtlEqualString), // 0x0117 (279) (uint32)FUNC(&xboxkrnl::RtlEqualUnicodeString), // 0x0118 (280) (uint32)FUNC(&xboxkrnl::RtlExtendedIntegerMultiply), // 0x0119 (281) - (uint32)PANIC(0x011A), // 0x011A (282) RtlExtendedLargeIntegerDivide + (uint32)FUNC(&xboxkrnl::RtlExtendedLargeIntegerDivide), // 0x011A (282) (uint32)PANIC(0x011B), // 0x011B (283) RtlExtendedMagicDivide (uint32)PANIC(0x011C), // 0x011C (284) RtlFillMemory (uint32)PANIC(0x011D), // 0x011D (285) RtlFillMemoryUlong From 7ced0be9e1874d0cb652bd36e82b0173d8025349 Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Mon, 26 Dec 2016 13:33:51 +0100 Subject: [PATCH 06/27] Implemented RtlExtendedMagicDivide --- import/OpenXDK/include/xboxkrnl/rtl.h | 11 ++++++++- src/CxbxKrnl/EmuKrnlRtl.cpp | 32 +++++++++++++++++++++++++++ src/CxbxKrnl/EmuNtDll.cpp | 1 + src/CxbxKrnl/EmuNtDll.h | 11 +++++++++ src/CxbxKrnl/KernelThunk.cpp | 2 +- 5 files changed, 55 insertions(+), 2 deletions(-) diff --git a/import/OpenXDK/include/xboxkrnl/rtl.h b/import/OpenXDK/include/xboxkrnl/rtl.h index ea9f30706..3ec2640d6 100644 --- a/import/OpenXDK/include/xboxkrnl/rtl.h +++ b/import/OpenXDK/include/xboxkrnl/rtl.h @@ -209,7 +209,16 @@ XBSYSAPI EXPORTNUM(282) LARGE_INTEGER NTAPI RtlExtendedLargeIntegerDivide IN PULONG Remainder // OUT? OPTIONAL? ); -XBSYSAPI VOID *RtlExtendedMagicDivide; +// ****************************************************************** +// * 0x011B - RtlExtendedMagicDivide() +// ****************************************************************** +XBSYSAPI EXPORTNUM(283) LARGE_INTEGER NTAPI RtlExtendedMagicDivide +( + IN LARGE_INTEGER Dividend, + IN LARGE_INTEGER MagicDivisor, + IN CCHAR ShiftCount +); + XBSYSAPI VOID *RtlFillMemory; XBSYSAPI VOID *RtlFillMemoryUlong; diff --git a/src/CxbxKrnl/EmuKrnlRtl.cpp b/src/CxbxKrnl/EmuKrnlRtl.cpp index 0393250d5..467510366 100644 --- a/src/CxbxKrnl/EmuKrnlRtl.cpp +++ b/src/CxbxKrnl/EmuKrnlRtl.cpp @@ -532,6 +532,38 @@ XBSYSAPI EXPORTNUM(282) xboxkrnl::LARGE_INTEGER NTAPI xboxkrnl::RtlExtendedLarge RETURN(ret); } +// ****************************************************************** +// * 0x011B - RtlExtendedMagicDivide() +// ****************************************************************** +XBSYSAPI EXPORTNUM(283) xboxkrnl::LARGE_INTEGER NTAPI xboxkrnl::RtlExtendedMagicDivide +( + IN LARGE_INTEGER Dividend, + IN LARGE_INTEGER MagicDivisor, + IN CCHAR ShiftCount +) +{ + LOG_FUNC_BEGIN + LOG_FUNC_ARG(Dividend) + LOG_FUNC_ARG(MagicDivisor) + LOG_FUNC_ARG(ShiftCount) + LOG_FUNC_END; + + LARGE_INTEGER ret; + + // As long as there are no type casts for NtDll::LARGE_INTEGER to xboxkrnl::LARGE_INTEGER + // and back, just copy the only member manually : + // TODO : Simplify this by adding typecasts between NtDll and xboxkrnl versions of LARGE_INTEGER + NtDll::LARGE_INTEGER NtDividend; + NtDividend.QuadPart = Dividend.QuadPart; + + NtDll::LARGE_INTEGER NtMagicDivisor; + NtMagicDivisor.QuadPart = MagicDivisor.QuadPart; + + ret.QuadPart = NtDll::RtlExtendedMagicDivide(NtDividend, NtMagicDivisor, (NtDll::CCHAR)ShiftCount).QuadPart; + + RETURN(ret); +} + // ****************************************************************** // * 0x011E - RtlFreeAnsiString() // ****************************************************************** diff --git a/src/CxbxKrnl/EmuNtDll.cpp b/src/CxbxKrnl/EmuNtDll.cpp index c84efb43d..557567252 100644 --- a/src/CxbxKrnl/EmuNtDll.cpp +++ b/src/CxbxKrnl/EmuNtDll.cpp @@ -125,6 +125,7 @@ IMPORT(RtlEqualString); IMPORT(RtlEqualUnicodeString); IMPORT(RtlExtendedIntegerMultiply); IMPORT(RtlExtendedLargeIntegerDivide); +IMPORT(RtlExtendedMagicDivide); IMPORT(RtlFreeAnsiString); IMPORT(RtlFreeHeap); IMPORT(RtlInitAnsiString); diff --git a/src/CxbxKrnl/EmuNtDll.h b/src/CxbxKrnl/EmuNtDll.h index 7e6ae6790..a72c77961 100644 --- a/src/CxbxKrnl/EmuNtDll.h +++ b/src/CxbxKrnl/EmuNtDll.h @@ -1091,6 +1091,16 @@ typedef LARGE_INTEGER (NTAPI *FPTR_RtlExtendedLargeIntegerDivide) OUT PULONG Remainder ); +// ****************************************************************** +// * RtlExtendedMagicDivide +// ****************************************************************** +typedef LARGE_INTEGER (NTAPI *FPTR_RtlExtendedMagicDivide) +( + IN LARGE_INTEGER Dividend, + IN LARGE_INTEGER MagicDivisor, + IN CCHAR ShiftCount +); + // ****************************************************************** // * NtDelayExecution // ****************************************************************** @@ -1743,6 +1753,7 @@ EXTERN(RtlEqualString); EXTERN(RtlEqualUnicodeString); EXTERN(RtlExtendedIntegerMultiply); EXTERN(RtlExtendedLargeIntegerDivide); +EXTERN(RtlExtendedMagicDivide); EXTERN(RtlFreeAnsiString); EXTERN(RtlFreeHeap); EXTERN(RtlInitAnsiString); diff --git a/src/CxbxKrnl/KernelThunk.cpp b/src/CxbxKrnl/KernelThunk.cpp index 597a8ef4e..d0eb93548 100644 --- a/src/CxbxKrnl/KernelThunk.cpp +++ b/src/CxbxKrnl/KernelThunk.cpp @@ -348,7 +348,7 @@ extern "C" CXBXKRNL_API uint32 CxbxKrnl_KernelThunkTable[379] = (uint32)FUNC(&xboxkrnl::RtlEqualUnicodeString), // 0x0118 (280) (uint32)FUNC(&xboxkrnl::RtlExtendedIntegerMultiply), // 0x0119 (281) (uint32)FUNC(&xboxkrnl::RtlExtendedLargeIntegerDivide), // 0x011A (282) - (uint32)PANIC(0x011B), // 0x011B (283) RtlExtendedMagicDivide + (uint32)FUNC(&xboxkrnl::RtlExtendedMagicDivide), // 0x011B (283) (uint32)PANIC(0x011C), // 0x011C (284) RtlFillMemory (uint32)PANIC(0x011D), // 0x011D (285) RtlFillMemoryUlong (uint32)FUNC(&xboxkrnl::RtlFreeAnsiString), // 0x011E (286) From eb841563de647f8de564a42275d17613b422fb06 Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Mon, 26 Dec 2016 13:44:44 +0100 Subject: [PATCH 07/27] Implemented RtlFillMemory --- import/OpenXDK/include/xboxkrnl/rtl.h | 11 ++++++++++- src/CxbxKrnl/EmuKrnlRtl.cpp | 22 ++++++++++++++++++++++ src/CxbxKrnl/EmuNtDll.cpp | 1 + src/CxbxKrnl/EmuNtDll.h | 11 +++++++++++ src/CxbxKrnl/KernelThunk.cpp | 2 +- 5 files changed, 45 insertions(+), 2 deletions(-) diff --git a/import/OpenXDK/include/xboxkrnl/rtl.h b/import/OpenXDK/include/xboxkrnl/rtl.h index 3ec2640d6..0448ea466 100644 --- a/import/OpenXDK/include/xboxkrnl/rtl.h +++ b/import/OpenXDK/include/xboxkrnl/rtl.h @@ -219,7 +219,16 @@ XBSYSAPI EXPORTNUM(283) LARGE_INTEGER NTAPI RtlExtendedMagicDivide IN CCHAR ShiftCount ); -XBSYSAPI VOID *RtlFillMemory; +// ****************************************************************** +// * 0x011C - RtlFillMemory() +// ****************************************************************** +XBSYSAPI EXPORTNUM(284) VOID NTAPI RtlFillMemory +( + IN VOID UNALIGNED *Destination, + IN DWORD Length, + IN BYTE Fill +); + XBSYSAPI VOID *RtlFillMemoryUlong; // ****************************************************************** diff --git a/src/CxbxKrnl/EmuKrnlRtl.cpp b/src/CxbxKrnl/EmuKrnlRtl.cpp index 467510366..294a47254 100644 --- a/src/CxbxKrnl/EmuKrnlRtl.cpp +++ b/src/CxbxKrnl/EmuKrnlRtl.cpp @@ -564,6 +564,28 @@ XBSYSAPI EXPORTNUM(283) xboxkrnl::LARGE_INTEGER NTAPI xboxkrnl::RtlExtendedMagic RETURN(ret); } +// Prevent errors compiling RtlFillMemory (TODO : How should we really do this?) +#undef RtlFillMemory + +// ****************************************************************** +// * 0x011C - RtlFillMemory() +// ****************************************************************** +XBSYSAPI EXPORTNUM(284) xboxkrnl::VOID NTAPI xboxkrnl::RtlFillMemory +( + IN VOID UNALIGNED *Destination, + IN DWORD Length, + IN BYTE Fill +) +{ + LOG_FUNC_BEGIN + LOG_FUNC_ARG(Destination) + LOG_FUNC_ARG(Length) + LOG_FUNC_ARG(Fill) + LOG_FUNC_END; + + NtDll::RtlFillMemory(Destination, Length, Fill); +} + // ****************************************************************** // * 0x011E - RtlFreeAnsiString() // ****************************************************************** diff --git a/src/CxbxKrnl/EmuNtDll.cpp b/src/CxbxKrnl/EmuNtDll.cpp index 557567252..d6c7cd6a1 100644 --- a/src/CxbxKrnl/EmuNtDll.cpp +++ b/src/CxbxKrnl/EmuNtDll.cpp @@ -126,6 +126,7 @@ IMPORT(RtlEqualUnicodeString); IMPORT(RtlExtendedIntegerMultiply); IMPORT(RtlExtendedLargeIntegerDivide); IMPORT(RtlExtendedMagicDivide); +IMPORT(RtlFillMemory); IMPORT(RtlFreeAnsiString); IMPORT(RtlFreeHeap); IMPORT(RtlInitAnsiString); diff --git a/src/CxbxKrnl/EmuNtDll.h b/src/CxbxKrnl/EmuNtDll.h index a72c77961..62e95ac48 100644 --- a/src/CxbxKrnl/EmuNtDll.h +++ b/src/CxbxKrnl/EmuNtDll.h @@ -1101,6 +1101,16 @@ typedef LARGE_INTEGER (NTAPI *FPTR_RtlExtendedMagicDivide) IN CCHAR ShiftCount ); +// ****************************************************************** +// * RtlFillMemory +// ****************************************************************** +typedef VOID (NTAPI *FPTR_RtlFillMemory) +( + OUT VOID UNALIGNED *Destination, + IN SIZE_T Length, + IN UCHAR Fill +); + // ****************************************************************** // * NtDelayExecution // ****************************************************************** @@ -1754,6 +1764,7 @@ EXTERN(RtlEqualUnicodeString); EXTERN(RtlExtendedIntegerMultiply); EXTERN(RtlExtendedLargeIntegerDivide); EXTERN(RtlExtendedMagicDivide); +EXTERN(RtlFillMemory); EXTERN(RtlFreeAnsiString); EXTERN(RtlFreeHeap); EXTERN(RtlInitAnsiString); diff --git a/src/CxbxKrnl/KernelThunk.cpp b/src/CxbxKrnl/KernelThunk.cpp index d0eb93548..4d7718fdd 100644 --- a/src/CxbxKrnl/KernelThunk.cpp +++ b/src/CxbxKrnl/KernelThunk.cpp @@ -349,7 +349,7 @@ extern "C" CXBXKRNL_API uint32 CxbxKrnl_KernelThunkTable[379] = (uint32)FUNC(&xboxkrnl::RtlExtendedIntegerMultiply), // 0x0119 (281) (uint32)FUNC(&xboxkrnl::RtlExtendedLargeIntegerDivide), // 0x011A (282) (uint32)FUNC(&xboxkrnl::RtlExtendedMagicDivide), // 0x011B (283) - (uint32)PANIC(0x011C), // 0x011C (284) RtlFillMemory + (uint32)FUNC(&xboxkrnl::RtlFillMemory), // 0x011C (284) (uint32)PANIC(0x011D), // 0x011D (285) RtlFillMemoryUlong (uint32)FUNC(&xboxkrnl::RtlFreeAnsiString), // 0x011E (286) (uint32)PANIC(0x011F), // 0x011F (287) RtlFreeUnicodeString From 39a5c6478643210509badbd15fdd80e9385b3d1b Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Mon, 26 Dec 2016 16:14:58 +0100 Subject: [PATCH 08/27] Implemented RtlFillMemoryUlong --- import/OpenXDK/include/xboxkrnl/rtl.h | 10 +++++++++- src/CxbxKrnl/EmuKrnlRtl.cpp | 19 +++++++++++++++++++ src/CxbxKrnl/EmuNtDll.cpp | 1 + src/CxbxKrnl/EmuNtDll.h | 11 +++++++++++ src/CxbxKrnl/KernelThunk.cpp | 2 +- 5 files changed, 41 insertions(+), 2 deletions(-) diff --git a/import/OpenXDK/include/xboxkrnl/rtl.h b/import/OpenXDK/include/xboxkrnl/rtl.h index 0448ea466..c391443e1 100644 --- a/import/OpenXDK/include/xboxkrnl/rtl.h +++ b/import/OpenXDK/include/xboxkrnl/rtl.h @@ -229,7 +229,15 @@ XBSYSAPI EXPORTNUM(284) VOID NTAPI RtlFillMemory IN BYTE Fill ); -XBSYSAPI VOID *RtlFillMemoryUlong; +// ****************************************************************** +// * 0x011D - RtlFillMemoryUlong() +// ****************************************************************** +XBSYSAPI EXPORTNUM(285) VOID NTAPI RtlFillMemoryUlong +( + IN PVOID Destination, + IN SIZE_T Length, + IN ULONG Pattern +); // ****************************************************************** // * RtlFreeAnsiString diff --git a/src/CxbxKrnl/EmuKrnlRtl.cpp b/src/CxbxKrnl/EmuKrnlRtl.cpp index 294a47254..3fc89bb72 100644 --- a/src/CxbxKrnl/EmuKrnlRtl.cpp +++ b/src/CxbxKrnl/EmuKrnlRtl.cpp @@ -586,6 +586,25 @@ XBSYSAPI EXPORTNUM(284) xboxkrnl::VOID NTAPI xboxkrnl::RtlFillMemory NtDll::RtlFillMemory(Destination, Length, Fill); } +// ****************************************************************** +// * 0x011D - RtlFillMemoryUlong() +// ****************************************************************** +XBSYSAPI EXPORTNUM(285) xboxkrnl::VOID NTAPI xboxkrnl::RtlFillMemoryUlong +( + IN PVOID Destination, + IN SIZE_T Length, + IN ULONG Pattern +) +{ + LOG_FUNC_BEGIN + LOG_FUNC_ARG(Destination) + LOG_FUNC_ARG(Length) + LOG_FUNC_ARG(Pattern) + LOG_FUNC_END; + + NtDll::RtlFillMemoryUlong(Destination, Length, Pattern); +} + // ****************************************************************** // * 0x011E - RtlFreeAnsiString() // ****************************************************************** diff --git a/src/CxbxKrnl/EmuNtDll.cpp b/src/CxbxKrnl/EmuNtDll.cpp index d6c7cd6a1..948b94714 100644 --- a/src/CxbxKrnl/EmuNtDll.cpp +++ b/src/CxbxKrnl/EmuNtDll.cpp @@ -127,6 +127,7 @@ IMPORT(RtlExtendedIntegerMultiply); IMPORT(RtlExtendedLargeIntegerDivide); IMPORT(RtlExtendedMagicDivide); IMPORT(RtlFillMemory); +IMPORT(RtlFillMemoryUlong); IMPORT(RtlFreeAnsiString); IMPORT(RtlFreeHeap); IMPORT(RtlInitAnsiString); diff --git a/src/CxbxKrnl/EmuNtDll.h b/src/CxbxKrnl/EmuNtDll.h index 62e95ac48..e531a803b 100644 --- a/src/CxbxKrnl/EmuNtDll.h +++ b/src/CxbxKrnl/EmuNtDll.h @@ -1111,6 +1111,16 @@ typedef VOID (NTAPI *FPTR_RtlFillMemory) IN UCHAR Fill ); +// ****************************************************************** +// * RtlFillMemoryUlong +// ****************************************************************** +typedef VOID (NTAPI *FPTR_RtlFillMemoryUlong) +( + OUT PVOID Destination, + IN SIZE_T Length, + IN ULONG Pattern +); + // ****************************************************************** // * NtDelayExecution // ****************************************************************** @@ -1765,6 +1775,7 @@ EXTERN(RtlExtendedIntegerMultiply); EXTERN(RtlExtendedLargeIntegerDivide); EXTERN(RtlExtendedMagicDivide); EXTERN(RtlFillMemory); +EXTERN(RtlFillMemoryUlong); EXTERN(RtlFreeAnsiString); EXTERN(RtlFreeHeap); EXTERN(RtlInitAnsiString); diff --git a/src/CxbxKrnl/KernelThunk.cpp b/src/CxbxKrnl/KernelThunk.cpp index 4d7718fdd..5b0d1924a 100644 --- a/src/CxbxKrnl/KernelThunk.cpp +++ b/src/CxbxKrnl/KernelThunk.cpp @@ -350,7 +350,7 @@ extern "C" CXBXKRNL_API uint32 CxbxKrnl_KernelThunkTable[379] = (uint32)FUNC(&xboxkrnl::RtlExtendedLargeIntegerDivide), // 0x011A (282) (uint32)FUNC(&xboxkrnl::RtlExtendedMagicDivide), // 0x011B (283) (uint32)FUNC(&xboxkrnl::RtlFillMemory), // 0x011C (284) - (uint32)PANIC(0x011D), // 0x011D (285) RtlFillMemoryUlong + (uint32)FUNC(&xboxkrnl::RtlFillMemoryUlong), // 0x011D (285) (uint32)FUNC(&xboxkrnl::RtlFreeAnsiString), // 0x011E (286) (uint32)PANIC(0x011F), // 0x011F (287) RtlFreeUnicodeString (uint32)PANIC(0x0120), // 0x0120 (288) RtlGetCallersAddress From b1cbc31c1bc98bbb2210cb407e24c3c531fc90e4 Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Mon, 26 Dec 2016 16:19:50 +0100 Subject: [PATCH 09/27] Implemented RtlFreeUnicodeString --- import/OpenXDK/include/xboxkrnl/rtl.h | 9 ++++++++- src/CxbxKrnl/EmuKrnlRtl.cpp | 13 +++++++++++++ src/CxbxKrnl/EmuNtDll.cpp | 1 + src/CxbxKrnl/EmuNtDll.h | 9 +++++++++ src/CxbxKrnl/KernelThunk.cpp | 2 +- 5 files changed, 32 insertions(+), 2 deletions(-) diff --git a/import/OpenXDK/include/xboxkrnl/rtl.h b/import/OpenXDK/include/xboxkrnl/rtl.h index c391443e1..4ecae2e01 100644 --- a/import/OpenXDK/include/xboxkrnl/rtl.h +++ b/import/OpenXDK/include/xboxkrnl/rtl.h @@ -247,7 +247,14 @@ XBSYSAPI EXPORTNUM(286) VOID NTAPI RtlFreeAnsiString IN OUT PANSI_STRING AnsiString ); -XBSYSAPI VOID *RtlFreeUnicodeString; +// ****************************************************************** +// * 0x011F - RtlFreeUnicodeString() +// ****************************************************************** +XBSYSAPI EXPORTNUM(287) VOID NTAPI RtlFreeUnicodeString +( + IN OUT PUNICODE_STRING UnicodeString +); + XBSYSAPI VOID *RtlGetCallersAddress; // ****************************************************************** diff --git a/src/CxbxKrnl/EmuKrnlRtl.cpp b/src/CxbxKrnl/EmuKrnlRtl.cpp index 3fc89bb72..1a50376fe 100644 --- a/src/CxbxKrnl/EmuKrnlRtl.cpp +++ b/src/CxbxKrnl/EmuKrnlRtl.cpp @@ -618,6 +618,19 @@ XBSYSAPI EXPORTNUM(286) xboxkrnl::VOID NTAPI xboxkrnl::RtlFreeAnsiString NtDll::RtlFreeAnsiString((NtDll::PANSI_STRING)AnsiString); } +// ****************************************************************** +// * 0x011F - RtlFreeUnicodeString() +// ****************************************************************** +XBSYSAPI EXPORTNUM(287) xboxkrnl::VOID NTAPI xboxkrnl::RtlFreeUnicodeString +( + IN OUT PUNICODE_STRING UnicodeString +) +{ + LOG_FUNC_ONE_ARG(UnicodeString); + + NtDll::RtlFreeUnicodeString((NtDll::PUNICODE_STRING)UnicodeString); +} + // ****************************************************************** // * 0x0121 - RtlInitAnsiString() // ****************************************************************** diff --git a/src/CxbxKrnl/EmuNtDll.cpp b/src/CxbxKrnl/EmuNtDll.cpp index 948b94714..cfa3febbd 100644 --- a/src/CxbxKrnl/EmuNtDll.cpp +++ b/src/CxbxKrnl/EmuNtDll.cpp @@ -130,6 +130,7 @@ IMPORT(RtlFillMemory); IMPORT(RtlFillMemoryUlong); IMPORT(RtlFreeAnsiString); IMPORT(RtlFreeHeap); +IMPORT(RtlFreeUnicodeString); IMPORT(RtlInitAnsiString); IMPORT(RtlInitializeCriticalSection); IMPORT(RtlInitUnicodeString); diff --git a/src/CxbxKrnl/EmuNtDll.h b/src/CxbxKrnl/EmuNtDll.h index e531a803b..2d18bde74 100644 --- a/src/CxbxKrnl/EmuNtDll.h +++ b/src/CxbxKrnl/EmuNtDll.h @@ -1052,6 +1052,14 @@ typedef VOID (NTAPI *FPTR_RtlFreeAnsiString) IN OUT PANSI_STRING AnsiString ); +// ****************************************************************** +// * RtlFreeUnicodeString +// ****************************************************************** +typedef VOID(NTAPI *FPTR_RtlFreeUnicodeString) +( + IN OUT PUNICODE_STRING UnicodeString +); + // ****************************************************************** // * RtlEqualString // ****************************************************************** @@ -1778,6 +1786,7 @@ EXTERN(RtlFillMemory); EXTERN(RtlFillMemoryUlong); EXTERN(RtlFreeAnsiString); EXTERN(RtlFreeHeap); +EXTERN(RtlFreeUnicodeString); EXTERN(RtlInitAnsiString); EXTERN(RtlInitializeCriticalSection); EXTERN(RtlInitUnicodeString); diff --git a/src/CxbxKrnl/KernelThunk.cpp b/src/CxbxKrnl/KernelThunk.cpp index 5b0d1924a..e3a87076f 100644 --- a/src/CxbxKrnl/KernelThunk.cpp +++ b/src/CxbxKrnl/KernelThunk.cpp @@ -352,7 +352,7 @@ extern "C" CXBXKRNL_API uint32 CxbxKrnl_KernelThunkTable[379] = (uint32)FUNC(&xboxkrnl::RtlFillMemory), // 0x011C (284) (uint32)FUNC(&xboxkrnl::RtlFillMemoryUlong), // 0x011D (285) (uint32)FUNC(&xboxkrnl::RtlFreeAnsiString), // 0x011E (286) - (uint32)PANIC(0x011F), // 0x011F (287) RtlFreeUnicodeString + (uint32)FUNC(&xboxkrnl::RtlFreeUnicodeString), // 0x011F (287) (uint32)PANIC(0x0120), // 0x0120 (288) RtlGetCallersAddress (uint32)FUNC(&xboxkrnl::RtlInitAnsiString), // 0x0121 (289) (uint32)FUNC(&xboxkrnl::RtlInitUnicodeString), // 0x0122 (290) From ab33052f5cc01e56ef7e90e9ef428a3857784532 Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Mon, 26 Dec 2016 16:29:38 +0100 Subject: [PATCH 10/27] Implemented RtlIntegerToChar --- import/OpenXDK/include/xboxkrnl/rtl.h | 12 ++++++++++- import/OpenXDK/include/xboxkrnl/xboxkrnl.h | 1 + src/CxbxKrnl/EmuKrnlRtl.cpp | 23 ++++++++++++++++++++++ src/CxbxKrnl/EmuNtDll.cpp | 1 + src/CxbxKrnl/EmuNtDll.h | 11 +++++++++++ src/CxbxKrnl/KernelThunk.cpp | 2 +- 6 files changed, 48 insertions(+), 2 deletions(-) diff --git a/import/OpenXDK/include/xboxkrnl/rtl.h b/import/OpenXDK/include/xboxkrnl/rtl.h index 4ecae2e01..4609e2868 100644 --- a/import/OpenXDK/include/xboxkrnl/rtl.h +++ b/import/OpenXDK/include/xboxkrnl/rtl.h @@ -284,7 +284,17 @@ XBSYSAPI EXPORTNUM(291) VOID NTAPI RtlInitializeCriticalSection IN PRTL_CRITICAL_SECTION CriticalSection ); -XBSYSAPI VOID *RtlIntegerToChar; +// ****************************************************************** +// * 0x0124 - RtlIntegerToChar() +// ****************************************************************** +XBSYSAPI EXPORTNUM(292) NTSTATUS NTAPI RtlIntegerToChar +( + IN ULONG Value, + IN ULONG Base, + IN LONG OutputLength, + IN PSZ String +); + XBSYSAPI VOID *RtlIntegerToUnicodeString; // ****************************************************************** diff --git a/import/OpenXDK/include/xboxkrnl/xboxkrnl.h b/import/OpenXDK/include/xboxkrnl/xboxkrnl.h index d5050a70d..99e9d154b 100644 --- a/import/OpenXDK/include/xboxkrnl/xboxkrnl.h +++ b/import/OpenXDK/include/xboxkrnl/xboxkrnl.h @@ -104,6 +104,7 @@ typedef wchar_t WCHAR; // * Pointer types // ****************************************************************** typedef CHAR *PCHAR; +typedef char *PSZ; typedef CHAR *PCSZ; typedef BYTE *PBYTE; typedef BOOLEAN *PBOOLEAN; diff --git a/src/CxbxKrnl/EmuKrnlRtl.cpp b/src/CxbxKrnl/EmuKrnlRtl.cpp index 1a50376fe..79fc2182a 100644 --- a/src/CxbxKrnl/EmuKrnlRtl.cpp +++ b/src/CxbxKrnl/EmuKrnlRtl.cpp @@ -695,6 +695,29 @@ XBSYSAPI EXPORTNUM(291) xboxkrnl::VOID NTAPI xboxkrnl::RtlInitializeCriticalSect //NtDll::RtlInitializeCriticalSection((NtDll::_RTL_CRITICAL_SECTION*)CriticalSection); } +// ****************************************************************** +// * 0x0124 - RtlIntegerToChar() +// ****************************************************************** +XBSYSAPI EXPORTNUM(292) xboxkrnl::NTSTATUS NTAPI xboxkrnl::RtlIntegerToChar +( + IN ULONG Value, + IN ULONG Base, + IN LONG OutputLength, + IN PSZ String +) +{ + LOG_FUNC_BEGIN + LOG_FUNC_ARG(Value) + LOG_FUNC_ARG(Base) + LOG_FUNC_ARG(OutputLength) + LOG_FUNC_ARG(String) + LOG_FUNC_END; + + NTSTATUS result = NtDll::RtlIntegerToChar(Value, Base, OutputLength, String); + + RETURN(result); +} + // ****************************************************************** // * 0x0126 - RtlEnterCriticalSection() // ****************************************************************** diff --git a/src/CxbxKrnl/EmuNtDll.cpp b/src/CxbxKrnl/EmuNtDll.cpp index cfa3febbd..0a3248ba5 100644 --- a/src/CxbxKrnl/EmuNtDll.cpp +++ b/src/CxbxKrnl/EmuNtDll.cpp @@ -131,6 +131,7 @@ IMPORT(RtlFillMemoryUlong); IMPORT(RtlFreeAnsiString); IMPORT(RtlFreeHeap); IMPORT(RtlFreeUnicodeString); +IMPORT(RtlIntegerToChar); IMPORT(RtlInitAnsiString); IMPORT(RtlInitializeCriticalSection); IMPORT(RtlInitUnicodeString); diff --git a/src/CxbxKrnl/EmuNtDll.h b/src/CxbxKrnl/EmuNtDll.h index 2d18bde74..d55ee1cc8 100644 --- a/src/CxbxKrnl/EmuNtDll.h +++ b/src/CxbxKrnl/EmuNtDll.h @@ -1129,6 +1129,16 @@ typedef VOID (NTAPI *FPTR_RtlFillMemoryUlong) IN ULONG Pattern ); +// ****************************************************************** +// * RtlIntegerToChar +// ****************************************************************** +typedef NTSTATUS(NTAPI *FPTR_RtlIntegerToChar) +( + IN ULONG Value, + IN ULONG Base, + IN ULONG Length, + IN PCHAR Str +); // ****************************************************************** // * NtDelayExecution // ****************************************************************** @@ -1787,6 +1797,7 @@ EXTERN(RtlFillMemoryUlong); EXTERN(RtlFreeAnsiString); EXTERN(RtlFreeHeap); EXTERN(RtlFreeUnicodeString); +EXTERN(RtlIntegerToChar); EXTERN(RtlInitAnsiString); EXTERN(RtlInitializeCriticalSection); EXTERN(RtlInitUnicodeString); diff --git a/src/CxbxKrnl/KernelThunk.cpp b/src/CxbxKrnl/KernelThunk.cpp index e3a87076f..9f5711e58 100644 --- a/src/CxbxKrnl/KernelThunk.cpp +++ b/src/CxbxKrnl/KernelThunk.cpp @@ -357,7 +357,7 @@ extern "C" CXBXKRNL_API uint32 CxbxKrnl_KernelThunkTable[379] = (uint32)FUNC(&xboxkrnl::RtlInitAnsiString), // 0x0121 (289) (uint32)FUNC(&xboxkrnl::RtlInitUnicodeString), // 0x0122 (290) (uint32)FUNC(&xboxkrnl::RtlInitializeCriticalSection), // 0x0123 (291) - (uint32)PANIC(0x0124), // 0x0124 (292) RtlIntegerToChar + (uint32)FUNC(&xboxkrnl::RtlIntegerToChar), // 0x0124 (292) (uint32)PANIC(0x0125), // 0x0125 (293) RtlIntegerToUnicodeString (uint32)FUNC(&xboxkrnl::RtlLeaveCriticalSection), // 0x0126 (294) (uint32)PANIC(0x0127), // 0x0127 (295) RtlLeaveCriticalSectionAndRegion From 023261faf3150336a589366fa434aca3d6437b78 Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Mon, 26 Dec 2016 16:36:27 +0100 Subject: [PATCH 11/27] Implemented RtlIntegerToUnicodeString --- import/OpenXDK/include/xboxkrnl/rtl.h | 10 +++++++++- src/CxbxKrnl/EmuKrnlRtl.cpp | 21 +++++++++++++++++++++ src/CxbxKrnl/EmuNtDll.cpp | 1 + src/CxbxKrnl/EmuNtDll.h | 14 +++++++++++++- src/CxbxKrnl/KernelThunk.cpp | 2 +- 5 files changed, 45 insertions(+), 3 deletions(-) diff --git a/import/OpenXDK/include/xboxkrnl/rtl.h b/import/OpenXDK/include/xboxkrnl/rtl.h index 4609e2868..d57af38ae 100644 --- a/import/OpenXDK/include/xboxkrnl/rtl.h +++ b/import/OpenXDK/include/xboxkrnl/rtl.h @@ -295,7 +295,15 @@ XBSYSAPI EXPORTNUM(292) NTSTATUS NTAPI RtlIntegerToChar IN PSZ String ); -XBSYSAPI VOID *RtlIntegerToUnicodeString; +// ****************************************************************** +// * 0x0125 - RtlIntegerToUnicodeString() +// ****************************************************************** +XBSYSAPI EXPORTNUM(293) NTSTATUS NTAPI RtlIntegerToUnicodeString +( + IN ULONG Value, + IN ULONG Base, + IN PUNICODE_STRING String +); // ****************************************************************** // * RtlLeaveCriticalSection diff --git a/src/CxbxKrnl/EmuKrnlRtl.cpp b/src/CxbxKrnl/EmuKrnlRtl.cpp index 79fc2182a..f7f71dfc8 100644 --- a/src/CxbxKrnl/EmuKrnlRtl.cpp +++ b/src/CxbxKrnl/EmuKrnlRtl.cpp @@ -718,6 +718,27 @@ XBSYSAPI EXPORTNUM(292) xboxkrnl::NTSTATUS NTAPI xboxkrnl::RtlIntegerToChar RETURN(result); } +// ****************************************************************** +// * 0x0125 - RtlIntegerToUnicodeString() +// ****************************************************************** +XBSYSAPI EXPORTNUM(293) xboxkrnl::NTSTATUS NTAPI xboxkrnl::RtlIntegerToUnicodeString +( + IN ULONG Value, + IN ULONG Base, + IN PUNICODE_STRING String +) +{ + LOG_FUNC_BEGIN + LOG_FUNC_ARG(Value) + LOG_FUNC_ARG(Base) + LOG_FUNC_ARG_OUT(String) + LOG_FUNC_END; + + NTSTATUS result = NtDll::RtlIntegerToUnicodeString(Value, Base, (NtDll::PUNICODE_STRING)String); + + RETURN(result); +} + // ****************************************************************** // * 0x0126 - RtlEnterCriticalSection() // ****************************************************************** diff --git a/src/CxbxKrnl/EmuNtDll.cpp b/src/CxbxKrnl/EmuNtDll.cpp index 0a3248ba5..56613d21a 100644 --- a/src/CxbxKrnl/EmuNtDll.cpp +++ b/src/CxbxKrnl/EmuNtDll.cpp @@ -132,6 +132,7 @@ IMPORT(RtlFreeAnsiString); IMPORT(RtlFreeHeap); IMPORT(RtlFreeUnicodeString); IMPORT(RtlIntegerToChar); +IMPORT(RtlIntegerToUnicodeString); IMPORT(RtlInitAnsiString); IMPORT(RtlInitializeCriticalSection); IMPORT(RtlInitUnicodeString); diff --git a/src/CxbxKrnl/EmuNtDll.h b/src/CxbxKrnl/EmuNtDll.h index d55ee1cc8..53c6d3067 100644 --- a/src/CxbxKrnl/EmuNtDll.h +++ b/src/CxbxKrnl/EmuNtDll.h @@ -1132,13 +1132,24 @@ typedef VOID (NTAPI *FPTR_RtlFillMemoryUlong) // ****************************************************************** // * RtlIntegerToChar // ****************************************************************** -typedef NTSTATUS(NTAPI *FPTR_RtlIntegerToChar) +typedef NTSTATUS (NTAPI *FPTR_RtlIntegerToChar) ( IN ULONG Value, IN ULONG Base, IN ULONG Length, IN PCHAR Str ); + +// ****************************************************************** +// * RtlIntegerToUnicodeString +// ****************************************************************** +typedef NTSTATUS (NTAPI *FPTR_RtlIntegerToUnicodeString) +( + IN ULONG Value, + IN ULONG Base OPTIONAL, + IN OUT PUNICODE_STRING String +); + // ****************************************************************** // * NtDelayExecution // ****************************************************************** @@ -1798,6 +1809,7 @@ EXTERN(RtlFreeAnsiString); EXTERN(RtlFreeHeap); EXTERN(RtlFreeUnicodeString); EXTERN(RtlIntegerToChar); +EXTERN(RtlIntegerToUnicodeString); EXTERN(RtlInitAnsiString); EXTERN(RtlInitializeCriticalSection); EXTERN(RtlInitUnicodeString); diff --git a/src/CxbxKrnl/KernelThunk.cpp b/src/CxbxKrnl/KernelThunk.cpp index 9f5711e58..24761cb65 100644 --- a/src/CxbxKrnl/KernelThunk.cpp +++ b/src/CxbxKrnl/KernelThunk.cpp @@ -358,7 +358,7 @@ extern "C" CXBXKRNL_API uint32 CxbxKrnl_KernelThunkTable[379] = (uint32)FUNC(&xboxkrnl::RtlInitUnicodeString), // 0x0122 (290) (uint32)FUNC(&xboxkrnl::RtlInitializeCriticalSection), // 0x0123 (291) (uint32)FUNC(&xboxkrnl::RtlIntegerToChar), // 0x0124 (292) - (uint32)PANIC(0x0125), // 0x0125 (293) RtlIntegerToUnicodeString + (uint32)FUNC(&xboxkrnl::RtlIntegerToUnicodeString), // 0x0125 (293) (uint32)FUNC(&xboxkrnl::RtlLeaveCriticalSection), // 0x0126 (294) (uint32)PANIC(0x0127), // 0x0127 (295) RtlLeaveCriticalSectionAndRegion (uint32)FUNC(&xboxkrnl::RtlLowerChar), // 0x0128 (296) From d804711bab817d17be0b982a10088eb85b6123b3 Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Mon, 26 Dec 2016 16:59:46 +0100 Subject: [PATCH 12/27] Implemented RtlMapGenericMask --- import/OpenXDK/include/xboxkrnl/rtl.h | 9 +++++++- import/OpenXDK/include/xboxkrnl/xboxkrnl.h | 12 ++++++++++ src/CxbxKrnl/EmuKrnlRtl.cpp | 17 ++++++++++++++ src/CxbxKrnl/EmuNtDll.cpp | 1 + src/CxbxKrnl/EmuNtDll.h | 26 +++++++++++++++++++++- src/CxbxKrnl/KernelThunk.cpp | 2 +- 6 files changed, 64 insertions(+), 3 deletions(-) diff --git a/import/OpenXDK/include/xboxkrnl/rtl.h b/import/OpenXDK/include/xboxkrnl/rtl.h index d57af38ae..38f441f47 100644 --- a/import/OpenXDK/include/xboxkrnl/rtl.h +++ b/import/OpenXDK/include/xboxkrnl/rtl.h @@ -320,7 +320,14 @@ XBSYSAPI VOID *RtlLeaveCriticalSectionAndRegion; // ****************************************************************** XBSYSAPI EXPORTNUM(296) CHAR NTAPI RtlLowerChar(CHAR Character); -XBSYSAPI VOID *RtlMapGenericMask; +// ****************************************************************** +// * 0x0129 - RtlMapGenericMask() +// ****************************************************************** +XBSYSAPI EXPORTNUM(297) VOID NTAPI RtlMapGenericMask +( + IN PACCESS_MASK AccessMask, + IN PGENERIC_MAPPING GenericMapping +); // ****************************************************************** // * RtlMoveMemory diff --git a/import/OpenXDK/include/xboxkrnl/xboxkrnl.h b/import/OpenXDK/include/xboxkrnl/xboxkrnl.h index 99e9d154b..d2e387a1e 100644 --- a/import/OpenXDK/include/xboxkrnl/xboxkrnl.h +++ b/import/OpenXDK/include/xboxkrnl/xboxkrnl.h @@ -537,6 +537,18 @@ FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS; #define FILE_ATTRIBUTE_VALID_SET_FLAGS 0x000031a7 +// ****************************************************************** +// * GENERIC_MAPPING +// ****************************************************************** +typedef struct _GENERIC_MAPPING +{ + ACCESS_MASK GenericRead; + ACCESS_MASK GenericWrite; + ACCESS_MASK GenericExecute; + ACCESS_MASK GenericAll; +} +GENERIC_MAPPING, *PGENERIC_MAPPING; + // ****************************************************************** // * OBJECT_ATTRIBUTES // ****************************************************************** diff --git a/src/CxbxKrnl/EmuKrnlRtl.cpp b/src/CxbxKrnl/EmuKrnlRtl.cpp index f7f71dfc8..d54cc57ac 100644 --- a/src/CxbxKrnl/EmuKrnlRtl.cpp +++ b/src/CxbxKrnl/EmuKrnlRtl.cpp @@ -785,6 +785,23 @@ XBSYSAPI EXPORTNUM(296) xboxkrnl::CHAR NTAPI xboxkrnl::RtlLowerChar RETURN(ret); } +// ****************************************************************** +// * 0x0129 - RtlMapGenericMask() +// ****************************************************************** +XBSYSAPI EXPORTNUM(297) xboxkrnl::VOID NTAPI xboxkrnl::RtlMapGenericMask +( + IN PACCESS_MASK AccessMask, + IN PGENERIC_MAPPING GenericMapping +) +{ + LOG_FUNC_BEGIN + LOG_FUNC_ARG(AccessMask) + LOG_FUNC_ARG(GenericMapping) + LOG_FUNC_END; + + NtDll::RtlMapGenericMask(AccessMask, (NtDll::PGENERIC_MAPPING)GenericMapping); +} + // Prevent errors compiling RtlMoveMemory (TODO : How should we really do this?) #undef RtlMoveMemory diff --git a/src/CxbxKrnl/EmuNtDll.cpp b/src/CxbxKrnl/EmuNtDll.cpp index 56613d21a..ce117496b 100644 --- a/src/CxbxKrnl/EmuNtDll.cpp +++ b/src/CxbxKrnl/EmuNtDll.cpp @@ -137,6 +137,7 @@ IMPORT(RtlInitAnsiString); IMPORT(RtlInitializeCriticalSection); IMPORT(RtlInitUnicodeString); IMPORT(RtlLeaveCriticalSection); +IMPORT(RtlMapGenericMask); IMPORT(RtlNtStatusToDosError); IMPORT(RtlReAllocateHeap); IMPORT(RtlSizeHeap); diff --git a/src/CxbxKrnl/EmuNtDll.h b/src/CxbxKrnl/EmuNtDll.h index 53c6d3067..1fa2173b9 100644 --- a/src/CxbxKrnl/EmuNtDll.h +++ b/src/CxbxKrnl/EmuNtDll.h @@ -780,6 +780,17 @@ KUSER_SHARED_DATA, *PKUSER_SHARED_DATA; // This is only the top of the actual definition. For the complete version, // see http://processhacker.sourceforge.net/doc/ntexapi_8h_source.html +// ****************************************************************** +// * GENERIC_MAPPING +// ****************************************************************** +typedef struct _GENERIC_MAPPING +{ + ACCESS_MASK GenericRead; + ACCESS_MASK GenericWrite; + ACCESS_MASK GenericExecute; + ACCESS_MASK GenericAll; +} +GENERIC_MAPPING, *PGENERIC_MAPPING; // ****************************************************************** // * KeDelayExecutionThread @@ -853,10 +864,22 @@ typedef SIZE_T (NTAPI *FPTR_RtlSizeHeap) IN PVOID lpMem ); +// ****************************************************************** +// * RtlMapGenericMask +// ****************************************************************** +typedef VOID (NTAPI *FPTR_RtlMapGenericMask) +( + IN OUT PACCESS_MASK AccessMask, + IN PGENERIC_MAPPING GenericMapping +); + // ****************************************************************** // * RtlNtStatusToDosError // ****************************************************************** -typedef ULONG (NTAPI *FPTR_RtlNtStatusToDosError)(NTSTATUS Status); +typedef ULONG (NTAPI *FPTR_RtlNtStatusToDosError) +( + IN NTSTATUS Status +); // ****************************************************************** // * RtlTimeToTimeFields @@ -1814,6 +1837,7 @@ EXTERN(RtlInitAnsiString); EXTERN(RtlInitializeCriticalSection); EXTERN(RtlInitUnicodeString); EXTERN(RtlLeaveCriticalSection); +EXTERN(RtlMapGenericMask); EXTERN(RtlNtStatusToDosError); EXTERN(RtlReAllocateHeap); EXTERN(RtlSizeHeap); diff --git a/src/CxbxKrnl/KernelThunk.cpp b/src/CxbxKrnl/KernelThunk.cpp index 24761cb65..41b92000f 100644 --- a/src/CxbxKrnl/KernelThunk.cpp +++ b/src/CxbxKrnl/KernelThunk.cpp @@ -362,7 +362,7 @@ extern "C" CXBXKRNL_API uint32 CxbxKrnl_KernelThunkTable[379] = (uint32)FUNC(&xboxkrnl::RtlLeaveCriticalSection), // 0x0126 (294) (uint32)PANIC(0x0127), // 0x0127 (295) RtlLeaveCriticalSectionAndRegion (uint32)FUNC(&xboxkrnl::RtlLowerChar), // 0x0128 (296) - (uint32)PANIC(0x0129), // 0x0129 (297) RtlMapGenericMask + (uint32)FUNC(&xboxkrnl::RtlMapGenericMask), // 0x0129 (297) (uint32)FUNC(&xboxkrnl::RtlMoveMemory), // 0x012A (298) (uint32)PANIC(0x012B), // 0x012B (299) RtlMultiByteToUnicodeN (uint32)PANIC(0x012C), // 0x012C (300) RtlMultiByteToUnicodeSize From 6b2fa8f98499f24809c184d3a884af733ec5861f Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Mon, 26 Dec 2016 17:21:28 +0100 Subject: [PATCH 13/27] Implement RtlMultiByteToUnicodeN --- import/OpenXDK/include/xboxkrnl/rtl.h | 15 ++++++++-- import/OpenXDK/include/xboxkrnl/xboxkrnl.h | 1 + src/CxbxKrnl/EmuKrnlRtl.cpp | 32 +++++++++++++++++++++- src/CxbxKrnl/EmuNtDll.cpp | 1 + src/CxbxKrnl/EmuNtDll.h | 13 +++++++++ src/CxbxKrnl/KernelThunk.cpp | 2 +- 6 files changed, 60 insertions(+), 4 deletions(-) diff --git a/import/OpenXDK/include/xboxkrnl/rtl.h b/import/OpenXDK/include/xboxkrnl/rtl.h index 38f441f47..fce8b4f38 100644 --- a/import/OpenXDK/include/xboxkrnl/rtl.h +++ b/import/OpenXDK/include/xboxkrnl/rtl.h @@ -330,7 +330,7 @@ XBSYSAPI EXPORTNUM(297) VOID NTAPI RtlMapGenericMask ); // ****************************************************************** -// * RtlMoveMemory +// * 0x012A - RtlMoveMemory() // ****************************************************************** // * // * Move memory either forward or backward, aligned or unaligned, @@ -344,7 +344,18 @@ XBSYSAPI EXPORTNUM(298) VOID NTAPI RtlMoveMemory IN SIZE_T Length ); -XBSYSAPI VOID *RtlMultiByteToUnicodeN; +// ****************************************************************** +// * 0x012B - RtlMultiByteToUnicodeN() +// ****************************************************************** +XBSYSAPI EXPORTNUM(299) NTSTATUS NTAPI RtlMultiByteToUnicodeN +( + IN PWSTR UnicodeString, + IN ULONG MaxBytesInUnicodeString, + IN PULONG BytesInUnicodeString, + IN PCHAR MultiByteString, + IN ULONG BytesInMultiByteString +); + XBSYSAPI VOID *RtlMultiByteToUnicodeSize; // ****************************************************************** diff --git a/import/OpenXDK/include/xboxkrnl/xboxkrnl.h b/import/OpenXDK/include/xboxkrnl/xboxkrnl.h index d2e387a1e..8a286f14f 100644 --- a/import/OpenXDK/include/xboxkrnl/xboxkrnl.h +++ b/import/OpenXDK/include/xboxkrnl/xboxkrnl.h @@ -130,6 +130,7 @@ typedef LONGLONG *PLONGLONG; // ****************************************************************** typedef CHAR *PCHAR, *LPCH, *PCH; typedef CONST CHAR *LPCCH, *PCCH; +typedef WCHAR *LPWSTR, *PWSTR; typedef /*_Null_terminated_*/ CONST WCHAR *LPCWSTR, *PCWSTR; diff --git a/src/CxbxKrnl/EmuKrnlRtl.cpp b/src/CxbxKrnl/EmuKrnlRtl.cpp index d54cc57ac..aae0fefb4 100644 --- a/src/CxbxKrnl/EmuKrnlRtl.cpp +++ b/src/CxbxKrnl/EmuKrnlRtl.cpp @@ -806,7 +806,7 @@ XBSYSAPI EXPORTNUM(297) xboxkrnl::VOID NTAPI xboxkrnl::RtlMapGenericMask #undef RtlMoveMemory // ****************************************************************** -// * 0x012A - RtlMoveMemory +// * 0x012A - RtlMoveMemory() // ****************************************************************** XBSYSAPI EXPORTNUM(298) xboxkrnl::VOID NTAPI xboxkrnl::RtlMoveMemory ( @@ -824,6 +824,36 @@ XBSYSAPI EXPORTNUM(298) xboxkrnl::VOID NTAPI xboxkrnl::RtlMoveMemory ::memmove(Destination, Source, Length); } +// ****************************************************************** +// * 0x012B - RtlMultiByteToUnicodeN() +// ****************************************************************** +XBSYSAPI EXPORTNUM(299) xboxkrnl::NTSTATUS NTAPI xboxkrnl::RtlMultiByteToUnicodeN +( + IN PWSTR UnicodeString, + IN ULONG MaxBytesInUnicodeString, + IN PULONG BytesInUnicodeString, + IN PCHAR MultiByteString, + IN ULONG BytesInMultiByteString +) +{ + LOG_FUNC_BEGIN + LOG_FUNC_ARG(UnicodeString) + LOG_FUNC_ARG(MaxBytesInUnicodeString); + LOG_FUNC_ARG(BytesInUnicodeString); + LOG_FUNC_ARG(MultiByteString); + LOG_FUNC_ARG(BytesInMultiByteString) + LOG_FUNC_END; + + NTSTATUS result = NtDll::RtlMultiByteToUnicodeN( + UnicodeString, + MaxBytesInUnicodeString, + BytesInUnicodeString, + MultiByteString, + BytesInMultiByteString); + + RETURN(result); +} + // ****************************************************************** // * 0x012D - RtlNtStatusToDosError() // ****************************************************************** diff --git a/src/CxbxKrnl/EmuNtDll.cpp b/src/CxbxKrnl/EmuNtDll.cpp index ce117496b..16fe786ea 100644 --- a/src/CxbxKrnl/EmuNtDll.cpp +++ b/src/CxbxKrnl/EmuNtDll.cpp @@ -138,6 +138,7 @@ IMPORT(RtlInitializeCriticalSection); IMPORT(RtlInitUnicodeString); IMPORT(RtlLeaveCriticalSection); IMPORT(RtlMapGenericMask); +IMPORT(RtlMultiByteToUnicodeN); IMPORT(RtlNtStatusToDosError); IMPORT(RtlReAllocateHeap); IMPORT(RtlSizeHeap); diff --git a/src/CxbxKrnl/EmuNtDll.h b/src/CxbxKrnl/EmuNtDll.h index 1fa2173b9..2cdefc864 100644 --- a/src/CxbxKrnl/EmuNtDll.h +++ b/src/CxbxKrnl/EmuNtDll.h @@ -1173,6 +1173,18 @@ typedef NTSTATUS (NTAPI *FPTR_RtlIntegerToUnicodeString) IN OUT PUNICODE_STRING String ); +// ****************************************************************** +// * RtlMultiByteToUnicodeN +// ****************************************************************** +typedef NTSTATUS (NTAPI *FPTR_RtlMultiByteToUnicodeN) +( + OUT PWCH UnicodeString, + IN ULONG MaxBytesInUnicodeString, + OUT PULONG BytesInUnicodeString OPTIONAL, + IN const CHAR *MultiByteString, + IN ULONG BytesInMultiByteString +); + // ****************************************************************** // * NtDelayExecution // ****************************************************************** @@ -1838,6 +1850,7 @@ EXTERN(RtlInitializeCriticalSection); EXTERN(RtlInitUnicodeString); EXTERN(RtlLeaveCriticalSection); EXTERN(RtlMapGenericMask); +EXTERN(RtlMultiByteToUnicodeN); EXTERN(RtlNtStatusToDosError); EXTERN(RtlReAllocateHeap); EXTERN(RtlSizeHeap); diff --git a/src/CxbxKrnl/KernelThunk.cpp b/src/CxbxKrnl/KernelThunk.cpp index 41b92000f..2622488b5 100644 --- a/src/CxbxKrnl/KernelThunk.cpp +++ b/src/CxbxKrnl/KernelThunk.cpp @@ -364,7 +364,7 @@ extern "C" CXBXKRNL_API uint32 CxbxKrnl_KernelThunkTable[379] = (uint32)FUNC(&xboxkrnl::RtlLowerChar), // 0x0128 (296) (uint32)FUNC(&xboxkrnl::RtlMapGenericMask), // 0x0129 (297) (uint32)FUNC(&xboxkrnl::RtlMoveMemory), // 0x012A (298) - (uint32)PANIC(0x012B), // 0x012B (299) RtlMultiByteToUnicodeN + (uint32)FUNC(&xboxkrnl::RtlMultiByteToUnicodeN), // 0x012B (299) (uint32)PANIC(0x012C), // 0x012C (300) RtlMultiByteToUnicodeSize (uint32)FUNC(&xboxkrnl::RtlNtStatusToDosError), // 0x012D (301) (uint32)PANIC(0x012E), // 0x012E (302) RtlRaiseException From 6a1ae1e42f92065c3656d879789ae379e8757da8 Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Mon, 26 Dec 2016 17:26:30 +0100 Subject: [PATCH 14/27] Implement RtlMultiByteToUnicodeSize --- import/OpenXDK/include/xboxkrnl/rtl.h | 10 +++++++++- src/CxbxKrnl/EmuKrnlRtl.cpp | 24 ++++++++++++++++++++++++ src/CxbxKrnl/EmuNtDll.cpp | 1 + src/CxbxKrnl/EmuNtDll.h | 11 +++++++++++ src/CxbxKrnl/KernelThunk.cpp | 2 +- 5 files changed, 46 insertions(+), 2 deletions(-) diff --git a/import/OpenXDK/include/xboxkrnl/rtl.h b/import/OpenXDK/include/xboxkrnl/rtl.h index fce8b4f38..174ae6e92 100644 --- a/import/OpenXDK/include/xboxkrnl/rtl.h +++ b/import/OpenXDK/include/xboxkrnl/rtl.h @@ -356,7 +356,15 @@ XBSYSAPI EXPORTNUM(299) NTSTATUS NTAPI RtlMultiByteToUnicodeN IN ULONG BytesInMultiByteString ); -XBSYSAPI VOID *RtlMultiByteToUnicodeSize; +// ****************************************************************** +// * 0x012C - RtlMultiByteToUnicodeSize() +// ****************************************************************** +XBSYSAPI EXPORTNUM(300) NTSTATUS NTAPI RtlMultiByteToUnicodeSize +( + IN PULONG BytesInUnicodeString, + IN PCHAR MultiByteString, + IN ULONG BytesInMultiByteString +); // ****************************************************************** // * RtlNtStatusToDosError diff --git a/src/CxbxKrnl/EmuKrnlRtl.cpp b/src/CxbxKrnl/EmuKrnlRtl.cpp index aae0fefb4..4fe1cbd71 100644 --- a/src/CxbxKrnl/EmuKrnlRtl.cpp +++ b/src/CxbxKrnl/EmuKrnlRtl.cpp @@ -854,6 +854,30 @@ XBSYSAPI EXPORTNUM(299) xboxkrnl::NTSTATUS NTAPI xboxkrnl::RtlMultiByteToUnicode RETURN(result); } +// ****************************************************************** +// * 0x012C - RtlMultiByteToUnicodeSize() +// ****************************************************************** +XBSYSAPI EXPORTNUM(300) xboxkrnl::NTSTATUS NTAPI xboxkrnl::RtlMultiByteToUnicodeSize +( + IN PULONG BytesInUnicodeString, + IN PCHAR MultiByteString, + IN ULONG BytesInMultiByteString +) +{ + LOG_FUNC_BEGIN + LOG_FUNC_ARG(BytesInUnicodeString) + LOG_FUNC_ARG(MultiByteString); + LOG_FUNC_ARG(BytesInMultiByteString) + LOG_FUNC_END; + + NTSTATUS result = NtDll::RtlMultiByteToUnicodeSize( + BytesInUnicodeString, + MultiByteString, + BytesInMultiByteString); + + RETURN(result); +} + // ****************************************************************** // * 0x012D - RtlNtStatusToDosError() // ****************************************************************** diff --git a/src/CxbxKrnl/EmuNtDll.cpp b/src/CxbxKrnl/EmuNtDll.cpp index 16fe786ea..a90c7d5b9 100644 --- a/src/CxbxKrnl/EmuNtDll.cpp +++ b/src/CxbxKrnl/EmuNtDll.cpp @@ -139,6 +139,7 @@ IMPORT(RtlInitUnicodeString); IMPORT(RtlLeaveCriticalSection); IMPORT(RtlMapGenericMask); IMPORT(RtlMultiByteToUnicodeN); +IMPORT(RtlMultiByteToUnicodeSize); IMPORT(RtlNtStatusToDosError); IMPORT(RtlReAllocateHeap); IMPORT(RtlSizeHeap); diff --git a/src/CxbxKrnl/EmuNtDll.h b/src/CxbxKrnl/EmuNtDll.h index 2cdefc864..815c48b0a 100644 --- a/src/CxbxKrnl/EmuNtDll.h +++ b/src/CxbxKrnl/EmuNtDll.h @@ -1185,6 +1185,16 @@ typedef NTSTATUS (NTAPI *FPTR_RtlMultiByteToUnicodeN) IN ULONG BytesInMultiByteString ); +// ****************************************************************** +// * RtlMultiByteToUnicodeSize +// ****************************************************************** +typedef NTSTATUS (NTAPI *FPTR_RtlMultiByteToUnicodeSize) +( + OUT PULONG BytesInUnicodeString, + IN const CHAR *MultiByteString, + IN ULONG BytesInMultiByteString +); + // ****************************************************************** // * NtDelayExecution // ****************************************************************** @@ -1851,6 +1861,7 @@ EXTERN(RtlInitUnicodeString); EXTERN(RtlLeaveCriticalSection); EXTERN(RtlMapGenericMask); EXTERN(RtlMultiByteToUnicodeN); +EXTERN(RtlMultiByteToUnicodeSize); EXTERN(RtlNtStatusToDosError); EXTERN(RtlReAllocateHeap); EXTERN(RtlSizeHeap); diff --git a/src/CxbxKrnl/KernelThunk.cpp b/src/CxbxKrnl/KernelThunk.cpp index 2622488b5..00b91fa5a 100644 --- a/src/CxbxKrnl/KernelThunk.cpp +++ b/src/CxbxKrnl/KernelThunk.cpp @@ -365,7 +365,7 @@ extern "C" CXBXKRNL_API uint32 CxbxKrnl_KernelThunkTable[379] = (uint32)FUNC(&xboxkrnl::RtlMapGenericMask), // 0x0129 (297) (uint32)FUNC(&xboxkrnl::RtlMoveMemory), // 0x012A (298) (uint32)FUNC(&xboxkrnl::RtlMultiByteToUnicodeN), // 0x012B (299) - (uint32)PANIC(0x012C), // 0x012C (300) RtlMultiByteToUnicodeSize + (uint32)FUNC(&xboxkrnl::RtlMultiByteToUnicodeSize), // 0x012C (300) (uint32)FUNC(&xboxkrnl::RtlNtStatusToDosError), // 0x012D (301) (uint32)PANIC(0x012E), // 0x012E (302) RtlRaiseException (uint32)PANIC(0x012F), // 0x012F (303) RtlRaiseStatus From 75eab7a83df854122d525c8063ade2b25041c14e Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Mon, 26 Dec 2016 17:32:08 +0100 Subject: [PATCH 15/27] Implemented RtlUlongByteSwap --- import/OpenXDK/include/xboxkrnl/rtl.h | 8 +++++++- src/CxbxKrnl/EmuKrnlRtl.cpp | 15 +++++++++++++++ src/CxbxKrnl/EmuNtDll.cpp | 1 + src/CxbxKrnl/EmuNtDll.h | 9 +++++++++ src/CxbxKrnl/KernelThunk.cpp | 2 +- 5 files changed, 33 insertions(+), 2 deletions(-) diff --git a/import/OpenXDK/include/xboxkrnl/rtl.h b/import/OpenXDK/include/xboxkrnl/rtl.h index 174ae6e92..ec54e30d6 100644 --- a/import/OpenXDK/include/xboxkrnl/rtl.h +++ b/import/OpenXDK/include/xboxkrnl/rtl.h @@ -403,7 +403,13 @@ XBSYSAPI EXPORTNUM(306) BOOLEAN NTAPI RtlTryEnterCriticalSection IN PRTL_CRITICAL_SECTION CriticalSection ); -XBSYSAPI VOID *RtlUlongByteSwap; +// ****************************************************************** +// * 0x0133 - RtlUlongByteSwap() +// ****************************************************************** +XBSYSAPI EXPORTNUM(307) ULONG FASTCALL RtlUlongByteSwap +( + IN ULONG Source +); // ****************************************************************** // * RtlUnicodeStringToAnsiString diff --git a/src/CxbxKrnl/EmuKrnlRtl.cpp b/src/CxbxKrnl/EmuKrnlRtl.cpp index 4fe1cbd71..a2a9c536c 100644 --- a/src/CxbxKrnl/EmuKrnlRtl.cpp +++ b/src/CxbxKrnl/EmuKrnlRtl.cpp @@ -966,6 +966,21 @@ XBSYSAPI EXPORTNUM(306) xboxkrnl::BOOLEAN NTAPI xboxkrnl::RtlTryEnterCriticalSec RETURN(bRet); } +// ****************************************************************** +// * 0x0133 - RtlUlongByteSwap() +// ****************************************************************** +XBSYSAPI EXPORTNUM(307) xboxkrnl::ULONG FASTCALL xboxkrnl::RtlUlongByteSwap +( + IN ULONG Source +) +{ + LOG_FUNC_ONE_ARG(Source); + + ULONG ret = NtDll::RtlUlongByteSwap(Source); + + RETURN(ret); +} + // ****************************************************************** // * 0x0134 - RtlUnicodeStringToAnsiString() // ****************************************************************** diff --git a/src/CxbxKrnl/EmuNtDll.cpp b/src/CxbxKrnl/EmuNtDll.cpp index a90c7d5b9..fe06edda0 100644 --- a/src/CxbxKrnl/EmuNtDll.cpp +++ b/src/CxbxKrnl/EmuNtDll.cpp @@ -146,4 +146,5 @@ IMPORT(RtlSizeHeap); IMPORT(RtlTimeFieldsToTime); IMPORT(RtlTimeToTimeFields); IMPORT(RtlTryEnterCriticalSection); +IMPORT(RtlUlongByteSwap); IMPORT(RtlUnicodeStringToAnsiString); diff --git a/src/CxbxKrnl/EmuNtDll.h b/src/CxbxKrnl/EmuNtDll.h index 815c48b0a..e8ce69f77 100644 --- a/src/CxbxKrnl/EmuNtDll.h +++ b/src/CxbxKrnl/EmuNtDll.h @@ -907,6 +907,14 @@ typedef BOOL (NTAPI *FPTR_RtlTryEnterCriticalSection) IN PRTL_CRITICAL_SECTION CriticalSection ); +// ****************************************************************** +// * RtlUlongByteSwap +// ****************************************************************** +typedef ULONG (NTAPI *FPTR_RtlUlongByteSwap) +( + IN ULONG Source +); + // ****************************************************************** // * RtlCompareMemory // ****************************************************************** @@ -1868,6 +1876,7 @@ EXTERN(RtlSizeHeap); EXTERN(RtlTimeFieldsToTime); EXTERN(RtlTimeToTimeFields); EXTERN(RtlTryEnterCriticalSection); +EXTERN(RtlUlongByteSwap); EXTERN(RtlUnicodeStringToAnsiString); #if defined(__cplusplus) diff --git a/src/CxbxKrnl/KernelThunk.cpp b/src/CxbxKrnl/KernelThunk.cpp index 00b91fa5a..80b42e79d 100644 --- a/src/CxbxKrnl/KernelThunk.cpp +++ b/src/CxbxKrnl/KernelThunk.cpp @@ -372,7 +372,7 @@ extern "C" CXBXKRNL_API uint32 CxbxKrnl_KernelThunkTable[379] = (uint32)FUNC(&xboxkrnl::RtlTimeFieldsToTime), // 0x0130 (304) (uint32)FUNC(&xboxkrnl::RtlTimeToTimeFields), // 0x0131 (305) (uint32)FUNC(&xboxkrnl::RtlTryEnterCriticalSection), // 0x0132 (306) - (uint32)PANIC(0x0133), // 0x0133 (307) RtlUlongByteSwap + (uint32)FUNC(&xboxkrnl::RtlUlongByteSwap), // 0x0133 (307) (uint32)FUNC(&xboxkrnl::RtlUnicodeStringToAnsiString), // 0x0134 (308) (uint32)PANIC(0x0135), // 0x0135 (309) RtlUnicodeStringToInteger (uint32)PANIC(0x0136), // 0x0136 (310) RtlUnicodeToMultiByteN From c009ff8eb417e9c466f1b0ccc36a100d797ec575 Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Mon, 26 Dec 2016 17:38:49 +0100 Subject: [PATCH 16/27] Implemented RtlUnicodeStringToInteger --- import/OpenXDK/include/xboxkrnl/rtl.h | 11 ++++++++++- src/CxbxKrnl/EmuKrnlRtl.cpp | 21 +++++++++++++++++++++ src/CxbxKrnl/EmuNtDll.cpp | 1 + src/CxbxKrnl/EmuNtDll.h | 11 +++++++++++ src/CxbxKrnl/KernelThunk.cpp | 2 +- 5 files changed, 44 insertions(+), 2 deletions(-) diff --git a/import/OpenXDK/include/xboxkrnl/rtl.h b/import/OpenXDK/include/xboxkrnl/rtl.h index ec54e30d6..388a66011 100644 --- a/import/OpenXDK/include/xboxkrnl/rtl.h +++ b/import/OpenXDK/include/xboxkrnl/rtl.h @@ -421,7 +421,16 @@ XBSYSAPI EXPORTNUM(308) NTSTATUS NTAPI RtlUnicodeStringToAnsiString IN BOOLEAN AllocateDestinationString ); -XBSYSAPI VOID *RtlUnicodeStringToInteger; +// ****************************************************************** +// * 0x0135 - RtlUnicodeStringToInteger() +// ****************************************************************** +XBSYSAPI EXPORTNUM(309) NTSTATUS NTAPI RtlUnicodeStringToInteger +( + IN PUNICODE_STRING String, + IN ULONG Base, + IN PULONG Value +); + XBSYSAPI VOID *RtlUnicodeToMultiByteN; XBSYSAPI VOID *RtlUnicodeToMultiByteSize; XBSYSAPI VOID *RtlUnwind; diff --git a/src/CxbxKrnl/EmuKrnlRtl.cpp b/src/CxbxKrnl/EmuKrnlRtl.cpp index a2a9c536c..a26eb4df9 100644 --- a/src/CxbxKrnl/EmuKrnlRtl.cpp +++ b/src/CxbxKrnl/EmuKrnlRtl.cpp @@ -1002,6 +1002,27 @@ XBSYSAPI EXPORTNUM(308) xboxkrnl::NTSTATUS NTAPI xboxkrnl::RtlUnicodeStringToAns RETURN(ret); } +// ****************************************************************** +// * 0x0135 - RtlUnicodeStringToInteger() +// ****************************************************************** +XBSYSAPI EXPORTNUM(309) xboxkrnl::NTSTATUS NTAPI xboxkrnl::RtlUnicodeStringToInteger +( + IN PUNICODE_STRING String, + IN ULONG Base, + IN PULONG Value +) +{ + LOG_FUNC_BEGIN + LOG_FUNC_ARG(String) + LOG_FUNC_ARG(Base) + LOG_FUNC_ARG(Value) + LOG_FUNC_END; + + NTSTATUS ret = NtDll::RtlUnicodeStringToInteger((NtDll::PUNICODE_STRING)String, Base, Value); + + RETURN(ret); +} + // Prevent errors compiling RtlZeroMemory (TODO : How should we really do this?) #undef RtlZeroMemory diff --git a/src/CxbxKrnl/EmuNtDll.cpp b/src/CxbxKrnl/EmuNtDll.cpp index fe06edda0..492297e84 100644 --- a/src/CxbxKrnl/EmuNtDll.cpp +++ b/src/CxbxKrnl/EmuNtDll.cpp @@ -148,3 +148,4 @@ IMPORT(RtlTimeToTimeFields); IMPORT(RtlTryEnterCriticalSection); IMPORT(RtlUlongByteSwap); IMPORT(RtlUnicodeStringToAnsiString); +IMPORT(RtlUnicodeStringToInteger); diff --git a/src/CxbxKrnl/EmuNtDll.h b/src/CxbxKrnl/EmuNtDll.h index e8ce69f77..3302d5a15 100644 --- a/src/CxbxKrnl/EmuNtDll.h +++ b/src/CxbxKrnl/EmuNtDll.h @@ -915,6 +915,16 @@ typedef ULONG (NTAPI *FPTR_RtlUlongByteSwap) IN ULONG Source ); +// ****************************************************************** +// * RtlUnicodeStringToInteger +// ****************************************************************** +typedef NTSTATUS (NTAPI *FPTR_RtlUnicodeStringToInteger) +( + IN PCUNICODE_STRING String, + IN ULONG Base OPTIONAL, + OUT PULONG Value +); + // ****************************************************************** // * RtlCompareMemory // ****************************************************************** @@ -1878,6 +1888,7 @@ EXTERN(RtlTimeToTimeFields); EXTERN(RtlTryEnterCriticalSection); EXTERN(RtlUlongByteSwap); EXTERN(RtlUnicodeStringToAnsiString); +EXTERN(RtlUnicodeStringToInteger); #if defined(__cplusplus) } diff --git a/src/CxbxKrnl/KernelThunk.cpp b/src/CxbxKrnl/KernelThunk.cpp index 80b42e79d..b3c0fa48f 100644 --- a/src/CxbxKrnl/KernelThunk.cpp +++ b/src/CxbxKrnl/KernelThunk.cpp @@ -374,7 +374,7 @@ extern "C" CXBXKRNL_API uint32 CxbxKrnl_KernelThunkTable[379] = (uint32)FUNC(&xboxkrnl::RtlTryEnterCriticalSection), // 0x0132 (306) (uint32)FUNC(&xboxkrnl::RtlUlongByteSwap), // 0x0133 (307) (uint32)FUNC(&xboxkrnl::RtlUnicodeStringToAnsiString), // 0x0134 (308) - (uint32)PANIC(0x0135), // 0x0135 (309) RtlUnicodeStringToInteger + (uint32)FUNC(&xboxkrnl::RtlUnicodeStringToInteger), // 0x0135 (309) (uint32)PANIC(0x0136), // 0x0136 (310) RtlUnicodeToMultiByteN (uint32)PANIC(0x0137), // 0x0137 (311) RtlUnicodeToMultiByteSize (uint32)PANIC(0x0138), // 0x0138 (312) RtlUnwind From a847c1d45cdc7c5e752a6ad3089d3d1c3814953b Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Mon, 26 Dec 2016 17:45:33 +0100 Subject: [PATCH 17/27] Implemented RtlUnicodeToMultiByteN --- import/OpenXDK/include/xboxkrnl/rtl.h | 13 +++++++++++- src/CxbxKrnl/EmuKrnlRtl.cpp | 30 +++++++++++++++++++++++++++ src/CxbxKrnl/EmuNtDll.cpp | 3 ++- src/CxbxKrnl/EmuNtDll.h | 13 ++++++++++++ src/CxbxKrnl/KernelThunk.cpp | 2 +- 5 files changed, 58 insertions(+), 3 deletions(-) diff --git a/import/OpenXDK/include/xboxkrnl/rtl.h b/import/OpenXDK/include/xboxkrnl/rtl.h index 388a66011..096266764 100644 --- a/import/OpenXDK/include/xboxkrnl/rtl.h +++ b/import/OpenXDK/include/xboxkrnl/rtl.h @@ -431,7 +431,18 @@ XBSYSAPI EXPORTNUM(309) NTSTATUS NTAPI RtlUnicodeStringToInteger IN PULONG Value ); -XBSYSAPI VOID *RtlUnicodeToMultiByteN; +// ****************************************************************** +// * 0x0136 - RtlUnicodeToMultiByteN() +// ****************************************************************** +XBSYSAPI EXPORTNUM(310) NTSTATUS NTAPI RtlUnicodeToMultiByteN +( + IN PCHAR MultiByteString, + IN ULONG MaxBytesInMultiByteString, + IN PULONG BytesInMultiByteString, + IN PWSTR UnicodeString, + IN ULONG BytesInUnicodeString +); + XBSYSAPI VOID *RtlUnicodeToMultiByteSize; XBSYSAPI VOID *RtlUnwind; XBSYSAPI VOID *RtlUpcaseUnicodeChar; diff --git a/src/CxbxKrnl/EmuKrnlRtl.cpp b/src/CxbxKrnl/EmuKrnlRtl.cpp index a26eb4df9..e73c9d97a 100644 --- a/src/CxbxKrnl/EmuKrnlRtl.cpp +++ b/src/CxbxKrnl/EmuKrnlRtl.cpp @@ -1023,6 +1023,36 @@ XBSYSAPI EXPORTNUM(309) xboxkrnl::NTSTATUS NTAPI xboxkrnl::RtlUnicodeStringToInt RETURN(ret); } +// ****************************************************************** +// * 0x0136 - RtlUnicodeToMultiByteN() +// ****************************************************************** +XBSYSAPI EXPORTNUM(310) xboxkrnl::NTSTATUS NTAPI xboxkrnl::RtlUnicodeToMultiByteN +( + IN PCHAR MultiByteString, + IN ULONG MaxBytesInMultiByteString, + IN PULONG BytesInMultiByteString, + IN PWSTR UnicodeString, + IN ULONG BytesInUnicodeString +) +{ + LOG_FUNC_BEGIN + LOG_FUNC_ARG_OUT(MultiByteString) + LOG_FUNC_ARG(MaxBytesInMultiByteString) + LOG_FUNC_ARG(BytesInMultiByteString) + LOG_FUNC_ARG(UnicodeString) + LOG_FUNC_ARG(BytesInUnicodeString) + LOG_FUNC_END; + + NTSTATUS ret = NtDll::RtlUnicodeToMultiByteN( + MultiByteString, + MaxBytesInMultiByteString, + BytesInMultiByteString, + UnicodeString, + BytesInUnicodeString); + + RETURN(ret); +} + // Prevent errors compiling RtlZeroMemory (TODO : How should we really do this?) #undef RtlZeroMemory diff --git a/src/CxbxKrnl/EmuNtDll.cpp b/src/CxbxKrnl/EmuNtDll.cpp index 492297e84..67f547c2e 100644 --- a/src/CxbxKrnl/EmuNtDll.cpp +++ b/src/CxbxKrnl/EmuNtDll.cpp @@ -148,4 +148,5 @@ IMPORT(RtlTimeToTimeFields); IMPORT(RtlTryEnterCriticalSection); IMPORT(RtlUlongByteSwap); IMPORT(RtlUnicodeStringToAnsiString); -IMPORT(RtlUnicodeStringToInteger); +IMPORT(RtlUnicodeStringToInteger); +IMPORT(RtlUnicodeToMultiByteN); diff --git a/src/CxbxKrnl/EmuNtDll.h b/src/CxbxKrnl/EmuNtDll.h index 3302d5a15..fbd0de1ec 100644 --- a/src/CxbxKrnl/EmuNtDll.h +++ b/src/CxbxKrnl/EmuNtDll.h @@ -925,6 +925,18 @@ typedef NTSTATUS (NTAPI *FPTR_RtlUnicodeStringToInteger) OUT PULONG Value ); +// ****************************************************************** +// * RtlUnicodeToMultiByteN +// ****************************************************************** +typedef NTSTATUS (NTAPI *FPTR_RtlUnicodeToMultiByteN) +( + OUT PCHAR MultiByteString, + IN ULONG MaxBytesInMultiByteString, + OUT PULONG BytesInMultiByteString OPTIONAL, + IN PCWCH UnicodeString, + IN ULONG BytesInUnicodeString +); + // ****************************************************************** // * RtlCompareMemory // ****************************************************************** @@ -1889,6 +1901,7 @@ EXTERN(RtlTryEnterCriticalSection); EXTERN(RtlUlongByteSwap); EXTERN(RtlUnicodeStringToAnsiString); EXTERN(RtlUnicodeStringToInteger); +EXTERN(RtlUnicodeToMultiByteN); #if defined(__cplusplus) } diff --git a/src/CxbxKrnl/KernelThunk.cpp b/src/CxbxKrnl/KernelThunk.cpp index b3c0fa48f..8b3acd80e 100644 --- a/src/CxbxKrnl/KernelThunk.cpp +++ b/src/CxbxKrnl/KernelThunk.cpp @@ -375,7 +375,7 @@ extern "C" CXBXKRNL_API uint32 CxbxKrnl_KernelThunkTable[379] = (uint32)FUNC(&xboxkrnl::RtlUlongByteSwap), // 0x0133 (307) (uint32)FUNC(&xboxkrnl::RtlUnicodeStringToAnsiString), // 0x0134 (308) (uint32)FUNC(&xboxkrnl::RtlUnicodeStringToInteger), // 0x0135 (309) - (uint32)PANIC(0x0136), // 0x0136 (310) RtlUnicodeToMultiByteN + (uint32)FUNC(&xboxkrnl::RtlUnicodeToMultiByteN), // 0x0136 (310) (uint32)PANIC(0x0137), // 0x0137 (311) RtlUnicodeToMultiByteSize (uint32)PANIC(0x0138), // 0x0138 (312) RtlUnwind (uint32)PANIC(0x0139), // 0x0139 (313) RtlUpcaseUnicodeChar From fdfda0d2393d1e2ecc9689d5cb944935a63b6b5a Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Mon, 26 Dec 2016 17:54:38 +0100 Subject: [PATCH 18/27] Marked NtDll header of RtlUlongByteSwap with FASTCALL --- src/CxbxKrnl/EmuNtDll.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CxbxKrnl/EmuNtDll.h b/src/CxbxKrnl/EmuNtDll.h index fbd0de1ec..a0e77e827 100644 --- a/src/CxbxKrnl/EmuNtDll.h +++ b/src/CxbxKrnl/EmuNtDll.h @@ -910,7 +910,7 @@ typedef BOOL (NTAPI *FPTR_RtlTryEnterCriticalSection) // ****************************************************************** // * RtlUlongByteSwap // ****************************************************************** -typedef ULONG (NTAPI *FPTR_RtlUlongByteSwap) +typedef ULONG (FASTCALL *FPTR_RtlUlongByteSwap) ( IN ULONG Source ); From 5e243062d5199652158e0e6f86f793fc56cf3b0d Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Mon, 26 Dec 2016 18:02:24 +0100 Subject: [PATCH 19/27] Implemented RtlUnicodeToMultiByteSize --- import/OpenXDK/include/xboxkrnl/rtl.h | 11 ++++++++++- src/CxbxKrnl/EmuKrnlRtl.cpp | 24 ++++++++++++++++++++++++ src/CxbxKrnl/EmuNtDll.cpp | 1 + src/CxbxKrnl/EmuNtDll.h | 11 +++++++++++ src/CxbxKrnl/KernelThunk.cpp | 2 +- 5 files changed, 47 insertions(+), 2 deletions(-) diff --git a/import/OpenXDK/include/xboxkrnl/rtl.h b/import/OpenXDK/include/xboxkrnl/rtl.h index 096266764..1ccaf0be5 100644 --- a/import/OpenXDK/include/xboxkrnl/rtl.h +++ b/import/OpenXDK/include/xboxkrnl/rtl.h @@ -443,7 +443,16 @@ XBSYSAPI EXPORTNUM(310) NTSTATUS NTAPI RtlUnicodeToMultiByteN IN ULONG BytesInUnicodeString ); -XBSYSAPI VOID *RtlUnicodeToMultiByteSize; +// ****************************************************************** +// * 0x0137 - RtlUnicodeToMultiByteSize() +// ****************************************************************** +XBSYSAPI EXPORTNUM(311) NTSTATUS NTAPI RtlUnicodeToMultiByteSize +( + IN PULONG BytesInMultiByteString, + IN PWSTR UnicodeString, + IN ULONG BytesInUnicodeString +); + XBSYSAPI VOID *RtlUnwind; XBSYSAPI VOID *RtlUpcaseUnicodeChar; XBSYSAPI VOID *RtlUpcaseUnicodeString; diff --git a/src/CxbxKrnl/EmuKrnlRtl.cpp b/src/CxbxKrnl/EmuKrnlRtl.cpp index e73c9d97a..f394a20c2 100644 --- a/src/CxbxKrnl/EmuKrnlRtl.cpp +++ b/src/CxbxKrnl/EmuKrnlRtl.cpp @@ -1053,6 +1053,30 @@ XBSYSAPI EXPORTNUM(310) xboxkrnl::NTSTATUS NTAPI xboxkrnl::RtlUnicodeToMultiByte RETURN(ret); } +// ****************************************************************** +// * 0x0137 - RtlUnicodeToMultiByteSize() +// ****************************************************************** +XBSYSAPI EXPORTNUM(311) xboxkrnl::NTSTATUS NTAPI xboxkrnl::RtlUnicodeToMultiByteSize +( + IN PULONG BytesInMultiByteString, + IN PWSTR UnicodeString, + IN ULONG BytesInUnicodeString +) +{ + LOG_FUNC_BEGIN + LOG_FUNC_ARG(BytesInMultiByteString) + LOG_FUNC_ARG(UnicodeString) + LOG_FUNC_ARG(BytesInUnicodeString) + LOG_FUNC_END; + + NTSTATUS ret = NtDll::RtlUnicodeToMultiByteSize( + BytesInMultiByteString, + UnicodeString, + BytesInUnicodeString); + + RETURN(ret); +} + // Prevent errors compiling RtlZeroMemory (TODO : How should we really do this?) #undef RtlZeroMemory diff --git a/src/CxbxKrnl/EmuNtDll.cpp b/src/CxbxKrnl/EmuNtDll.cpp index 67f547c2e..e67e0ecf3 100644 --- a/src/CxbxKrnl/EmuNtDll.cpp +++ b/src/CxbxKrnl/EmuNtDll.cpp @@ -150,3 +150,4 @@ IMPORT(RtlUlongByteSwap); IMPORT(RtlUnicodeStringToAnsiString); IMPORT(RtlUnicodeStringToInteger); IMPORT(RtlUnicodeToMultiByteN); +IMPORT(RtlUnicodeToMultiByteSize); diff --git a/src/CxbxKrnl/EmuNtDll.h b/src/CxbxKrnl/EmuNtDll.h index a0e77e827..1872e86a4 100644 --- a/src/CxbxKrnl/EmuNtDll.h +++ b/src/CxbxKrnl/EmuNtDll.h @@ -937,6 +937,16 @@ typedef NTSTATUS (NTAPI *FPTR_RtlUnicodeToMultiByteN) IN ULONG BytesInUnicodeString ); +// ****************************************************************** +// * RtlUnicodeToMultiByteSize +// ****************************************************************** +typedef NTSTATUS (NTAPI *FPTR_RtlUnicodeToMultiByteSize) +( + OUT PULONG BytesInMultiByteString, + IN PWCH UnicodeString, + IN ULONG BytesInUnicodeString +); + // ****************************************************************** // * RtlCompareMemory // ****************************************************************** @@ -1902,6 +1912,7 @@ EXTERN(RtlUlongByteSwap); EXTERN(RtlUnicodeStringToAnsiString); EXTERN(RtlUnicodeStringToInteger); EXTERN(RtlUnicodeToMultiByteN); +EXTERN(RtlUnicodeToMultiByteSize); #if defined(__cplusplus) } diff --git a/src/CxbxKrnl/KernelThunk.cpp b/src/CxbxKrnl/KernelThunk.cpp index 8b3acd80e..e8e345fda 100644 --- a/src/CxbxKrnl/KernelThunk.cpp +++ b/src/CxbxKrnl/KernelThunk.cpp @@ -376,7 +376,7 @@ extern "C" CXBXKRNL_API uint32 CxbxKrnl_KernelThunkTable[379] = (uint32)FUNC(&xboxkrnl::RtlUnicodeStringToAnsiString), // 0x0134 (308) (uint32)FUNC(&xboxkrnl::RtlUnicodeStringToInteger), // 0x0135 (309) (uint32)FUNC(&xboxkrnl::RtlUnicodeToMultiByteN), // 0x0136 (310) - (uint32)PANIC(0x0137), // 0x0137 (311) RtlUnicodeToMultiByteSize + (uint32)FUNC(&xboxkrnl::RtlUnicodeToMultiByteSize), // 0x0137 (311) (uint32)PANIC(0x0138), // 0x0138 (312) RtlUnwind (uint32)PANIC(0x0139), // 0x0139 (313) RtlUpcaseUnicodeChar (uint32)PANIC(0x013A), // 0x013A (314) RtlUpcaseUnicodeString From 6f8a8a728a22035b0f9a6ccb66e18a58eef9bbd3 Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Mon, 26 Dec 2016 18:10:20 +0100 Subject: [PATCH 20/27] Implemented RtlUpcaseUnicodeChar --- import/OpenXDK/include/xboxkrnl/rtl.h | 10 +++++++++- src/CxbxKrnl/EmuKrnlRtl.cpp | 15 +++++++++++++++ src/CxbxKrnl/EmuNtDll.cpp | 1 + src/CxbxKrnl/EmuNtDll.h | 9 +++++++++ src/CxbxKrnl/KernelThunk.cpp | 2 +- 5 files changed, 35 insertions(+), 2 deletions(-) diff --git a/import/OpenXDK/include/xboxkrnl/rtl.h b/import/OpenXDK/include/xboxkrnl/rtl.h index 1ccaf0be5..2889aa588 100644 --- a/import/OpenXDK/include/xboxkrnl/rtl.h +++ b/import/OpenXDK/include/xboxkrnl/rtl.h @@ -454,7 +454,15 @@ XBSYSAPI EXPORTNUM(311) NTSTATUS NTAPI RtlUnicodeToMultiByteSize ); XBSYSAPI VOID *RtlUnwind; -XBSYSAPI VOID *RtlUpcaseUnicodeChar; + +// ****************************************************************** +// * 0x0139 - RtlUpcaseUnicodeChar() +// ****************************************************************** +XBSYSAPI EXPORTNUM(313) WCHAR NTAPI RtlUpcaseUnicodeChar +( + IN WCHAR SourceCharacter +); + XBSYSAPI VOID *RtlUpcaseUnicodeString; XBSYSAPI VOID *RtlUpcaseUnicodeToMultiByteN; XBSYSAPI VOID *RtlUpperChar; diff --git a/src/CxbxKrnl/EmuKrnlRtl.cpp b/src/CxbxKrnl/EmuKrnlRtl.cpp index f394a20c2..ca6aac5fa 100644 --- a/src/CxbxKrnl/EmuKrnlRtl.cpp +++ b/src/CxbxKrnl/EmuKrnlRtl.cpp @@ -1077,6 +1077,21 @@ XBSYSAPI EXPORTNUM(311) xboxkrnl::NTSTATUS NTAPI xboxkrnl::RtlUnicodeToMultiByte RETURN(ret); } +// ****************************************************************** +// * 0x0139 - RtlUpcaseUnicodeChar() +// ****************************************************************** +XBSYSAPI EXPORTNUM(313) xboxkrnl::WCHAR NTAPI xboxkrnl::RtlUpcaseUnicodeChar +( + IN WCHAR SourceCharacter +) +{ + LOG_FUNC_ONE_ARG(SourceCharacter); + + WCHAR result = NtDll::RtlUpcaseUnicodeChar((NtDll::WCHAR)SourceCharacter); + + RETURN(result); +} + // Prevent errors compiling RtlZeroMemory (TODO : How should we really do this?) #undef RtlZeroMemory diff --git a/src/CxbxKrnl/EmuNtDll.cpp b/src/CxbxKrnl/EmuNtDll.cpp index e67e0ecf3..c96f0a126 100644 --- a/src/CxbxKrnl/EmuNtDll.cpp +++ b/src/CxbxKrnl/EmuNtDll.cpp @@ -151,3 +151,4 @@ IMPORT(RtlUnicodeStringToAnsiString); IMPORT(RtlUnicodeStringToInteger); IMPORT(RtlUnicodeToMultiByteN); IMPORT(RtlUnicodeToMultiByteSize); +IMPORT(RtlUpcaseUnicodeChar); diff --git a/src/CxbxKrnl/EmuNtDll.h b/src/CxbxKrnl/EmuNtDll.h index 1872e86a4..da76efedf 100644 --- a/src/CxbxKrnl/EmuNtDll.h +++ b/src/CxbxKrnl/EmuNtDll.h @@ -947,6 +947,14 @@ typedef NTSTATUS (NTAPI *FPTR_RtlUnicodeToMultiByteSize) IN ULONG BytesInUnicodeString ); +// ****************************************************************** +// * RtlUpcaseUnicodeChar +// ****************************************************************** +typedef WCHAR (NTAPI *FPTR_RtlUpcaseUnicodeChar) +( + IN WCHAR SourceCharacter +); + // ****************************************************************** // * RtlCompareMemory // ****************************************************************** @@ -1913,6 +1921,7 @@ EXTERN(RtlUnicodeStringToAnsiString); EXTERN(RtlUnicodeStringToInteger); EXTERN(RtlUnicodeToMultiByteN); EXTERN(RtlUnicodeToMultiByteSize); +EXTERN(RtlUpcaseUnicodeChar); #if defined(__cplusplus) } diff --git a/src/CxbxKrnl/KernelThunk.cpp b/src/CxbxKrnl/KernelThunk.cpp index e8e345fda..c946088c2 100644 --- a/src/CxbxKrnl/KernelThunk.cpp +++ b/src/CxbxKrnl/KernelThunk.cpp @@ -378,7 +378,7 @@ extern "C" CXBXKRNL_API uint32 CxbxKrnl_KernelThunkTable[379] = (uint32)FUNC(&xboxkrnl::RtlUnicodeToMultiByteN), // 0x0136 (310) (uint32)FUNC(&xboxkrnl::RtlUnicodeToMultiByteSize), // 0x0137 (311) (uint32)PANIC(0x0138), // 0x0138 (312) RtlUnwind - (uint32)PANIC(0x0139), // 0x0139 (313) RtlUpcaseUnicodeChar + (uint32)FUNC(&xboxkrnl::RtlUpcaseUnicodeChar), // 0x0139 (313) (uint32)PANIC(0x013A), // 0x013A (314) RtlUpcaseUnicodeString (uint32)PANIC(0x013B), // 0x013B (315) RtlUpcaseUnicodeToMultiByteN (uint32)PANIC(0x013C), // 0x013C (316) RtlUpperChar From e01102d8d3824bf2686c47bc731f601ed6739c85 Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Mon, 26 Dec 2016 18:51:08 +0100 Subject: [PATCH 21/27] Implemented RtlUpcaseUnicodeString --- import/OpenXDK/include/xboxkrnl/rtl.h | 11 ++++++++- src/CxbxKrnl/EmuKrnlRtl.cpp | 32 +++++++++++++++++++++++---- src/CxbxKrnl/EmuNtDll.cpp | 1 + src/CxbxKrnl/EmuNtDll.h | 11 +++++++++ src/CxbxKrnl/KernelThunk.cpp | 2 +- 5 files changed, 51 insertions(+), 6 deletions(-) diff --git a/import/OpenXDK/include/xboxkrnl/rtl.h b/import/OpenXDK/include/xboxkrnl/rtl.h index 2889aa588..3b3dfe8b1 100644 --- a/import/OpenXDK/include/xboxkrnl/rtl.h +++ b/import/OpenXDK/include/xboxkrnl/rtl.h @@ -463,7 +463,16 @@ XBSYSAPI EXPORTNUM(313) WCHAR NTAPI RtlUpcaseUnicodeChar IN WCHAR SourceCharacter ); -XBSYSAPI VOID *RtlUpcaseUnicodeString; +// ****************************************************************** +// * 0x013A - RtlUpcaseUnicodeString() +// ****************************************************************** +XBSYSAPI EXPORTNUM(314) NTSTATUS NTAPI RtlUpcaseUnicodeString +( + OUT PUNICODE_STRING DestinationString, + IN PUNICODE_STRING SourceString, + IN BOOLEAN AllocateDestinationString +); + XBSYSAPI VOID *RtlUpcaseUnicodeToMultiByteN; XBSYSAPI VOID *RtlUpperChar; XBSYSAPI VOID *RtlUpperString; diff --git a/src/CxbxKrnl/EmuKrnlRtl.cpp b/src/CxbxKrnl/EmuKrnlRtl.cpp index ca6aac5fa..fb11564e2 100644 --- a/src/CxbxKrnl/EmuKrnlRtl.cpp +++ b/src/CxbxKrnl/EmuKrnlRtl.cpp @@ -313,7 +313,7 @@ XBSYSAPI EXPORTNUM(272) xboxkrnl::VOID NTAPI xboxkrnl::RtlCopyString ) { LOG_FUNC_BEGIN - LOG_FUNC_ARG(DestinationString) + LOG_FUNC_ARG_OUT(DestinationString) LOG_FUNC_ARG(SourceString) LOG_FUNC_END; @@ -330,7 +330,7 @@ XBSYSAPI EXPORTNUM(273) xboxkrnl::VOID NTAPI xboxkrnl::RtlCopyUnicodeString ) { LOG_FUNC_BEGIN - LOG_FUNC_ARG(DestinationString) + LOG_FUNC_ARG_OUT(DestinationString) LOG_FUNC_ARG(SourceString) LOG_FUNC_END; @@ -347,7 +347,7 @@ XBSYSAPI EXPORTNUM(274) xboxkrnl::BOOLEAN NTAPI xboxkrnl::RtlCreateUnicodeString ) { LOG_FUNC_BEGIN - LOG_FUNC_ARG(DestinationString) + LOG_FUNC_ARG_OUT(DestinationString) LOG_FUNC_ARG(SourceString) LOG_FUNC_END; @@ -382,7 +382,7 @@ XBSYSAPI EXPORTNUM(276) xboxkrnl::NTSTATUS NTAPI xboxkrnl::RtlDowncaseUnicodeStr ) { LOG_FUNC_BEGIN - LOG_FUNC_ARG(DestinationString) + LOG_FUNC_ARG_OUT(DestinationString) LOG_FUNC_ARG(SourceString) LOG_FUNC_ARG(AllocateDestinationString) LOG_FUNC_END; @@ -1092,6 +1092,30 @@ XBSYSAPI EXPORTNUM(313) xboxkrnl::WCHAR NTAPI xboxkrnl::RtlUpcaseUnicodeChar RETURN(result); } +// ****************************************************************** +// * 0x013A - RtlUpcaseUnicodeString() +// ****************************************************************** +XBSYSAPI EXPORTNUM(314) xboxkrnl::NTSTATUS NTAPI xboxkrnl::RtlUpcaseUnicodeString +( + OUT PUNICODE_STRING DestinationString, + IN PUNICODE_STRING SourceString, + IN BOOLEAN AllocateDestinationString +) +{ + LOG_FUNC_BEGIN + LOG_FUNC_ARG_OUT(DestinationString) + LOG_FUNC_ARG(SourceString) + LOG_FUNC_ARG(AllocateDestinationString) + LOG_FUNC_END; + + NTSTATUS result = NtDll::RtlUpcaseUnicodeString( + (NtDll::PUNICODE_STRING)DestinationString, + (NtDll::PUNICODE_STRING)SourceString, + AllocateDestinationString); + + RETURN(result); +} + // Prevent errors compiling RtlZeroMemory (TODO : How should we really do this?) #undef RtlZeroMemory diff --git a/src/CxbxKrnl/EmuNtDll.cpp b/src/CxbxKrnl/EmuNtDll.cpp index c96f0a126..3c5b8ccb0 100644 --- a/src/CxbxKrnl/EmuNtDll.cpp +++ b/src/CxbxKrnl/EmuNtDll.cpp @@ -152,3 +152,4 @@ IMPORT(RtlUnicodeStringToInteger); IMPORT(RtlUnicodeToMultiByteN); IMPORT(RtlUnicodeToMultiByteSize); IMPORT(RtlUpcaseUnicodeChar); +IMPORT(RtlUpcaseUnicodeString); diff --git a/src/CxbxKrnl/EmuNtDll.h b/src/CxbxKrnl/EmuNtDll.h index da76efedf..1829790aa 100644 --- a/src/CxbxKrnl/EmuNtDll.h +++ b/src/CxbxKrnl/EmuNtDll.h @@ -955,6 +955,16 @@ typedef WCHAR (NTAPI *FPTR_RtlUpcaseUnicodeChar) IN WCHAR SourceCharacter ); +// ****************************************************************** +// * RtlUpcaseUnicodeString +// ****************************************************************** +typedef NTSTATUS (NTAPI *FPTR_RtlUpcaseUnicodeString) +( + OUT PUNICODE_STRING DestinationString, + IN PUNICODE_STRING SourceString, + IN BOOLEAN AllocateDestinationString +); + // ****************************************************************** // * RtlCompareMemory // ****************************************************************** @@ -1922,6 +1932,7 @@ EXTERN(RtlUnicodeStringToInteger); EXTERN(RtlUnicodeToMultiByteN); EXTERN(RtlUnicodeToMultiByteSize); EXTERN(RtlUpcaseUnicodeChar); +EXTERN(RtlUpcaseUnicodeString); #if defined(__cplusplus) } diff --git a/src/CxbxKrnl/KernelThunk.cpp b/src/CxbxKrnl/KernelThunk.cpp index c946088c2..0600fde8b 100644 --- a/src/CxbxKrnl/KernelThunk.cpp +++ b/src/CxbxKrnl/KernelThunk.cpp @@ -379,7 +379,7 @@ extern "C" CXBXKRNL_API uint32 CxbxKrnl_KernelThunkTable[379] = (uint32)FUNC(&xboxkrnl::RtlUnicodeToMultiByteSize), // 0x0137 (311) (uint32)PANIC(0x0138), // 0x0138 (312) RtlUnwind (uint32)FUNC(&xboxkrnl::RtlUpcaseUnicodeChar), // 0x0139 (313) - (uint32)PANIC(0x013A), // 0x013A (314) RtlUpcaseUnicodeString + (uint32)FUNC(&xboxkrnl::RtlUpcaseUnicodeString), // 0x013A (314) (uint32)PANIC(0x013B), // 0x013B (315) RtlUpcaseUnicodeToMultiByteN (uint32)PANIC(0x013C), // 0x013C (316) RtlUpperChar (uint32)PANIC(0x013D), // 0x013D (317) RtlUpperString From cdd8b4dc932cd1d9e2b117785d02a7bb17e4e872 Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Mon, 26 Dec 2016 19:39:57 +0100 Subject: [PATCH 22/27] Implemented RtlUpcaseUnicodeToMultiByteN --- import/OpenXDK/include/xboxkrnl/rtl.h | 13 +++++++++++- src/CxbxKrnl/EmuKrnlRtl.cpp | 30 +++++++++++++++++++++++++++ src/CxbxKrnl/EmuNtDll.cpp | 1 + src/CxbxKrnl/EmuNtDll.h | 13 ++++++++++++ src/CxbxKrnl/KernelThunk.cpp | 2 +- 5 files changed, 57 insertions(+), 2 deletions(-) diff --git a/import/OpenXDK/include/xboxkrnl/rtl.h b/import/OpenXDK/include/xboxkrnl/rtl.h index 3b3dfe8b1..83d646206 100644 --- a/import/OpenXDK/include/xboxkrnl/rtl.h +++ b/import/OpenXDK/include/xboxkrnl/rtl.h @@ -473,7 +473,18 @@ XBSYSAPI EXPORTNUM(314) NTSTATUS NTAPI RtlUpcaseUnicodeString IN BOOLEAN AllocateDestinationString ); -XBSYSAPI VOID *RtlUpcaseUnicodeToMultiByteN; +// ****************************************************************** +// * 0x013B - RtlUpcaseUnicodeToMultiByteN() +// ****************************************************************** +XBSYSAPI EXPORTNUM(315) NTSTATUS NTAPI RtlUpcaseUnicodeToMultiByteN +( + IN OUT PCHAR MultiByteString, + IN ULONG MaxBytesInMultiByteString, + IN PULONG BytesInMultiByteString, + IN PWSTR UnicodeString, + IN ULONG BytesInUnicodeString +); + XBSYSAPI VOID *RtlUpperChar; XBSYSAPI VOID *RtlUpperString; XBSYSAPI VOID *RtlUshortByteSwap; diff --git a/src/CxbxKrnl/EmuKrnlRtl.cpp b/src/CxbxKrnl/EmuKrnlRtl.cpp index fb11564e2..6fdc39c9c 100644 --- a/src/CxbxKrnl/EmuKrnlRtl.cpp +++ b/src/CxbxKrnl/EmuKrnlRtl.cpp @@ -1116,6 +1116,36 @@ XBSYSAPI EXPORTNUM(314) xboxkrnl::NTSTATUS NTAPI xboxkrnl::RtlUpcaseUnicodeStrin RETURN(result); } +// ****************************************************************** +// * 0x013B - RtlUpcaseUnicodeToMultiByteN() +// ****************************************************************** +XBSYSAPI EXPORTNUM(315) xboxkrnl::NTSTATUS NTAPI xboxkrnl::RtlUpcaseUnicodeToMultiByteN +( + IN OUT PCHAR MultiByteString, + IN ULONG MaxBytesInMultiByteString, + IN PULONG BytesInMultiByteString, + IN PWSTR UnicodeString, + IN ULONG BytesInUnicodeString +) +{ + LOG_FUNC_BEGIN + LOG_FUNC_ARG_OUT(MultiByteString) + LOG_FUNC_ARG(MaxBytesInMultiByteString) + LOG_FUNC_ARG(BytesInMultiByteString) + LOG_FUNC_ARG(UnicodeString) + LOG_FUNC_ARG(BytesInUnicodeString) + LOG_FUNC_END; + + NTSTATUS result = NtDll::RtlUpcaseUnicodeToMultiByteN( + MultiByteString, + MaxBytesInMultiByteString, + BytesInMultiByteString, + UnicodeString, + BytesInUnicodeString); + + RETURN(result); +} + // Prevent errors compiling RtlZeroMemory (TODO : How should we really do this?) #undef RtlZeroMemory diff --git a/src/CxbxKrnl/EmuNtDll.cpp b/src/CxbxKrnl/EmuNtDll.cpp index 3c5b8ccb0..c0de36d30 100644 --- a/src/CxbxKrnl/EmuNtDll.cpp +++ b/src/CxbxKrnl/EmuNtDll.cpp @@ -153,3 +153,4 @@ IMPORT(RtlUnicodeToMultiByteN); IMPORT(RtlUnicodeToMultiByteSize); IMPORT(RtlUpcaseUnicodeChar); IMPORT(RtlUpcaseUnicodeString); +IMPORT(RtlUpcaseUnicodeToMultiByteN); diff --git a/src/CxbxKrnl/EmuNtDll.h b/src/CxbxKrnl/EmuNtDll.h index 1829790aa..fc3b95e61 100644 --- a/src/CxbxKrnl/EmuNtDll.h +++ b/src/CxbxKrnl/EmuNtDll.h @@ -965,6 +965,18 @@ typedef NTSTATUS (NTAPI *FPTR_RtlUpcaseUnicodeString) IN BOOLEAN AllocateDestinationString ); +// ****************************************************************** +// * RtlUpcaseUnicodeToMultiByteN +// ****************************************************************** +typedef NTSTATUS (NTAPI *FPTR_RtlUpcaseUnicodeToMultiByteN) +( + OUT PCHAR MultiByteString, + IN ULONG MaxBytesInMultiByteString, + OUT PULONG BytesInMultiByteString OPTIONAL, + IN PCWCH UnicodeString, + IN ULONG BytesInUnicodeString +); + // ****************************************************************** // * RtlCompareMemory // ****************************************************************** @@ -1933,6 +1945,7 @@ EXTERN(RtlUnicodeToMultiByteN); EXTERN(RtlUnicodeToMultiByteSize); EXTERN(RtlUpcaseUnicodeChar); EXTERN(RtlUpcaseUnicodeString); +EXTERN(RtlUpcaseUnicodeToMultiByteN); #if defined(__cplusplus) } diff --git a/src/CxbxKrnl/KernelThunk.cpp b/src/CxbxKrnl/KernelThunk.cpp index 0600fde8b..b448b189d 100644 --- a/src/CxbxKrnl/KernelThunk.cpp +++ b/src/CxbxKrnl/KernelThunk.cpp @@ -380,7 +380,7 @@ extern "C" CXBXKRNL_API uint32 CxbxKrnl_KernelThunkTable[379] = (uint32)PANIC(0x0138), // 0x0138 (312) RtlUnwind (uint32)FUNC(&xboxkrnl::RtlUpcaseUnicodeChar), // 0x0139 (313) (uint32)FUNC(&xboxkrnl::RtlUpcaseUnicodeString), // 0x013A (314) - (uint32)PANIC(0x013B), // 0x013B (315) RtlUpcaseUnicodeToMultiByteN + (uint32)FUNC(&xboxkrnl::RtlUpcaseUnicodeToMultiByteN), // 0x013B (315) (uint32)PANIC(0x013C), // 0x013C (316) RtlUpperChar (uint32)PANIC(0x013D), // 0x013D (317) RtlUpperString (uint32)PANIC(0x013E), // 0x013E (318) RtlUshortByteSwap From 0c31aeddb40efdfd369c4218be51076cfafbf321 Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Mon, 26 Dec 2016 19:41:55 +0100 Subject: [PATCH 23/27] Implemented RtlUpperChar --- import/OpenXDK/include/xboxkrnl/rtl.h | 9 ++++++++- src/CxbxKrnl/EmuKrnlRtl.cpp | 15 +++++++++++++++ src/CxbxKrnl/KernelThunk.cpp | 2 +- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/import/OpenXDK/include/xboxkrnl/rtl.h b/import/OpenXDK/include/xboxkrnl/rtl.h index 83d646206..435d3aa08 100644 --- a/import/OpenXDK/include/xboxkrnl/rtl.h +++ b/import/OpenXDK/include/xboxkrnl/rtl.h @@ -485,7 +485,14 @@ XBSYSAPI EXPORTNUM(315) NTSTATUS NTAPI RtlUpcaseUnicodeToMultiByteN IN ULONG BytesInUnicodeString ); -XBSYSAPI VOID *RtlUpperChar; +// ****************************************************************** +// * 0x013C - RtlUpperChar() +// ****************************************************************** +XBSYSAPI EXPORTNUM(316) CHAR NTAPI RtlUpperChar +( + CHAR Character +); + XBSYSAPI VOID *RtlUpperString; XBSYSAPI VOID *RtlUshortByteSwap; XBSYSAPI VOID *RtlWalkFrameChain; diff --git a/src/CxbxKrnl/EmuKrnlRtl.cpp b/src/CxbxKrnl/EmuKrnlRtl.cpp index 6fdc39c9c..f2eedaf61 100644 --- a/src/CxbxKrnl/EmuKrnlRtl.cpp +++ b/src/CxbxKrnl/EmuKrnlRtl.cpp @@ -1146,6 +1146,21 @@ XBSYSAPI EXPORTNUM(315) xboxkrnl::NTSTATUS NTAPI xboxkrnl::RtlUpcaseUnicodeToMul RETURN(result); } +// ****************************************************************** +// * 0x013C - RtlUpperChar() +// ****************************************************************** +XBSYSAPI EXPORTNUM(316) xboxkrnl::CHAR NTAPI xboxkrnl::RtlUpperChar +( + CHAR Character +) +{ + LOG_FUNC_ONE_ARG(Character); + + CHAR ret = toupper(Character); + + RETURN(ret); +} + // Prevent errors compiling RtlZeroMemory (TODO : How should we really do this?) #undef RtlZeroMemory diff --git a/src/CxbxKrnl/KernelThunk.cpp b/src/CxbxKrnl/KernelThunk.cpp index b448b189d..47138ee9c 100644 --- a/src/CxbxKrnl/KernelThunk.cpp +++ b/src/CxbxKrnl/KernelThunk.cpp @@ -381,7 +381,7 @@ extern "C" CXBXKRNL_API uint32 CxbxKrnl_KernelThunkTable[379] = (uint32)FUNC(&xboxkrnl::RtlUpcaseUnicodeChar), // 0x0139 (313) (uint32)FUNC(&xboxkrnl::RtlUpcaseUnicodeString), // 0x013A (314) (uint32)FUNC(&xboxkrnl::RtlUpcaseUnicodeToMultiByteN), // 0x013B (315) - (uint32)PANIC(0x013C), // 0x013C (316) RtlUpperChar + (uint32)FUNC(&xboxkrnl::RtlUpperChar), // 0x013C (316) (uint32)PANIC(0x013D), // 0x013D (317) RtlUpperString (uint32)PANIC(0x013E), // 0x013E (318) RtlUshortByteSwap (uint32)PANIC(0x013F), // 0x013F (319) RtlWalkFrameChain From 9383e9f6a9050cad7015ed999ae88145e7ffdd71 Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Mon, 26 Dec 2016 19:47:35 +0100 Subject: [PATCH 24/27] Implemented RtlUpperString --- import/OpenXDK/include/xboxkrnl/rtl.h | 10 +++++++++- src/CxbxKrnl/EmuKrnlRtl.cpp | 17 +++++++++++++++++ src/CxbxKrnl/EmuNtDll.cpp | 1 + src/CxbxKrnl/EmuNtDll.h | 10 ++++++++++ src/CxbxKrnl/KernelThunk.cpp | 2 +- 5 files changed, 38 insertions(+), 2 deletions(-) diff --git a/import/OpenXDK/include/xboxkrnl/rtl.h b/import/OpenXDK/include/xboxkrnl/rtl.h index 435d3aa08..8fd3d26ea 100644 --- a/import/OpenXDK/include/xboxkrnl/rtl.h +++ b/import/OpenXDK/include/xboxkrnl/rtl.h @@ -493,7 +493,15 @@ XBSYSAPI EXPORTNUM(316) CHAR NTAPI RtlUpperChar CHAR Character ); -XBSYSAPI VOID *RtlUpperString; +// ****************************************************************** +// * 0x013D - RtlUpperString() +// ****************************************************************** +XBSYSAPI EXPORTNUM(317) VOID NTAPI RtlUpperString +( + OUT PSTRING DestinationString, + IN PSTRING SourceString +); + XBSYSAPI VOID *RtlUshortByteSwap; XBSYSAPI VOID *RtlWalkFrameChain; diff --git a/src/CxbxKrnl/EmuKrnlRtl.cpp b/src/CxbxKrnl/EmuKrnlRtl.cpp index f2eedaf61..bb3e3ed9a 100644 --- a/src/CxbxKrnl/EmuKrnlRtl.cpp +++ b/src/CxbxKrnl/EmuKrnlRtl.cpp @@ -1161,6 +1161,23 @@ XBSYSAPI EXPORTNUM(316) xboxkrnl::CHAR NTAPI xboxkrnl::RtlUpperChar RETURN(ret); } +// ****************************************************************** +// * 0x013D - RtlUpperString() +// ****************************************************************** +XBSYSAPI EXPORTNUM(317) xboxkrnl::VOID NTAPI xboxkrnl::RtlUpperString +( + OUT PSTRING DestinationString, + IN PSTRING SourceString +) +{ + LOG_FUNC_BEGIN + LOG_FUNC_ARG_OUT(DestinationString) + LOG_FUNC_ARG(SourceString) + LOG_FUNC_END; + + NtDll::RtlUpperString((NtDll::PSTRING)DestinationString, (NtDll::PSTRING)SourceString); +} + // Prevent errors compiling RtlZeroMemory (TODO : How should we really do this?) #undef RtlZeroMemory diff --git a/src/CxbxKrnl/EmuNtDll.cpp b/src/CxbxKrnl/EmuNtDll.cpp index c0de36d30..cbaa5cbe3 100644 --- a/src/CxbxKrnl/EmuNtDll.cpp +++ b/src/CxbxKrnl/EmuNtDll.cpp @@ -154,3 +154,4 @@ IMPORT(RtlUnicodeToMultiByteSize); IMPORT(RtlUpcaseUnicodeChar); IMPORT(RtlUpcaseUnicodeString); IMPORT(RtlUpcaseUnicodeToMultiByteN); +IMPORT(RtlUpperString); diff --git a/src/CxbxKrnl/EmuNtDll.h b/src/CxbxKrnl/EmuNtDll.h index fc3b95e61..907e348ac 100644 --- a/src/CxbxKrnl/EmuNtDll.h +++ b/src/CxbxKrnl/EmuNtDll.h @@ -977,6 +977,15 @@ typedef NTSTATUS (NTAPI *FPTR_RtlUpcaseUnicodeToMultiByteN) IN ULONG BytesInUnicodeString ); +// ****************************************************************** +// * RtlUpperString +// ****************************************************************** +typedef VOID (NTAPI *FPTR_RtlUpperString) +( + OUT PSTRING DestinationString, + IN const STRING *SourceString +); + // ****************************************************************** // * RtlCompareMemory // ****************************************************************** @@ -1946,6 +1955,7 @@ EXTERN(RtlUnicodeToMultiByteSize); EXTERN(RtlUpcaseUnicodeChar); EXTERN(RtlUpcaseUnicodeString); EXTERN(RtlUpcaseUnicodeToMultiByteN); +EXTERN(RtlUpperString); #if defined(__cplusplus) } diff --git a/src/CxbxKrnl/KernelThunk.cpp b/src/CxbxKrnl/KernelThunk.cpp index 47138ee9c..405c13b3d 100644 --- a/src/CxbxKrnl/KernelThunk.cpp +++ b/src/CxbxKrnl/KernelThunk.cpp @@ -382,7 +382,7 @@ extern "C" CXBXKRNL_API uint32 CxbxKrnl_KernelThunkTable[379] = (uint32)FUNC(&xboxkrnl::RtlUpcaseUnicodeString), // 0x013A (314) (uint32)FUNC(&xboxkrnl::RtlUpcaseUnicodeToMultiByteN), // 0x013B (315) (uint32)FUNC(&xboxkrnl::RtlUpperChar), // 0x013C (316) - (uint32)PANIC(0x013D), // 0x013D (317) RtlUpperString + (uint32)FUNC(&xboxkrnl::RtlUpperString), // 0x013D (317) (uint32)PANIC(0x013E), // 0x013E (318) RtlUshortByteSwap (uint32)PANIC(0x013F), // 0x013F (319) RtlWalkFrameChain (uint32)FUNC(&xboxkrnl::RtlZeroMemory), // 0x0140 (320) From 1e639d98af3fc6644d3c95af64438061805749db Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Mon, 26 Dec 2016 19:51:22 +0100 Subject: [PATCH 25/27] Implemented RtlUshortByteSwap --- import/OpenXDK/include/xboxkrnl/rtl.h | 9 ++++++++- src/CxbxKrnl/EmuKrnlRtl.cpp | 15 +++++++++++++++ src/CxbxKrnl/EmuNtDll.cpp | 1 + src/CxbxKrnl/EmuNtDll.h | 9 +++++++++ src/CxbxKrnl/KernelThunk.cpp | 2 +- 5 files changed, 34 insertions(+), 2 deletions(-) diff --git a/import/OpenXDK/include/xboxkrnl/rtl.h b/import/OpenXDK/include/xboxkrnl/rtl.h index 8fd3d26ea..8082905b8 100644 --- a/import/OpenXDK/include/xboxkrnl/rtl.h +++ b/import/OpenXDK/include/xboxkrnl/rtl.h @@ -502,7 +502,14 @@ XBSYSAPI EXPORTNUM(317) VOID NTAPI RtlUpperString IN PSTRING SourceString ); -XBSYSAPI VOID *RtlUshortByteSwap; +// ****************************************************************** +// * 0x013E - RtlUshortByteSwap() +// ****************************************************************** +XBSYSAPI EXPORTNUM(318) USHORT FASTCALL RtlUshortByteSwap +( + IN USHORT Source +); + XBSYSAPI VOID *RtlWalkFrameChain; // ****************************************************************** diff --git a/src/CxbxKrnl/EmuKrnlRtl.cpp b/src/CxbxKrnl/EmuKrnlRtl.cpp index bb3e3ed9a..48690c492 100644 --- a/src/CxbxKrnl/EmuKrnlRtl.cpp +++ b/src/CxbxKrnl/EmuKrnlRtl.cpp @@ -1178,6 +1178,21 @@ XBSYSAPI EXPORTNUM(317) xboxkrnl::VOID NTAPI xboxkrnl::RtlUpperString NtDll::RtlUpperString((NtDll::PSTRING)DestinationString, (NtDll::PSTRING)SourceString); } +// ****************************************************************** +// * 0x013E - RtlUshortByteSwap() +// ****************************************************************** +XBSYSAPI EXPORTNUM(318) xboxkrnl::USHORT FASTCALL xboxkrnl::RtlUshortByteSwap +( + IN USHORT Source +) +{ + LOG_FUNC_ONE_ARG(Source); + + ULONG ret = NtDll::RtlUshortByteSwap(Source); + + RETURN(ret); +} + // Prevent errors compiling RtlZeroMemory (TODO : How should we really do this?) #undef RtlZeroMemory diff --git a/src/CxbxKrnl/EmuNtDll.cpp b/src/CxbxKrnl/EmuNtDll.cpp index cbaa5cbe3..766956f06 100644 --- a/src/CxbxKrnl/EmuNtDll.cpp +++ b/src/CxbxKrnl/EmuNtDll.cpp @@ -155,3 +155,4 @@ IMPORT(RtlUpcaseUnicodeChar); IMPORT(RtlUpcaseUnicodeString); IMPORT(RtlUpcaseUnicodeToMultiByteN); IMPORT(RtlUpperString); +IMPORT(RtlUshortByteSwap); diff --git a/src/CxbxKrnl/EmuNtDll.h b/src/CxbxKrnl/EmuNtDll.h index 907e348ac..607a238df 100644 --- a/src/CxbxKrnl/EmuNtDll.h +++ b/src/CxbxKrnl/EmuNtDll.h @@ -986,6 +986,14 @@ typedef VOID (NTAPI *FPTR_RtlUpperString) IN const STRING *SourceString ); +// ****************************************************************** +// * RtlUshortByteSwap +// ****************************************************************** +typedef USHORT (FASTCALL *FPTR_RtlUshortByteSwap) +( + IN USHORT Source +); + // ****************************************************************** // * RtlCompareMemory // ****************************************************************** @@ -1956,6 +1964,7 @@ EXTERN(RtlUpcaseUnicodeChar); EXTERN(RtlUpcaseUnicodeString); EXTERN(RtlUpcaseUnicodeToMultiByteN); EXTERN(RtlUpperString); +EXTERN(RtlUshortByteSwap); #if defined(__cplusplus) } diff --git a/src/CxbxKrnl/KernelThunk.cpp b/src/CxbxKrnl/KernelThunk.cpp index 405c13b3d..4d566ff35 100644 --- a/src/CxbxKrnl/KernelThunk.cpp +++ b/src/CxbxKrnl/KernelThunk.cpp @@ -383,7 +383,7 @@ extern "C" CXBXKRNL_API uint32 CxbxKrnl_KernelThunkTable[379] = (uint32)FUNC(&xboxkrnl::RtlUpcaseUnicodeToMultiByteN), // 0x013B (315) (uint32)FUNC(&xboxkrnl::RtlUpperChar), // 0x013C (316) (uint32)FUNC(&xboxkrnl::RtlUpperString), // 0x013D (317) - (uint32)PANIC(0x013E), // 0x013E (318) RtlUshortByteSwap + (uint32)FUNC(&xboxkrnl::RtlUshortByteSwap), // 0x013E (318) (uint32)PANIC(0x013F), // 0x013F (319) RtlWalkFrameChain (uint32)FUNC(&xboxkrnl::RtlZeroMemory), // 0x0140 (320) (uint32)VARIABLE(&xboxkrnl::XboxEEPROMKey), // 0x0141 (321) From bdc11da533f812d88bcdf417a9853344a1098254 Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Mon, 26 Dec 2016 20:17:54 +0100 Subject: [PATCH 26/27] Typo fixed in RtlUshortByteSwap --- src/CxbxKrnl/EmuKrnlRtl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CxbxKrnl/EmuKrnlRtl.cpp b/src/CxbxKrnl/EmuKrnlRtl.cpp index 48690c492..c41e20130 100644 --- a/src/CxbxKrnl/EmuKrnlRtl.cpp +++ b/src/CxbxKrnl/EmuKrnlRtl.cpp @@ -1188,7 +1188,7 @@ XBSYSAPI EXPORTNUM(318) xboxkrnl::USHORT FASTCALL xboxkrnl::RtlUshortByteSwap { LOG_FUNC_ONE_ARG(Source); - ULONG ret = NtDll::RtlUshortByteSwap(Source); + USHORT ret = NtDll::RtlUshortByteSwap(Source); RETURN(ret); } From ad04ffbfe45ad3595e1e5224ad2d7bada926e90d Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Thu, 29 Dec 2016 12:00:17 +0100 Subject: [PATCH 27/27] LLE APU and GPU switches added --- src/CxbxKrnl/HLEDataBase.cpp | 98 ++++++++++---------- src/CxbxKrnl/HLEDataBase.h | 13 ++- src/CxbxKrnl/HLEIntercept.cpp | 162 ++++++++++++++++++---------------- 3 files changed, 152 insertions(+), 121 deletions(-) diff --git a/src/CxbxKrnl/HLEDataBase.cpp b/src/CxbxKrnl/HLEDataBase.cpp index 0e59ed0bd..71dbcc623 100644 --- a/src/CxbxKrnl/HLEDataBase.cpp +++ b/src/CxbxKrnl/HLEDataBase.cpp @@ -39,8 +39,16 @@ extern "C" const char *szHLELastCompileTime = __TIMESTAMP__; -// Uncomment this line for experimental DSOUND LLE -// #define DSOUND_LLE +const char *Lib_D3D8 = "D3D8"; +const char *Lib_D3D8LTCG = "D3D8LTCG"; +const char *Lib_D3DX8 = "D3DX8"; +const char *Lib_DSOUND = "DSOUND"; +const char *Lib_XACTENG = "XACTENG"; +const char *Lib_XAPILIB = "XAPILIB"; +const char *Lib_XGRAPHC = "XGRAPHC"; +const char *Lib_XNETS = "XNETS"; +const char *Lib_XONLINE = "XONLINE"; // TODO : Typo for XONLINES? +const char *Lib_XONLINES = "XONLINES"; #include "Emu.h" #include "EmuXTL.h" @@ -95,261 +103,259 @@ HLEData HLEDataBase[] = { // Xapilib Version 1.0.3911 { - "XAPILIB", + Lib_XAPILIB, 1, 0, 3911, XAPI_1_0_3911, XAPI_1_0_3911_SIZE }, // Xapilib Version 1.0.4034 { - "XAPILIB", + Lib_XAPILIB, 1, 0, 4034, XAPI_1_0_4034, XAPI_1_0_4034_SIZE }, // Xapilib Version 1.0.4134 { - "XAPILIB", + Lib_XAPILIB, 1, 0, 4134, XAPI_1_0_4134, XAPI_1_0_4134_SIZE }, // Xapilib Version 1.0.4361 { - "XAPILIB", + Lib_XAPILIB, 1, 0, 4361, XAPI_1_0_4361, XAPI_1_0_4361_SIZE }, // Xapilib Version 1.0.4432 { - "XAPILIB", + Lib_XAPILIB, 1, 0, 4432, XAPI_1_0_4432, XAPI_1_0_4432_SIZE }, // Xapilib Version 1.0.4627 { - "XAPILIB", + Lib_XAPILIB, 1, 0, 4627, XAPI_1_0_4627, XAPI_1_0_4627_SIZE }, // Xapilib Version 1.0.5233 { - "XAPILIB", + Lib_XAPILIB, 1, 0, 5233, XAPI_1_0_5233, XAPI_1_0_5233_SIZE }, // Xapilib Version 1.0.5558 { - "XAPILIB", + Lib_XAPILIB, 1, 0, 5558, XAPI_1_0_5558, XAPI_1_0_5558_SIZE }, // Xapilib Version 1.0.5849 { - "XAPILIB", + Lib_XAPILIB, 1, 0, 5849, XAPI_1_0_5849, XAPI_1_0_5849_SIZE }, // D3D8 Version 1.0.3925 { - "D3D8", + Lib_D3D8, 1, 0, 3925, D3D8_1_0_3925, D3D8_1_0_3925_SIZE }, // D3D8 Version 1.0.4034 { - "D3D8", + Lib_D3D8, 1, 0, 4034, D3D8_1_0_4034, D3D8_1_0_4034_SIZE }, // D3D8 Version 1.0.4134 { - "D3D8", + Lib_D3D8, 1, 0, 4134, D3D8_1_0_4134, D3D8_1_0_4134_SIZE }, // D3D8 Version 1.0.4361 { - "D3D8", + Lib_D3D8, 1, 0, 4361, D3D8_1_0_4361, D3D8_1_0_4361_SIZE }, // D3D8 Version 1.0.4432 { - "D3D8", + Lib_D3D8, 1, 0, 4432, D3D8_1_0_4432, D3D8_1_0_4432_SIZE }, // D3D8 Version 1.0.4627 { - "D3D8", + Lib_D3D8, 1, 0, 4627, D3D8_1_0_4627, D3D8_1_0_4627_SIZE }, // D3D8 Version 1.0.5233 { - "D3D8", + Lib_D3D8, 1, 0, 5233, D3D8_1_0_5233, D3D8_1_0_5233_SIZE }, // D3D8 Version 1.0.5558 { - "D3D8", + Lib_D3D8, 1, 0, 5558, D3D8_1_0_5558, D3D8_1_0_5558_SIZE }, // D3D8 Version 1.0.5849 { - "D3D8", + Lib_D3D8, 1, 0, 5849, D3D8_1_0_5849, D3D8_1_0_5849_SIZE }, // D3D8LTCG Version 1.0.5849 { - "D3D8LTCG", + Lib_D3D8LTCG, 1, 0, 5849, D3D8LTCG_1_0_5849, D3D8LTCG_1_0_5849_SIZE }, -#ifndef DSOUND_LLE // DSound Version 1.0.3936 { - "DSOUND", + Lib_DSOUND, 1, 0, 3936, DSound_1_0_3936, DSound_1_0_3936_SIZE }, // DSound Version 1.0.4134 { - "DSOUND", + Lib_DSOUND, 1, 0, 4134, DSound_1_0_4134, DSound_1_0_4134_SIZE }, // DSound Version 1.0.4361 { - "DSOUND", + Lib_DSOUND, 1, 0, 4361, DSound_1_0_4361, DSound_1_0_4361_SIZE }, // DSound Version 1.0.4432 { - "DSOUND", + Lib_DSOUND, 1, 0, 4432, DSound_1_0_4432, DSound_1_0_4432_SIZE }, // DSound Version 1.0.4627 { - "DSOUND", + Lib_DSOUND, 1, 0, 4627, DSound_1_0_4627, DSound_1_0_4627_SIZE }, // DSound Version 1.0.5233 { - "DSOUND", + Lib_DSOUND, 1, 0, 5233, DSound_1_0_5233, DSound_1_0_5233_SIZE }, // DSound Version 1.0.5558 { - "DSOUND", + Lib_DSOUND, 1, 0, 5558, DSound_1_0_5558, DSound_1_0_5558_SIZE }, // DSound Version 1.0.5849 { - "DSOUND", + Lib_DSOUND, 1, 0, 5849, DSound_1_0_5849, DSound_1_0_5849_SIZE }, -#endif // XG Version 1.0.3911 { - "XGRAPHC", + Lib_XGRAPHC, 1, 0, 3911, XG_1_0_3911, XG_1_0_3911_SIZE }, // XG Version 1.0.4034 { - "XGRAPHC", + Lib_XGRAPHC, 1, 0, 4034, XG_1_0_4034, XG_1_0_4034_SIZE }, // XG Version 1.0.4361 { - "XGRAPHC", + Lib_XGRAPHC, 1, 0, 4361, XG_1_0_4361, XG_1_0_4361_SIZE }, // XG Version 1.0.4432 { - "XGRAPHC", + Lib_XGRAPHC, 1, 0, 4432, XG_1_0_4432, XG_1_0_4432_SIZE }, // XG Version 1.0.4627 { - "XGRAPHC", + Lib_XGRAPHC, 1, 0, 4627, XG_1_0_4627, XG_1_0_4627_SIZE }, // XG Version 1.0.5233 { - "XGRAPHC", + Lib_XGRAPHC, 1, 0, 5233, XG_1_0_5233, XG_1_0_5233_SIZE }, // XG Version 1.0.5558 { - "XGRAPHC", + Lib_XGRAPHC, 1, 0, 5558, XG_1_0_5558, XG_1_0_5558_SIZE }, // XG Version 1.0.5849 { - "XGRAPHC", + Lib_XGRAPHC, 1, 0, 5849, XG_1_0_5849, XG_1_0_5849_SIZE }, // XNet Version 1.0.3911 { - "XNETS", + Lib_XNETS, 1, 0, 3911, XNet_1_0_3911, XNet_1_0_3911_SIZE }, // XOnline Version 1.0.4361 { - "XONLINE", + Lib_XONLINE, // TODO : Typo for XONLINES? 1, 0, 4361, XOnline_1_0_4361, XOnline_1_0_4361_SIZE @@ -357,35 +363,35 @@ HLEData HLEDataBase[] = // XOnline(s) Version 1.0.4627 // TODO: Verify differences between XONLINE and XONLINES (if any) { - "XONLINES", + Lib_XONLINES, 1, 0, 4627, XOnline_1_0_4627, XOnline_1_0_4627_SIZE }, // XOnline(s) Version 1.0.5233 { - "XONLINES", + Lib_XONLINES, 1, 0, 5233, XOnline_1_0_5233, XOnline_1_0_5233_SIZE }, // XOnline(s) Version 1.0.5558 { - "XONLINES", + Lib_XONLINES, 1, 0, 5558, XOnline_1_0_5558, XOnline_1_0_5558_SIZE }, // XOnline(s) Version 1.0.5849 { - "XONLINES", + Lib_XONLINES, 1, 0, 5849, XOnline_1_0_5849, XOnline_1_0_5849_SIZE }, // XactEng Version 1.0.4627 { - "XACTENG", + Lib_XACTENG, 1, 0, 4627, XactEng_1_0_4627, XactEng_1_0_4627_SIZE diff --git a/src/CxbxKrnl/HLEDataBase.h b/src/CxbxKrnl/HLEDataBase.h index 45724497f..7cef79823 100644 --- a/src/CxbxKrnl/HLEDataBase.h +++ b/src/CxbxKrnl/HLEDataBase.h @@ -82,12 +82,23 @@ // ****************************************************************** extern "C" const char *szHLELastCompileTime; +extern const char *Lib_D3D8; +extern const char *Lib_D3D8LTCG; +extern const char *Lib_D3DX8; +extern const char *Lib_DSOUND; +extern const char *Lib_XACTENG; +extern const char *Lib_XAPILIB; +extern const char *Lib_XGRAPHC; +extern const char *Lib_XNETS; +extern const char *Lib_XONLINE; // TODO : Typo for XONLINES? +extern const char *Lib_XONLINES; + // ****************************************************************** // * HLEDataBase // ****************************************************************** extern struct HLEData { - char *Library; + const char *Library; uint16 MajorVersion; uint16 MinorVersion; diff --git a/src/CxbxKrnl/HLEIntercept.cpp b/src/CxbxKrnl/HLEIntercept.cpp index b371de69d..0c33d9427 100644 --- a/src/CxbxKrnl/HLEIntercept.cpp +++ b/src/CxbxKrnl/HLEIntercept.cpp @@ -162,7 +162,11 @@ void EmuHLEIntercept(Xbe::LibraryVersion *pLibraryVersion, Xbe::Header *pXbeHead uint32 LastUnResolvedXRefs = UnResolvedXRefs+1; uint32 OrigUnResolvedXRefs = UnResolvedXRefs; - for(int p=0;UnResolvedXRefs < LastUnResolvedXRefs;p++) + // Set these for experimental APU(sound) / GPU (graphics) LLE + bool bLLE_APU = false; + bool bLLE_GPU = false; + + for(int p=0;UnResolvedXRefs < LastUnResolvedXRefs;p++) { DbgPrintf("HLE: Starting pass #%d...\n", p+1); @@ -216,27 +220,54 @@ void EmuHLEIntercept(Xbe::LibraryVersion *pLibraryVersion, Xbe::Header *pXbeHead szOrigLibraryName[c] = pLibraryVersion[v].szName[c]; } - // Test - if(strcmp(szLibraryName, "XGRAPHC") == 0) + // TODO: HACK: D3DX8 is packed into D3D8 database + if (strcmp(szLibraryName, Lib_D3DX8) == 0) { - // if(BuildVersion == 4432) - // BuildVersion = 4361; - if(BuildVersion == 3944) - BuildVersion = 3911; - if(OrigBuildVersion == 4531) - BuildVersion = 4361; - // Quick test (JSRF) - if(OrigBuildVersion == 4134) - BuildVersion = 4361; - // Quick test (Simpsons: RoadRage) - // if(BuildVersion == 4034) - // BuildVersion = 3911; + strcpy(szLibraryName, Lib_D3D8); } - // Several 3911 titles has different DSound builds. - if(strcmp(szLibraryName, "DSOUND") == 0) + if(strcmp(szLibraryName, Lib_D3D8LTCG) == 0) + { + // Skip scanning for D3D8LTCG symbols when LLE GPU is selected + if (bLLE_GPU) + continue; + + // Test (do not release uncommented!) + /*strcpy(szLibraryName, Lib_D3D8);*/ + } + + if (strcmp(szLibraryName, Lib_D3D8) == 0) + { + // Skip scanning for D3D8 symbols when LLE GPU is selected + if (bLLE_GPU) + continue; + + // Prevent scanning D3D8 again (since D3D8X is packed into it above) + if (bFoundD3D) + { + //DbgPrintf("Redundant\n"); + continue; + } + + bFoundD3D = true; + + // Some 3911 titles have different D3D8 builds + if (BuildVersion <= 3948) + BuildVersion = 3925; + + // Testing... don't release with this code in it! + // TODO: 5233 and 5558 + // if(BuildVersion == 4134) + // BuildVersion = 4627; + } + else if(strcmp(szLibraryName, Lib_DSOUND) == 0) { - if(BuildVersion < 4034) + // Skip scanning for DSOUND symbols when LLE APU is selected + if (bLLE_APU) + continue; + + // Several 3911 titles has different DSound builds. + if(BuildVersion < 4034) { BuildVersion = 3936; } @@ -246,22 +277,9 @@ void EmuHLEIntercept(Xbe::LibraryVersion *pLibraryVersion, Xbe::Header *pXbeHead BuildVersion == 4531 ) BuildVersion = 4627; } - - // Some 3911 titles have different D3D8 builds - if(strcmp(szLibraryName, "D3D8") == 0) - { - if(BuildVersion <= 3948) - BuildVersion = 3925; - - // Testing... don't release with this code in it! - // TODO: 5233 and 5558 - // if(BuildVersion == 4134) - // BuildVersion = 4627; - } - - // Change a few XAPILIB versions to similar counterparts - if(strcmp(szLibraryName, "XAPILIB") == 0) + else if(strcmp(szLibraryName, Lib_XAPILIB) == 0) { + // Change a few XAPILIB versions to similar counterparts if(BuildVersion == 3944) BuildVersion = 3911; if(BuildVersion == 3950) @@ -269,33 +287,29 @@ void EmuHLEIntercept(Xbe::LibraryVersion *pLibraryVersion, Xbe::Header *pXbeHead if(OrigBuildVersion == 4531) BuildVersion = 4627; } - - // Test (do not release uncommented!) - /*if(strcmp(szLibraryName, "D3D8LTCG") == 0) + else if (strcmp(szLibraryName, Lib_XGRAPHC) == 0) { - strcpy(szLibraryName, "D3D8"); - }*/ + // Skip scanning for XGRAPHC (XG) symbols when LLE GPU is selected + if (bLLE_GPU) + continue; - // TODO: HACK: These libraries are packed into one database - if(strcmp(szLibraryName, "D3DX8") == 0) + // if(BuildVersion == 4432) + // BuildVersion = 4361; + if (BuildVersion == 3944) + BuildVersion = 3911; + if (OrigBuildVersion == 4531) + BuildVersion = 4361; + // Quick test (JSRF) + if (OrigBuildVersion == 4134) + BuildVersion = 4361; + // Quick test (Simpsons: RoadRage) + // if(BuildVersion == 4034) + // BuildVersion = 3911; + } + + if(bXRefFirstPass) { - strcpy(szLibraryName, "D3D8"); - } - - if(strcmp(szLibraryName, "D3D8") == 0) - { - if(bFoundD3D) - { - //DbgPrintf("Redundant\n"); - continue; - } - - bFoundD3D = true; - } - - if(bXRefFirstPass) - { - if(strcmp("XAPILIB", szLibraryName) == 0 && MajorVersion == 1 && MinorVersion == 0 && + if(strcmp(Lib_XAPILIB, szLibraryName) == 0 && MajorVersion == 1 && MinorVersion == 0 && (BuildVersion == 3911 || BuildVersion == 4034 || BuildVersion == 4134 || BuildVersion == 4361 || BuildVersion == 4432 || BuildVersion == 4627 || BuildVersion == 5233 || BuildVersion == 5558 || BuildVersion == 5849)) @@ -303,7 +317,7 @@ void EmuHLEIntercept(Xbe::LibraryVersion *pLibraryVersion, Xbe::Header *pXbeHead uint32 lower = pXbeHeader->dwBaseAddr; uint32 upper = pXbeHeader->dwBaseAddr + pXbeHeader->dwSizeofImage; } - else if(strcmp("D3D8", szLibraryName) == 0 /*&& strcmp("D3D8LTCG", szOrigLibraryName)*/ && + else if(strcmp(Lib_D3D8, szLibraryName) == 0 /*&& strcmp(Lib_D3D8LTCG, szOrigLibraryName)*/ && MajorVersion == 1 && MinorVersion == 0 && (BuildVersion == 3925 || BuildVersion == 4134 || BuildVersion == 4361 || BuildVersion == 4432 || BuildVersion == 4627 || BuildVersion == 5233 || BuildVersion == 5558 || BuildVersion == 5849)) @@ -315,7 +329,7 @@ void EmuHLEIntercept(Xbe::LibraryVersion *pLibraryVersion, Xbe::Header *pXbeHead uint32 lower = pXbeHeader->dwBaseAddr; uint32 upper = pXbeHeader->dwBaseAddr + pXbeHeader->dwSizeofImage; - void *pFunc = 0; + void *pFunc = nullptr; if(BuildVersion == 3925) pFunc = EmuLocateFunction((OOVPA*)&IDirect3DDevice8_SetRenderState_CullMode_1_0_3925, lower, upper); @@ -325,7 +339,7 @@ void EmuHLEIntercept(Xbe::LibraryVersion *pLibraryVersion, Xbe::Header *pXbeHead pFunc = EmuLocateFunction((OOVPA*)&IDirect3DDevice8_SetRenderState_CullMode_1_0_5233, lower, upper); // locate D3DDeferredRenderState - if(pFunc != 0) + if(pFunc != nullptr) { // offset for stencil cull enable render state in the deferred render state buffer int patchOffset = 0; @@ -378,13 +392,13 @@ void EmuHLEIntercept(Xbe::LibraryVersion *pLibraryVersion, Xbe::Header *pXbeHead } else { - XTL::EmuD3DDeferredRenderState = 0; + XTL::EmuD3DDeferredRenderState = nullptr; CxbxKrnlCleanup("EmuD3DDeferredRenderState was not found!"); } // locate D3DDeferredTextureState { - pFunc = 0; + pFunc = nullptr; if(BuildVersion == 3925) pFunc = EmuLocateFunction((OOVPA*)&IDirect3DDevice8_SetTextureState_TexCoordIndex_1_0_3925, lower, upper); @@ -395,7 +409,7 @@ void EmuHLEIntercept(Xbe::LibraryVersion *pLibraryVersion, Xbe::Header *pXbeHead else if(BuildVersion == 4627 || BuildVersion == 5233 || BuildVersion == 5558 || BuildVersion == 5849) pFunc = EmuLocateFunction((OOVPA*)&IDirect3DDevice8_SetTextureState_TexCoordIndex_1_0_4627, lower, upper); - if(pFunc != 0) + if(pFunc != nullptr) { if(BuildVersion == 3925) // 0x18F180 XTL::EmuD3DDeferredTextureState = (DWORD*)(*(DWORD*)((uint32)pFunc + 0x11) - 0x70); // TODO: Verify @@ -414,12 +428,12 @@ void EmuHLEIntercept(Xbe::LibraryVersion *pLibraryVersion, Xbe::Header *pXbeHead } else { - XTL::EmuD3DDeferredTextureState = 0; + XTL::EmuD3DDeferredTextureState = nullptr; CxbxKrnlCleanup("EmuD3DDeferredTextureState was not found!"); } } } - //else if(strcmp("D3D8LTCG", szLibraryName) == 0 && MajorVersion == 1 && MinorVersion == 0 && + //else if(strcmp(Lib_D3D8LTCG, szLibraryName) == 0 && MajorVersion == 1 && MinorVersion == 0 && // (BuildVersion == 5849)) // 5849 only so far... // { // // Save D3D8 build version @@ -429,13 +443,13 @@ void EmuHLEIntercept(Xbe::LibraryVersion *pLibraryVersion, Xbe::Header *pXbeHead // uint32 lower = pXbeHeader->dwBaseAddr; // uint32 upper = pXbeHeader->dwBaseAddr + pXbeHeader->dwSizeofImage; - // void *pFunc = 0; + // void *pFunc = nullptr; // if(BuildVersion == 5849) // pFunc = EmuLocateFunction((OOVPA*)&IDirect3DDevice8_SetRenderState_CullMode_1_0_5849_LTCG, lower, upper); // // locate D3DDeferredRenderState - // if(pFunc != 0) + // if(pFunc != nullptr) // { // // offset for stencil cull enable render state in the deferred render state buffer // int patchOffset = 0; @@ -464,18 +478,18 @@ void EmuHLEIntercept(Xbe::LibraryVersion *pLibraryVersion, Xbe::Header *pXbeHead // } // else // { - // XTL::EmuD3DDeferredRenderState = 0; + // XTL::EmuD3DDeferredRenderState = nullptr; // CxbxKrnlCleanup("EmuD3DDeferredRenderState was not found!"); // } // // locate D3DDeferredTextureState // { - // pFunc = 0; + // pFunc = nullptr; // if(BuildVersion == 3925) // pFunc = EmuLocateFunction((OOVPA*)&IDirect3DDevice8_SetTextureState_TexCoordIndex_1_0_5849_LTCG, lower, upper); - // if(pFunc != 0) + // if(pFunc != nullptr) // { // if(BuildVersion == 3925) // 0x18F180 // XTL::EmuD3DDeferredTextureState = (DWORD*)(*(DWORD*)((uint32)pFunc + 0x11) - 0x70); // TODO: Verify @@ -494,7 +508,7 @@ void EmuHLEIntercept(Xbe::LibraryVersion *pLibraryVersion, Xbe::Header *pXbeHead // } // else // { - // XTL::EmuD3DDeferredTextureState = 0; + // XTL::EmuD3DDeferredTextureState = nullptr; // CxbxKrnlCleanup("EmuD3DDeferredTextureState was not found!"); // } // } @@ -745,7 +759,7 @@ static void EmuInstallWrappers(OOVPATable *OovpaTable, uint32 OovpaTableSize, Xb { OOVPA *Oovpa = OovpaTable[a].Oovpa; - void *pFunc = NULL; + void *pFunc = nullptr; if(bCacheInp && (vCacheInpIter != vCacheInp.end())) { @@ -759,13 +773,13 @@ static void EmuInstallWrappers(OOVPATable *OovpaTable, uint32 OovpaTableSize, Xb vCacheOut.push_back(pFunc); } - if(pFunc != 0) + if(pFunc != nullptr) { #ifdef _DEBUG_TRACE DbgPrintf("HLE: 0x%.08X -> %s\n", pFunc, OovpaTable[a].szFuncName); #endif - if(OovpaTable[a].lpRedirect == 0) + if(OovpaTable[a].lpRedirect == nullptr) { // Insert breakpoint *(uint8_t*)pFunc = 0xCC;