VeraCrypt
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2024-11-17 21:37:16 +0100
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2024-11-17 21:37:16 +0100
commit93868acfdd9ca721ddf32a92d8dec8d0fff1d7d8 (patch)
treef36c426867bf1c29f25a472522d72bec0f2103ba
parent42fdbcf3ce37c33f777773a49d02dac6258c8dac (diff)
downloadVeraCrypt-93868acfdd9ca721ddf32a92d8dec8d0fff1d7d8.tar.gz
VeraCrypt-93868acfdd9ca721ddf32a92d8dec8d0fff1d7d8.zip
Windows Driver: Use system functions directly instead of dynamic loading since we are targeting Windows 10
-rw-r--r--src/Common/Pkcs5.c24
-rw-r--r--src/Common/Tcdefs.h47
-rw-r--r--src/Crypto/Camellia.c8
-rw-r--r--src/Driver/DriveFilter.c5
-rw-r--r--src/Driver/Ntdriver.c190
-rw-r--r--src/Driver/Ntvol.c2
6 files changed, 53 insertions, 223 deletions
diff --git a/src/Common/Pkcs5.c b/src/Common/Pkcs5.c
index 6cffddf2..6d8ce08a 100644
--- a/src/Common/Pkcs5.c
+++ b/src/Common/Pkcs5.c
@@ -91,7 +91,7 @@ void hmac_sha256
NTSTATUS saveStatus = STATUS_INVALID_PARAMETER;
XSTATE_SAVE SaveState;
if (IsCpuIntel() && HasSAVX())
- saveStatus = KeSaveExtendedProcessorStateVC(XSTATE_MASK_GSSE, &SaveState);
+ saveStatus = KeSaveExtendedProcessorState(XSTATE_MASK_GSSE, &SaveState);
#endif
/* If the key is longer than the hash algorithm block size,
let key = sha256(key), as per HMAC specifications. */
@@ -136,7 +136,7 @@ void hmac_sha256
#if defined (DEVICE_DRIVER) && !defined(_M_ARM64)
if (NT_SUCCESS (saveStatus))
- KeRestoreExtendedProcessorStateVC(&SaveState);
+ KeRestoreExtendedProcessorState(&SaveState);
#endif
/* Prevent leaks */
@@ -208,7 +208,7 @@ void derive_key_sha256 (const unsigned char *pwd, int pwd_len, const unsigned ch
NTSTATUS saveStatus = STATUS_INVALID_PARAMETER;
XSTATE_SAVE SaveState;
if (IsCpuIntel() && HasSAVX())
- saveStatus = KeSaveExtendedProcessorStateVC(XSTATE_MASK_GSSE, &SaveState);
+ saveStatus = KeSaveExtendedProcessorState(XSTATE_MASK_GSSE, &SaveState);
#endif
/* If the password is longer than the hash algorithm block size,
let pwd = sha256(pwd), as per HMAC specifications. */
@@ -275,7 +275,7 @@ void derive_key_sha256 (const unsigned char *pwd, int pwd_len, const unsigned ch
#if defined (DEVICE_DRIVER) && !defined(_M_ARM64)
if (NT_SUCCESS (saveStatus))
- KeRestoreExtendedProcessorStateVC(&SaveState);
+ KeRestoreExtendedProcessorState(&SaveState);
#endif
/* Prevent possible leaks. */
@@ -341,7 +341,7 @@ void hmac_sha512
NTSTATUS saveStatus = STATUS_INVALID_PARAMETER;
XSTATE_SAVE SaveState;
if (IsCpuIntel() && HasSAVX())
- saveStatus = KeSaveExtendedProcessorStateVC(XSTATE_MASK_GSSE, &SaveState);
+ saveStatus = KeSaveExtendedProcessorState(XSTATE_MASK_GSSE, &SaveState);
#endif
/* If the key is longer than the hash algorithm block size,
@@ -387,7 +387,7 @@ void hmac_sha512
#if defined (DEVICE_DRIVER) && !defined(_M_ARM64)
if (NT_SUCCESS (saveStatus))
- KeRestoreExtendedProcessorStateVC(&SaveState);
+ KeRestoreExtendedProcessorState(&SaveState);
#endif
/* Prevent leaks */
@@ -433,7 +433,7 @@ void derive_key_sha512 (const unsigned char *pwd, int pwd_len, const unsigned ch
NTSTATUS saveStatus = STATUS_INVALID_PARAMETER;
XSTATE_SAVE SaveState;
if (IsCpuIntel() && HasSAVX())
- saveStatus = KeSaveExtendedProcessorStateVC(XSTATE_MASK_GSSE, &SaveState);
+ saveStatus = KeSaveExtendedProcessorState(XSTATE_MASK_GSSE, &SaveState);
#endif
/* If the password is longer than the hash algorithm block size,
@@ -500,7 +500,7 @@ void derive_key_sha512 (const unsigned char *pwd, int pwd_len, const unsigned ch
#if defined (DEVICE_DRIVER) && !defined(_M_ARM64)
if (NT_SUCCESS (saveStatus))
- KeRestoreExtendedProcessorStateVC(&SaveState);
+ KeRestoreExtendedProcessorState(&SaveState);
#endif
/* Prevent possible leaks. */
@@ -565,7 +565,7 @@ void hmac_blake2s
NTSTATUS saveStatus = STATUS_INVALID_PARAMETER;
XSTATE_SAVE SaveState;
if (IsCpuIntel() && HasSAVX())
- saveStatus = KeSaveExtendedProcessorStateVC(XSTATE_MASK_GSSE, &SaveState);
+ saveStatus = KeSaveExtendedProcessorState(XSTATE_MASK_GSSE, &SaveState);
#endif
/* If the key is longer than the hash algorithm block size,
let key = blake2s(key), as per HMAC specifications. */
@@ -610,7 +610,7 @@ void hmac_blake2s
#if defined (DEVICE_DRIVER) && !defined(_M_ARM64)
if (NT_SUCCESS (saveStatus))
- KeRestoreExtendedProcessorStateVC(&SaveState);
+ KeRestoreExtendedProcessorState(&SaveState);
#endif
/* Prevent leaks */
@@ -682,7 +682,7 @@ void derive_key_blake2s (const unsigned char *pwd, int pwd_len, const unsigned c
NTSTATUS saveStatus = STATUS_INVALID_PARAMETER;
XSTATE_SAVE SaveState;
if (IsCpuIntel() && HasSAVX())
- saveStatus = KeSaveExtendedProcessorStateVC(XSTATE_MASK_GSSE, &SaveState);
+ saveStatus = KeSaveExtendedProcessorState(XSTATE_MASK_GSSE, &SaveState);
#endif
/* If the password is longer than the hash algorithm block size,
let pwd = blake2s(pwd), as per HMAC specifications. */
@@ -749,7 +749,7 @@ void derive_key_blake2s (const unsigned char *pwd, int pwd_len, const unsigned c
#if defined (DEVICE_DRIVER) && !defined(_M_ARM64)
if (NT_SUCCESS (saveStatus))
- KeRestoreExtendedProcessorStateVC(&SaveState);
+ KeRestoreExtendedProcessorState(&SaveState);
#endif
/* Prevent possible leaks. */
diff --git a/src/Common/Tcdefs.h b/src/Common/Tcdefs.h
index e7eee177..0dd7fe40 100644
--- a/src/Common/Tcdefs.h
+++ b/src/Common/Tcdefs.h
@@ -286,53 +286,6 @@ typedef unsigned char BOOLEAN;
#define FALSE !TRUE
#endif
-typedef NTSTATUS (NTAPI *KeSaveExtendedProcessorStateFn) (
- __in ULONG64 Mask,
- PXSTATE_SAVE XStateSave
- );
-
-
-typedef VOID (NTAPI *KeRestoreExtendedProcessorStateFn) (
- PXSTATE_SAVE XStateSave
- );
-
-typedef NTSTATUS (NTAPI *ExGetFirmwareEnvironmentVariableFn) (
- PUNICODE_STRING VariableName,
- LPGUID VendorGuid,
- PVOID Value,
- PULONG ValueLength,
- PULONG Attributes
-);
-
-typedef ULONG64 (NTAPI *KeQueryInterruptTimePreciseFn)(
- PULONG64 QpcTimeStamp
-);
-
-typedef BOOLEAN (NTAPI *KeAreAllApcsDisabledFn) ();
-
-typedef void (NTAPI *KeSetSystemGroupAffinityThreadFn)(
- PGROUP_AFFINITY Affinity,
- PGROUP_AFFINITY PreviousAffinity
-);
-
-typedef USHORT (NTAPI *KeQueryActiveGroupCountFn)();
-
-typedef ULONG (NTAPI *KeQueryActiveProcessorCountExFn)(
- USHORT GroupNumber
-);
-
-extern NTSTATUS NTAPI KeSaveExtendedProcessorStateVC (
- __in ULONG64 Mask,
- PXSTATE_SAVE XStateSave
- );
-
-
-extern VOID NTAPI KeRestoreExtendedProcessorStateVC (
- PXSTATE_SAVE XStateSave
- );
-
-extern BOOLEAN VC_KeAreAllApcsDisabled (VOID);
-
#else /* !TC_WINDOWS_DRIVER */
#if !defined(_UEFI)
diff --git a/src/Crypto/Camellia.c b/src/Crypto/Camellia.c
index 675fc0bd..3fd49023 100644
--- a/src/Crypto/Camellia.c
+++ b/src/Crypto/Camellia.c
@@ -1100,7 +1100,7 @@ void camellia_encrypt_blocks(unsigned __int8 *instance, const uint8* in_blk, uin
{
#if defined (TC_WINDOWS_DRIVER)
XSTATE_SAVE SaveState;
- if (NT_SUCCESS (KeSaveExtendedProcessorStateVC(XSTATE_MASK_GSSE, &SaveState)))
+ if (NT_SUCCESS (KeSaveExtendedProcessorState(XSTATE_MASK_GSSE, &SaveState)))
{
#endif
while (blockCount >= 16)
@@ -1111,7 +1111,7 @@ void camellia_encrypt_blocks(unsigned __int8 *instance, const uint8* in_blk, uin
blockCount -= 16;
}
#if defined (TC_WINDOWS_DRIVER)
- KeRestoreExtendedProcessorStateVC(&SaveState);
+ KeRestoreExtendedProcessorState(&SaveState);
}
#endif
}
@@ -1136,7 +1136,7 @@ void camellia_decrypt_blocks(unsigned __int8 *instance, const uint8* in_blk, uin
{
#if defined (TC_WINDOWS_DRIVER)
XSTATE_SAVE SaveState;
- if (NT_SUCCESS (KeSaveExtendedProcessorStateVC(XSTATE_MASK_GSSE, &SaveState)))
+ if (NT_SUCCESS (KeSaveExtendedProcessorState(XSTATE_MASK_GSSE, &SaveState)))
{
#endif
while (blockCount >= 16)
@@ -1147,7 +1147,7 @@ void camellia_decrypt_blocks(unsigned __int8 *instance, const uint8* in_blk, uin
blockCount -= 16;
}
#if defined (TC_WINDOWS_DRIVER)
- KeRestoreExtendedProcessorStateVC(&SaveState);
+ KeRestoreExtendedProcessorState(&SaveState);
}
#endif
}
diff --git a/src/Driver/DriveFilter.c b/src/Driver/DriveFilter.c
index 7503a8ee..a280d20e 100644
--- a/src/Driver/DriveFilter.c
+++ b/src/Driver/DriveFilter.c
@@ -363,7 +363,7 @@ static void ComputeBootLoaderFingerprint(PDEVICE_OBJECT LowerDeviceObject, uint8
NTSTATUS saveStatus = STATUS_INVALID_PARAMETER;
XSTATE_SAVE SaveState;
if (IsCpuIntel() && HasSAVX())
- saveStatus = KeSaveExtendedProcessorStateVC(XSTATE_MASK_GSSE, &SaveState);
+ saveStatus = KeSaveExtendedProcessorState(XSTATE_MASK_GSSE, &SaveState);
#endif
WHIRLPOOL_add (ioBuffer, TC_BOOT_SECTOR_PIM_VALUE_OFFSET, &whirlpool);
WHIRLPOOL_add (ioBuffer + TC_BOOT_SECTOR_USER_MESSAGE_OFFSET + TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH, (TC_BOOT_SECTOR_USER_CONFIG_OFFSET - (TC_BOOT_SECTOR_USER_MESSAGE_OFFSET + TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH)), &whirlpool);
@@ -401,7 +401,7 @@ static void ComputeBootLoaderFingerprint(PDEVICE_OBJECT LowerDeviceObject, uint8
#ifndef _M_ARM64
if (NT_SUCCESS(saveStatus))
- KeRestoreExtendedProcessorStateVC(&SaveState);
+ KeRestoreExtendedProcessorState(&SaveState);
#endif
}
else
@@ -978,7 +978,6 @@ static NTSTATUS DispatchPower (PDEVICE_OBJECT DeviceObject, PIRP Irp, DriveFilte
// Dismount the system drive on shutdown on Windows 7 and later
if (DriverShuttingDown
&& EraseKeysOnShutdown
- && IsOSAtLeast (WIN_7)
&& Extension->BootDrive
&& Extension->DriveMounted
&& irpSp->MinorFunction == IRP_MN_SET_POWER
diff --git a/src/Driver/Ntdriver.c b/src/Driver/Ntdriver.c
index e6b7af1f..ac2fb00a 100644
--- a/src/Driver/Ntdriver.c
+++ b/src/Driver/Ntdriver.c
@@ -142,14 +142,6 @@ static BOOL PagingFileCreationPrevented = FALSE;
static BOOL EnableExtendedIoctlSupport = FALSE;
static BOOL AllowTrimCommand = FALSE;
static BOOL RamEncryptionActivated = FALSE;
-static KeSaveExtendedProcessorStateFn KeSaveExtendedProcessorStatePtr = NULL;
-static KeRestoreExtendedProcessorStateFn KeRestoreExtendedProcessorStatePtr = NULL;
-static ExGetFirmwareEnvironmentVariableFn ExGetFirmwareEnvironmentVariablePtr = NULL;
-static KeQueryInterruptTimePreciseFn KeQueryInterruptTimePrecisePtr = NULL;
-static KeAreAllApcsDisabledFn KeAreAllApcsDisabledPtr = NULL;
-static KeSetSystemGroupAffinityThreadFn KeSetSystemGroupAffinityThreadPtr = NULL;
-static KeQueryActiveGroupCountFn KeQueryActiveGroupCountPtr = NULL;
-static KeQueryActiveProcessorCountExFn KeQueryActiveProcessorCountExPtr = NULL;
int EncryptionIoRequestCount = 0;
int EncryptionItemCount = 0;
int EncryptionFragmentSize = 0;
@@ -187,22 +179,15 @@ BOOL IsUefiBoot ()
Dump ("IsUefiBoot BEGIN\n");
ASSERT (KeGetCurrentIrql() == PASSIVE_LEVEL);
- if (ExGetFirmwareEnvironmentVariablePtr)
- {
- ULONG valueLengh = 0;
- UNICODE_STRING emptyName;
- GUID guid;
- RtlInitUnicodeString(&emptyName, L"");
- memset (&guid, 0, sizeof(guid));
- Dump ("IsUefiBoot calling ExGetFirmwareEnvironmentVariable\n");
- ntStatus = ExGetFirmwareEnvironmentVariablePtr (&emptyName, &guid, NULL, &valueLengh, NULL);
- Dump ("IsUefiBoot ExGetFirmwareEnvironmentVariable returned 0x%08x\n", ntStatus);
- }
- else
- {
- Dump ("IsUefiBoot ExGetFirmwareEnvironmentVariable not found on the system\n");
- }
-
+ ULONG valueLengh = 0;
+ UNICODE_STRING emptyName;
+ GUID guid;
+ RtlInitUnicodeString(&emptyName, L"");
+ memset (&guid, 0, sizeof(guid));
+ Dump ("IsUefiBoot calling ExGetFirmwareEnvironmentVariable\n");
+ ntStatus = ExGetFirmwareEnvironmentVariable (&emptyName, &guid, NULL, &valueLengh, NULL);
+ Dump ("IsUefiBoot ExGetFirmwareEnvironmentVariable returned 0x%08x\n", ntStatus);
+
if (STATUS_NOT_IMPLEMENTED != ntStatus)
bStatus = TRUE;
@@ -229,17 +214,10 @@ void GetDriverRandomSeed (unsigned char* pbRandSeed, size_t cbRandSeed)
iSeed = KeQueryPerformanceCounter (&iSeed2);
WHIRLPOOL_add ((unsigned char *) &(iSeed.QuadPart), sizeof(iSeed.QuadPart), &tctx);
WHIRLPOOL_add ((unsigned char *) &(iSeed2.QuadPart), sizeof(iSeed2.QuadPart), &tctx);
- if (KeQueryInterruptTimePrecisePtr)
- {
- iSeed.QuadPart = KeQueryInterruptTimePrecisePtr ((PULONG64) & iSeed2.QuadPart);
- WHIRLPOOL_add ((unsigned char *) &(iSeed.QuadPart), sizeof(iSeed.QuadPart), &tctx);
- WHIRLPOOL_add ((unsigned char *) &(iSeed2.QuadPart), sizeof(iSeed2.QuadPart), &tctx);
- }
- else
- {
- iSeed.QuadPart = KeQueryInterruptTime ();
- WHIRLPOOL_add ((unsigned char *) &(iSeed.QuadPart), sizeof(iSeed.QuadPart), &tctx);
- }
+
+ iSeed.QuadPart = KeQueryInterruptTimePrecise ((PULONG64) & iSeed2.QuadPart);
+ WHIRLPOOL_add ((unsigned char *) &(iSeed.QuadPart), sizeof(iSeed.QuadPart), &tctx);
+ WHIRLPOOL_add ((unsigned char *) &(iSeed2.QuadPart), sizeof(iSeed2.QuadPart), &tctx);
/* use JitterEntropy library to get good quality random bytes based on CPU timing jitter */
if (0 == jent_entropy_init ())
@@ -293,48 +271,6 @@ NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
Dump("OsMajorVersion=%d OsMinorVersion=%d\n", OsMajorVersion, OsMinorVersion);
- // KeAreAllApcsDisabled is available starting from Windows Server 2003
- if ((OsMajorVersion > 5) || (OsMajorVersion == 5 && OsMinorVersion >= 2))
- {
- UNICODE_STRING KeAreAllApcsDisabledFuncName;
- RtlInitUnicodeString(&KeAreAllApcsDisabledFuncName, L"KeAreAllApcsDisabled");
-
- KeAreAllApcsDisabledPtr = (KeAreAllApcsDisabledFn)MmGetSystemRoutineAddress(&KeAreAllApcsDisabledFuncName);
- }
-
- // KeSaveExtendedProcessorState/KeRestoreExtendedProcessorState are available starting from Windows 7
- // KeQueryActiveGroupCount/KeQueryActiveProcessorCountEx/KeSetSystemGroupAffinityThread are available starting from Windows 7
- if ((OsMajorVersion > 6) || (OsMajorVersion == 6 && OsMinorVersion >= 1))
- {
- UNICODE_STRING saveFuncName, restoreFuncName, groupCountFuncName, procCountFuncName, setAffinityFuncName;
- RtlInitUnicodeString(&saveFuncName, L"KeSaveExtendedProcessorState");
- RtlInitUnicodeString(&restoreFuncName, L"KeRestoreExtendedProcessorState");
- RtlInitUnicodeString(&groupCountFuncName, L"KeQueryActiveGroupCount");
- RtlInitUnicodeString(&procCountFuncName, L"KeQueryActiveProcessorCountEx");
- RtlInitUnicodeString(&setAffinityFuncName, L"KeSetSystemGroupAffinityThread");
- KeSaveExtendedProcessorStatePtr = (KeSaveExtendedProcessorStateFn)MmGetSystemRoutineAddress(&saveFuncName);
- KeRestoreExtendedProcessorStatePtr = (KeRestoreExtendedProcessorStateFn)MmGetSystemRoutineAddress(&restoreFuncName);
- KeSetSystemGroupAffinityThreadPtr = (KeSetSystemGroupAffinityThreadFn)MmGetSystemRoutineAddress(&setAffinityFuncName);
- KeQueryActiveGroupCountPtr = (KeQueryActiveGroupCountFn)MmGetSystemRoutineAddress(&groupCountFuncName);
- KeQueryActiveProcessorCountExPtr = (KeQueryActiveProcessorCountExFn)MmGetSystemRoutineAddress(&procCountFuncName);
- }
-
- // ExGetFirmwareEnvironmentVariable is available starting from Windows 8
- if ((OsMajorVersion > 6) || (OsMajorVersion == 6 && OsMinorVersion >= 2))
- {
- UNICODE_STRING funcName;
- RtlInitUnicodeString(&funcName, L"ExGetFirmwareEnvironmentVariable");
- ExGetFirmwareEnvironmentVariablePtr = (ExGetFirmwareEnvironmentVariableFn)MmGetSystemRoutineAddress(&funcName);
- }
-
- // KeQueryInterruptTimePrecise is available starting from Windows 8.1
- if ((OsMajorVersion > 6) || (OsMajorVersion == 6 && OsMinorVersion >= 3))
- {
- UNICODE_STRING funcName;
- RtlInitUnicodeString(&funcName, L"KeQueryInterruptTimePrecise");
- KeQueryInterruptTimePrecisePtr = (KeQueryInterruptTimePreciseFn)MmGetSystemRoutineAddress(&funcName);
- }
-
// Load dump filter if the main driver is already loaded
if (NT_SUCCESS(TCDeviceIoControl(NT_ROOT_PREFIX, TC_IOCTL_GET_DRIVER_VERSION, NULL, 0, &version, sizeof(version))))
return DumpFilterEntry((PFILTER_EXTENSION)DriverObject, (PFILTER_INITIALIZATION_DATA)RegistryPath);
@@ -994,7 +930,7 @@ NTSTATUS ProcessVolumeDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION
case IOCTL_DISK_GET_DRIVE_GEOMETRY_EX:
Dump ("ProcessVolumeDeviceControlIrp (IOCTL_DISK_GET_DRIVE_GEOMETRY_EX)\n");
{
- ULONG minOutputSize = IsOSAtLeast (WIN_SERVER_2003)? sizeof (DISK_GEOMETRY_EX) : sizeof (DISK_GEOMETRY) + sizeof (LARGE_INTEGER);
+ ULONG minOutputSize = sizeof (DISK_GEOMETRY_EX);
ULONG fullOutputSize = sizeof (DISK_GEOMETRY) + sizeof (LARGE_INTEGER) + sizeof (DISK_PARTITION_INFO) + sizeof (DISK_DETECTION_INFO);
if (ValidateIOBufferSize (Irp, minOutputSize, ValidateOutput))
@@ -3463,7 +3399,7 @@ NTSTATUS TCDeviceIoControl (PWSTR deviceName, ULONG IoControlCode, void *InputBu
KEVENT event;
UNICODE_STRING name;
- if ((KeGetCurrentIrql() >= APC_LEVEL) || VC_KeAreAllApcsDisabled())
+ if ((KeGetCurrentIrql() >= APC_LEVEL) || KeAreAllApcsDisabled())
{
TCDeviceIoControlWorkItemArgs args;
@@ -3548,7 +3484,7 @@ NTSTATUS SendDeviceIoControlRequest (PDEVICE_OBJECT deviceObject, ULONG ioContro
PIRP irp;
KEVENT event;
- if ((KeGetCurrentIrql() >= APC_LEVEL) || VC_KeAreAllApcsDisabled())
+ if ((KeGetCurrentIrql() >= APC_LEVEL) || KeAreAllApcsDisabled())
{
SendDeviceIoControlRequestWorkItemArgs args;
@@ -3893,7 +3829,7 @@ static NTSTATUS UpdateFsVolumeInformation (MOUNT_STRUCT* mount, PEXTENSION NewEx
BOOL bIsNTFS = FALSE;
ULONG labelMaxLen, labelEffectiveLen;
- if ((KeGetCurrentIrql() >= APC_LEVEL) || VC_KeAreAllApcsDisabled())
+ if ((KeGetCurrentIrql() >= APC_LEVEL) || KeAreAllApcsDisabled())
{
UpdateFsVolumeInformationWorkItemArgs args;
@@ -4160,7 +4096,7 @@ NTSTATUS UnmountDevice (UNMOUNT_STRUCT *unmountRequest, PDEVICE_OBJECT deviceObj
HANDLE volumeHandle;
PFILE_OBJECT volumeFileObject;
- if ((KeGetCurrentIrql() >= APC_LEVEL) || VC_KeAreAllApcsDisabled())
+ if ((KeGetCurrentIrql() >= APC_LEVEL) || KeAreAllApcsDisabled())
{
UnmountDeviceWorkItemArgs args;
@@ -4190,7 +4126,7 @@ NTSTATUS UnmountDevice (UNMOUNT_STRUCT *unmountRequest, PDEVICE_OBJECT deviceObj
int dismountRetry;
// Dismounting a writable NTFS filesystem prevents the driver from being unloaded on Windows 7
- if (IsOSAtLeast (WIN_7) && !extension->bReadOnly)
+ if (!extension->bReadOnly)
{
NTFS_VOLUME_DATA_BUFFER ntfsData;
@@ -4454,33 +4390,14 @@ NTSTATUS TCCompleteDiskIrp (PIRP irp, NTSTATUS status, ULONG_PTR information)
size_t GetCpuCount (WORD* pGroupCount)
{
size_t cpuCount = 0;
- if (KeQueryActiveGroupCountPtr && KeQueryActiveProcessorCountExPtr)
+ USHORT i, groupCount = KeQueryActiveGroupCount ();
+ for (i = 0; i < groupCount; i++)
{
- USHORT i, groupCount = KeQueryActiveGroupCountPtr ();
- for (i = 0; i < groupCount; i++)
- {
- cpuCount += (size_t) KeQueryActiveProcessorCountExPtr (i);
- }
-
- if (pGroupCount)
- *pGroupCount = groupCount;
+ cpuCount += (size_t) KeQueryActiveProcessorCountEx (i);
}
- else
- {
- KAFFINITY activeCpuMap = KeQueryActiveProcessors();
- size_t mapSize = sizeof (activeCpuMap) * 8;
-
- while (mapSize--)
- {
- if (activeCpuMap & 1)
- ++cpuCount;
- activeCpuMap >>= 1;
- }
-
- if (pGroupCount)
- *pGroupCount = 1;
- }
+ if (pGroupCount)
+ *pGroupCount = groupCount;
if (cpuCount == 0)
return 1;
@@ -4490,17 +4407,14 @@ size_t GetCpuCount (WORD* pGroupCount)
USHORT GetCpuGroup (size_t index)
{
- if (KeQueryActiveGroupCountPtr && KeQueryActiveProcessorCountExPtr)
+ USHORT i, groupCount = KeQueryActiveGroupCount ();
+ size_t cpuCount = 0;
+ for (i = 0; i < groupCount; i++)
{
- USHORT i, groupCount = KeQueryActiveGroupCountPtr ();
- size_t cpuCount = 0;
- for (i = 0; i < groupCount; i++)
+ cpuCount += (size_t) KeQueryActiveProcessorCountEx (i);
+ if (cpuCount >= index)
{
- cpuCount += (size_t) KeQueryActiveProcessorCountExPtr (i);
- if (cpuCount >= index)
- {
- return i;
- }
+ return i;
}
}
@@ -4509,13 +4423,10 @@ USHORT GetCpuGroup (size_t index)
void SetThreadCpuGroupAffinity (USHORT index)
{
- if (KeSetSystemGroupAffinityThreadPtr)
- {
- GROUP_AFFINITY groupAffinity = {0};
- groupAffinity.Mask = ~0ULL;
- groupAffinity.Group = index;
- KeSetSystemGroupAffinityThreadPtr (&groupAffinity, NULL);
- }
+ GROUP_AFFINITY groupAffinity = {0};
+ groupAffinity.Mask = ~0ULL;
+ groupAffinity.Group = index;
+ KeSetSystemGroupAffinityThread (&groupAffinity, NULL);
}
void EnsureNullTerminatedString (wchar_t *str, size_t maxSizeInBytes)
@@ -4958,36 +4869,3 @@ BOOL IsOSAtLeast (OSVersionEnum reqMinOS)
return ((OsMajorVersion << 16 | OsMinorVersion << 8)
>= (major << 16 | minor << 8));
}
-
-NTSTATUS NTAPI KeSaveExtendedProcessorStateVC (
- __in ULONG64 Mask,
- PXSTATE_SAVE XStateSave
- )
-{
- if (KeSaveExtendedProcessorStatePtr)
- {
- return (KeSaveExtendedProcessorStatePtr) (Mask, XStateSave);
- }
- else
- {
- return STATUS_SUCCESS;
- }
-}
-
-VOID NTAPI KeRestoreExtendedProcessorStateVC (
- PXSTATE_SAVE XStateSave
- )
-{
- if (KeRestoreExtendedProcessorStatePtr)
- {
- (KeRestoreExtendedProcessorStatePtr) (XStateSave);
- }
-}
-
-BOOLEAN VC_KeAreAllApcsDisabled (VOID)
-{
- if (KeAreAllApcsDisabledPtr)
- return (KeAreAllApcsDisabledPtr) ();
- else
- return FALSE;
-}
diff --git a/src/Driver/Ntvol.c b/src/Driver/Ntvol.c
index 7bd59831..0376033f 100644
--- a/src/Driver/Ntvol.c
+++ b/src/Driver/Ntvol.c
@@ -947,7 +947,7 @@ NTSTATUS TCSendHostDeviceIoControlRequestEx (PDEVICE_OBJECT DeviceObject,
UNREFERENCED_PARAMETER(DeviceObject); /* Remove compiler warning */
- if ((KeGetCurrentIrql() >= APC_LEVEL) || VC_KeAreAllApcsDisabled())
+ if ((KeGetCurrentIrql() >= APC_LEVEL) || KeAreAllApcsDisabled())
{
TCSendHostDeviceIoControlRequestExWorkItemArgs args;