Merge pull request #57 from PatrickvL/master

Implemented a bunch of kernel API's
This commit is contained in:
Luke Usher 2016-12-23 17:55:22 +00:00 committed by GitHub
commit 5cb13ba3ac
7 changed files with 406 additions and 22 deletions

View File

@ -127,7 +127,13 @@ XBSYSAPI EXPORTNUM(194) NTSTATUS NTAPI NtCreateTimer
IN TIMER_TYPE TimerType IN TIMER_TYPE TimerType
); );
XBSYSAPI VOID *NtDeleteFile; // ******************************************************************
// * 0x00C3 - NtDeleteFile()
// ******************************************************************
XBSYSAPI EXPORTNUM(195) NTSTATUS NTAPI NtDeleteFile
(
IN POBJECT_ATTRIBUTES ObjectAttributes
);
// ****************************************************************** // ******************************************************************
// * 0x00C4 - NtDeviceIoControlFile // * 0x00C4 - NtDeviceIoControlFile

View File

@ -74,19 +74,45 @@ XBSYSAPI EXPORTNUM(267) NTSTATUS NTAPI RtlCharToInteger
// * compare block of memory, return number of equivalent bytes. // * compare block of memory, return number of equivalent bytes.
// * // *
// ****************************************************************** // ******************************************************************
XBSYSAPI EXPORTNUM(268) SIZE_T NTAPI RtlCompareMemory XBSYSAPI EXPORTNUM(268) BOOLEAN NTAPI RtlCompareMemory
( (
IN CONST VOID *Source1, IN CONST VOID *Source1,
IN CONST VOID *Source2, IN CONST VOID *Source2,
IN SIZE_T Length IN SIZE_T Length
); );
XBSYSAPI VOID *RtlCompareMemoryUlong; // ******************************************************************
XBSYSAPI VOID *RtlCompareString; // * 0x010D - RtlCompareMemoryUlong()
XBSYSAPI VOID *RtlCompareUnicodeString; // ******************************************************************
XBSYSAPI EXPORTNUM(269) SIZE_T NTAPI RtlCompareMemoryUlong
(
IN PVOID Source,
IN SIZE_T Length,
IN ULONG Pattern
);
// ****************************************************************** // ******************************************************************
// * RtlCopyString // * 0x010E - RtlCompareString()
// ******************************************************************
XBSYSAPI EXPORTNUM(270) LONG NTAPI RtlCompareString
(
IN PSTRING String1,
IN PSTRING String2,
IN BOOLEAN CaseInSensitive
);
// ******************************************************************
// * 0x010F - RtlCompareUnicodeString()
// ******************************************************************
XBSYSAPI EXPORTNUM(271) LONG NTAPI RtlCompareUnicodeString
(
IN PUNICODE_STRING String1,
IN PUNICODE_STRING String2,
IN BOOLEAN CaseInSensitive
);
// ******************************************************************
// * 0x0110 - RtlCopyString()
// ****************************************************************** // ******************************************************************
// * // *
// * Copy Source to Destination // * Copy Source to Destination
@ -94,14 +120,45 @@ XBSYSAPI VOID *RtlCompareUnicodeString;
// ****************************************************************** // ******************************************************************
XBSYSAPI EXPORTNUM(272) VOID NTAPI RtlCopyString XBSYSAPI EXPORTNUM(272) VOID NTAPI RtlCopyString
( (
IN OUT PVOID Destination, // TODO: should be STRING OUT PSTRING DestinationString,
IN PVOID Source OPTIONAL // TODO: should be STRING IN PSTRING SourceString OPTIONAL
); );
XBSYSAPI VOID *RtlCopyUnicodeString; // ******************************************************************
XBSYSAPI VOID *RtlCreateUnicodeString; // * 0x0111 - RtlCopyUnicodeString()
XBSYSAPI VOID *RtlDowncaseUnicodeChar; // ******************************************************************
XBSYSAPI VOID *RtlDowncaseUnicodeString; XBSYSAPI EXPORTNUM(273) VOID NTAPI RtlCopyUnicodeString
(
OUT PUNICODE_STRING DestinationString,
IN PUNICODE_STRING SourceString OPTIONAL
);
// ******************************************************************
// * 0x0112 - RtlCreateUnicodeString()
// ******************************************************************
XBSYSAPI EXPORTNUM(274) BOOLEAN NTAPI RtlCreateUnicodeString
(
OUT PUNICODE_STRING DestinationString,
IN PCWSTR SourceString
);
// ******************************************************************
// * 0x0113 - RtlDowncaseUnicodeChar()
// ******************************************************************
XBSYSAPI EXPORTNUM(275) WCHAR NTAPI RtlDowncaseUnicodeChar
(
IN WCHAR SourceCharacter
);
// ******************************************************************
// * 0x0114 - RtlDowncaseUnicodeString()
// ******************************************************************
XBSYSAPI EXPORTNUM(276) NTSTATUS NTAPI RtlDowncaseUnicodeString
(
OUT PUNICODE_STRING DestinationString,
IN PUNICODE_STRING SourceString,
IN BOOLEAN AllocateDestinationString
);
// ****************************************************************** // ******************************************************************
// * RtlEnterCriticalSection // * RtlEnterCriticalSection

View File

@ -416,6 +416,34 @@ XBSYSAPI EXPORTNUM(194) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtCreateTimer
RETURN(ret); RETURN(ret);
} }
// ******************************************************************
// * 0x00C3 - NtDeleteFile()
// ******************************************************************
XBSYSAPI EXPORTNUM(195) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtDeleteFile
(
IN POBJECT_ATTRIBUTES ObjectAttributes
)
{
LOG_FUNC_ONE_ARG(ObjectAttributes);
NativeObjectAttributes nativeObjectAttributes;
NTSTATUS ret = CxbxObjectAttributesToNT(
ObjectAttributes,
nativeObjectAttributes,
"NtDeleteFile");
if (ret == STATUS_SUCCESS)
{
ret = NtDll::NtDeleteFile(
nativeObjectAttributes.NtObjAttrPtr);
}
if (FAILED(ret))
EmuWarning("NtDeleteFile Failed!");
RETURN(ret);
}
// ****************************************************************** // ******************************************************************
// * 0x00C4 - NtDeviceIoControlFile() // * 0x00C4 - NtDeviceIoControlFile()
// ****************************************************************** // ******************************************************************

View File

@ -215,6 +215,186 @@ XBSYSAPI EXPORTNUM(267) xboxkrnl::NTSTATUS NTAPI xboxkrnl::RtlCharToInteger
RETURN(result); RETURN(result);
} }
// ******************************************************************
// * 0x010C - RtlCompareMemory()
// ******************************************************************
// *
// * compare block of memory, return number of equivalent bytes.
// *
// ******************************************************************
XBSYSAPI EXPORTNUM(268) xboxkrnl::BOOLEAN NTAPI xboxkrnl::RtlCompareMemory
(
IN CONST VOID *Source1,
IN CONST VOID *Source2,
IN SIZE_T Length
)
{
LOG_FUNC_BEGIN
LOG_FUNC_ARG(Source1)
LOG_FUNC_ARG(Source2)
LOG_FUNC_ARG(Length)
LOG_FUNC_END;
BOOL result = NtDll::RtlCompareMemory(Source1, Source2, Length);
RETURN(result);
}
// ******************************************************************
// * 0x010D - RtlCompareMemoryUlong()
// ******************************************************************
XBSYSAPI EXPORTNUM(269) xboxkrnl::SIZE_T NTAPI xboxkrnl::RtlCompareMemoryUlong
(
IN PVOID Source,
IN SIZE_T Length,
IN ULONG Pattern
)
{
LOG_FUNC_BEGIN
LOG_FUNC_ARG(Source)
LOG_FUNC_ARG(Length)
LOG_FUNC_ARG(Pattern)
LOG_FUNC_END;
SIZE_T result = NtDll::RtlCompareMemoryUlong(Source, Length, Pattern);
RETURN(result);
}
// ******************************************************************
// * 0x010E - RtlCompareString()
// ******************************************************************
XBSYSAPI EXPORTNUM(270) xboxkrnl::LONG NTAPI xboxkrnl::RtlCompareString
(
IN PSTRING String1,
IN PSTRING String2,
IN BOOLEAN CaseInSensitive
)
{
LOG_FUNC_BEGIN
LOG_FUNC_ARG(String1)
LOG_FUNC_ARG(String2)
LOG_FUNC_ARG(CaseInSensitive)
LOG_FUNC_END;
LONG result = NtDll::RtlCompareString((NtDll::STRING *)String1, (NtDll::STRING *)String2, CaseInSensitive);
RETURN(result);
}
// ******************************************************************
// * 0x010F - RtlCompareUnicodeString()
// ******************************************************************
XBSYSAPI EXPORTNUM(271) xboxkrnl::LONG NTAPI xboxkrnl::RtlCompareUnicodeString
(
IN PUNICODE_STRING String1,
IN PUNICODE_STRING String2,
IN BOOLEAN CaseInSensitive
)
{
LOG_FUNC_BEGIN
LOG_FUNC_ARG(String1)
LOG_FUNC_ARG(String2)
LOG_FUNC_ARG(CaseInSensitive)
LOG_FUNC_END;
LONG result = NtDll::RtlCompareUnicodeString((NtDll::PUNICODE_STRING)String1, (NtDll::PUNICODE_STRING)String2, CaseInSensitive);
RETURN(result);
}
// ******************************************************************
// * 0x0110 - RtlCopyString()
// ******************************************************************
XBSYSAPI EXPORTNUM(272) xboxkrnl::VOID NTAPI xboxkrnl::RtlCopyString
(
OUT PSTRING DestinationString,
IN PSTRING SourceString OPTIONAL
)
{
LOG_FUNC_BEGIN
LOG_FUNC_ARG(DestinationString)
LOG_FUNC_ARG(SourceString)
LOG_FUNC_END;
NtDll::RtlCopyString((NtDll::PSTRING)DestinationString, (NtDll::PSTRING)SourceString);
}
// ******************************************************************
// * 0x0111 - RtlCopyUnicodeString()
// ******************************************************************
XBSYSAPI EXPORTNUM(273) xboxkrnl::VOID NTAPI xboxkrnl::RtlCopyUnicodeString
(
OUT PUNICODE_STRING DestinationString,
IN PUNICODE_STRING SourceString OPTIONAL
)
{
LOG_FUNC_BEGIN
LOG_FUNC_ARG(DestinationString)
LOG_FUNC_ARG(SourceString)
LOG_FUNC_END;
NtDll::RtlCopyUnicodeString((NtDll::PUNICODE_STRING)DestinationString, (NtDll::PUNICODE_STRING)SourceString);
}
// ******************************************************************
// * 0x0112 - RtlCreateUnicodeString()
// ******************************************************************
XBSYSAPI EXPORTNUM(274) xboxkrnl::BOOLEAN NTAPI xboxkrnl::RtlCreateUnicodeString
(
OUT PUNICODE_STRING DestinationString,
IN PCWSTR SourceString
)
{
LOG_FUNC_BEGIN
LOG_FUNC_ARG(DestinationString)
LOG_FUNC_ARG(SourceString)
LOG_FUNC_END;
BOOLEAN result = NtDll::RtlCreateUnicodeString((NtDll::PUNICODE_STRING)DestinationString, (NtDll::PCWSTR)SourceString);
RETURN(result);
}
// ******************************************************************
// * 0x0113 - RtlDowncaseUnicodeChar()
// ******************************************************************
XBSYSAPI EXPORTNUM(275) xboxkrnl::WCHAR NTAPI xboxkrnl::RtlDowncaseUnicodeChar
(
IN WCHAR SourceCharacter
)
{
LOG_FUNC_ONE_ARG(SourceCharacter);
WCHAR result = NtDll::RtlDowncaseUnicodeChar((NtDll::WCHAR)SourceCharacter);
RETURN(result);
}
// ******************************************************************
// * 0x0114 - RtlDowncaseUnicodeString()
// ******************************************************************
XBSYSAPI EXPORTNUM(276) xboxkrnl::NTSTATUS NTAPI xboxkrnl::RtlDowncaseUnicodeString
(
OUT PUNICODE_STRING DestinationString,
IN PUNICODE_STRING SourceString,
IN BOOLEAN AllocateDestinationString
)
{
LOG_FUNC_BEGIN
LOG_FUNC_ARG(DestinationString)
LOG_FUNC_ARG(SourceString)
LOG_FUNC_ARG(AllocateDestinationString)
LOG_FUNC_END;
NTSTATUS result = NtDll::RtlDowncaseUnicodeString(
(NtDll::PUNICODE_STRING)DestinationString,
(NtDll::PUNICODE_STRING)SourceString,
AllocateDestinationString);
RETURN(result);
}
// ****************************************************************** // ******************************************************************
// * 0x0115 - RtlEnterCriticalSection() // * 0x0115 - RtlEnterCriticalSection()
// ****************************************************************** // ******************************************************************

View File

@ -73,6 +73,7 @@ IMPORT(NtCreateMutant);
IMPORT(NtCreateSemaphore); IMPORT(NtCreateSemaphore);
IMPORT(NtCreateTimer); IMPORT(NtCreateTimer);
IMPORT(NtDelayExecution); IMPORT(NtDelayExecution);
IMPORT(NtDeleteFile);
IMPORT(NtDeviceIoControlFile); IMPORT(NtDeviceIoControlFile);
IMPORT(NtDuplicateObject); IMPORT(NtDuplicateObject);
IMPORT(NtFlushBuffersFile); IMPORT(NtFlushBuffersFile);
@ -106,8 +107,17 @@ IMPORT(RtlAppendStringToString);
IMPORT(RtlAppendUnicodeStringToString); IMPORT(RtlAppendUnicodeStringToString);
IMPORT(RtlAppendUnicodeToString); IMPORT(RtlAppendUnicodeToString);
IMPORT(RtlCharToInteger); IMPORT(RtlCharToInteger);
IMPORT(RtlCompareMemory);
IMPORT(RtlCompareMemoryUlong);
IMPORT(RtlCompareString);
IMPORT(RtlCompareUnicodeString);
IMPORT(RtlCopyString);
IMPORT(RtlCopyUnicodeString);
IMPORT(RtlCreateHeap); IMPORT(RtlCreateHeap);
IMPORT(RtlCreateUnicodeString);
IMPORT(RtlDestroyHeap); IMPORT(RtlDestroyHeap);
IMPORT(RtlDowncaseUnicodeChar);
IMPORT(RtlDowncaseUnicodeString);
IMPORT(RtlEnterCriticalSection); IMPORT(RtlEnterCriticalSection);
IMPORT(RtlEqualString); IMPORT(RtlEqualString);
IMPORT(RtlFreeAnsiString); IMPORT(RtlFreeAnsiString);

View File

@ -862,6 +862,26 @@ typedef BOOL (NTAPI *FPTR_RtlTryEnterCriticalSection)
IN PRTL_CRITICAL_SECTION CriticalSection IN PRTL_CRITICAL_SECTION CriticalSection
); );
// ******************************************************************
// * RtlCompareMemory
// ******************************************************************
typedef BOOL (NTAPI *FPTR_RtlCompareMemory)
(
IN const VOID *Source1,
IN const VOID *Source2,
IN SIZE_T Length
);
// ******************************************************************
// * RtlCompareMemoryUlong
// ******************************************************************
typedef BOOL(NTAPI *FPTR_RtlCompareMemoryUlong)
(
IN PVOID Source,
IN SIZE_T Length,
IN ULONG Pattern
);
// ****************************************************************** // ******************************************************************
// * RtlInitAnsiString // * RtlInitAnsiString
// ****************************************************************** // ******************************************************************
@ -927,6 +947,71 @@ typedef NTSTATUS(NTAPI *FPTR_RtlCharToInteger)
OUT PULONG Value OUT PULONG Value
); );
// ******************************************************************
// * RtlCompareString
// ******************************************************************
typedef LONG (NTAPI *FPTR_RtlCompareString)
(
IN const STRING *String1,
IN const STRING *String2,
IN BOOLEAN CaseInSensitive
);
// ******************************************************************
// * RtlCompareUnicodeString
// ******************************************************************
typedef LONG (NTAPI *FPTR_RtlCompareUnicodeString)
(
IN PCUNICODE_STRING String1,
IN PCUNICODE_STRING String2,
IN BOOLEAN CaseInSensitive
);
// ******************************************************************
// * RtlCopyString
// ******************************************************************
typedef LONG (NTAPI *FPTR_RtlCopyString)
(
OUT PSTRING DestinationString,
IN const STRING *SourceString OPTIONAL
);
// ******************************************************************
// * RtlCopyUnicodeString
// ******************************************************************
typedef LONG (NTAPI *FPTR_RtlCopyUnicodeString)
(
OUT PUNICODE_STRING DestinationString,
IN PUNICODE_STRING SourceString OPTIONAL
);
// ******************************************************************
// * RtlCreateUnicodeString
// ******************************************************************
typedef BOOLEAN (NTAPI *FPTR_RtlCreateUnicodeString)
(
OUT PUNICODE_STRING DestinationString,
IN PCWSTR SourceString
);
// ******************************************************************
// * RtlDowncaseUnicodeChar
// ******************************************************************
typedef WCHAR (NTAPI *FPTR_RtlDowncaseUnicodeChar)
(
IN WCHAR SourceCharacter
);
// ******************************************************************
// * RtlDowncaseUnicodeString
// ******************************************************************
typedef NTSTATUS (NTAPI *FPTR_RtlDowncaseUnicodeString)
(
OUT PUNICODE_STRING DestinationString,
IN PUNICODE_STRING SourceString,
IN BOOLEAN AllocateDestinationString
);
// ****************************************************************** // ******************************************************************
// * RtlUnicodeStringToAnsiString // * RtlUnicodeStringToAnsiString
// ****************************************************************** // ******************************************************************
@ -1210,6 +1295,14 @@ typedef NTSTATUS (NTAPI *FPTR_NtCreateFile)
IN ULONG EaLength IN ULONG EaLength
); );
// ******************************************************************
// * NtDeleteFile
// ******************************************************************
typedef NTSTATUS(NTAPI *FPTR_NtDeleteFile)
(
IN POBJECT_ATTRIBUTES ObjectAttributes
);
// ****************************************************************** // ******************************************************************
// * NtCreateDirectoryObject // * NtCreateDirectoryObject
// ****************************************************************** // ******************************************************************
@ -1523,6 +1616,7 @@ EXTERN(NtCreateMutant);
EXTERN(NtCreateSemaphore); EXTERN(NtCreateSemaphore);
EXTERN(NtCreateTimer); EXTERN(NtCreateTimer);
EXTERN(NtDelayExecution); EXTERN(NtDelayExecution);
EXTERN(NtDeleteFile);
EXTERN(NtDeviceIoControlFile); EXTERN(NtDeviceIoControlFile);
EXTERN(NtDuplicateObject); EXTERN(NtDuplicateObject);
EXTERN(NtFlushBuffersFile); EXTERN(NtFlushBuffersFile);
@ -1556,8 +1650,17 @@ EXTERN(RtlAppendStringToString);
EXTERN(RtlAppendUnicodeStringToString); EXTERN(RtlAppendUnicodeStringToString);
EXTERN(RtlAppendUnicodeToString); EXTERN(RtlAppendUnicodeToString);
EXTERN(RtlCharToInteger); EXTERN(RtlCharToInteger);
EXTERN(RtlCompareMemory);
EXTERN(RtlCompareMemoryUlong);
EXTERN(RtlCompareString);
EXTERN(RtlCompareUnicodeString);
EXTERN(RtlCopyString);
EXTERN(RtlCopyUnicodeString);
EXTERN(RtlCreateHeap); EXTERN(RtlCreateHeap);
EXTERN(RtlCreateUnicodeString);
EXTERN(RtlDestroyHeap); EXTERN(RtlDestroyHeap);
EXTERN(RtlDowncaseUnicodeChar);
EXTERN(RtlDowncaseUnicodeString);
EXTERN(RtlEnterCriticalSection); EXTERN(RtlEnterCriticalSection);
EXTERN(RtlEqualString); EXTERN(RtlEqualString);
EXTERN(RtlFreeAnsiString); EXTERN(RtlFreeAnsiString);

View File

@ -260,7 +260,7 @@ extern "C" CXBXKRNL_API uint32 CxbxKrnl_KernelThunkTable[379] =
(uint32)FUNC(&xboxkrnl::NtCreateMutant), // 0x00C0 (192) (uint32)FUNC(&xboxkrnl::NtCreateMutant), // 0x00C0 (192)
(uint32)FUNC(&xboxkrnl::NtCreateSemaphore), // 0x00C1 (193) (uint32)FUNC(&xboxkrnl::NtCreateSemaphore), // 0x00C1 (193)
(uint32)FUNC(&xboxkrnl::NtCreateTimer), // 0x00C2 (194) (uint32)FUNC(&xboxkrnl::NtCreateTimer), // 0x00C2 (194)
(uint32)PANIC(0x00C3), // 0x00C3 (195) NtDeleteFile (uint32)FUNC(&xboxkrnl::NtDeleteFile), // 0x00C3 (195)
(uint32)FUNC(&xboxkrnl::NtDeviceIoControlFile), // 0x00C4 (196) (uint32)FUNC(&xboxkrnl::NtDeviceIoControlFile), // 0x00C4 (196)
(uint32)FUNC(&xboxkrnl::NtDuplicateObject), // 0x00C5 (197) (uint32)FUNC(&xboxkrnl::NtDuplicateObject), // 0x00C5 (197)
(uint32)FUNC(&xboxkrnl::NtFlushBuffersFile), // 0x00C6 (198) (uint32)FUNC(&xboxkrnl::NtFlushBuffersFile), // 0x00C6 (198)
@ -333,15 +333,15 @@ extern "C" CXBXKRNL_API uint32 CxbxKrnl_KernelThunkTable[379] =
(uint32)PANIC(0x0109), // 0x0109 (265) RtlCaptureContext (uint32)PANIC(0x0109), // 0x0109 (265) RtlCaptureContext
(uint32)PANIC(0x010A), // 0x010A (266) RtlCaptureStackBackTrace (uint32)PANIC(0x010A), // 0x010A (266) RtlCaptureStackBackTrace
(uint32)FUNC(&xboxkrnl::RtlCharToInteger), // 0x010B (267) (uint32)FUNC(&xboxkrnl::RtlCharToInteger), // 0x010B (267)
(uint32)PANIC(0x010C), // 0x010C (268) RtlCompareMemory (uint32)FUNC(&xboxkrnl::RtlCompareMemory), // 0x010C (268)
(uint32)PANIC(0x010D), // 0x010D (269) RtlCompareMemoryUlong (uint32)FUNC(&xboxkrnl::RtlCompareMemoryUlong), // 0x010D (269)
(uint32)PANIC(0x010E), // 0x010E (270) RtlCompareString (uint32)FUNC(&xboxkrnl::RtlCompareString), // 0x010E (270)
(uint32)PANIC(0x010F), // 0x010F (271) RtlCompareUnicodeString (uint32)FUNC(&xboxkrnl::RtlCompareUnicodeString), // 0x010F (271)
(uint32)PANIC(0x0110), // 0x0110 (272) RtlCopyString (uint32)FUNC(&xboxkrnl::RtlCopyString), // 0x0110 (272)
(uint32)PANIC(0x0111), // 0x0111 (273) RtlCopyUnicodeString (uint32)FUNC(&xboxkrnl::RtlCopyUnicodeString), // 0x0111 (273)
(uint32)PANIC(0x0112), // 0x0112 (274) RtlCreateUnicodeString (uint32)FUNC(&xboxkrnl::RtlCreateUnicodeString), // 0x0112 (274)
(uint32)PANIC(0x0113), // 0x0113 (275) RtlDowncaseUnicodeChar (uint32)FUNC(&xboxkrnl::RtlDowncaseUnicodeChar), // 0x0113 (275)
(uint32)PANIC(0x0114), // 0x0114 (276) RtlDowncaseUnicodeString (uint32)FUNC(&xboxkrnl::RtlDowncaseUnicodeString), // 0x0114 (276)
(uint32)FUNC(&xboxkrnl::RtlEnterCriticalSection), // 0x0115 (277) (uint32)FUNC(&xboxkrnl::RtlEnterCriticalSection), // 0x0115 (277)
(uint32)PANIC(0x0116), // 0x0116 (278) RtlEnterCriticalSectionAndRegion (uint32)PANIC(0x0116), // 0x0116 (278) RtlEnterCriticalSectionAndRegion
(uint32)FUNC(&xboxkrnl::RtlEqualString), // 0x0117 (279) (uint32)FUNC(&xboxkrnl::RtlEqualString), // 0x0117 (279)