[NTOS][NDK][RTL] A bunch of 'wrong size' fixes

This commit is contained in:
Ivan Labutin 2017-11-13 15:06:29 +01:00 committed by Timo Kreuzer
parent 4d35d59fb9
commit d6792047f3
8 changed files with 21 additions and 16 deletions

View file

@ -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 */

View file

@ -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;

View file

@ -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;

View file

@ -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 */

View file

@ -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 */

View file

@ -109,7 +109,7 @@ NTAPI
LdrLockLoaderLock(
_In_ ULONG Flags,
_Out_opt_ PULONG Disposition,
_Out_opt_ PULONG Cookie
_Out_opt_ PULONG_PTR Cookie
);
NTSTATUS

View file

@ -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));
}

View file

@ -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)))