[NTDLL:LDR] Little fixes about SAL annotation and behavior (#5793)

- Uniform function declarations in .c and .h with fixes and SAL2 improvements.
- Use LDR_[UN]LOCK_LOADER_LOCK_FLAG_XXX correctly.
- Fix incorrect UsedSize calculation in LdrQueryProcessModuleInformationEx (caught by ThFabba).
- Whatever the callback request stop the enumeration or not in LdrEnumerateLoadedModules, the following operations should be the same.
- Fix 2 incorrect DPRINT1 that printed incorrect parameter.
- Return error if RtlAllocateHeap failed in LdrpGetProcedureAddress, and add comments about NT6.2 new changes.
This commit is contained in:
Ratin Gao 2023-11-16 03:59:32 +08:00 committed by GitHub
parent bd9e2d6beb
commit bd0a5498b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 120 additions and 103 deletions

View file

@ -97,8 +97,8 @@ LdrGetProcedureAddress(
ULONG
NTAPI
LdrRelocateImage(
_In_ PVOID NewBase,
_In_ PCCH LoaderName,
_In_ PVOID BaseAddress,
_In_opt_ PCSTR LoaderName,
_In_ ULONG Success,
_In_ ULONG Conflict,
_In_ ULONG Invalid
@ -139,9 +139,9 @@ LdrProcessRelocationBlockLongLong(
NTSTATUS
NTAPI
LdrEnumerateLoadedModules(
_In_ BOOLEAN ReservedFlag,
_Reserved_ ULONG ReservedFlag,
_In_ PLDR_ENUM_CALLBACK EnumProc,
_In_ PVOID Context
_In_opt_ PVOID Context
);
#endif

View file

@ -238,7 +238,7 @@ typedef struct _ALT_RESOURCE_MODULE
//
// Callback function for LdrEnumerateLoadedModules
//
typedef VOID (NTAPI LDR_ENUM_CALLBACK)(_In_ PLDR_DATA_TABLE_ENTRY ModuleInformation, _In_ PVOID Parameter, _Out_ BOOLEAN *Stop);
typedef VOID (NTAPI LDR_ENUM_CALLBACK)(_In_ PLDR_DATA_TABLE_ENTRY ModuleInformation, _In_opt_ PVOID Context, _Out_ BOOLEAN *Stop);
typedef LDR_ENUM_CALLBACK *PLDR_ENUM_CALLBACK;
//

View file

@ -3975,13 +3975,12 @@ RtlImageRvaToSection(
_In_ ULONG Rva
);
NTSYSAPI
ULONG
NTAPI
LdrRelocateImageWithBias(
_In_ PVOID NewAddress,
_In_ PVOID BaseAddress,
_In_ LONGLONG AdditionalBias,
_In_ PCCH LoaderName,
_In_opt_ PCSTR LoaderName,
_In_ ULONG Success,
_In_ ULONG Conflict,
_In_ ULONG Invalid

View file

@ -158,9 +158,9 @@ NTSTATUS
NTAPI
LdrLoadDll(
_In_opt_ PWSTR SearchPath,
_In_opt_ PULONG LoadFlags,
_In_ PUNICODE_STRING Name,
_Out_opt_ PVOID *BaseAddress
_In_opt_ PULONG DllCharacteristics,
_In_ PUNICODE_STRING DllName,
_Out_ PVOID *BaseAddress
);
PIMAGE_BASE_RELOCATION
@ -177,18 +177,18 @@ NTAPI
LdrQueryImageFileExecutionOptions(
_In_ PUNICODE_STRING SubKey,
_In_ PCWSTR ValueName,
_In_ ULONG ValueSize,
_In_ ULONG Type,
_Out_ PVOID Buffer,
_In_ ULONG BufferSize,
_Out_opt_ PULONG RetunedLength
_Out_opt_ PULONG ReturnedLength
);
NTSTATUS
NTAPI
LdrQueryProcessModuleInformation(
_In_opt_ PRTL_PROCESS_MODULES ModuleInformation,
_In_opt_ ULONG Size,
_Out_ PULONG ReturnedSize
_Out_writes_bytes_to_(Size, *ReturnedSize) PRTL_PROCESS_MODULES ModuleInformation,
_In_ ULONG Size,
_Out_opt_ PULONG ReturnedSize
);
VOID
@ -221,7 +221,7 @@ LdrVerifyImageMatchesChecksum(
_In_ HANDLE FileHandle,
_In_ PLDR_CALLBACK Callback,
_In_ PVOID CallbackContext,
_Out_ PUSHORT ImageCharacterstics
_Out_ PUSHORT ImageCharacteristics
);
NTSTATUS