30 __in_opt HANDLE KeyHandle,
32 __in ULONG DefaultValue
40 #pragma alloc_text(PAGE, DriverEntry)
41 #pragma alloc_text(PAGE, DriverUnload)
42 #pragma alloc_text(PAGE, KphpReadIntegerParameter)
43 #pragma alloc_text(PAGE, KphpReadDriverParameters)
44 #pragma alloc_text(PAGE, KpiGetFeatures)
47 PDRIVER_OBJECT KphDriverObject;
48 PDEVICE_OBJECT KphDeviceObject;
53 __in PDRIVER_OBJECT DriverObject,
59 PDEVICE_OBJECT deviceObject;
63 KphDriverObject = DriverObject;
77 status = IoCreateDevice(
90 KphDeviceObject = deviceObject;
98 deviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
106 __in PDRIVER_OBJECT DriverObject
111 IoDeleteDevice(KphDeviceObject);
117 __in PDEVICE_OBJECT DeviceObject,
121 NTSTATUS status = STATUS_SUCCESS;
122 PIO_STACK_LOCATION stackLocation;
123 PIO_SECURITY_CONTEXT securityContext;
125 stackLocation = IoGetCurrentIrpStackLocation(Irp);
126 securityContext = stackLocation->Parameters.Create.SecurityContext;
128 dprintf(
"Client (PID %Iu) is connecting\n", PsGetCurrentProcessId());
132 UCHAR requiredPrivilegesBuffer[FIELD_OFFSET(PRIVILEGE_SET, Privilege) +
sizeof(LUID_AND_ATTRIBUTES)];
133 PPRIVILEGE_SET requiredPrivileges;
137 requiredPrivileges = (PPRIVILEGE_SET)requiredPrivilegesBuffer;
138 requiredPrivileges->PrivilegeCount = 1;
139 requiredPrivileges->Control = PRIVILEGE_SET_ALL_NECESSARY;
141 requiredPrivileges->Privilege[0].Luid.HighPart = 0;
142 requiredPrivileges->Privilege[0].Attributes = 0;
144 if (!SePrivilegeCheck(
146 &securityContext->AccessState->SubjectSecurityContext,
150 status = STATUS_PRIVILEGE_NOT_HELD;
151 dprintf(
"Client (PID %Iu) was rejected\n", PsGetCurrentProcessId());
155 Irp->IoStatus.Status = status;
156 Irp->IoStatus.Information = 0;
157 IoCompleteRequest(Irp, IO_NO_INCREMENT);
174 __in_opt HANDLE KeyHandle,
176 __in ULONG DefaultValue
200 if (info->Type != REG_DWORD)
201 status = STATUS_OBJECT_TYPE_MISMATCH;
205 dprintf(
"Unable to query parameter %.*S: 0x%x\n", ValueName->Length /
sizeof(WCHAR), ValueName->Buffer, status);
209 return *(PULONG)info->Data;
222 HANDLE parametersKeyHandle;
234 parametersKeyName.
Length = RegistryPath->Length + parametersString.
Length;
236 parametersKeyName.Buffer = ExAllocatePoolWithTag(PagedPool, parametersKeyName.
MaximumLength,
'ThpK');
238 if (!parametersKeyName.Buffer)
239 return STATUS_INSUFFICIENT_RESOURCES;
241 memcpy(parametersKeyName.Buffer, RegistryPath->Buffer, RegistryPath->
Length);
242 memcpy(¶metersKeyName.Buffer[RegistryPath->Length /
sizeof(WCHAR)], parametersString.Buffer, parametersString.
Length);
252 ¶metersKeyHandle,
256 ExFreePoolWithTag(parametersKeyName.Buffer,
'ThpK');
260 dprintf(
"Unable to open Parameters key: 0x%x\n", status);
261 status = STATUS_SUCCESS;
262 parametersKeyHandle = NULL;
276 if (parametersKeyHandle)
283 __out PULONG Features,
284 __in KPROCESSOR_MODE AccessMode
289 if (AccessMode != KernelMode)
293 ProbeForWrite(Features,
sizeof(ULONG),
sizeof(ULONG));
294 *Features = KphFeatures;
296 __except (EXCEPTION_EXECUTE_HANDLER)
298 return GetExceptionCode();
303 *Features = KphFeatures;
306 return STATUS_SUCCESS;
331 buffer = ExAllocatePoolWithTag(PagedPool, bufferSize,
'ThpK');
335 status = STATUS_INSUFFICIENT_RESOURCES;
353 ExFreePoolWithTag(buffer,
'ThpK');
355 if (status != STATUS_INFO_LENGTH_MISMATCH)
359 }
while (--attempts);
390 (ULONG_PTR)Address + Length >= (ULONG_PTR)Address &&
401 ExFreePoolWithTag(modules,
'ThpK');
404 status = STATUS_SUCCESS;
406 status = STATUS_ACCESS_VIOLATION;