mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 08:55:19 +00:00
- Fix NtSetInformationThread(ThreadBasePriority)
- Fix buffer overflow in KeRosDumpStackFrames - Fix usage of garbage/uninitialized handle entry local variable in ObpCreateHandle - Fix buffer overflow and logic bug in IoConnectInterrupt - Fix MSVC warnings svn path=/trunk/; revision=28153
This commit is contained in:
parent
ce187084c2
commit
415aa5eb49
34 changed files with 101 additions and 96 deletions
|
@ -38,7 +38,6 @@ Author:
|
|||
#include <excpt.h> // C Standard Header
|
||||
#include <stdarg.h> // C Standard Header
|
||||
#include <umtypes.h> // General Definitions
|
||||
#include <intrin.h> // Use Inlined Intrinsics
|
||||
|
||||
//
|
||||
// Type Headers
|
||||
|
|
|
@ -239,6 +239,6 @@ CcUninitializeCacheMap (
|
|||
UNIMPLEMENTED;
|
||||
return FALSE;
|
||||
#else
|
||||
return CcRosReleaseFileCache(FileObject);
|
||||
return NT_SUCCESS(CcRosReleaseFileCache(FileObject));
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ CmpCompressedNameSize(IN PWCHAR Name,
|
|||
* that it will remain that way forever, so -never- assume this code
|
||||
* below internally!
|
||||
*/
|
||||
return Length * sizeof(WCHAR);
|
||||
return (USHORT)Length * sizeof(WCHAR);
|
||||
}
|
||||
|
||||
LONG
|
||||
|
|
|
@ -455,7 +455,7 @@ CmpInitializeSystemHive(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
|
|||
}
|
||||
|
||||
/* Setup the unicode string */
|
||||
RtlInitEmptyUnicodeString(&CmpLoadOptions, Buffer, Length);
|
||||
RtlInitEmptyUnicodeString(&CmpLoadOptions, Buffer, (USHORT)Length);
|
||||
|
||||
/* Add the load options and null-terminate */
|
||||
RtlAnsiStringToUnicodeString(&CmpLoadOptions, &LoadString, FALSE);
|
||||
|
|
|
@ -135,7 +135,7 @@ ExReleaseFastMutex(IN OUT PFAST_MUTEX FastMutex)
|
|||
|
||||
/* Erase the owner */
|
||||
FastMutex->Owner = NULL;
|
||||
OldIrql = FastMutex->OldIrql;
|
||||
OldIrql = (KIRQL)FastMutex->OldIrql;
|
||||
|
||||
/* Increase the count */
|
||||
if (InterlockedIncrement(&FastMutex->Count) <= 0)
|
||||
|
|
|
@ -1094,7 +1094,7 @@ ExpInitializeExecutive(IN ULONG Cpu,
|
|||
}
|
||||
|
||||
/* Update length */
|
||||
CmCSDVersionString.MaximumLength = sizeof(Buffer) - Remaining;
|
||||
CmCSDVersionString.MaximumLength = (USHORT)sizeof(Buffer) - Remaining;
|
||||
}
|
||||
|
||||
/* Check if we have an RC number */
|
||||
|
|
|
@ -65,7 +65,7 @@ ExpQueryModuleInformation(IN PLIST_ENTRY KernelModeList,
|
|||
ModuleInfo->ImageSize = LdrEntry->SizeOfImage;
|
||||
ModuleInfo->Flags = LdrEntry->Flags;
|
||||
ModuleInfo->LoadCount = LdrEntry->LoadCount;
|
||||
ModuleInfo->LoadOrderIndex = ModuleCount;
|
||||
ModuleInfo->LoadOrderIndex = (USHORT)ModuleCount;
|
||||
ModuleInfo->InitOrderIndex = 0;
|
||||
|
||||
/* Setup name */
|
||||
|
@ -231,7 +231,7 @@ NtQuerySystemEnvironmentValue (IN PUNICODE_STRING VariableName,
|
|||
{
|
||||
ANSI_STRING AName;
|
||||
UNICODE_STRING WName;
|
||||
BOOLEAN Result;
|
||||
ARC_STATUS Result;
|
||||
PCH Value;
|
||||
ANSI_STRING AValue;
|
||||
UNICODE_STRING WValue;
|
||||
|
@ -417,7 +417,7 @@ NtSetSystemEnvironmentValue (IN PUNICODE_STRING VariableName,
|
|||
TRUE);
|
||||
if(NT_SUCCESS(Status))
|
||||
{
|
||||
BOOLEAN Result = HalSetEnvironmentVariable(AName.Buffer,
|
||||
ARC_STATUS Result = HalSetEnvironmentVariable(AName.Buffer,
|
||||
AValue.Buffer);
|
||||
|
||||
Status = (Result ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL);
|
||||
|
@ -766,7 +766,7 @@ QSI_DEF(SystemProcessInformation)
|
|||
SpiCur->UserTime.QuadPart = pr->Pcb.UserTime * 100000LL;
|
||||
SpiCur->KernelTime.QuadPart = pr->Pcb.KernelTime * 100000LL;
|
||||
SpiCur->ImageName.Length = strlen(pr->ImageFileName) * sizeof(WCHAR);
|
||||
SpiCur->ImageName.MaximumLength = inLen;
|
||||
SpiCur->ImageName.MaximumLength = (USHORT)inLen;
|
||||
SpiCur->ImageName.Buffer = (void*)(pCur+curSize);
|
||||
|
||||
// copy name to the end of the struct
|
||||
|
@ -1058,7 +1058,7 @@ QSI_DEF(SystemHandleInformation)
|
|||
|
||||
for (Count = 0; HandleCount > 0 ; HandleCount--)
|
||||
{
|
||||
Shi->Handles[i].UniqueProcessId = (ULONG)pr->UniqueProcessId;
|
||||
Shi->Handles[i].UniqueProcessId = (USHORT)(ULONG)pr->UniqueProcessId;
|
||||
Count++;
|
||||
i++;
|
||||
}
|
||||
|
|
|
@ -372,7 +372,7 @@ InbvSolidColorFill(IN ULONG Left,
|
|||
if (InbvBootDriverInstalled)
|
||||
{
|
||||
/* Call bootvid */
|
||||
VidSolidColorFill(Left, Top, Width, Height, Color);
|
||||
VidSolidColorFill(Left, Top, Width, Height, (UCHAR)Color);
|
||||
}
|
||||
|
||||
/* FIXME: Headless */
|
||||
|
|
|
@ -92,7 +92,7 @@ IoCreateController(IN ULONG Size)
|
|||
/* Zero the Object and set its data */
|
||||
RtlZeroMemory(Controller, sizeof(CONTROLLER_OBJECT) + Size);
|
||||
Controller->Type = IO_TYPE_CONTROLLER;
|
||||
Controller->Size = sizeof(CONTROLLER_OBJECT) + Size;
|
||||
Controller->Size = (CSHORT)sizeof(CONTROLLER_OBJECT) + Size;
|
||||
Controller->ControllerExtension = (Controller + 1);
|
||||
|
||||
/* Initialize its Queue */
|
||||
|
|
|
@ -765,7 +765,7 @@ IoCreateDevice(IN PDRIVER_OBJECT DriverObject,
|
|||
* because that's only padding for the DevObjExt and not part of the Object.
|
||||
*/
|
||||
CreatedDeviceObject->Type = IO_TYPE_DEVICE;
|
||||
CreatedDeviceObject->Size = sizeof(DEVICE_OBJECT) + DeviceExtensionSize;
|
||||
CreatedDeviceObject->Size = (USHORT)sizeof(DEVICE_OBJECT) + DeviceExtensionSize;
|
||||
|
||||
/* The kernel extension is after the driver internal extension */
|
||||
DeviceObjectExtension = (PDEVOBJ_EXTENSION)
|
||||
|
@ -1402,7 +1402,7 @@ IoStartNextPacketByKey(IN PDEVICE_OBJECT DeviceObject,
|
|||
IopStartNextPacketByKeyEx(DeviceObject,
|
||||
Key,
|
||||
DOE_SIO_WITH_KEY |
|
||||
(Cancelable) ? DOE_SIO_CANCELABLE : 0);
|
||||
(Cancelable ? DOE_SIO_CANCELABLE : 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1431,7 +1431,7 @@ IoStartNextPacket(IN PDEVICE_OBJECT DeviceObject,
|
|||
IopStartNextPacketByKeyEx(DeviceObject,
|
||||
0,
|
||||
DOE_SIO_NO_KEY |
|
||||
(Cancelable) ? DOE_SIO_CANCELABLE : 0);
|
||||
(Cancelable ? DOE_SIO_CANCELABLE : 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -300,7 +300,7 @@ IoGetDeviceInterfaces(IN CONST GUID *InterfaceClassGuid,
|
|||
}
|
||||
|
||||
/* Open device key */
|
||||
KeyName.Length = KeyName.MaximumLength = DeviceBi->NameLength;
|
||||
KeyName.Length = KeyName.MaximumLength = (USHORT)DeviceBi->NameLength;
|
||||
KeyName.Buffer = DeviceBi->Name;
|
||||
InitializeObjectAttributes(
|
||||
&ObjectAttributes,
|
||||
|
@ -370,7 +370,7 @@ IoGetDeviceInterfaces(IN CONST GUID *InterfaceClassGuid,
|
|||
goto cleanup;
|
||||
}
|
||||
|
||||
KeyName.Length = KeyName.MaximumLength = ReferenceBi->NameLength;
|
||||
KeyName.Length = KeyName.MaximumLength = (USHORT)ReferenceBi->NameLength;
|
||||
KeyName.Buffer = ReferenceBi->Name;
|
||||
if (RtlEqualUnicodeString(&KeyName, &Control, TRUE))
|
||||
{
|
||||
|
@ -475,7 +475,7 @@ IoGetDeviceInterfaces(IN CONST GUID *InterfaceClassGuid,
|
|||
Status = STATUS_UNSUCCESSFUL;
|
||||
goto cleanup;
|
||||
}
|
||||
KeyName.Length = KeyName.MaximumLength = bip->DataLength - 4 * sizeof(WCHAR);
|
||||
KeyName.Length = KeyName.MaximumLength = (USHORT)bip->DataLength - 4 * sizeof(WCHAR);
|
||||
KeyName.Buffer = &((PWSTR)bip->Data)[4];
|
||||
if (KeyName.Length && KeyName.Buffer[KeyName.Length / sizeof(WCHAR)] == UNICODE_NULL)
|
||||
{
|
||||
|
@ -976,7 +976,7 @@ IoSetDeviceInterfaceState(IN PUNICODE_STRING SymbolicLinkName,
|
|||
return STATUS_INVALID_PARAMETER_1;
|
||||
}
|
||||
GuidString.Buffer = StartPosition;
|
||||
GuidString.MaximumLength = GuidString.Length = (ULONG_PTR)(EndPosition + 1) - (ULONG_PTR)StartPosition;
|
||||
GuidString.MaximumLength = GuidString.Length = (USHORT)((ULONG_PTR)(EndPosition + 1) - (ULONG_PTR)StartPosition);
|
||||
|
||||
/* Get pointer to the PDO */
|
||||
Status = IoGetDeviceObjectPointer(
|
||||
|
|
|
@ -323,8 +323,8 @@ IoCreateDriverList(VOID)
|
|||
if (KeyInfo->NameLength < MAX_PATH * sizeof(WCHAR))
|
||||
{
|
||||
|
||||
SubKeyName.Length = KeyInfo->NameLength;
|
||||
SubKeyName.MaximumLength = KeyInfo->NameLength + sizeof(WCHAR);
|
||||
SubKeyName.Length = (USHORT)KeyInfo->NameLength;
|
||||
SubKeyName.MaximumLength = (USHORT)KeyInfo->NameLength + sizeof(WCHAR);
|
||||
SubKeyName.Buffer = KeyInfo->Name;
|
||||
SubKeyName.Buffer[SubKeyName.Length / sizeof(WCHAR)] = 0;
|
||||
|
||||
|
|
|
@ -338,8 +338,8 @@ IopLogWorker(IN PVOID Parameter)
|
|||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
/* Success, update the information */
|
||||
ObjectNameInfo->Name.Length = 100 -
|
||||
DriverNameLength;
|
||||
ObjectNameInfo->Name.Length = (USHORT)100 -
|
||||
DriverNameLength;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -434,7 +434,8 @@ IopLogWorker(IN PVOID Parameter)
|
|||
|
||||
/* Update size */
|
||||
InterlockedExchangeAdd(&IopTotalLogSize,
|
||||
-(LogEntry->Size - sizeof(ERROR_LOG_ENTRY)));
|
||||
-(LONG)(LogEntry->Size -
|
||||
sizeof(ERROR_LOG_ENTRY)));
|
||||
}
|
||||
|
||||
/* Free the LPC Message */
|
||||
|
@ -557,7 +558,7 @@ IoFreeErrorLogEntry(IN PVOID ElEntry)
|
|||
|
||||
/* Decrease total allocation size and free the entry */
|
||||
InterlockedExchangeAdd(&IopTotalLogSize,
|
||||
-(LogEntry->Size - sizeof(ERROR_LOG_ENTRY)));
|
||||
-(LONG)(LogEntry->Size - sizeof(ERROR_LOG_ENTRY)));
|
||||
ExFreePool(LogEntry);
|
||||
}
|
||||
|
||||
|
|
|
@ -512,7 +512,7 @@ IopParseDevice(IN PVOID ParseObject,
|
|||
StackLoc->Parameters.Create.EaLength = OpenPacket->EaLength;
|
||||
|
||||
/* Set the flags */
|
||||
StackLoc->Flags = OpenPacket->Options;
|
||||
StackLoc->Flags = (UCHAR)OpenPacket->Options;
|
||||
StackLoc->Flags |= !(Attributes & OBJ_CASE_INSENSITIVE) ?
|
||||
SL_CASE_SENSITIVE: 0;
|
||||
break;
|
||||
|
@ -764,7 +764,8 @@ IopParseDevice(IN PVOID ParseObject,
|
|||
FileObject->DeviceObject = NULL;
|
||||
|
||||
/* Save this now because the FO might go away */
|
||||
OpenCancelled = FileObject->Flags & FO_FILE_OPEN_CANCELLED;
|
||||
OpenCancelled = FileObject->Flags & FO_FILE_OPEN_CANCELLED ?
|
||||
TRUE : FALSE;
|
||||
|
||||
/* Clear the file object in the open packet */
|
||||
OpenPacket->FileObject = NULL;
|
||||
|
@ -1370,9 +1371,10 @@ IopQueryNameFile(IN PVOID ObjectBody,
|
|||
|
||||
/* Setup the length and maximum length */
|
||||
FileLength = (ULONG_PTR)p - (ULONG_PTR)ObjectNameInfo;
|
||||
ObjectNameInfo->Name.Length = FileLength - sizeof(OBJECT_NAME_INFORMATION);
|
||||
ObjectNameInfo->Name.MaximumLength = ObjectNameInfo->Name.Length +
|
||||
sizeof(UNICODE_NULL);
|
||||
ObjectNameInfo->Name.Length = (USHORT)FileLength -
|
||||
sizeof(OBJECT_NAME_INFORMATION);
|
||||
ObjectNameInfo->Name.MaximumLength = (USHORT)ObjectNameInfo->Name.Length +
|
||||
sizeof(UNICODE_NULL);
|
||||
|
||||
/* Free buffer and return */
|
||||
ExFreePool(LocalInfo);
|
||||
|
@ -1745,8 +1747,8 @@ IoCreateFile(OUT PHANDLE FileHandle,
|
|||
OpenPacket.OriginalAttributes = *ObjectAttributes;
|
||||
OpenPacket.AllocationSize = SafeAllocationSize;
|
||||
OpenPacket.CreateOptions = CreateOptions;
|
||||
OpenPacket.FileAttributes = FileAttributes;
|
||||
OpenPacket.ShareAccess = ShareAccess;
|
||||
OpenPacket.FileAttributes = (USHORT)FileAttributes;
|
||||
OpenPacket.ShareAccess = (USHORT)ShareAccess;
|
||||
OpenPacket.EaBuffer = SystemEaBuffer;
|
||||
OpenPacket.EaLength = EaLength;
|
||||
OpenPacket.Options = Options;
|
||||
|
@ -2078,7 +2080,7 @@ STDCALL
|
|||
IoIsFileOriginRemote(IN PFILE_OBJECT FileObject)
|
||||
{
|
||||
/* Return the flag status */
|
||||
return (FileObject->Flags & FO_REMOTE_ORIGIN);
|
||||
return FileObject->Flags & FO_REMOTE_ORIGIN ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -533,8 +533,8 @@ IopQueryBusDescription(
|
|||
|
||||
/* Enumerate the Bus. */
|
||||
BusString.Buffer = BasicInformation->Name;
|
||||
BusString.Length = BasicInformation->NameLength;
|
||||
BusString.MaximumLength = BasicInformation->NameLength;
|
||||
BusString.Length = (USHORT)BasicInformation->NameLength;
|
||||
BusString.MaximumLength = (USHORT)BasicInformation->NameLength;
|
||||
|
||||
/* Open a handle to the Root Registry Key */
|
||||
InitializeObjectAttributes(
|
||||
|
|
|
@ -36,28 +36,28 @@ IoConnectInterrupt(OUT PKINTERRUPT *InterruptObject,
|
|||
PIO_INTERRUPT IoInterrupt;
|
||||
PKSPIN_LOCK SpinLockUsed;
|
||||
BOOLEAN FirstRun = TRUE;
|
||||
ULONG count;
|
||||
LONG i;
|
||||
CCHAR Count = 0;
|
||||
KAFFINITY Affinity;
|
||||
PAGED_CODE();
|
||||
|
||||
/* Assume failure */
|
||||
*InterruptObject = NULL;
|
||||
|
||||
/* Convert the Mask */
|
||||
ProcessorEnableMask &= ((1 << KeNumberProcessors) - 1);
|
||||
|
||||
/* Make sure at least one CPU is on it */
|
||||
if (!ProcessorEnableMask) return STATUS_INVALID_PARAMETER;
|
||||
|
||||
/* Determine the allocation */
|
||||
for (i = 0, count = 0; i < KeNumberProcessors; i++)
|
||||
/* Get the affinity */
|
||||
Affinity = ProcessorEnableMask & KeActiveProcessors;
|
||||
while (Affinity)
|
||||
{
|
||||
if (ProcessorEnableMask & (1 << i)) count++;
|
||||
/* Increase count */
|
||||
if (Affinity & 1) Count++;
|
||||
Affinity >>= 1;
|
||||
}
|
||||
|
||||
/* Make sure we have a valid CPU count */
|
||||
if (!Count) return STATUS_INVALID_PARAMETER;
|
||||
|
||||
/* Allocate the array of I/O Interrupts */
|
||||
IoInterrupt = ExAllocatePoolWithTag(NonPagedPool,
|
||||
(count - 1)* sizeof(KINTERRUPT) +
|
||||
(Count - 1) * sizeof(KINTERRUPT) +
|
||||
sizeof(IO_INTERRUPT),
|
||||
TAG_KINTERRUPT);
|
||||
if (!IoInterrupt) return STATUS_INSUFFICIENT_RESOURCES;
|
||||
|
@ -74,10 +74,10 @@ IoConnectInterrupt(OUT PKINTERRUPT *InterruptObject,
|
|||
RtlZeroMemory(IoInterrupt, sizeof(IO_INTERRUPT));
|
||||
|
||||
/* Now create all the interrupts */
|
||||
for (i = 0; i < KeNumberProcessors; i++)
|
||||
for (Count = 0; Affinity; Count++, Affinity >>= 1)
|
||||
{
|
||||
/* Check if it's enabled for this CPU */
|
||||
if (ProcessorEnableMask & (1 << i))
|
||||
if (Affinity & 1)
|
||||
{
|
||||
/* Check which one we will use */
|
||||
InterruptUsed = FirstRun ? &IoInterrupt->FirstInterrupt : Interrupt;
|
||||
|
@ -92,7 +92,7 @@ IoConnectInterrupt(OUT PKINTERRUPT *InterruptObject,
|
|||
SynchronizeIrql,
|
||||
InterruptMode,
|
||||
ShareVector,
|
||||
i,
|
||||
Count,
|
||||
FloatingSave);
|
||||
|
||||
/* Connect it */
|
||||
|
@ -122,7 +122,7 @@ IoConnectInterrupt(OUT PKINTERRUPT *InterruptObject,
|
|||
else
|
||||
{
|
||||
/* Move on to the next one */
|
||||
IoInterrupt->Interrupt[i] = Interrupt++;
|
||||
IoInterrupt->Interrupt[(UCHAR)Count] = Interrupt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#define NDEBUG
|
||||
#include <ntoskrnl.h>
|
||||
#include <internal/debug.h>
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
#if defined (ALLOC_PRAGMA)
|
||||
#pragma alloc_text(INIT, IopInitPnpNotificationImplementation)
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#define NDEBUG
|
||||
#include <ntoskrnl.h>
|
||||
#include <internal/debug.h>
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
|
|
|
@ -287,7 +287,7 @@ QueryStringCallback(
|
|||
String->Buffer = ExAllocatePoolWithTag(PagedPool, ValueLength, TAG_PNP_ROOT);
|
||||
if (String->Buffer == NULL)
|
||||
return STATUS_NO_MEMORY;
|
||||
String->Length = String->MaximumLength = ValueLength;
|
||||
String->Length = String->MaximumLength = (USHORT)ValueLength;
|
||||
RtlCopyMemory(String->Buffer, ValueData, ValueLength);
|
||||
if (ValueLength > 0 && String->Buffer[ValueLength / sizeof(WCHAR) - 1] == L'\0')
|
||||
String->Length -= sizeof(WCHAR);
|
||||
|
|
|
@ -143,7 +143,7 @@ KeRosDumpStackFrames(IN PULONG Frame OPTIONAL,
|
|||
PLDR_DATA_TABLE_ENTRY LdrEntry;
|
||||
|
||||
/* If the caller didn't ask, assume 32 frames */
|
||||
if (!FrameCount) FrameCount = 32;
|
||||
if (!FrameCount || FrameCount > 32) FrameCount = 32;
|
||||
|
||||
/* Get the current frames */
|
||||
FrameCount = RtlCaptureStackBackTrace(2, FrameCount, (PVOID*)Frames, NULL);
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <roscfg.h>
|
||||
//#include <roscfg.h>
|
||||
#include <ndk/asm.h>
|
||||
.intel_syntax noprefix
|
||||
|
||||
|
|
|
@ -170,7 +170,8 @@ KiRecordDr7(OUT PULONG Dr7Ptr,
|
|||
if (Mask != NewMask)
|
||||
{
|
||||
/* Update it */
|
||||
KeGetCurrentThread()->DispatcherHeader.DebugActive = NewMask;
|
||||
KeGetCurrentThread()->DispatcherHeader.DebugActive =
|
||||
(BOOLEAN)NewMask;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -216,10 +216,11 @@ KiInitMachineDependent(VOID)
|
|||
CurrentSample->TSCStart;
|
||||
|
||||
/* Compute CPU Speed */
|
||||
CurrentSample->MHz = ((CurrentSample->TSCDelta *
|
||||
CurrentSample->PerfFreq.QuadPart +
|
||||
500000) /
|
||||
(CurrentSample->PerfDelta * 1000000));
|
||||
CurrentSample->MHz = (ULONG)((CurrentSample->TSCDelta *
|
||||
CurrentSample->
|
||||
PerfFreq.QuadPart + 500000) /
|
||||
(CurrentSample->PerfDelta *
|
||||
1000000));
|
||||
|
||||
/* Check if this isn't the first sample */
|
||||
if (Sample)
|
||||
|
|
|
@ -308,7 +308,7 @@ KeSetPriorityAndQuantumProcess(IN PKPROCESS Process,
|
|||
|
||||
/* Save the current base priority and update it */
|
||||
OldPriority = Process->BasePriority;
|
||||
Process->BasePriority = Priority;
|
||||
Process->BasePriority = (SCHAR)Priority;
|
||||
|
||||
/* Calculate the priority delta */
|
||||
Delta = Priority - OldPriority;
|
||||
|
@ -364,7 +364,7 @@ KeSetPriorityAndQuantumProcess(IN PKPROCESS Process,
|
|||
}
|
||||
|
||||
/* Update priority and quantum */
|
||||
Thread->BasePriority = NewPriority;
|
||||
Thread->BasePriority = (SCHAR)NewPriority;
|
||||
Thread->Quantum = Thread->QuantumReset;
|
||||
|
||||
/* Disable decrements and update priority */
|
||||
|
@ -426,7 +426,7 @@ KeSetPriorityAndQuantumProcess(IN PKPROCESS Process,
|
|||
}
|
||||
|
||||
/* Update priority and quantum */
|
||||
Thread->BasePriority = NewPriority;
|
||||
Thread->BasePriority = (SCHAR)NewPriority;
|
||||
Thread->Quantum = Thread->QuantumReset;
|
||||
|
||||
/* Disable decrements and update priority */
|
||||
|
|
|
@ -358,7 +358,7 @@ KeRemoveQueue(IN PKQUEUE Queue,
|
|||
{
|
||||
/* Check if the timer expired */
|
||||
InterruptTime.QuadPart = KeQueryInterruptTime();
|
||||
if (InterruptTime.QuadPart >= Timer->DueTime.QuadPart)
|
||||
if ((ULONG64)InterruptTime.QuadPart >= Timer->DueTime.QuadPart)
|
||||
{
|
||||
/* It did, so we don't need to wait */
|
||||
QueueEntry = (PLIST_ENTRY)STATUS_TIMEOUT;
|
||||
|
|
|
@ -134,8 +134,8 @@ NtAcceptConnectPort(OUT PHANDLE PortHandle,
|
|||
}
|
||||
|
||||
/* Set the sizes of our reply message */
|
||||
Message->Request.u1.s1.DataLength = sizeof(LPCP_CONNECTION_MESSAGE) +
|
||||
ConnectionInfoLength;
|
||||
Message->Request.u1.s1.DataLength = (CSHORT)ConnectionInfoLength +
|
||||
sizeof(LPCP_CONNECTION_MESSAGE);
|
||||
Message->Request.u1.s1.TotalLength = sizeof(LPCP_MESSAGE) +
|
||||
Message->Request.u1.s1.DataLength;
|
||||
|
||||
|
|
|
@ -352,8 +352,8 @@ NtSecureConnectPort(OUT PHANDLE PortHandle,
|
|||
ConnectMessage->SectionToMap = SectionToMap;
|
||||
|
||||
/* Set the data for the connection request message */
|
||||
Message->Request.u1.s1.DataLength = sizeof(LPCP_CONNECTION_MESSAGE) +
|
||||
ConnectionInfoLength;
|
||||
Message->Request.u1.s1.DataLength = (CSHORT)ConnectionInfoLength +
|
||||
sizeof(LPCP_CONNECTION_MESSAGE);
|
||||
Message->Request.u1.s1.TotalLength = sizeof(LPCP_MESSAGE) +
|
||||
Message->Request.u1.s1.DataLength;
|
||||
Message->Request.u2.s2.Type = LPC_CONNECTION_REQUEST;
|
||||
|
|
|
@ -180,8 +180,8 @@ NtReplyWaitReceivePortEx(IN HANDLE PortHandle,
|
|||
if (ReplyMessage)
|
||||
{
|
||||
/* Validate its length */
|
||||
if ((ReplyMessage->u1.s1.DataLength + sizeof(PORT_MESSAGE)) >
|
||||
ReplyMessage->u1.s1.TotalLength)
|
||||
if (((ULONG)ReplyMessage->u1.s1.DataLength + sizeof(PORT_MESSAGE)) >
|
||||
(ULONG)ReplyMessage->u1.s1.TotalLength)
|
||||
{
|
||||
/* Fail */
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
|
@ -204,8 +204,9 @@ NtReplyWaitReceivePortEx(IN HANDLE PortHandle,
|
|||
if (ReplyMessage)
|
||||
{
|
||||
/* Validate its length in respect to the port object */
|
||||
if ((ReplyMessage->u1.s1.TotalLength > Port->MaxMessageLength) ||
|
||||
(ReplyMessage->u1.s1.TotalLength <= ReplyMessage->u1.s1.DataLength))
|
||||
if (((ULONG)ReplyMessage->u1.s1.TotalLength > Port->MaxMessageLength) ||
|
||||
((ULONG)ReplyMessage->u1.s1.TotalLength <=
|
||||
(ULONG)ReplyMessage->u1.s1.DataLength))
|
||||
{
|
||||
/* Too large, fail */
|
||||
ObDereferenceObject(Port);
|
||||
|
@ -408,9 +409,9 @@ NtReplyWaitReceivePortEx(IN HANDLE PortHandle,
|
|||
Message = NULL;
|
||||
|
||||
/* Setup the receive message */
|
||||
ReceiveMessage->u1.s1.TotalLength = sizeof(LPCP_MESSAGE) +
|
||||
ConnectionInfoLength;
|
||||
ReceiveMessage->u1.s1.DataLength = ConnectionInfoLength;
|
||||
ReceiveMessage->u1.s1.TotalLength = (CSHORT)(sizeof(LPCP_MESSAGE) +
|
||||
ConnectionInfoLength);
|
||||
ReceiveMessage->u1.s1.DataLength = (CSHORT)ConnectionInfoLength;
|
||||
RtlCopyMemory(ReceiveMessage + 1,
|
||||
ConnectMessage + 1,
|
||||
ConnectionInfoLength);
|
||||
|
|
|
@ -60,8 +60,8 @@ LpcRequestPort(IN PVOID PortObject,
|
|||
if (LpcMessage->u2.s2.DataInfoOffset) return STATUS_INVALID_PARAMETER;
|
||||
|
||||
/* Validate message sizes */
|
||||
if ((LpcMessage->u1.s1.TotalLength > Port->MaxMessageLength) ||
|
||||
(LpcMessage->u1.s1.TotalLength <= LpcMessage->u1.s1.DataLength))
|
||||
if (((ULONG)LpcMessage->u1.s1.TotalLength > Port->MaxMessageLength) ||
|
||||
((ULONG)LpcMessage->u1.s1.TotalLength <= (ULONG)LpcMessage->u1.s1.DataLength))
|
||||
{
|
||||
/* Fail */
|
||||
return STATUS_PORT_MESSAGE_TOO_LONG;
|
||||
|
@ -241,8 +241,8 @@ NtRequestWaitReplyPort(IN HANDLE PortHandle,
|
|||
MessageType = LpcRequest->u2.s2.Type;
|
||||
|
||||
/* Validate the length */
|
||||
if ((LpcRequest->u1.s1.DataLength + sizeof(PORT_MESSAGE)) >
|
||||
LpcRequest->u1.s1.TotalLength)
|
||||
if (((ULONG)LpcRequest->u1.s1.DataLength + sizeof(PORT_MESSAGE)) >
|
||||
(ULONG)LpcRequest->u1.s1.TotalLength)
|
||||
{
|
||||
/* Fail */
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
|
@ -258,8 +258,8 @@ NtRequestWaitReplyPort(IN HANDLE PortHandle,
|
|||
if (!NT_SUCCESS(Status)) return Status;
|
||||
|
||||
/* Validate the message length */
|
||||
if ((LpcRequest->u1.s1.TotalLength > Port->MaxMessageLength) ||
|
||||
(LpcRequest->u1.s1.TotalLength <= LpcRequest->u1.s1.DataLength))
|
||||
if (((ULONG)LpcRequest->u1.s1.TotalLength > Port->MaxMessageLength) ||
|
||||
((ULONG)LpcRequest->u1.s1.TotalLength <= (ULONG)LpcRequest->u1.s1.DataLength))
|
||||
{
|
||||
/* Fail */
|
||||
ObDereferenceObject(Port);
|
||||
|
|
|
@ -40,7 +40,7 @@ MmSetMemoryPriorityProcess(IN PEPROCESS Process,
|
|||
}
|
||||
|
||||
/* Save the old priority and update it */
|
||||
OldPriority = Process->Vm.Flags.MemoryPriority;
|
||||
OldPriority = (UCHAR)Process->Vm.Flags.MemoryPriority;
|
||||
Process->Vm.Flags.MemoryPriority = MemoryPriority;
|
||||
|
||||
/* Return the old priority */
|
||||
|
@ -331,7 +331,7 @@ MmCreatePeb(PEPROCESS Process)
|
|||
Peb->OSMinorVersion = NtMinorVersion;
|
||||
Peb->OSBuildNumber = (USHORT)(NtBuildNumber & 0x3FFF);
|
||||
Peb->OSPlatformId = 2; /* VER_PLATFORM_WIN32_NT */
|
||||
Peb->OSCSDVersion = CmNtCSDVersion;
|
||||
Peb->OSCSDVersion = (USHORT)CmNtCSDVersion;
|
||||
|
||||
/* Heap and Debug Data */
|
||||
Peb->NumberOfProcessors = KeNumberProcessors;
|
||||
|
|
|
@ -1362,7 +1362,7 @@ ObpCreateUnnamedHandle(IN PVOID Object,
|
|||
{
|
||||
/* Dereference it as many times as required */
|
||||
InterlockedExchangeAdd(&ObjectHeader->PointerCount,
|
||||
-AdditionalReferences);
|
||||
-(LONG)AdditionalReferences);
|
||||
}
|
||||
|
||||
/* Decrement the handle count and detach */
|
||||
|
@ -1457,6 +1457,9 @@ ObpCreateHandle(IN OB_OPEN_REASON OpenReason,
|
|||
return STATUS_OBJECT_TYPE_MISMATCH;
|
||||
}
|
||||
|
||||
/* Save the object header */
|
||||
NewEntry.Object = ObjectHeader;
|
||||
|
||||
/* Check if this is a kernel handle */
|
||||
if (HandleAttributes & OBJ_KERNEL_HANDLE)
|
||||
{
|
||||
|
@ -1530,9 +1533,6 @@ ObpCreateHandle(IN OB_OPEN_REASON OpenReason,
|
|||
/* Now we can release the object */
|
||||
if (Context) ObpCleanupDirectoryLookup(Context);
|
||||
|
||||
/* Save the object header */
|
||||
NewEntry.Object = ObjectHeader;
|
||||
|
||||
/* Save the access mask */
|
||||
NewEntry.GrantedAccess = GrantedAccess;
|
||||
|
||||
|
@ -1617,7 +1617,7 @@ ObpCreateHandle(IN OB_OPEN_REASON OpenReason,
|
|||
{
|
||||
/* Dereference it many times */
|
||||
InterlockedExchangeAdd(&ObjectHeader->PointerCount,
|
||||
-(AdditionalReferences - 1));
|
||||
-(LONG)(AdditionalReferences - 1));
|
||||
}
|
||||
|
||||
/* Dereference the object one last time */
|
||||
|
|
|
@ -58,7 +58,7 @@ BOOLEAN PspDoingGiveBacks;
|
|||
|
||||
/* PRIVATE FUNCTIONS *********************************************************/
|
||||
|
||||
ULONG
|
||||
USHORT
|
||||
NTAPI
|
||||
NameToOrdinal(IN PCHAR Name,
|
||||
IN PVOID DllBase,
|
||||
|
|
|
@ -815,7 +815,7 @@ NtSetInformationThread(IN HANDLE ThreadHandle,
|
|||
(Priority < THREAD_BASE_PRIORITY_MIN))
|
||||
{
|
||||
/* These ones are OK */
|
||||
if ((Priority != THREAD_BASE_PRIORITY_LOWRT + 1) ||
|
||||
if ((Priority != THREAD_BASE_PRIORITY_LOWRT + 1) &&
|
||||
(Priority != THREAD_BASE_PRIORITY_IDLE - 1))
|
||||
{
|
||||
/* Check if the process is real time */
|
||||
|
|
|
@ -703,7 +703,7 @@ BOOLEAN
|
|||
NTAPI
|
||||
PsGetThreadHardErrorsAreDisabled(IN PETHREAD Thread)
|
||||
{
|
||||
return Thread->HardErrorsAreDisabled;
|
||||
return Thread->HardErrorsAreDisabled ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -823,7 +823,7 @@ BOOLEAN
|
|||
NTAPI
|
||||
PsIsThreadImpersonating(IN PETHREAD Thread)
|
||||
{
|
||||
return Thread->ActiveImpersonationInfo;
|
||||
return Thread->ActiveImpersonationInfo ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue