From 6d2487a69215f8d018e7be830e838c6cb94c15ce Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 24 Jul 2024 13:38:14 +0100 Subject: [PATCH] Add some more Ntdll calls --- core/sys/windows/ntdll.odin | 108 +++++++++++++++++++++++++++++++++++- core/sys/windows/types.odin | 34 ++++++------ 2 files changed, 124 insertions(+), 18 deletions(-) diff --git a/core/sys/windows/ntdll.odin b/core/sys/windows/ntdll.odin index b75ac695a..20c75c801 100644 --- a/core/sys/windows/ntdll.odin +++ b/core/sys/windows/ntdll.odin @@ -15,10 +15,27 @@ foreign ntdll_lib { ProcessInformationLength: u32, ReturnLength: ^u32, ) -> u32 --- + + NtQueryInformationFile :: proc( + FileHandle: HANDLE, + IoStatusBlock: PIO_STATUS_BLOCK, + FileInformation: rawptr, + Length: ULONG, + FileInformationClass: FILE_INFORMATION_CLASS, + ) -> NTSTATUS --- +} + +PIO_STATUS_BLOCK :: ^IO_STATUS_BLOCK +IO_STATUS_BLOCK :: struct { + using _: struct #raw_union { + Status: NTSTATUS, + Pointer: rawptr, + }, + Information: ULONG_PTR, } -PROCESS_INFO_CLASS :: enum i32 { +PROCESS_INFO_CLASS :: enum c_int { ProcessBasicInformation = 0, ProcessDebugPort = 7, ProcessWow64Information = 26, @@ -29,6 +46,95 @@ PROCESS_INFO_CLASS :: enum i32 { } +PFILE_INFORMATION_CLASS :: ^FILE_INFORMATION_CLASS +FILE_INFORMATION_CLASS :: enum c_int { + FileDirectoryInformation = 1, + FileFullDirectoryInformation = 2, + FileBothDirectoryInformation = 3, + FileBasicInformation = 4, + FileStandardInformation = 5, + FileInternalInformation = 6, + FileEaInformation = 7, + FileAccessInformation = 8, + FileNameInformation = 9, + FileRenameInformation = 10, + FileLinkInformation = 11, + FileNamesInformation = 12, + FileDispositionInformation = 13, + FilePositionInformation = 14, + FileFullEaInformation = 15, + FileModeInformation = 16, + FileAlignmentInformation = 17, + FileAllInformation = 18, + FileAllocationInformation = 19, + FileEndOfFileInformation = 20, + FileAlternateNameInformation = 21, + FileStreamInformation = 22, + FilePipeInformation = 23, + FilePipeLocalInformation = 24, + FilePipeRemoteInformation = 25, + FileMailslotQueryInformation = 26, + FileMailslotSetInformation = 27, + FileCompressionInformation = 28, + FileObjectIdInformation = 29, + FileCompletionInformation = 30, + FileMoveClusterInformation = 31, + FileQuotaInformation = 32, + FileReparsePointInformation = 33, + FileNetworkOpenInformation = 34, + FileAttributeTagInformation = 35, + FileTrackingInformation = 36, + FileIdBothDirectoryInformation = 37, + FileIdFullDirectoryInformation = 38, + FileValidDataLengthInformation = 39, + FileShortNameInformation = 40, + FileIoCompletionNotificationInformation = 41, + FileIoStatusBlockRangeInformation = 42, + FileIoPriorityHintInformation = 43, + FileSfioReserveInformation = 44, + FileSfioVolumeInformation = 45, + FileHardLinkInformation = 46, + FileProcessIdsUsingFileInformation = 47, + FileNormalizedNameInformation = 48, + FileNetworkPhysicalNameInformation = 49, + FileIdGlobalTxDirectoryInformation = 50, + FileIsRemoteDeviceInformation = 51, + FileUnusedInformation = 52, + FileNumaNodeInformation = 53, + FileStandardLinkInformation = 54, + FileRemoteProtocolInformation = 55, + FileRenameInformationBypassAccessCheck = 56, + FileLinkInformationBypassAccessCheck = 57, + FileVolumeNameInformation = 58, + FileIdInformation = 59, + FileIdExtdDirectoryInformation = 60, + FileReplaceCompletionInformation = 61, + FileHardLinkFullIdInformation = 62, + FileIdExtdBothDirectoryInformation = 63, + FileDispositionInformationEx = 64, + FileRenameInformationEx = 65, + FileRenameInformationExBypassAccessCheck = 66, + FileDesiredStorageClassInformation = 67, + FileStatInformation = 68, + FileMemoryPartitionInformation = 69, + FileStatLxInformation = 70, + FileCaseSensitiveInformation = 71, + FileLinkInformationEx = 72, + FileLinkInformationExBypassAccessCheck = 73, + FileStorageReserveIdInformation = 74, + FileCaseSensitiveInformationForceAccessCheck = 75, + FileKnownFolderInformation = 76, + FileStatBasicInformation = 77, + FileId64ExtdDirectoryInformation = 78, + FileId64ExtdBothDirectoryInformation = 79, + FileIdAllExtdDirectoryInformation = 80, + FileIdAllExtdBothDirectoryInformation = 81, + FileStreamReservationInformation, + FileMupProviderInfo, + FileMaximumInformation, +} + + PROCESS_BASIC_INFORMATION :: struct { ExitStatus: NTSTATUS, diff --git a/core/sys/windows/types.odin b/core/sys/windows/types.odin index 675f681e5..ac8b63a63 100644 --- a/core/sys/windows/types.odin +++ b/core/sys/windows/types.odin @@ -2714,41 +2714,41 @@ NEON128 :: struct { EXCEPTION_POINTERS :: struct { ExceptionRecord: ^EXCEPTION_RECORD, - ContextRecord: ^CONTEXT, + ContextRecord: ^CONTEXT, } PVECTORED_EXCEPTION_HANDLER :: #type proc "system" (ExceptionInfo: ^EXCEPTION_POINTERS) -> LONG CONSOLE_READCONSOLE_CONTROL :: struct { - nLength: ULONG, - nInitialChars: ULONG, - dwCtrlWakeupMask: ULONG, + nLength: ULONG, + nInitialChars: ULONG, + dwCtrlWakeupMask: ULONG, dwControlKeyState: ULONG, } PCONSOLE_READCONSOLE_CONTROL :: ^CONSOLE_READCONSOLE_CONTROL BY_HANDLE_FILE_INFORMATION :: struct { - dwFileAttributes: DWORD, - ftCreationTime: FILETIME, - ftLastAccessTime: FILETIME, - ftLastWriteTime: FILETIME, + dwFileAttributes: DWORD, + ftCreationTime: FILETIME, + ftLastAccessTime: FILETIME, + ftLastWriteTime: FILETIME, dwVolumeSerialNumber: DWORD, - nFileSizeHigh: DWORD, - nFileSizeLow: DWORD, - nNumberOfLinks: DWORD, - nFileIndexHigh: DWORD, - nFileIndexLow: DWORD, + nFileSizeHigh: DWORD, + nFileSizeLow: DWORD, + nNumberOfLinks: DWORD, + nFileIndexHigh: DWORD, + nFileIndexLow: DWORD, } LPBY_HANDLE_FILE_INFORMATION :: ^BY_HANDLE_FILE_INFORMATION FILE_STANDARD_INFO :: struct { AllocationSize: LARGE_INTEGER, - EndOfFile: LARGE_INTEGER, - NumberOfLinks: DWORD, - DeletePending: BOOLEAN, - Directory: BOOLEAN, + EndOfFile: LARGE_INTEGER, + NumberOfLinks: DWORD, + DeletePending: BOOLEAN, + Directory: BOOLEAN, } FILE_ATTRIBUTE_TAG_INFO :: struct {