-
Notifications
You must be signed in to change notification settings - Fork 93
Xbox kernel header improvements #770
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
PatrickvL
wants to merge
11
commits into
XboxDev:master
Choose a base branch
from
PatrickvL:xbox_kernel_suite_fixes
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+54
−12
Draft
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ee3d445
Add missing NTSTATUS codes
PatrickvL 206eee5
Add PROFILE_LEVEL and HIGH_LEVEL IRQL constants
PatrickvL c425da5
Add KOBJECTS enum for dispatcher object types
PatrickvL 5177264
Add SLIST_ENTRY typedef alias for SINGLE_LIST_ENTRY
PatrickvL 37ea1af
Add IRP_MJ_* major function code constants
PatrickvL b64463d
Add REG_* registry value type constants
PatrickvL b3db1ec
Add DUPLICATE_CLOSE_SOURCE constant for NtDuplicateObject
PatrickvL 2930955
Fix type errors in kernel header declarations
PatrickvL 13a3a02
Fix ExInterlockedAddLargeInteger stdcall decoration (@16 -> @12)
PatrickvL 9e80468
Fix return types: RtlSnprintf, RtlSprintf, RtlVsnprintf, RtlVsprintf …
PatrickvL c756c44
Fix RtlVsprintf/RtlVsnprintf: take VA_LIST, not variadic arguments
PatrickvL File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,6 +71,8 @@ typedef UCHAR KIRQL, *PKIRQL; | |
| #define PASSIVE_LEVEL 0 | ||
| #define APC_LEVEL 1 | ||
| #define DISPATCH_LEVEL 2 | ||
| #define PROFILE_LEVEL 27 | ||
| #define HIGH_LEVEL 31 | ||
|
|
||
| typedef ULONG PFN_COUNT; | ||
| typedef ULONG PFN_NUMBER, *PPFN_NUMBER; | ||
|
|
@@ -719,6 +721,17 @@ typedef struct _LAUNCH_DATA_PAGE | |
| #define LDT_LAUNCH_DASHBOARD_REASON_FORCE_ACCOUNT_NAME_CHANGE 11 | ||
| #define LDT_LAUNCH_DASHBOARD_REASON_FORCE_BILLING_CHANGE 12 | ||
|
|
||
| typedef enum _KOBJECTS { | ||
| EventNotificationObject = 0, | ||
| EventSynchronizationObject = 1, | ||
| MutantObject = 2, | ||
| QueueObject = 4, | ||
| SemaphoreObject = 5, | ||
| ThreadObject = 6, | ||
| TimerNotificationObject = 8, | ||
| TimerSynchronizationObject = 9, | ||
| } KOBJECTS; | ||
|
|
||
| typedef struct _DISPATCHER_HEADER | ||
| { | ||
| UCHAR Type; | ||
|
|
@@ -1082,6 +1095,8 @@ typedef struct _SINGLE_LIST_ENTRY | |
| struct _SINGLE_LIST_ENTRY *Next; /**< Pointer to the next (or first, if this is a header) entry in the singly linked list (NULL if there is none) */ | ||
| } SINGLE_LIST_ENTRY, *PSINGLE_LIST_ENTRY; | ||
|
|
||
| typedef SINGLE_LIST_ENTRY SLIST_ENTRY, *PSLIST_ENTRY; | ||
|
|
||
| /** | ||
| * Serves as a header for a singly linked list. Initialized by ExInitializeSListHead | ||
| */ | ||
|
|
@@ -1237,12 +1252,21 @@ typedef NTSTATUS (NTAPI *PDRIVER_DISPATCH) ( | |
| IN struct _IRP *Irp | ||
| ); | ||
|
|
||
| #define IRP_MJ_CREATE 0x00 | ||
| #define IRP_MJ_CLOSE 0x01 | ||
| #define IRP_MJ_READ 0x02 | ||
| #define IRP_MJ_WRITE 0x03 | ||
| #define IRP_MJ_FLUSH_BUFFERS 0x06 | ||
| #define IRP_MJ_DEVICE_CONTROL 0x0A | ||
| #define IRP_MJ_INTERNAL_DEVICE_CONTROL 0x0B | ||
| #define IRP_MJ_MAXIMUM_FUNCTION 0x0D | ||
|
|
||
| typedef struct _DRIVER_OBJECT | ||
| { | ||
| PDRIVER_STARTIO DriverStartIo; | ||
| PDRIVER_DELETEDEVICE DriverDeleteDevice; | ||
| PDRIVER_DISMOUNTVOLUME DriverDismountVolume; | ||
| PDRIVER_DISPATCH MajorFunction[0x0E]; | ||
| PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1]; | ||
| } DRIVER_OBJECT, *PDRIVER_OBJECT; | ||
|
|
||
| typedef struct _DEVICE_OBJECT | ||
|
|
@@ -1853,19 +1877,19 @@ XBAPI ULONG NTAPI RtlWalkFrameChain | |
| IN ULONG Flags | ||
| ); | ||
|
|
||
| XBAPI VOID CDECL RtlVsprintf | ||
| XBAPI INT CDECL RtlVsprintf | ||
| ( | ||
| CHAR *, | ||
| CONST CHAR*, | ||
| ... | ||
| VA_LIST | ||
| ); | ||
|
|
||
| XBAPI VOID CDECL RtlVsnprintf | ||
| XBAPI INT CDECL RtlVsnprintf | ||
| ( | ||
| CHAR *, | ||
| SIZE_T, | ||
| CONST CHAR*, | ||
| ... | ||
| VA_LIST | ||
| ); | ||
|
|
||
| XBAPI VOID NTAPI RtlUpperString | ||
|
|
@@ -1937,7 +1961,7 @@ XBAPI NTSTATUS NTAPI RtlUnicodeToMultiByteN | |
| ULONG BytesInUnicodeString | ||
| ); | ||
|
|
||
| XBAPI NTSTATUS XBAPI RtlUnicodeStringToInteger | ||
| XBAPI NTSTATUS NTAPI RtlUnicodeStringToInteger | ||
| ( | ||
| PUNICODE_STRING String, | ||
| ULONG Base, | ||
|
|
@@ -1985,14 +2009,14 @@ XBAPI BOOLEAN NTAPI RtlTimeFieldsToTime | |
| OUT PLARGE_INTEGER Time | ||
| ); | ||
|
|
||
| XBAPI VOID CDECL RtlSprintf | ||
| XBAPI INT CDECL RtlSprintf | ||
| ( | ||
| CHAR *, | ||
| CONST CHAR *, | ||
| ... | ||
| ); | ||
|
|
||
| XBAPI VOID CDECL RtlSnprintf | ||
| XBAPI INT CDECL RtlSnprintf | ||
| ( | ||
| CHAR *, | ||
| SIZE_T, | ||
|
|
@@ -2972,6 +2996,8 @@ XBAPI NTSTATUS NTAPI NtFlushBuffersFile | |
| OUT PIO_STATUS_BLOCK IoStatusBlock | ||
| ); | ||
|
|
||
| #define DUPLICATE_CLOSE_SOURCE 0x00000001 | ||
|
|
||
| XBAPI NTSTATUS NTAPI NtDuplicateObject | ||
| ( | ||
| IN HANDLE SourceHandle, | ||
|
|
@@ -3050,7 +3076,7 @@ XBAPI NTSTATUS NTAPI NtDeviceIoControlFile | |
| ); | ||
|
|
||
|
|
||
| XBAPI BOOLEAN NTAPI NtDeleteFile | ||
| XBAPI NTSTATUS NTAPI NtDeleteFile | ||
| ( | ||
| IN POBJECT_ATTRIBUTES ObjectAttributes | ||
| ); | ||
|
|
@@ -3637,7 +3663,7 @@ XBAPI PLIST_ENTRY NTAPI KeRemoveQueue | |
| XBAPI BOOLEAN NTAPI KeRemoveEntryDeviceQueue | ||
| ( | ||
| IN PKDEVICE_QUEUE DeviceQueue, | ||
| IN PKDEVICE_QUEUE DeviceQueueEntry | ||
| IN PKDEVICE_QUEUE_ENTRY DeviceQueueEntry | ||
| ); | ||
|
|
||
| XBAPI PKDEVICE_QUEUE_ENTRY NTAPI KeRemoveDeviceQueue | ||
|
|
@@ -3703,7 +3729,7 @@ XBAPI VOID NTAPI KeLeaveCriticalRegion (void); | |
| * Checks whether the code is executed in a DPC context | ||
| * @return TRUE if the code is running in a DPC context, FALSE otherwise | ||
| **/ | ||
| XBAPI BOOLEAN NTAPI KeIsExecutingDpc (void); | ||
| XBAPI ULONG NTAPI KeIsExecutingDpc (void); | ||
|
|
||
| XBAPI volatile KSYSTEM_TIME KeInterruptTime; | ||
|
|
||
|
|
@@ -4216,6 +4242,16 @@ XBAPI PFN_COUNT NTAPI FscGetCacheSize (void); | |
| XBAPI OBJECT_TYPE ExTimerObjectType; | ||
| XBAPI OBJECT_TYPE ExSemaphoreObjectType; | ||
|
|
||
| /* Registry value types */ | ||
| #define REG_NONE 0 | ||
| #define REG_SZ 1 | ||
| #define REG_EXPAND_SZ 2 | ||
| #define REG_BINARY 3 | ||
| #define REG_DWORD 4 | ||
| #define REG_DWORD_LITTLE_ENDIAN 4 | ||
| #define REG_DWORD_BIG_ENDIAN 5 | ||
| #define REG_MULTI_SZ 7 | ||
|
Comment on lines
+4243
to
+4251
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not aware of these being used with the kernel API, is there value in nxdk providing these, considering there is no registry? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| /* Offsets for ExSaveNonVolatileSetting / ExQueryNonVolatileSetting */ | ||
| #define XC_TIMEZONE_BIAS 0x0000 | ||
| #define XC_TZ_STD_NAME 0x0001 | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these the correct ones for Xbox? I believe they differ between Xbox and common Windows.
(Edit: Maybe we should also have a code-comment about the fact that these have a different value in the original Xbox kernel)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on
FatxDriverObjectthese should be:Based on
IoBuildDeviceIoControlRequestit's safe to assume 0x0B isIRP_MJ_INTERNAL_DEVICE_CONTROLThe only reference I could find to 0x0C is in
IoBuildAsynchronousFsdRequest. Based on context I would say it's safe to assume that 0x0C isIRP_MJ_SHUTDOWN.Final:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this detailed feedback!
Shall I amend the commit these symbols reside in, or push a fix-up commit? (I would prefer to amend, if you don't mind, but will wait a while for guidance.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First of all, thanks for the depth details on IRP_MJ_ defines @LoveMHz. For sure it is more than what I had documented. There's one question I have to ask, is the
FatxDriverObjectinfo came from your own documentation you had discovered? I'm just wondering.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RadWolfie yes, it's from my research using recovered cv meta from 5849 (and older kernels) using ghidra-coff-process-cv.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely amend. I'd even say that if the commits don't conflict, I'd prefer this PR be split into a few smaller ones that only contain related commits (like the fixes for the printf-style functions). I've only looked at a few commits so far and they look reasonable, but I'd like to check more closely and that would prevent the discussions from potentially becoming unwieldy.
Please also adjust the commit messages, like starting the title with
xboxkrnl:and keeping them short enough so they don't get cut off in GH, avoid using the @ sign or wrap it in backticks to prevent GH turning it into a tag. We don't often use commit messages that consist of more than a commit title, but I'm not against it if it provides useful detail or context.