/* Check who is calling */
if (PreviousMode != KernelMode)
{
- static const UNICODE_STRING Win32kName =
+ static const UNICODE_STRING Win32kName =
RTL_CONSTANT_STRING(L"\\SystemRoot\\System32\\win32k.sys");
/* Make sure we can load drivers */
/* FIXME: We can't, fail */
return STATUS_PRIVILEGE_NOT_HELD;
}
-
+
_SEH2_TRY
{
/* Probe and copy the unicode string */
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
-
+
/* Recursively call the function, so that we are from kernel mode */
return ZwSetSystemInformation(SystemExtendServiceTableInformation,
(PVOID)&Win32kName,
SI_QX(SystemPerformanceInformation),
SI_QX(SystemTimeOfDayInformation),
SI_QX(SystemPathInformation), /* should be SI_XX */
- SI_QX(SystemProcessInformation),
- SI_QX(SystemCallCountInformation),
- SI_QX(SystemDeviceInformation),
- SI_QX(SystemProcessorPerformanceInformation),
- SI_QS(SystemFlagsInformation),
+ SI_QX(SystemProcessInformation), // aka SystemProcessesAndThreadsInformation
+ SI_QX(SystemCallCountInformation), // aka SystemCallCounts
+ SI_QX(SystemDeviceInformation), // aka SystemConfigurationInformation
+ SI_QX(SystemProcessorPerformanceInformation), // aka SystemProcessorTimes
+ SI_QS(SystemFlagsInformation), // aka SystemGlobalFlag
SI_QX(SystemCallTimeInformation), /* should be SI_XX */
SI_QX(SystemModuleInformation),
- SI_QX(SystemLocksInformation),
+ SI_QX(SystemLocksInformation), // aka SystemLockInformation
SI_QX(SystemStackTraceInformation), /* should be SI_XX */
SI_QX(SystemPagedPoolInformation), /* should be SI_XX */
SI_QX(SystemNonPagedPoolInformation), /* should be SI_XX */
SI_QX(SystemHandleInformation),
SI_QX(SystemObjectInformation),
- SI_QX(SystemPageFileInformation),
- SI_QX(SystemVdmInstemulInformation),
+ SI_QX(SystemPageFileInformation), // aka SystemPagefileInformation
+ SI_QX(SystemVdmInstemulInformation), // aka SystemInstructionEmulationCounts
SI_QX(SystemVdmBopInformation), /* it should be SI_XX */
- SI_QS(SystemFileCacheInformation),
+ SI_QS(SystemFileCacheInformation), // aka SystemCacheInformation
SI_QX(SystemPoolTagInformation),
- SI_QX(SystemInterruptInformation),
- SI_QS(SystemDpcBehaviourInformation),
+ SI_QX(SystemInterruptInformation), // aka SystemProcessorStatistics
+ SI_QS(SystemDpcBehaviourInformation), // aka SystemDpcInformation
SI_QX(SystemFullMemoryInformation), /* it should be SI_XX */
- SI_XS(SystemLoadGdiDriverInformation),
- SI_XS(SystemUnloadGdiDriverInformation),
- SI_QS(SystemTimeAdjustmentInformation),
+ SI_XS(SystemLoadGdiDriverInformation), // correct: SystemLoadImage
+ SI_XS(SystemUnloadGdiDriverInformation), // correct: SystemUnloadImage
+ SI_QS(SystemTimeAdjustmentInformation), // aka SystemTimeAdjustment
SI_QX(SystemSummaryMemoryInformation), /* it should be SI_XX */
SI_QX(SystemNextEventIdInformation), /* it should be SI_XX */
- SI_QX(SystemEventIdsInformation), /* it should be SI_XX */
+ SI_QX(SystemEventIdsInformation), /* it should be SI_XX */ // SystemPerformanceTraceInformation
SI_QX(SystemCrashDumpInformation),
SI_QX(SystemExceptionInformation),
SI_QX(SystemCrashDumpStateInformation),
SI_QX(SystemKernelDebuggerInformation),
SI_QX(SystemContextSwitchInformation),
SI_QS(SystemRegistryQuotaInformation),
- SI_XS(SystemExtendServiceTableInformation),
+ SI_XS(SystemExtendServiceTableInformation), // correct: SystemLoadAndCallImage
SI_XS(SystemPrioritySeperation),
SI_QX(SystemPlugPlayBusInformation), /* it should be SI_XX */
SI_QX(SystemDockInformation), /* it should be SI_XX */
- SI_QX(SystemPowerInformation), /* it should be SI_XX */
+ SI_QX(SystemPowerInformation), /* it should be SI_XX */ // SystemPowerInformationNative? SystemInvalidInfoClass2
SI_QX(SystemProcessorSpeedInformation), /* it should be SI_XX */
- SI_QS(SystemCurrentTimeZoneInformation), /* it should be SI_QX */
+ SI_QS(SystemCurrentTimeZoneInformation), /* it should be SI_QX */ // aka SystemTimeZoneInformation
SI_QX(SystemLookasideInformation),
SI_XS(SystemSetTimeSlipEvent),
SI_XS(SystemCreateSession),
SI_XS(SystemDeleteSession),
- SI_QX(SystemInvalidInfoClass4), /* it should be SI_XX */
+ SI_QX(SystemInvalidInfoClass4), /* it should be SI_XX */ // SystemSessionInformation?
SI_QX(SystemRangeStartInformation),
SI_QS(SystemVerifierInformation),
SI_XS(SystemAddVerifier),
OUT PULONG UnsafeResultLength)
{
KPROCESSOR_MODE PreviousMode;
- ULONG ResultLength;
+ ULONG ResultLength = 0;
NTSTATUS FStatus = STATUS_NOT_IMPLEMENTED;
PAGED_CODE();
ProbeForWriteUlong(UnsafeResultLength);
}
+ if (UnsafeResultLength)
+ *UnsafeResultLength = 0;
+
/*
- * Check the request is valid.
+ * Check if the request is valid.
*/
if (SystemInformationClass >= MAX_SYSTEM_INFO_CLASS)
{
Exclusive = TRUE;
ResourceToAcquire = FcbHeader->Resource;
}
- else if (!FcbHeader->PagingIoResource ||
+ else if (!FcbHeader->PagingIoResource ||
(FcbHeader->Flags & FSRTL_FLAG_ACQUIRE_MAIN_RSRC_SH))
{
/* Acquire main resource shared if flag is specified or
*--*/
NTSTATUS
NTAPI
-FsRtlRegisterFileSystemFilterCallbacks(IN PDRIVER_OBJECT FilterDriverObject,
- IN PFS_FILTER_CALLBACKS Callbacks)
+FsRtlRegisterFileSystemFilterCallbacks(
+ PDRIVER_OBJECT FilterDriverObject,
+ PFS_FILTER_CALLBACKS Callbacks)
{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
+ PFS_FILTER_CALLBACKS NewCallbacks;
+ PEXTENDED_DRIVER_EXTENSION DriverExtension;
+ PAGED_CODE();
+
+ /* Verify parameters */
+ if ((FilterDriverObject == NULL) || (Callbacks == NULL))
+ {
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ /* Allocate a buffer for a copy of the callbacks */
+ NewCallbacks = ExAllocatePoolWithTag(NonPagedPool,
+ Callbacks->SizeOfFsFilterCallbacks,
+ 'gmSF');
+ if (NewCallbacks == NULL)
+ {
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ /* Copy the callbacks */
+ RtlCopyMemory(NewCallbacks, Callbacks, Callbacks->SizeOfFsFilterCallbacks);
+
+ /* Set the callbacks in the driver extension */
+ DriverExtension = (PEXTENDED_DRIVER_EXTENSION)FilterDriverObject->DriverExtension;
+ DriverExtension->FsFilterCallbacks = NewCallbacks;
+
+ return STATUS_SUCCESS;
}
IOC_TAG1,
32,
&ExSystemLookasideListHead);
-
+
/* Initialize the Lookaside List for Large IRPs */
ExInitializeSystemLookasideList(&IoLargeIrpLookaside,
NonPagedPool,
&ExSystemLookasideListHead);
/* Allocate the global lookaside list buffer */
- CurrentList = ExAllocatePoolWithTag(NonPagedPool,
+ CurrentList = ExAllocatePoolWithTag(NonPagedPool,
4 * KeNumberProcessors *
sizeof(GENERAL_LOOKASIDE),
TAG_IO);
-
+
/* Loop all processors */
for (i = 0; i < KeNumberProcessors; i++)
{
&ExSystemLookasideListHead);
Prcb->PPLookasideList[LookasideCompletionList].P = CurrentList;
CurrentList++;
-
+
}
else
{
Prcb->PPLookasideList[LookasideCompletionList].P = &IoCompletionPacketLookaside;
}
-
+
/* Set the Large IRP List */
Prcb->PPLookasideList[LookasideLargeIrpList].L = &IoLargeIrpLookaside;
if (CurrentList)
&ExSystemLookasideListHead);
Prcb->PPLookasideList[LookasideLargeIrpList].P = CurrentList;
CurrentList++;
-
+
}
else
{
&ExSystemLookasideListHead);
Prcb->PPLookasideList[LookasideSmallIrpList].P = CurrentList;
CurrentList++;
-
+
}
else
{
TAG_MDL,
128,
&ExSystemLookasideListHead);
-
+
Prcb->PPLookasideList[LookasideMdlList].P = CurrentList;
CurrentList++;
-
+
}
else
{
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING DirName;
HANDLE Handle;
+ NTSTATUS Status;
/* Create the '\Driver' object directory */
RtlInitUnicodeString(&DirName, L"\\Driver");
OBJ_PERMANENT,
NULL,
NULL);
- if (!NT_SUCCESS(NtCreateDirectoryObject(&Handle,
- DIRECTORY_ALL_ACCESS,
- &ObjectAttributes))) return FALSE;
+ Status = NtCreateDirectoryObject(&Handle,
+ DIRECTORY_ALL_ACCESS,
+ &ObjectAttributes);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("Failed to create \\Driver directory: 0x%lx\n", Status);
+ return FALSE;
+ }
NtClose(Handle);
/* Create the '\FileSystem' object directory */
OBJ_PERMANENT,
NULL,
NULL);
- if (!NT_SUCCESS(NtCreateDirectoryObject(&Handle,
- DIRECTORY_ALL_ACCESS,
- &ObjectAttributes))) return FALSE;
+ Status = NtCreateDirectoryObject(&Handle,
+ DIRECTORY_ALL_ACCESS,
+ &ObjectAttributes);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("Failed to create \\FileSystem directory: 0x%lx\n", Status);
+ return FALSE;
+ }
+ NtClose(Handle);
+
+ /* Create the '\FileSystem' object directory */
+ RtlInitUnicodeString(&DirName, L"\\FileSystem\\Filters");
+ InitializeObjectAttributes(&ObjectAttributes,
+ &DirName,
+ OBJ_PERMANENT,
+ NULL,
+ NULL);
+ Status = NtCreateDirectoryObject(&Handle,
+ DIRECTORY_ALL_ACCESS,
+ &ObjectAttributes);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("Failed to create \\FileSystem\\Filters directory: 0x%lx\n", Status);
+ return FALSE;
+ }
NtClose(Handle);
/* Return success */