diff --git a/import/OpenXDK/include/xboxkrnl/nt.h b/import/OpenXDK/include/xboxkrnl/nt.h index 0c1c954ea..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 @@ -298,7 +306,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/rtl.h b/import/OpenXDK/include/xboxkrnl/rtl.h index 4d7979e07..8082905b8 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,12 +180,64 @@ XBSYSAPI EXPORTNUM(279) BOOLEAN NTAPI RtlEqualString IN BOOLEAN CaseSensitive ); -XBSYSAPI VOID *RtlEqualUnicodeString; -XBSYSAPI VOID *RtlExtendedIntegerMultiply; -XBSYSAPI VOID *RtlExtendedLargeIntegerDivide; -XBSYSAPI VOID *RtlExtendedMagicDivide; -XBSYSAPI VOID *RtlFillMemory; -XBSYSAPI VOID *RtlFillMemoryUlong; +// ****************************************************************** +// * 0x0118 - RtlEqualUnicodeString() +// ****************************************************************** +XBSYSAPI EXPORTNUM(280) BOOLEAN NTAPI RtlEqualUnicodeString +( + IN PUNICODE_STRING String1, + IN PUNICODE_STRING String2, + IN BOOLEAN CaseSensitive +); + +// ****************************************************************** +// * 0x0119 - RtlExtendedIntegerMultiply() +// ****************************************************************** +XBSYSAPI EXPORTNUM(281) LARGE_INTEGER NTAPI RtlExtendedIntegerMultiply +( + IN LARGE_INTEGER Multiplicand, + IN LONG Multiplier +); + +// ****************************************************************** +// * 0x011A - RtlExtendedLargeIntegerDivide() +// ****************************************************************** +XBSYSAPI EXPORTNUM(282) LARGE_INTEGER NTAPI RtlExtendedLargeIntegerDivide +( + IN LARGE_INTEGER Dividend, + IN ULONG Divisor, + IN PULONG Remainder // OUT? OPTIONAL? +); + +// ****************************************************************** +// * 0x011B - RtlExtendedMagicDivide() +// ****************************************************************** +XBSYSAPI EXPORTNUM(283) LARGE_INTEGER NTAPI RtlExtendedMagicDivide +( + IN LARGE_INTEGER Dividend, + IN LARGE_INTEGER MagicDivisor, + IN CCHAR ShiftCount +); + +// ****************************************************************** +// * 0x011C - RtlFillMemory() +// ****************************************************************** +XBSYSAPI EXPORTNUM(284) VOID NTAPI RtlFillMemory +( + IN VOID UNALIGNED *Destination, + IN DWORD Length, + IN BYTE Fill +); + +// ****************************************************************** +// * 0x011D - RtlFillMemoryUlong() +// ****************************************************************** +XBSYSAPI EXPORTNUM(285) VOID NTAPI RtlFillMemoryUlong +( + IN PVOID Destination, + IN SIZE_T Length, + IN ULONG Pattern +); // ****************************************************************** // * RtlFreeAnsiString @@ -195,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; // ****************************************************************** @@ -225,8 +284,26 @@ XBSYSAPI EXPORTNUM(291) VOID NTAPI RtlInitializeCriticalSection IN PRTL_CRITICAL_SECTION CriticalSection ); -XBSYSAPI VOID *RtlIntegerToChar; -XBSYSAPI VOID *RtlIntegerToUnicodeString; +// ****************************************************************** +// * 0x0124 - RtlIntegerToChar() +// ****************************************************************** +XBSYSAPI EXPORTNUM(292) NTSTATUS NTAPI RtlIntegerToChar +( + IN ULONG Value, + IN ULONG Base, + IN LONG OutputLength, + IN PSZ String +); + +// ****************************************************************** +// * 0x0125 - RtlIntegerToUnicodeString() +// ****************************************************************** +XBSYSAPI EXPORTNUM(293) NTSTATUS NTAPI RtlIntegerToUnicodeString +( + IN ULONG Value, + IN ULONG Base, + IN PUNICODE_STRING String +); // ****************************************************************** // * RtlLeaveCriticalSection @@ -243,10 +320,17 @@ 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 +// * 0x012A - RtlMoveMemory() // ****************************************************************** // * // * Move memory either forward or backward, aligned or unaligned, @@ -260,8 +344,27 @@ XBSYSAPI EXPORTNUM(298) VOID NTAPI RtlMoveMemory IN SIZE_T Length ); -XBSYSAPI VOID *RtlMultiByteToUnicodeN; -XBSYSAPI VOID *RtlMultiByteToUnicodeSize; +// ****************************************************************** +// * 0x012B - RtlMultiByteToUnicodeN() +// ****************************************************************** +XBSYSAPI EXPORTNUM(299) NTSTATUS NTAPI RtlMultiByteToUnicodeN +( + IN PWSTR UnicodeString, + IN ULONG MaxBytesInUnicodeString, + IN PULONG BytesInUnicodeString, + IN PCHAR MultiByteString, + IN ULONG BytesInMultiByteString +); + +// ****************************************************************** +// * 0x012C - RtlMultiByteToUnicodeSize() +// ****************************************************************** +XBSYSAPI EXPORTNUM(300) NTSTATUS NTAPI RtlMultiByteToUnicodeSize +( + IN PULONG BytesInUnicodeString, + IN PCHAR MultiByteString, + IN ULONG BytesInMultiByteString +); // ****************************************************************** // * RtlNtStatusToDosError @@ -300,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 @@ -312,16 +421,95 @@ XBSYSAPI EXPORTNUM(308) NTSTATUS NTAPI RtlUnicodeStringToAnsiString IN BOOLEAN AllocateDestinationString ); -XBSYSAPI VOID *RtlUnicodeStringToInteger; -XBSYSAPI VOID *RtlUnicodeToMultiByteN; -XBSYSAPI VOID *RtlUnicodeToMultiByteSize; +// ****************************************************************** +// * 0x0135 - RtlUnicodeStringToInteger() +// ****************************************************************** +XBSYSAPI EXPORTNUM(309) NTSTATUS NTAPI RtlUnicodeStringToInteger +( + IN PUNICODE_STRING String, + IN ULONG Base, + IN PULONG Value +); + +// ****************************************************************** +// * 0x0136 - RtlUnicodeToMultiByteN() +// ****************************************************************** +XBSYSAPI EXPORTNUM(310) NTSTATUS NTAPI RtlUnicodeToMultiByteN +( + IN PCHAR MultiByteString, + IN ULONG MaxBytesInMultiByteString, + IN PULONG BytesInMultiByteString, + IN PWSTR UnicodeString, + IN ULONG BytesInUnicodeString +); + +// ****************************************************************** +// * 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; -XBSYSAPI VOID *RtlUpcaseUnicodeToMultiByteN; -XBSYSAPI VOID *RtlUpperChar; -XBSYSAPI VOID *RtlUpperString; -XBSYSAPI VOID *RtlUshortByteSwap; + +// ****************************************************************** +// * 0x0139 - RtlUpcaseUnicodeChar() +// ****************************************************************** +XBSYSAPI EXPORTNUM(313) WCHAR NTAPI RtlUpcaseUnicodeChar +( + IN WCHAR SourceCharacter +); + +// ****************************************************************** +// * 0x013A - RtlUpcaseUnicodeString() +// ****************************************************************** +XBSYSAPI EXPORTNUM(314) NTSTATUS NTAPI RtlUpcaseUnicodeString +( + OUT PUNICODE_STRING DestinationString, + IN PUNICODE_STRING SourceString, + IN BOOLEAN AllocateDestinationString +); + +// ****************************************************************** +// * 0x013B - RtlUpcaseUnicodeToMultiByteN() +// ****************************************************************** +XBSYSAPI EXPORTNUM(315) NTSTATUS NTAPI RtlUpcaseUnicodeToMultiByteN +( + IN OUT PCHAR MultiByteString, + IN ULONG MaxBytesInMultiByteString, + IN PULONG BytesInMultiByteString, + IN PWSTR UnicodeString, + IN ULONG BytesInUnicodeString +); + +// ****************************************************************** +// * 0x013C - RtlUpperChar() +// ****************************************************************** +XBSYSAPI EXPORTNUM(316) CHAR NTAPI RtlUpperChar +( + CHAR Character +); + +// ****************************************************************** +// * 0x013D - RtlUpperString() +// ****************************************************************** +XBSYSAPI EXPORTNUM(317) VOID NTAPI RtlUpperString +( + OUT PSTRING DestinationString, + IN PSTRING SourceString +); + +// ****************************************************************** +// * 0x013E - RtlUshortByteSwap() +// ****************************************************************** +XBSYSAPI EXPORTNUM(318) USHORT FASTCALL RtlUshortByteSwap +( + IN USHORT Source +); + XBSYSAPI VOID *RtlWalkFrameChain; // ****************************************************************** diff --git a/import/OpenXDK/include/xboxkrnl/xboxkrnl.h b/import/OpenXDK/include/xboxkrnl/xboxkrnl.h index c5d1ae740..8a286f14f 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; @@ -129,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; @@ -536,6 +538,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 // ****************************************************************** @@ -986,7 +1000,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 +1176,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; @@ -1169,6 +1190,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..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() // ****************************************************************** @@ -1002,6 +1029,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/EmuKrnlRtl.cpp b/src/CxbxKrnl/EmuKrnlRtl.cpp index 92d88b192..c41e20130 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; @@ -455,6 +455,156 @@ 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); +} + +// ****************************************************************** +// * 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); +} + +// ****************************************************************** +// * 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); +} + +// ****************************************************************** +// * 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); +} + +// 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); +} + +// ****************************************************************** +// * 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() // ****************************************************************** @@ -468,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() // ****************************************************************** @@ -532,6 +695,50 @@ 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); +} + +// ****************************************************************** +// * 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() // ****************************************************************** @@ -578,11 +785,28 @@ 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 // ****************************************************************** -// * 0x012A - RtlMoveMemory +// * 0x012A - RtlMoveMemory() // ****************************************************************** XBSYSAPI EXPORTNUM(298) xboxkrnl::VOID NTAPI xboxkrnl::RtlMoveMemory ( @@ -600,6 +824,60 @@ 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); +} + +// ****************************************************************** +// * 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() // ****************************************************************** @@ -688,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() // ****************************************************************** @@ -709,6 +1002,197 @@ 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); +} + +// ****************************************************************** +// * 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); +} + +// ****************************************************************** +// * 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); +} + +// ****************************************************************** +// * 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); +} + +// ****************************************************************** +// * 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); +} + +// ****************************************************************** +// * 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); +} + +// ****************************************************************** +// * 0x013C - RtlUpperChar() +// ****************************************************************** +XBSYSAPI EXPORTNUM(316) xboxkrnl::CHAR NTAPI xboxkrnl::RtlUpperChar +( + CHAR Character +) +{ + LOG_FUNC_ONE_ARG(Character); + + CHAR ret = toupper(Character); + + 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); +} + +// ****************************************************************** +// * 0x013E - RtlUshortByteSwap() +// ****************************************************************** +XBSYSAPI EXPORTNUM(318) xboxkrnl::USHORT FASTCALL xboxkrnl::RtlUshortByteSwap +( + IN USHORT Source +) +{ + LOG_FUNC_ONE_ARG(Source); + + USHORT 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 c38c455fd..766956f06 100644 --- a/src/CxbxKrnl/EmuNtDll.cpp +++ b/src/CxbxKrnl/EmuNtDll.cpp @@ -82,8 +82,10 @@ IMPORT(NtFsControlFile); IMPORT(NtOpenSymbolicLinkObject); IMPORT(NtPulseEvent); IMPORT(NtQueryDirectoryFile); +IMPORT(NtQueryEvent); IMPORT(NtQueryFullAttributesFile); IMPORT(NtQueryInformationFile); +IMPORT(NtQuerySemaphore); IMPORT(NtQueryTimer); IMPORT(NtQueryVirtualMemory); IMPORT(NtQueryVolumeInformationFile); @@ -120,16 +122,37 @@ IMPORT(RtlDowncaseUnicodeChar); IMPORT(RtlDowncaseUnicodeString); IMPORT(RtlEnterCriticalSection); IMPORT(RtlEqualString); +IMPORT(RtlEqualUnicodeString); +IMPORT(RtlExtendedIntegerMultiply); +IMPORT(RtlExtendedLargeIntegerDivide); +IMPORT(RtlExtendedMagicDivide); +IMPORT(RtlFillMemory); +IMPORT(RtlFillMemoryUlong); IMPORT(RtlFreeAnsiString); IMPORT(RtlFreeHeap); +IMPORT(RtlFreeUnicodeString); +IMPORT(RtlIntegerToChar); +IMPORT(RtlIntegerToUnicodeString); IMPORT(RtlInitAnsiString); IMPORT(RtlInitializeCriticalSection); IMPORT(RtlInitUnicodeString); IMPORT(RtlLeaveCriticalSection); +IMPORT(RtlMapGenericMask); +IMPORT(RtlMultiByteToUnicodeN); +IMPORT(RtlMultiByteToUnicodeSize); IMPORT(RtlNtStatusToDosError); IMPORT(RtlReAllocateHeap); IMPORT(RtlSizeHeap); IMPORT(RtlTimeFieldsToTime); IMPORT(RtlTimeToTimeFields); IMPORT(RtlTryEnterCriticalSection); +IMPORT(RtlUlongByteSwap); IMPORT(RtlUnicodeStringToAnsiString); +IMPORT(RtlUnicodeStringToInteger); +IMPORT(RtlUnicodeToMultiByteN); +IMPORT(RtlUnicodeToMultiByteSize); +IMPORT(RtlUpcaseUnicodeChar); +IMPORT(RtlUpcaseUnicodeString); +IMPORT(RtlUpcaseUnicodeToMultiByteN); +IMPORT(RtlUpperString); +IMPORT(RtlUshortByteSwap); diff --git a/src/CxbxKrnl/EmuNtDll.h b/src/CxbxKrnl/EmuNtDll.h index dea4b7204..607a238df 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; @@ -419,6 +427,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 // ****************************************************************** @@ -429,6 +444,13 @@ typedef enum _EVENT_TYPE } EVENT_TYPE; +// ****************************************************************** +// * EVENT_INFORMATION_CLASS +// ****************************************************************** +typedef enum _EVENT_INFORMATION_CLASS { + EventBasicInformation +} EVENT_INFORMATION_CLASS, *PEVENT_INFORMATION_CLASS; + // ****************************************************************** // * TIMER_TYPE // ****************************************************************** @@ -758,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 @@ -831,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 @@ -862,6 +907,93 @@ typedef BOOL (NTAPI *FPTR_RtlTryEnterCriticalSection) IN PRTL_CRITICAL_SECTION CriticalSection ); +// ****************************************************************** +// * RtlUlongByteSwap +// ****************************************************************** +typedef ULONG (FASTCALL *FPTR_RtlUlongByteSwap) +( + IN ULONG Source +); + +// ****************************************************************** +// * RtlUnicodeStringToInteger +// ****************************************************************** +typedef NTSTATUS (NTAPI *FPTR_RtlUnicodeStringToInteger) +( + IN PCUNICODE_STRING String, + IN ULONG Base OPTIONAL, + 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 +); + +// ****************************************************************** +// * RtlUnicodeToMultiByteSize +// ****************************************************************** +typedef NTSTATUS (NTAPI *FPTR_RtlUnicodeToMultiByteSize) +( + OUT PULONG BytesInMultiByteString, + IN PWCH UnicodeString, + IN ULONG BytesInUnicodeString +); + +// ****************************************************************** +// * RtlUpcaseUnicodeChar +// ****************************************************************** +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 +); + +// ****************************************************************** +// * RtlUpcaseUnicodeToMultiByteN +// ****************************************************************** +typedef NTSTATUS (NTAPI *FPTR_RtlUpcaseUnicodeToMultiByteN) +( + OUT PCHAR MultiByteString, + IN ULONG MaxBytesInMultiByteString, + OUT PULONG BytesInMultiByteString OPTIONAL, + IN PCWCH UnicodeString, + IN ULONG BytesInUnicodeString +); + +// ****************************************************************** +// * RtlUpperString +// ****************************************************************** +typedef VOID (NTAPI *FPTR_RtlUpperString) +( + OUT PSTRING DestinationString, + IN const STRING *SourceString +); + +// ****************************************************************** +// * RtlUshortByteSwap +// ****************************************************************** +typedef USHORT (FASTCALL *FPTR_RtlUshortByteSwap) +( + IN USHORT Source +); + // ****************************************************************** // * RtlCompareMemory // ****************************************************************** @@ -1030,6 +1162,14 @@ typedef VOID (NTAPI *FPTR_RtlFreeAnsiString) IN OUT PANSI_STRING AnsiString ); +// ****************************************************************** +// * RtlFreeUnicodeString +// ****************************************************************** +typedef VOID(NTAPI *FPTR_RtlFreeUnicodeString) +( + IN OUT PUNICODE_STRING UnicodeString +); + // ****************************************************************** // * RtlEqualString // ****************************************************************** @@ -1040,6 +1180,108 @@ 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 +); + +// ****************************************************************** +// * 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 +); + +// ****************************************************************** +// * RtlExtendedMagicDivide +// ****************************************************************** +typedef LARGE_INTEGER (NTAPI *FPTR_RtlExtendedMagicDivide) +( + IN LARGE_INTEGER Dividend, + IN LARGE_INTEGER MagicDivisor, + IN CCHAR ShiftCount +); + +// ****************************************************************** +// * RtlFillMemory +// ****************************************************************** +typedef VOID (NTAPI *FPTR_RtlFillMemory) +( + OUT VOID UNALIGNED *Destination, + IN SIZE_T Length, + IN UCHAR Fill +); + +// ****************************************************************** +// * RtlFillMemoryUlong +// ****************************************************************** +typedef VOID (NTAPI *FPTR_RtlFillMemoryUlong) +( + OUT PVOID Destination, + IN SIZE_T Length, + IN ULONG Pattern +); + +// ****************************************************************** +// * 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 +); + +// ****************************************************************** +// * RtlMultiByteToUnicodeN +// ****************************************************************** +typedef NTSTATUS (NTAPI *FPTR_RtlMultiByteToUnicodeN) +( + OUT PWCH UnicodeString, + IN ULONG MaxBytesInUnicodeString, + OUT PULONG BytesInUnicodeString OPTIONAL, + IN const CHAR *MultiByteString, + IN ULONG BytesInMultiByteString +); + +// ****************************************************************** +// * RtlMultiByteToUnicodeSize +// ****************************************************************** +typedef NTSTATUS (NTAPI *FPTR_RtlMultiByteToUnicodeSize) +( + OUT PULONG BytesInUnicodeString, + IN const CHAR *MultiByteString, + IN ULONG BytesInMultiByteString +); + // ****************************************************************** // * NtDelayExecution // ****************************************************************** @@ -1180,6 +1422,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 // ****************************************************************** @@ -1221,6 +1475,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 // ****************************************************************** @@ -1625,8 +1891,10 @@ EXTERN(NtFsControlFile); EXTERN(NtOpenSymbolicLinkObject); EXTERN(NtPulseEvent); EXTERN(NtQueryDirectoryFile); +EXTERN(NtQueryEvent); EXTERN(NtQueryFullAttributesFile); EXTERN(NtQueryInformationFile); +EXTERN(NtQuerySemaphore); EXTERN(NtQueryTimer); EXTERN(NtQueryVirtualMemory); EXTERN(NtQueryVolumeInformationFile); @@ -1663,19 +1931,40 @@ EXTERN(RtlDowncaseUnicodeChar); EXTERN(RtlDowncaseUnicodeString); EXTERN(RtlEnterCriticalSection); EXTERN(RtlEqualString); +EXTERN(RtlEqualUnicodeString); +EXTERN(RtlExtendedIntegerMultiply); +EXTERN(RtlExtendedLargeIntegerDivide); +EXTERN(RtlExtendedMagicDivide); +EXTERN(RtlFillMemory); +EXTERN(RtlFillMemoryUlong); EXTERN(RtlFreeAnsiString); EXTERN(RtlFreeHeap); +EXTERN(RtlFreeUnicodeString); +EXTERN(RtlIntegerToChar); +EXTERN(RtlIntegerToUnicodeString); EXTERN(RtlInitAnsiString); EXTERN(RtlInitializeCriticalSection); EXTERN(RtlInitUnicodeString); EXTERN(RtlLeaveCriticalSection); +EXTERN(RtlMapGenericMask); +EXTERN(RtlMultiByteToUnicodeN); +EXTERN(RtlMultiByteToUnicodeSize); EXTERN(RtlNtStatusToDosError); EXTERN(RtlReAllocateHeap); EXTERN(RtlSizeHeap); EXTERN(RtlTimeFieldsToTime); EXTERN(RtlTimeToTimeFields); EXTERN(RtlTryEnterCriticalSection); +EXTERN(RtlUlongByteSwap); EXTERN(RtlUnicodeStringToAnsiString); +EXTERN(RtlUnicodeStringToInteger); +EXTERN(RtlUnicodeToMultiByteN); +EXTERN(RtlUnicodeToMultiByteSize); +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 69144b952..4d566ff35 100644 --- a/src/CxbxKrnl/KernelThunk.cpp +++ b/src/CxbxKrnl/KernelThunk.cpp @@ -274,12 +274,12 @@ 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 (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) @@ -345,45 +345,45 @@ 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)PANIC(0x0119), // 0x0119 (281) RtlExtendedIntegerMultiply - (uint32)PANIC(0x011A), // 0x011A (282) RtlExtendedLargeIntegerDivide - (uint32)PANIC(0x011B), // 0x011B (283) RtlExtendedMagicDivide - (uint32)PANIC(0x011C), // 0x011C (284) RtlFillMemory - (uint32)PANIC(0x011D), // 0x011D (285) RtlFillMemoryUlong + (uint32)FUNC(&xboxkrnl::RtlEqualUnicodeString), // 0x0118 (280) + (uint32)FUNC(&xboxkrnl::RtlExtendedIntegerMultiply), // 0x0119 (281) + (uint32)FUNC(&xboxkrnl::RtlExtendedLargeIntegerDivide), // 0x011A (282) + (uint32)FUNC(&xboxkrnl::RtlExtendedMagicDivide), // 0x011B (283) + (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) (uint32)FUNC(&xboxkrnl::RtlInitializeCriticalSection), // 0x0123 (291) - (uint32)PANIC(0x0124), // 0x0124 (292) RtlIntegerToChar - (uint32)PANIC(0x0125), // 0x0125 (293) RtlIntegerToUnicodeString + (uint32)FUNC(&xboxkrnl::RtlIntegerToChar), // 0x0124 (292) + (uint32)FUNC(&xboxkrnl::RtlIntegerToUnicodeString), // 0x0125 (293) (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 + (uint32)FUNC(&xboxkrnl::RtlMultiByteToUnicodeN), // 0x012B (299) + (uint32)FUNC(&xboxkrnl::RtlMultiByteToUnicodeSize), // 0x012C (300) (uint32)FUNC(&xboxkrnl::RtlNtStatusToDosError), // 0x012D (301) (uint32)PANIC(0x012E), // 0x012E (302) RtlRaiseException (uint32)PANIC(0x012F), // 0x012F (303) RtlRaiseStatus (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 - (uint32)PANIC(0x0137), // 0x0137 (311) RtlUnicodeToMultiByteSize + (uint32)FUNC(&xboxkrnl::RtlUnicodeStringToInteger), // 0x0135 (309) + (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)PANIC(0x013A), // 0x013A (314) RtlUpcaseUnicodeString - (uint32)PANIC(0x013B), // 0x013B (315) RtlUpcaseUnicodeToMultiByteN - (uint32)PANIC(0x013C), // 0x013C (316) RtlUpperChar - (uint32)PANIC(0x013D), // 0x013D (317) RtlUpperString - (uint32)PANIC(0x013E), // 0x013E (318) RtlUshortByteSwap + (uint32)FUNC(&xboxkrnl::RtlUpcaseUnicodeChar), // 0x0139 (313) + (uint32)FUNC(&xboxkrnl::RtlUpcaseUnicodeString), // 0x013A (314) + (uint32)FUNC(&xboxkrnl::RtlUpcaseUnicodeToMultiByteN), // 0x013B (315) + (uint32)FUNC(&xboxkrnl::RtlUpperChar), // 0x013C (316) + (uint32)FUNC(&xboxkrnl::RtlUpperString), // 0x013D (317) + (uint32)FUNC(&xboxkrnl::RtlUshortByteSwap), // 0x013E (318) (uint32)PANIC(0x013F), // 0x013F (319) RtlWalkFrameChain (uint32)FUNC(&xboxkrnl::RtlZeroMemory), // 0x0140 (320) (uint32)VARIABLE(&xboxkrnl::XboxEEPROMKey), // 0x0141 (321)