https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d6792047f3e667017cf45…
commit d6792047f3e667017cf459e42c06d3ed9e5f78f9
Author: Ivan Labutin <linuxrf(a)gmail.com>
AuthorDate: Mon Nov 13 15:06:29 2017 +0100
[NTOS][NDK][RTL] A bunch of 'wrong size' fixes
---
dll/ntdll/ldr/ldrapi.c | 6 +++---
dll/win32/kernel32/client/loader.c | 4 ++--
ntoskrnl/fsrtl/stackovf.c | 4 ++--
ntoskrnl/io/pnpmgr/pnpreport.c | 4 ++--
ntoskrnl/ps/process.c | 4 ++--
sdk/include/ndk/ldrfuncs.h | 2 +-
sdk/lib/rtl/memstream.c | 9 +++++++--
sdk/lib/rtl/rtlp.h | 4 ++--
8 files changed, 21 insertions(+), 16 deletions(-)
diff --git a/dll/ntdll/ldr/ldrapi.c b/dll/ntdll/ldr/ldrapi.c
index c49be3dead..c33b21eff1 100644
--- a/dll/ntdll/ldr/ldrapi.c
+++ b/dll/ntdll/ldr/ldrapi.c
@@ -316,7 +316,7 @@ LdrLoadDll(IN PWSTR SearchPath OPTIONAL,
UNICODE_STRING DllString1, DllString2;
BOOLEAN RedirectedDll = FALSE;
NTSTATUS Status;
- ULONG Cookie;
+ ULONG_PTR Cookie;
PUNICODE_STRING OldTldDll;
PTEB Teb = NtCurrentTeb();
@@ -1117,7 +1117,7 @@ LdrEnumerateLoadedModules(IN BOOLEAN ReservedFlag,
PLIST_ENTRY ListHead, ListEntry;
PLDR_DATA_TABLE_ENTRY LdrEntry;
NTSTATUS Status;
- ULONG Cookie;
+ ULONG_PTR Cookie;
BOOLEAN Stop = FALSE;
/* Check parameters */
@@ -1232,7 +1232,7 @@ LdrAddRefDll(IN ULONG Flags,
{
PLDR_DATA_TABLE_ENTRY LdrEntry;
NTSTATUS Status = STATUS_SUCCESS;
- ULONG Cookie;
+ ULONG_PTR Cookie;
BOOLEAN Locked = FALSE;
/* Check for invalid flags */
diff --git a/dll/win32/kernel32/client/loader.c b/dll/win32/kernel32/client/loader.c
index bed45c541f..82f8c7d988 100644
--- a/dll/win32/kernel32/client/loader.c
+++ b/dll/win32/kernel32/client/loader.c
@@ -610,7 +610,7 @@ GetModuleFileNameW(HINSTANCE hModule,
PLIST_ENTRY ModuleListHead, Entry;
PLDR_DATA_TABLE_ENTRY Module;
ULONG Length = 0;
- ULONG Cookie;
+ ULONG_PTR Cookie;
PPEB Peb;
hModule = BasepMapModuleHandle(hModule, FALSE);
@@ -721,7 +721,7 @@ BOOLEAN
WINAPI
BasepGetModuleHandleExW(BOOLEAN NoLock, DWORD dwPublicFlags, LPCWSTR lpwModuleName,
HMODULE *phModule)
{
- DWORD Cookie;
+ ULONG_PTR Cookie;
NTSTATUS Status = STATUS_SUCCESS, Status2;
HANDLE hModule = NULL;
UNICODE_STRING ModuleNameU;
diff --git a/ntoskrnl/fsrtl/stackovf.c b/ntoskrnl/fsrtl/stackovf.c
index 076121f883..9016fce5da 100644
--- a/ntoskrnl/fsrtl/stackovf.c
+++ b/ntoskrnl/fsrtl/stackovf.c
@@ -115,7 +115,7 @@ FsRtlWorkerThread(IN PVOID StartContext)
KIRQL Irql;
PLIST_ENTRY Entry;
PWORK_QUEUE_ITEM WorkItem;
- ULONG QueueId = (ULONG)StartContext;
+ ULONG_PTR QueueId = (ULONG_PTR)StartContext;
/* Set our priority according to the queue we're dealing with */
KeSetPriorityThread(&PsGetCurrentThread()->Tcb, LOW_REALTIME_PRIORITY +
QueueId);
@@ -149,7 +149,7 @@ NTAPI
INIT_FUNCTION
FsRtlInitializeWorkerThread(VOID)
{
- ULONG i;
+ ULONG_PTR i;
NTSTATUS Status;
HANDLE ThreadHandle;
OBJECT_ATTRIBUTES ObjectAttributes;
diff --git a/ntoskrnl/io/pnpmgr/pnpreport.c b/ntoskrnl/io/pnpmgr/pnpreport.c
index 9449e2d01a..92523207c5 100644
--- a/ntoskrnl/io/pnpmgr/pnpreport.c
+++ b/ntoskrnl/io/pnpmgr/pnpreport.c
@@ -425,7 +425,7 @@ IoReportTargetDeviceChange(IN PDEVICE_OBJECT PhysicalDeviceObject,
/* Check for valid PDO */
if (!IopIsValidPhysicalDeviceObject(PhysicalDeviceObject))
{
- KeBugCheckEx(PNP_DETECTED_FATAL_ERROR, 0x2, (ULONG)PhysicalDeviceObject, 0, 0);
+ KeBugCheckEx(PNP_DETECTED_FATAL_ERROR, 0x2, (ULONG_PTR)PhysicalDeviceObject, 0,
0);
}
/* FileObject must be null. PnP will fill in it */
@@ -476,7 +476,7 @@ IoReportTargetDeviceChangeAsynchronous(IN PDEVICE_OBJECT
PhysicalDeviceObject,
/* Check for valid PDO */
if (!IopIsValidPhysicalDeviceObject(PhysicalDeviceObject))
{
- KeBugCheckEx(PNP_DETECTED_FATAL_ERROR, 0x2, (ULONG)PhysicalDeviceObject, 0, 0);
+ KeBugCheckEx(PNP_DETECTED_FATAL_ERROR, 0x2, (ULONG_PTR)PhysicalDeviceObject, 0,
0);
}
/* FileObject must be null. PnP will fill in it */
diff --git a/ntoskrnl/ps/process.c b/ntoskrnl/ps/process.c
index ab81ddca87..119997a753 100644
--- a/ntoskrnl/ps/process.c
+++ b/ntoskrnl/ps/process.c
@@ -1416,8 +1416,8 @@ NtCreateProcess(OUT PHANDLE ProcessHandle,
"Parent: %p Attributes: %p\n", ParentProcess, ObjectAttributes);
/* Set new-style flags */
- if ((ULONG)SectionHandle & 1) Flags |= PROCESS_CREATE_FLAGS_BREAKAWAY;
- if ((ULONG)DebugPort & 1) Flags |= PROCESS_CREATE_FLAGS_NO_DEBUG_INHERIT;
+ if ((ULONG_PTR)SectionHandle & 1) Flags |= PROCESS_CREATE_FLAGS_BREAKAWAY;
+ if ((ULONG_PTR)DebugPort & 1) Flags |= PROCESS_CREATE_FLAGS_NO_DEBUG_INHERIT;
if (InheritObjectTable) Flags |= PROCESS_CREATE_FLAGS_INHERIT_HANDLES;
/* Call the new API */
diff --git a/sdk/include/ndk/ldrfuncs.h b/sdk/include/ndk/ldrfuncs.h
index c134ecfb96..58859bcb35 100644
--- a/sdk/include/ndk/ldrfuncs.h
+++ b/sdk/include/ndk/ldrfuncs.h
@@ -109,7 +109,7 @@ NTAPI
LdrLockLoaderLock(
_In_ ULONG Flags,
_Out_opt_ PULONG Disposition,
- _Out_opt_ PULONG Cookie
+ _Out_opt_ PULONG_PTR Cookie
);
NTSTATUS
diff --git a/sdk/lib/rtl/memstream.c b/sdk/lib/rtl/memstream.c
index 0549424ca4..51dc8e6653 100644
--- a/sdk/lib/rtl/memstream.c
+++ b/sdk/lib/rtl/memstream.c
@@ -205,6 +205,7 @@ RtlReadOutOfProcessMemoryStream(
ULONG CopyLength;
PRTL_MEMORY_STREAM Stream = IStream_To_RTL_MEMORY_STREAM(This);
SIZE_T Available = (PUCHAR)Stream->End - (PUCHAR)Stream->Current;
+ SIZE_T LocalBytesRead = 0;
if (BytesRead)
*BytesRead = 0;
@@ -218,10 +219,14 @@ RtlReadOutOfProcessMemoryStream(
Stream->Current,
Buffer,
CopyLength,
- BytesRead);
+ &LocalBytesRead);
if (NT_SUCCESS(Status))
- Stream->Current = (PUCHAR)Stream->Current + *BytesRead;
+ {
+ Stream->Current = (PUCHAR)Stream->Current + LocalBytesRead;
+ if (BytesRead)
+ *BytesRead = (ULONG)LocalBytesRead;
+ }
return HRESULT_FROM_WIN32(RtlNtStatusToDosError(Status));
}
diff --git a/sdk/lib/rtl/rtlp.h b/sdk/lib/rtl/rtlp.h
index 6942e18fde..d0d4a41033 100644
--- a/sdk/lib/rtl/rtlp.h
+++ b/sdk/lib/rtl/rtlp.h
@@ -27,10 +27,10 @@ extern VOID FASTCALL CHECK_PAGED_CODE_RTL(char *file, int line);
#endif
#define ROUND_DOWN(n, align) \
- (((ULONG)(n)) & ~((align) - 1l))
+ (((ULONG_PTR)(n)) & ~((align) - 1l))
#define ROUND_UP(n, align) \
- ROUND_DOWN(((ULONG)(n)) + (align) - 1, (align))
+ ROUND_DOWN(((ULONG_PTR)(n)) + (align) - 1, (align))
#define RVA(m, b) ((PVOID)((ULONG_PTR)(b) + (ULONG_PTR)(m)))