VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Driver
diff options
context:
space:
mode:
Diffstat (limited to 'src/Driver')
-rw-r--r--src/Driver/DriveFilter.c121
-rw-r--r--src/Driver/DriveFilter.h17
-rw-r--r--src/Driver/DumpFilter.c6
-rw-r--r--src/Driver/EncryptedIoQueue.c4
-rw-r--r--src/Driver/Ntdriver.c232
-rw-r--r--src/Driver/Ntvol.c158
-rw-r--r--src/Driver/VolumeFilter.c6
7 files changed, 220 insertions, 324 deletions
diff --git a/src/Driver/DriveFilter.c b/src/Driver/DriveFilter.c
index 6fda3c37..140c31d1 100644
--- a/src/Driver/DriveFilter.c
+++ b/src/Driver/DriveFilter.c
@@ -359,15 +359,11 @@ static void ComputeBootLoaderFingerprint(PDEVICE_OBJECT LowerDeviceObject, uint8
status = TCReadDevice (LowerDeviceObject, ioBuffer, offset, TC_SECTOR_SIZE_BIOS);
if (NT_SUCCESS (status))
{
+#ifndef _M_ARM64
NTSTATUS saveStatus = STATUS_INVALID_PARAMETER;
-#ifdef _WIN64
XSTATE_SAVE SaveState;
if (IsCpuIntel() && HasSAVX())
saveStatus = KeSaveExtendedProcessorStateVC(XSTATE_MASK_GSSE, &SaveState);
-#else
- KFLOATING_SAVE floatingPointState;
- if (HasISSE() || (HasSSSE3() && HasMMX()))
- saveStatus = KeSaveFloatingPointState (&floatingPointState);
#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);
@@ -403,11 +399,9 @@ static void ComputeBootLoaderFingerprint(PDEVICE_OBJECT LowerDeviceObject, uint8
sha512_end (&BootLoaderFingerprint [WHIRLPOOL_DIGESTSIZE], &sha2);
}
- if (NT_SUCCESS (saveStatus))
-#ifdef _WIN64
+#ifndef _M_ARM64
+ if (NT_SUCCESS(saveStatus))
KeRestoreExtendedProcessorStateVC(&SaveState);
-#else
- KeRestoreFloatingPointState (&floatingPointState);
#endif
}
else
@@ -423,7 +417,7 @@ static NTSTATUS MountDrive (DriveFilterExtension *Extension, Password *password,
int64 hiddenHeaderOffset = BootArgs.HiddenSystemPartitionStart + TC_HIDDEN_VOLUME_HEADER_OFFSET;
NTSTATUS status;
LARGE_INTEGER offset;
- char *header;
+ unsigned char *header;
int pkcs5_prf = 0, pim = 0;
PARTITION_INFORMATION_EX pi;
BOOL bIsGPT = FALSE;
@@ -662,19 +656,12 @@ static NTSTATUS MountDrive (DriveFilterExtension *Extension, Password *password,
if (!NT_SUCCESS (status))
TC_BUG_CHECK (status);
- if (IsOSAtLeast (WIN_VISTA))
+ CrashDumpEnabled = TRUE;
+ HibernationEnabled = TRUE;
+ if (IsRamEncryptionEnabled())
{
- CrashDumpEnabled = TRUE;
- HibernationEnabled = TRUE;
-#ifdef _WIN64
- if (IsRamEncryptionEnabled())
- {
- HibernationEnabled = FALSE;
- }
-#endif
+ HibernationEnabled = FALSE;
}
- else if (!LegacyHibernationDriverFilterActive)
- StartLegacyHibernationDriverFilter();
// Hidden system hibernation is not supported if an extra boot partition is present as the system is not allowed to update the boot partition
if (IsHiddenSystemRunning() && (BootArgs.Flags & TC_BOOT_ARGS_FLAG_EXTRA_BOOT_PARTITION))
@@ -866,6 +853,7 @@ static void CheckDeviceTypeAndMount (DriveFilterExtension *filterExtension)
static VOID MountDriveWorkItemRoutine (PDEVICE_OBJECT deviceObject, DriveFilterExtension *filterExtension)
{
+ UNREFERENCED_PARAMETER(deviceObject);
CheckDeviceTypeAndMount (filterExtension);
KeSetEvent (&filterExtension->MountWorkItemCompletedEvent, IO_NO_INCREMENT, FALSE);
}
@@ -983,6 +971,7 @@ static NTSTATUS DispatchPnp (PDEVICE_OBJECT DeviceObject, PIRP Irp, DriveFilterE
static NTSTATUS DispatchPower (PDEVICE_OBJECT DeviceObject, PIRP Irp, DriveFilterExtension *Extension, PIO_STACK_LOCATION irpSp)
{
NTSTATUS status;
+ UNREFERENCED_PARAMETER(DeviceObject);
Dump ("IRP_MJ_POWER minor=%d type=%d shutdown=%d\n", (int) irpSp->MinorFunction, (int) irpSp->Parameters.Power.Type, (int) irpSp->Parameters.Power.ShutdownType);
if (SetupInProgress
@@ -1024,6 +1013,7 @@ static NTSTATUS DispatchControl (PDEVICE_OBJECT DeviceObject, PIRP Irp, DriveFil
{
BOOL bBlockTrim = BlockSystemTrimCommand || IsHiddenSystemRunning();
NTSTATUS status = IoAcquireRemoveLock (&Extension->Queue.RemoveLock, Irp);
+ UNREFERENCED_PARAMETER(DeviceObject);
if (!NT_SUCCESS (status))
return TCCompleteIrp (Irp, status, 0);
@@ -1033,7 +1023,6 @@ static NTSTATUS DispatchControl (PDEVICE_OBJECT DeviceObject, PIRP Irp, DriveFil
Dump ("DriverFilter-DispatchControl: IOCTL_STORAGE_MANAGE_DATA_SET_ATTRIBUTES\n");
if (bBlockTrim)
{
- PIO_STACK_LOCATION irpSp = IoGetCurrentIrpStackLocation (Irp);
DWORD inputLength = irpSp->Parameters.DeviceIoControl.InputBufferLength;
if (inputLength >= sizeof (DEVICE_MANAGE_DATA_SET_ATTRIBUTES))
{
@@ -1109,7 +1098,7 @@ NTSTATUS DriveFilterDispatchIrp (PDEVICE_OBJECT DeviceObject, PIRP Irp)
return status;
}
-void EmergencyClearAllKeys (PIRP irp, PIO_STACK_LOCATION irpSp)
+void EmergencyClearAllKeys (PIRP irp)
{
irp->IoStatus.Information = 0;
@@ -1136,18 +1125,16 @@ void EmergencyClearAllKeys (PIRP irp, PIO_STACK_LOCATION irpSp)
if (BootDriveFound && BootDriveFilterExtension && BootDriveFilterExtension->DriveMounted)
InvalidateDriveFilterKeys (BootDriveFilterExtension);
-#ifdef _WIN64
ClearSecurityParameters();
-#endif
irp->IoStatus.Status = STATUS_SUCCESS;
}
}
-void ReopenBootVolumeHeader (PIRP irp, PIO_STACK_LOCATION irpSp)
+void ReopenBootVolumeHeader (PIRP irp)
{
LARGE_INTEGER offset;
- char *header;
+ unsigned char *header;
ReopenBootVolumeHeaderRequest *request = (ReopenBootVolumeHeaderRequest *) irp->AssociatedIrp.SystemBuffer;
irp->IoStatus.Information = 0;
@@ -1192,22 +1179,20 @@ void ReopenBootVolumeHeader (PIRP irp, PIO_STACK_LOCATION irpSp)
goto ret;
}
-#ifdef _WIN64
if (IsRamEncryptionEnabled())
{
VcUnprotectKeys (BootDriveFilterExtension->HeaderCryptoInfo, VcGetEncryptionID (BootDriveFilterExtension->HeaderCryptoInfo));
}
-#endif
if (ReadVolumeHeader (!BootDriveFilterExtension->HiddenSystem, header, &request->VolumePassword, request->pkcs5_prf, request->pim, NULL, BootDriveFilterExtension->HeaderCryptoInfo) == 0)
{
Dump ("Header reopened\n");
-#ifdef _WIN64
+
if (IsRamEncryptionEnabled())
{
VcProtectKeys (BootDriveFilterExtension->HeaderCryptoInfo, VcGetEncryptionID(BootDriveFilterExtension->HeaderCryptoInfo));
}
-#endif
+
ComputeBootLoaderFingerprint (BootDriveFilterExtension->LowerDeviceObject, header);
BootDriveFilterExtension->Queue.CryptoInfo->pkcs5 = BootDriveFilterExtension->HeaderCryptoInfo->pkcs5;
@@ -1458,6 +1443,8 @@ static VOID LoadImageNotifyRoutine (PUNICODE_STRING fullImageName, HANDLE proces
ModuleTableItem *moduleItem;
LIST_ENTRY *listEntry;
KIRQL origIrql;
+ UNREFERENCED_PARAMETER(fullImageName);
+ UNREFERENCED_PARAMETER(processId);
if (!imageInfo || !imageInfo->SystemModeImage || !imageInfo->ImageBase || !TCDriverObject->DriverSection)
return;
@@ -1512,62 +1499,6 @@ static VOID LoadImageNotifyRoutine (PUNICODE_STRING fullImageName, HANDLE proces
}
-void StartLegacyHibernationDriverFilter ()
-{
- PHYSICAL_ADDRESS highestAcceptableWriteBufferAddr;
- NTSTATUS status;
-
- ASSERT (KeGetCurrentIrql() == PASSIVE_LEVEL);
- ASSERT (!IsOSAtLeast (WIN_VISTA));
-
- if (!TCDriverObject->DriverSection || !*(ModuleTableItem **) TCDriverObject->DriverSection)
- goto err;
-
- // All buffers required for hibernation must be allocated here
-#ifdef _WIN64
- highestAcceptableWriteBufferAddr.QuadPart = 0x7FFffffFFFFULL;
-#else
- highestAcceptableWriteBufferAddr.QuadPart = 0xffffFFFFULL;
-#endif
-
- HibernationWriteBuffer = MmAllocateContiguousMemory (TC_HIBERNATION_WRITE_BUFFER_SIZE, highestAcceptableWriteBufferAddr);
- if (!HibernationWriteBuffer)
- goto err;
-
- HibernationWriteBufferMdl = IoAllocateMdl (HibernationWriteBuffer, TC_HIBERNATION_WRITE_BUFFER_SIZE, FALSE, FALSE, NULL);
- if (!HibernationWriteBufferMdl)
- goto err;
-
- MmBuildMdlForNonPagedPool (HibernationWriteBufferMdl);
-
- status = PsSetLoadImageNotifyRoutine (LoadImageNotifyRoutine);
- if (!NT_SUCCESS (status))
- goto err;
-
- LegacyHibernationDriverFilterActive = TRUE;
- CrashDumpEnabled = FALSE;
- HibernationEnabled = TRUE;
- return;
-
-err:
- LegacyHibernationDriverFilterActive = FALSE;
- CrashDumpEnabled = FALSE;
- HibernationEnabled = FALSE;
-
- if (HibernationWriteBufferMdl)
- {
- IoFreeMdl (HibernationWriteBufferMdl);
- HibernationWriteBufferMdl = NULL;
- }
-
- if (HibernationWriteBuffer)
- {
- MmFreeContiguousMemory (HibernationWriteBuffer);
- HibernationWriteBuffer = NULL;
- }
-}
-
-
static VOID SetupThreadProc (PVOID threadArg)
{
DriveFilterExtension *Extension = BootDriveFilterExtension;
@@ -1590,6 +1521,7 @@ static VOID SetupThreadProc (PVOID threadArg)
// wipeRandCharsUpdate instead of relying on uninitialized stack memory
ChaCha20RngCtx rngCtx;
uint8 pbSeed[CHACHA20RNG_KEYSZ + CHACHA20RNG_IVSZ];
+ UNREFERENCED_PARAMETER(threadArg);
GetDriverRandomSeed (pbSeed, sizeof (pbSeed));
ChaCha20RngInit (&rngCtx, pbSeed, GetDriverRandomSeed, 0);
@@ -1951,7 +1883,7 @@ NTSTATUS StartBootEncryptionSetup (PDEVICE_OBJECT DeviceObject, PIRP irp, PIO_ST
}
-void GetBootDriveVolumeProperties (PIRP irp, PIO_STACK_LOCATION irpSp)
+void GetBootDriveVolumeProperties (PIRP irp)
{
if (ValidateIOBufferSize (irp, sizeof (VOLUME_PROPERTIES_STRUCT), ValidateOutput))
{
@@ -1989,7 +1921,7 @@ void GetBootDriveVolumeProperties (PIRP irp, PIO_STACK_LOCATION irpSp)
}
-void GetBootEncryptionStatus (PIRP irp, PIO_STACK_LOCATION irpSp)
+void GetBootEncryptionStatus (PIRP irp)
{
/* IMPORTANT: Do NOT add any potentially time-consuming operations to this function. */
@@ -2051,7 +1983,7 @@ void GetBootEncryptionStatus (PIRP irp, PIO_STACK_LOCATION irpSp)
}
-void GetBootLoaderVersion (PIRP irp, PIO_STACK_LOCATION irpSp)
+void GetBootLoaderVersion (PIRP irp)
{
if (ValidateIOBufferSize (irp, sizeof (uint16), ValidateOutput))
{
@@ -2069,7 +2001,7 @@ void GetBootLoaderVersion (PIRP irp, PIO_STACK_LOCATION irpSp)
}
}
-void GetBootLoaderFingerprint (PIRP irp, PIO_STACK_LOCATION irpSp)
+void GetBootLoaderFingerprint (PIRP irp)
{
if (ValidateIOBufferSize (irp, sizeof (BootLoaderFingerprintRequest), ValidateOutput))
{
@@ -2079,7 +2011,7 @@ void GetBootLoaderFingerprint (PIRP irp, PIO_STACK_LOCATION irpSp)
BootLoaderFingerprintRequest *bootLoaderFingerprint = (BootLoaderFingerprintRequest *) irp->AssociatedIrp.SystemBuffer;
/* compute the fingerprint again and check if it is the same as the one retrieved during boot */
- char *header = TCalloc (TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE);
+ unsigned char *header = TCalloc (TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE);
if (!header)
{
irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES;
@@ -2111,7 +2043,7 @@ void GetBootLoaderFingerprint (PIRP irp, PIO_STACK_LOCATION irpSp)
}
}
-void GetBootEncryptionAlgorithmName (PIRP irp, PIO_STACK_LOCATION irpSp)
+void GetBootEncryptionAlgorithmName (PIRP irp)
{
if (ValidateIOBufferSize (irp, sizeof (GetBootEncryptionAlgorithmNameRequest), ValidateOutput))
{
@@ -2193,6 +2125,7 @@ NTSTATUS AbortBootEncryptionSetup ()
static VOID DecoySystemWipeThreadProc (PVOID threadArg)
{
+ UNREFERENCED_PARAMETER(threadArg);
DriveFilterExtension *Extension = BootDriveFilterExtension;
LARGE_INTEGER offset;
@@ -2376,7 +2309,7 @@ BOOL IsDecoySystemWipeInProgress()
}
-void GetDecoySystemWipeStatus (PIRP irp, PIO_STACK_LOCATION irpSp)
+void GetDecoySystemWipeStatus (PIRP irp)
{
if (ValidateIOBufferSize (irp, sizeof (DecoySystemWipeStatus), ValidateOutput))
{
diff --git a/src/Driver/DriveFilter.h b/src/Driver/DriveFilter.h
index b164fa5b..307880fb 100644
--- a/src/Driver/DriveFilter.h
+++ b/src/Driver/DriveFilter.h
@@ -59,11 +59,11 @@ extern PKTHREAD DecoySystemWipeThread;
NTSTATUS AbortBootEncryptionSetup ();
NTSTATUS DriveFilterAddDevice (PDRIVER_OBJECT driverObject, PDEVICE_OBJECT pdo);
NTSTATUS DriveFilterDispatchIrp (PDEVICE_OBJECT DeviceObject, PIRP Irp);
-void GetBootDriveVolumeProperties (PIRP irp, PIO_STACK_LOCATION irpSp);
-void GetBootEncryptionAlgorithmName (PIRP irp, PIO_STACK_LOCATION irpSp);
-void GetBootEncryptionStatus (PIRP irp, PIO_STACK_LOCATION irpSp);
-void GetBootLoaderVersion (PIRP irp, PIO_STACK_LOCATION irpSp);
-void GetBootLoaderFingerprint (PIRP irp, PIO_STACK_LOCATION irpSp);
+void GetBootDriveVolumeProperties (PIRP irp);
+void GetBootEncryptionAlgorithmName (PIRP irp);
+void GetBootEncryptionStatus (PIRP irp);
+void GetBootLoaderVersion (PIRP irp);
+void GetBootLoaderFingerprint (PIRP irp);
NTSTATUS GetSetupResult ();
DriveFilterExtension *GetBootDriveFilterExtension ();
CRYPTO_INFO *GetSystemDriveCryptoInfo ();
@@ -73,14 +73,13 @@ BOOL IsHiddenSystemRunning ();
NTSTATUS LoadBootArguments (BOOL bIsEfi);
static NTSTATUS SaveDriveVolumeHeader (DriveFilterExtension *Extension);
NTSTATUS StartBootEncryptionSetup (PDEVICE_OBJECT DeviceObject, PIRP irp, PIO_STACK_LOCATION irpSp);
-void EmergencyClearAllKeys (PIRP irp, PIO_STACK_LOCATION irpSp);
-void ReopenBootVolumeHeader (PIRP irp, PIO_STACK_LOCATION irpSp);
+void EmergencyClearAllKeys (PIRP irp);
+void ReopenBootVolumeHeader (PIRP irp);
NTSTATUS StartDecoySystemWipe (PDEVICE_OBJECT DeviceObject, PIRP irp, PIO_STACK_LOCATION irpSp);
-void StartLegacyHibernationDriverFilter ();
NTSTATUS AbortDecoySystemWipe ();
BOOL IsDecoySystemWipeInProgress();
NTSTATUS GetDecoySystemWipeResult();
-void GetDecoySystemWipeStatus (PIRP irp, PIO_STACK_LOCATION irpSp);
+void GetDecoySystemWipeStatus (PIRP irp);
uint64 GetBootDriveLength ();
NTSTATUS WriteBootDriveSector (PIRP irp, PIO_STACK_LOCATION irpSp);
diff --git a/src/Driver/DumpFilter.c b/src/Driver/DumpFilter.c
index aa059d9d..94a130d9 100644
--- a/src/Driver/DumpFilter.c
+++ b/src/Driver/DumpFilter.c
@@ -158,6 +158,7 @@ err:
static NTSTATUS DumpFilterStart (PFILTER_EXTENSION filterExtension)
{
+ UNREFERENCED_PARAMETER(filterExtension);
Dump ("DumpFilterStart type=%d\n", filterExtension->DumpType);
if (BootDriveFilterExtension->MagicNumber != TC_BOOT_DRIVE_FILTER_EXTENSION_MAGIC_NUMBER)
@@ -175,6 +176,7 @@ static NTSTATUS DumpFilterWrite (PFILTER_EXTENSION filterExtension, PLARGE_INTEG
uint32 intersectLength;
PVOID writeBuffer;
CSHORT origMdlFlags;
+ UNREFERENCED_PARAMETER(filterExtension);
if (BootDriveFilterExtension->MagicNumber != TC_BOOT_DRIVE_FILTER_EXTENSION_MAGIC_NUMBER)
TC_BUG_CHECK (STATUS_CRC_ERROR);
@@ -194,7 +196,7 @@ static NTSTATUS DumpFilterWrite (PFILTER_EXTENSION filterExtension, PLARGE_INTEG
if ((offset & (ENCRYPTION_DATA_UNIT_SIZE - 1)) != 0)
TC_BUG_CHECK (STATUS_INVALID_PARAMETER);
- writeBuffer = MmGetSystemAddressForMdlSafe (writeMdl, (HighPagePriority | ExDefaultMdlProtection));
+ writeBuffer = MmGetSystemAddressForMdlSafe (writeMdl, (HighPagePriority | MdlMappingNoExecute));
if (!writeBuffer)
TC_BUG_CHECK (STATUS_INSUFFICIENT_RESOURCES);
@@ -242,6 +244,7 @@ static NTSTATUS DumpFilterWrite (PFILTER_EXTENSION filterExtension, PLARGE_INTEG
static NTSTATUS DumpFilterFinish (PFILTER_EXTENSION filterExtension)
{
+ UNREFERENCED_PARAMETER(filterExtension);
Dump ("DumpFilterFinish type=%d\n", filterExtension->DumpType);
return STATUS_SUCCESS;
@@ -250,6 +253,7 @@ static NTSTATUS DumpFilterFinish (PFILTER_EXTENSION filterExtension)
static NTSTATUS DumpFilterUnload (PFILTER_EXTENSION filterExtension)
{
+ UNREFERENCED_PARAMETER(filterExtension);
Dump ("DumpFilterUnload type=%d\n", filterExtension->DumpType);
if (WriteFilterBuffer)
diff --git a/src/Driver/EncryptedIoQueue.c b/src/Driver/EncryptedIoQueue.c
index 8c2e8a41..61bfe7dd 100644
--- a/src/Driver/EncryptedIoQueue.c
+++ b/src/Driver/EncryptedIoQueue.c
@@ -640,7 +640,7 @@ static VOID MainThreadProc (PVOID threadArg)
{
UINT64_STRUCT dataUnit;
- dataBuffer = (PUCHAR) MmGetSystemAddressForMdlSafe (irp->MdlAddress, (HighPagePriority | ExDefaultMdlProtection));
+ dataBuffer = (PUCHAR) MmGetSystemAddressForMdlSafe (irp->MdlAddress, (HighPagePriority | MdlMappingNoExecute));
if (!dataBuffer)
{
TCfree (buffer);
@@ -760,7 +760,7 @@ static VOID MainThreadProc (PVOID threadArg)
continue;
}
- dataBuffer = (PUCHAR) MmGetSystemAddressForMdlSafe (irp->MdlAddress, (HighPagePriority | ExDefaultMdlProtection));
+ dataBuffer = (PUCHAR) MmGetSystemAddressForMdlSafe (irp->MdlAddress, (HighPagePriority | MdlMappingNoExecute));
if (dataBuffer == NULL)
{
diff --git a/src/Driver/Ntdriver.c b/src/Driver/Ntdriver.c
index 96f60cdd..0edc6941 100644
--- a/src/Driver/Ntdriver.c
+++ b/src/Driver/Ntdriver.c
@@ -154,9 +154,6 @@ int EncryptionIoRequestCount = 0;
int EncryptionItemCount = 0;
int EncryptionFragmentSize = 0;
-POOL_TYPE ExDefaultNonPagedPoolType = NonPagedPool;
-ULONG ExDefaultMdlProtection = 0;
-
PDEVICE_OBJECT VirtualVolumeDeviceObjects[MAX_MOUNTED_VOLUME_DRIVE_NUMBER + 1];
BOOL AlignValue (ULONG ulValue, ULONG ulAlignment, ULONG *pulResult)
@@ -241,7 +238,7 @@ void GetDriverRandomSeed (unsigned char* pbRandSeed, size_t cbRandSeed)
WHIRLPOOL_add ((unsigned char *) &(iSeed2.QuadPart), sizeof(iSeed2.QuadPart), &tctx);
if (KeQueryInterruptTimePrecisePtr)
{
- iSeed.QuadPart = KeQueryInterruptTimePrecisePtr (&iSeed2.QuadPart);
+ 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);
}
@@ -294,26 +291,19 @@ void GetDriverRandomSeed (unsigned char* pbRandSeed, size_t cbRandSeed)
}
-NTSTATUS DriverEntry (PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
+NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
{
PKEY_VALUE_PARTIAL_INFORMATION startKeyValue;
LONG version;
int i;
- Dump ("DriverEntry " TC_APP_NAME " " VERSION_STRING VERSION_STRING_SUFFIX "\n");
-
- DetectX86Features ();
+ Dump("DriverEntry " TC_APP_NAME " " VERSION_STRING VERSION_STRING_SUFFIX "\n");
- PsGetVersion (&OsMajorVersion, &OsMinorVersion, NULL, NULL);
+ DetectX86Features();
- Dump ("OsMajorVersion=%d OsMinorVersion=%d\n", OsMajorVersion, OsMinorVersion);
+ PsGetVersion(&OsMajorVersion, &OsMinorVersion, NULL, NULL);
- // NX pool support is available starting from Windows 8
- if ((OsMajorVersion > 6) || (OsMajorVersion == 6 && OsMinorVersion >= 2))
- {
- ExDefaultNonPagedPoolType = (POOL_TYPE) NonPagedPoolNx;
- ExDefaultMdlProtection = MdlMappingNoExecute;
- }
+ Dump("OsMajorVersion=%d OsMinorVersion=%d\n", OsMajorVersion, OsMinorVersion);
// KeAreAllApcsDisabled is available starting from Windows Server 2003
if ((OsMajorVersion > 5) || (OsMajorVersion == 5 && OsMinorVersion >= 2))
@@ -321,7 +311,7 @@ NTSTATUS DriverEntry (PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
UNICODE_STRING KeAreAllApcsDisabledFuncName;
RtlInitUnicodeString(&KeAreAllApcsDisabledFuncName, L"KeAreAllApcsDisabled");
- KeAreAllApcsDisabledPtr = (KeAreAllApcsDisabledFn) MmGetSystemRoutineAddress(&KeAreAllApcsDisabledFuncName);
+ KeAreAllApcsDisabledPtr = (KeAreAllApcsDisabledFn)MmGetSystemRoutineAddress(&KeAreAllApcsDisabledFuncName);
}
// KeSaveExtendedProcessorState/KeRestoreExtendedProcessorState are available starting from Windows 7
@@ -334,19 +324,19 @@ NTSTATUS DriverEntry (PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
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);
+ 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);
+ ExGetFirmwareEnvironmentVariablePtr = (ExGetFirmwareEnvironmentVariableFn)MmGetSystemRoutineAddress(&funcName);
}
// KeQueryInterruptTimePrecise is available starting from Windows 8.1
@@ -354,62 +344,57 @@ NTSTATUS DriverEntry (PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
{
UNICODE_STRING funcName;
RtlInitUnicodeString(&funcName, L"KeQueryInterruptTimePrecise");
- KeQueryInterruptTimePrecisePtr = (KeQueryInterruptTimePreciseFn) MmGetSystemRoutineAddress(&funcName);
+ 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);
+ 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);
TCDriverObject = DriverObject;
- memset (VirtualVolumeDeviceObjects, 0, sizeof (VirtualVolumeDeviceObjects));
+ memset(VirtualVolumeDeviceObjects, 0, sizeof(VirtualVolumeDeviceObjects));
- ReadRegistryConfigFlags (TRUE);
- EncryptionThreadPoolStart (EncryptionThreadPoolFreeCpuCountLimit);
+ ReadRegistryConfigFlags(TRUE);
+ EncryptionThreadPoolStart(EncryptionThreadPoolFreeCpuCountLimit);
SelfTestsPassed = AutoTestAlgorithms();
// Enable device class filters and load boot arguments if the driver is set to start at system boot
- if (NT_SUCCESS (TCReadRegistryKey (RegistryPath, L"Start", &startKeyValue)))
+ if (NT_SUCCESS(TCReadRegistryKey(RegistryPath, L"Start", &startKeyValue)))
{
- if (startKeyValue->Type == REG_DWORD && *((uint32 *) startKeyValue->Data) == SERVICE_BOOT_START)
+ if (startKeyValue->Type == REG_DWORD && *((uint32*)startKeyValue->Data) == SERVICE_BOOT_START)
{
if (!SelfTestsPassed)
{
// in case of system encryption, if self-tests fail, disable all extended CPU
// features and try again in order to workaround faulty configurations
- DisableCPUExtendedFeatures ();
+ DisableCPUExtendedFeatures();
SelfTestsPassed = AutoTestAlgorithms();
// BUG CHECK if the self-tests still fail
if (!SelfTestsPassed)
- TC_BUG_CHECK (STATUS_INVALID_PARAMETER);
+ TC_BUG_CHECK(STATUS_INVALID_PARAMETER);
}
- LoadBootArguments(IsUefiBoot ());
+ LoadBootArguments(IsUefiBoot());
VolumeClassFilterRegistered = IsVolumeClassFilterRegistered();
DriverObject->DriverExtension->AddDevice = DriverAddDevice;
}
- TCfree (startKeyValue);
+ TCfree(startKeyValue);
}
-#ifdef _WIN64
- if ((OsMajorVersion > 6) || (OsMajorVersion == 6 && OsMinorVersion >= 1))
+
+ if (RamEncryptionActivated)
{
- // we enable RAM encryption only starting from Windows 7
- if (RamEncryptionActivated)
- {
- if (t1ha_selfcheck__t1ha2() != 0)
- TC_BUG_CHECK (STATUS_INVALID_PARAMETER);
- if (!InitializeSecurityParameters(GetDriverRandomSeed))
- TC_BUG_CHECK (STATUS_INVALID_PARAMETER);
+ if (t1ha_selfcheck__t1ha2() != 0)
+ TC_BUG_CHECK(STATUS_INVALID_PARAMETER);
+ if (!InitializeSecurityParameters(GetDriverRandomSeed))
+ TC_BUG_CHECK(STATUS_INVALID_PARAMETER);
- EnableRamEncryption (TRUE);
- }
+ EnableRamEncryption(TRUE);
}
-#endif
for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; ++i)
{
@@ -417,7 +402,7 @@ NTSTATUS DriverEntry (PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
}
DriverObject->DriverUnload = TCUnloadDriver;
- return TCCreateRootDeviceObject (DriverObject);
+ return TCCreateRootDeviceObject(DriverObject);
}
@@ -878,6 +863,7 @@ IOCTL_STORAGE_QUERY_PROPERTY 0x002D1400
NTSTATUS ProcessVolumeDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION Extension, PIRP Irp)
{
PIO_STACK_LOCATION irpSp = IoGetCurrentIrpStackLocation (Irp);
+ UNREFERENCED_PARAMETER(DeviceObject);
switch (irpSp->Parameters.DeviceIoControl.IoControlCode)
{
@@ -929,7 +915,7 @@ NTSTATUS ProcessVolumeDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION
else
{
ULONG outLength;
- UCHAR volId[128], tmp[] = { 0,0 };
+ CHAR volId[128], tmp[] = { 0,0 };
PMOUNTDEV_UNIQUE_ID outputBuffer = (PMOUNTDEV_UNIQUE_ID) Irp->AssociatedIrp.SystemBuffer;
RtlStringCbCopyA (volId, sizeof(volId),TC_UNIQUE_ID_PREFIX);
@@ -1024,7 +1010,6 @@ NTSTATUS ProcessVolumeDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION
if (ValidateIOBufferSize (Irp, minOutputSize, ValidateOutput))
{
- PIO_STACK_LOCATION irpSp = IoGetCurrentIrpStackLocation (Irp);
BOOL bFullBuffer = (irpSp->Parameters.DeviceIoControl.OutputBufferLength >= fullOutputSize)? TRUE : FALSE;
PDISK_GEOMETRY_EX outputBuffer = (PDISK_GEOMETRY_EX) Irp->AssociatedIrp.SystemBuffer;
@@ -1338,7 +1323,6 @@ NTSTATUS ProcessVolumeDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION
Dump ("ProcessVolumeDeviceControlIrp (IOCTL_DISK_GET_DRIVE_LAYOUT)\n");
if (ValidateIOBufferSize (Irp, sizeof (DRIVE_LAYOUT_INFORMATION), ValidateOutput))
{
- PIO_STACK_LOCATION irpSp = IoGetCurrentIrpStackLocation (Irp);
BOOL bFullBuffer = (irpSp->Parameters.DeviceIoControl.OutputBufferLength >= (sizeof (DRIVE_LAYOUT_INFORMATION) + 3*sizeof(PARTITION_INFORMATION)))? TRUE : FALSE;
PDRIVE_LAYOUT_INFORMATION outputBuffer = (PDRIVE_LAYOUT_INFORMATION)
Irp->AssociatedIrp.SystemBuffer;
@@ -1373,7 +1357,6 @@ NTSTATUS ProcessVolumeDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION
{
if (ValidateIOBufferSize (Irp, sizeof (DRIVE_LAYOUT_INFORMATION_EX), ValidateOutput))
{
- PIO_STACK_LOCATION irpSp = IoGetCurrentIrpStackLocation (Irp);
BOOL bFullBuffer = (irpSp->Parameters.DeviceIoControl.OutputBufferLength >= (sizeof (DRIVE_LAYOUT_INFORMATION_EX) + 3*sizeof(PARTITION_INFORMATION_EX)))? TRUE : FALSE;
PDRIVE_LAYOUT_INFORMATION_EX outputBuffer = (PDRIVE_LAYOUT_INFORMATION_EX)
Irp->AssociatedIrp.SystemBuffer;
@@ -1528,37 +1511,20 @@ NTSTATUS ProcessVolumeDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION
case IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS:
Dump ("ProcessVolumeDeviceControlIrp (IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS)\n");
// Vista's, Windows 8.1 and later filesystem defragmenter fails if IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS does not succeed.
- if (!(OsMajorVersion == 6 && OsMinorVersion == 0)
- && !(IsOSAtLeast (WIN_8_1) && AllowWindowsDefrag && Extension->bRawDevice)
- )
+ if (ValidateIOBufferSize(Irp, sizeof(VOLUME_DISK_EXTENTS), ValidateOutput))
{
- Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST;
- Irp->IoStatus.Information = 0;
- }
- else if (ValidateIOBufferSize (Irp, sizeof (VOLUME_DISK_EXTENTS), ValidateOutput))
- {
- VOLUME_DISK_EXTENTS *extents = (VOLUME_DISK_EXTENTS *) Irp->AssociatedIrp.SystemBuffer;
-
+ VOLUME_DISK_EXTENTS* extents = (VOLUME_DISK_EXTENTS*)Irp->AssociatedIrp.SystemBuffer;
- if (IsOSAtLeast (WIN_8_1))
- {
- // Windows 10 filesystem defragmenter works only if we report an extent with a real disk number
- // So in the case of a VeraCrypt disk based volume, we use the disk number
- // of the underlaying physical disk and we report a single extent
- extents->NumberOfDiskExtents = 1;
- extents->Extents[0].DiskNumber = Extension->DeviceNumber;
- extents->Extents[0].StartingOffset.QuadPart = BYTES_PER_MB; // Set offset to 1MB to emulate the partition offset on a real MBR disk
- extents->Extents[0].ExtentLength.QuadPart = Extension->DiskLength;
- }
- else
- {
- // Vista: No extent data can be returned as this is not a physical drive.
- memset (extents, 0, sizeof (*extents));
- extents->NumberOfDiskExtents = 0;
- }
+ // Windows 10 filesystem defragmenter works only if we report an extent with a real disk number
+ // So in the case of a VeraCrypt disk based volume, we use the disk number
+ // of the underlaying physical disk and we report a single extent
+ extents->NumberOfDiskExtents = 1;
+ extents->Extents[0].DiskNumber = Extension->DeviceNumber;
+ extents->Extents[0].StartingOffset.QuadPart = BYTES_PER_MB; // Set offset to 1MB to emulate the partition offset on a real MBR disk
+ extents->Extents[0].ExtentLength.QuadPart = Extension->DiskLength;
Irp->IoStatus.Status = STATUS_SUCCESS;
- Irp->IoStatus.Information = sizeof (*extents);
+ Irp->IoStatus.Information = sizeof(*extents);
}
break;
@@ -1723,7 +1689,6 @@ NTSTATUS ProcessVolumeDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION
{
if (ValidateIOBufferSize (Irp, sizeof (DEVICE_MANAGE_DATA_SET_ATTRIBUTES), ValidateInput))
{
- PIO_STACK_LOCATION irpSp = IoGetCurrentIrpStackLocation (Irp);
DWORD inputLength = irpSp->Parameters.DeviceIoControl.InputBufferLength;
PDEVICE_MANAGE_DATA_SET_ATTRIBUTES pInputAttrs = (PDEVICE_MANAGE_DATA_SET_ATTRIBUTES) Irp->AssociatedIrp.SystemBuffer;
DEVICE_DATA_MANAGEMENT_SET_ACTION action = pInputAttrs->Action;
@@ -1955,6 +1920,7 @@ NTSTATUS ProcessMainDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION Ex
{
PIO_STACK_LOCATION irpSp = IoGetCurrentIrpStackLocation (Irp);
NTSTATUS ntStatus;
+ UNREFERENCED_PARAMETER(Extension);
switch (irpSp->Parameters.DeviceIoControl.IoControlCode)
{
@@ -1981,7 +1947,7 @@ NTSTATUS ProcessMainDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION Ex
case TC_IOCTL_IS_DRIVER_UNLOAD_DISABLED:
if (ValidateIOBufferSize (Irp, sizeof (int), ValidateOutput))
{
- LONG deviceObjectCount = 0;
+ ULONG deviceObjectCount = 0;
*(int *) Irp->AssociatedIrp.SystemBuffer = DriverUnloadDisabled;
@@ -2025,7 +1991,6 @@ NTSTATUS ProcessMainDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION Ex
IO_STATUS_BLOCK IoStatus;
LARGE_INTEGER offset;
ACCESS_MASK access = FILE_READ_ATTRIBUTES;
- PIO_STACK_LOCATION irpSp = IoGetCurrentIrpStackLocation (Irp);
if (!ValidateIOBufferSize (Irp, sizeof (OPEN_TEST_STRUCT), ValidateInputOutput))
break;
@@ -2266,7 +2231,6 @@ NTSTATUS ProcessMainDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION Ex
if (readBuffer[510] == 0x55 && readBuffer[511] == 0xaa)
{
- int i;
for (i = 0; i < 4; ++i)
{
if (readBuffer[446 + i * 16 + 4] == PARTITION_LDM)
@@ -2459,16 +2423,16 @@ NTSTATUS ProcessMainDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION Ex
{
RESOLVE_SYMLINK_STRUCT *resolve = (RESOLVE_SYMLINK_STRUCT *) Irp->AssociatedIrp.SystemBuffer;
{
- NTSTATUS ntStatus;
+ NTSTATUS ntStatusLocal;
EnsureNullTerminatedString (resolve->symLinkName, sizeof (resolve->symLinkName));
- ntStatus = SymbolicLinkToTarget (resolve->symLinkName,
+ ntStatusLocal = SymbolicLinkToTarget (resolve->symLinkName,
resolve->targetName,
sizeof (resolve->targetName));
Irp->IoStatus.Information = sizeof (RESOLVE_SYMLINK_STRUCT);
- Irp->IoStatus.Status = ntStatus;
+ Irp->IoStatus.Status = ntStatusLocal;
}
}
break;
@@ -2479,12 +2443,12 @@ NTSTATUS ProcessMainDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION Ex
DISK_PARTITION_INFO_STRUCT *info = (DISK_PARTITION_INFO_STRUCT *) Irp->AssociatedIrp.SystemBuffer;
{
PARTITION_INFORMATION_EX pi;
- NTSTATUS ntStatus;
+ NTSTATUS ntStatusLocal;
EnsureNullTerminatedString (info->deviceName, sizeof (info->deviceName));
- ntStatus = TCDeviceIoControl (info->deviceName, IOCTL_DISK_GET_PARTITION_INFO_EX, NULL, 0, &pi, sizeof (pi));
- if (NT_SUCCESS(ntStatus))
+ ntStatusLocal = TCDeviceIoControl (info->deviceName, IOCTL_DISK_GET_PARTITION_INFO_EX, NULL, 0, &pi, sizeof (pi));
+ if (NT_SUCCESS(ntStatusLocal))
{
memset (&info->partInfo, 0, sizeof (info->partInfo));
@@ -2503,16 +2467,16 @@ NTSTATUS ProcessMainDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION Ex
else
{
// Windows 2000 does not support IOCTL_DISK_GET_PARTITION_INFO_EX
- ntStatus = TCDeviceIoControl (info->deviceName, IOCTL_DISK_GET_PARTITION_INFO, NULL, 0, &info->partInfo, sizeof (info->partInfo));
+ ntStatusLocal = TCDeviceIoControl (info->deviceName, IOCTL_DISK_GET_PARTITION_INFO, NULL, 0, &info->partInfo, sizeof (info->partInfo));
info->IsGPT = FALSE;
}
- if (!NT_SUCCESS (ntStatus))
+ if (!NT_SUCCESS (ntStatusLocal))
{
GET_LENGTH_INFORMATION lengthInfo;
- ntStatus = TCDeviceIoControl (info->deviceName, IOCTL_DISK_GET_LENGTH_INFO, NULL, 0, &lengthInfo, sizeof (lengthInfo));
+ ntStatusLocal = TCDeviceIoControl (info->deviceName, IOCTL_DISK_GET_LENGTH_INFO, NULL, 0, &lengthInfo, sizeof (lengthInfo));
- if (NT_SUCCESS (ntStatus))
+ if (NT_SUCCESS (ntStatusLocal))
{
memset (&info->partInfo, 0, sizeof (info->partInfo));
info->partInfo.PartitionLength = lengthInfo.Length;
@@ -2521,7 +2485,7 @@ NTSTATUS ProcessMainDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION Ex
info->IsDynamic = FALSE;
- if (NT_SUCCESS (ntStatus) && OsMajorVersion >= 6)
+ if (NT_SUCCESS (ntStatusLocal))
{
# define IOCTL_VOLUME_IS_DYNAMIC CTL_CODE(IOCTL_VOLUME_BASE, 18, METHOD_BUFFERED, FILE_ANY_ACCESS)
if (!NT_SUCCESS (TCDeviceIoControl (info->deviceName, IOCTL_VOLUME_IS_DYNAMIC, NULL, 0, &info->IsDynamic, sizeof (info->IsDynamic))))
@@ -2529,7 +2493,7 @@ NTSTATUS ProcessMainDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION Ex
}
Irp->IoStatus.Information = sizeof (DISK_PARTITION_INFO_STRUCT);
- Irp->IoStatus.Status = ntStatus;
+ Irp->IoStatus.Status = ntStatusLocal;
}
}
break;
@@ -2539,17 +2503,17 @@ NTSTATUS ProcessMainDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION Ex
{
DISK_GEOMETRY_STRUCT *g = (DISK_GEOMETRY_STRUCT *) Irp->AssociatedIrp.SystemBuffer;
{
- NTSTATUS ntStatus;
+ NTSTATUS ntStatusLocal;
EnsureNullTerminatedString (g->deviceName, sizeof (g->deviceName));
Dump ("Calling IOCTL_DISK_GET_DRIVE_GEOMETRY on %ls\n", g->deviceName);
- ntStatus = TCDeviceIoControl (g->deviceName,
+ ntStatusLocal = TCDeviceIoControl (g->deviceName,
IOCTL_DISK_GET_DRIVE_GEOMETRY,
NULL, 0, &g->diskGeometry, sizeof (g->diskGeometry));
Irp->IoStatus.Information = sizeof (DISK_GEOMETRY_STRUCT);
- Irp->IoStatus.Status = ntStatus;
+ Irp->IoStatus.Status = ntStatusLocal;
}
}
break;
@@ -2559,18 +2523,18 @@ NTSTATUS ProcessMainDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION Ex
{
DISK_GEOMETRY_EX_STRUCT *g = (DISK_GEOMETRY_EX_STRUCT *) Irp->AssociatedIrp.SystemBuffer;
{
- NTSTATUS ntStatus;
+ NTSTATUS ntStatusLocal;
PVOID buffer = TCalloc (256); // enough for DISK_GEOMETRY_EX and padded data
if (buffer)
{
EnsureNullTerminatedString (g->deviceName, sizeof (g->deviceName));
Dump ("Calling IOCTL_DISK_GET_DRIVE_GEOMETRY_EX on %ls\n", g->deviceName);
- ntStatus = TCDeviceIoControl (g->deviceName,
+ ntStatusLocal = TCDeviceIoControl (g->deviceName,
IOCTL_DISK_GET_DRIVE_GEOMETRY_EX,
NULL, 0, buffer, 256);
- if (NT_SUCCESS(ntStatus))
+ if (NT_SUCCESS(ntStatusLocal))
{
PDISK_GEOMETRY_EX pGeo = (PDISK_GEOMETRY_EX) buffer;
memcpy (&g->diskGeometry, &pGeo->Geometry, sizeof (DISK_GEOMETRY));
@@ -2580,30 +2544,27 @@ NTSTATUS ProcessMainDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION Ex
{
DISK_GEOMETRY dg = {0};
Dump ("Failed. Calling IOCTL_DISK_GET_DRIVE_GEOMETRY on %ls\n", g->deviceName);
- ntStatus = TCDeviceIoControl (g->deviceName,
+ ntStatusLocal = TCDeviceIoControl (g->deviceName,
IOCTL_DISK_GET_DRIVE_GEOMETRY,
NULL, 0, &dg, sizeof (dg));
- if (NT_SUCCESS(ntStatus))
+ if (NT_SUCCESS(ntStatusLocal))
{
- memcpy (&g->diskGeometry, &dg, sizeof (DISK_GEOMETRY));
+ memcpy(&g->diskGeometry, &dg, sizeof(DISK_GEOMETRY));
g->DiskSize.QuadPart = dg.Cylinders.QuadPart * dg.SectorsPerTrack * dg.TracksPerCylinder * dg.BytesPerSector;
- if (OsMajorVersion >= 6)
+ STORAGE_READ_CAPACITY storage = { 0 };
+ NTSTATUS lStatus;
+ storage.Version = sizeof(STORAGE_READ_CAPACITY);
+ Dump("Calling IOCTL_STORAGE_READ_CAPACITY on %ls\n", g->deviceName);
+ lStatus = TCDeviceIoControl(g->deviceName,
+ IOCTL_STORAGE_READ_CAPACITY,
+ NULL, 0, &storage, sizeof(STORAGE_READ_CAPACITY));
+ if (NT_SUCCESS(lStatus)
+ && (storage.Size == sizeof(STORAGE_READ_CAPACITY))
+ )
{
- STORAGE_READ_CAPACITY storage = {0};
- NTSTATUS lStatus;
- storage.Version = sizeof (STORAGE_READ_CAPACITY);
- Dump ("Calling IOCTL_STORAGE_READ_CAPACITY on %ls\n", g->deviceName);
- lStatus = TCDeviceIoControl (g->deviceName,
- IOCTL_STORAGE_READ_CAPACITY,
- NULL, 0, &storage, sizeof (STORAGE_READ_CAPACITY));
- if ( NT_SUCCESS(lStatus)
- && (storage.Size == sizeof (STORAGE_READ_CAPACITY))
- )
- {
- g->DiskSize.QuadPart = storage.DiskLength.QuadPart;
- }
+ g->DiskSize.QuadPart = storage.DiskLength.QuadPart;
}
}
}
@@ -2611,7 +2572,7 @@ NTSTATUS ProcessMainDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION Ex
TCfree (buffer);
Irp->IoStatus.Information = sizeof (DISK_GEOMETRY_EX_STRUCT);
- Irp->IoStatus.Status = ntStatus;
+ Irp->IoStatus.Status = ntStatusLocal;
}
else
{
@@ -2669,7 +2630,6 @@ NTSTATUS ProcessMainDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION Ex
if (ValidateIOBufferSize (Irp, sizeof (MOUNT_STRUCT), ValidateInputOutput))
{
MOUNT_STRUCT *mount = (MOUNT_STRUCT *) Irp->AssociatedIrp.SystemBuffer;
- PIO_STACK_LOCATION irpSp = IoGetCurrentIrpStackLocation (Irp);
if ((irpSp->Parameters.DeviceIoControl.InputBufferLength != sizeof (MOUNT_STRUCT))
|| mount->VolumePassword.Length > MAX_PASSWORD || mount->ProtectedHidVolPassword.Length > MAX_PASSWORD
@@ -2703,7 +2663,6 @@ NTSTATUS ProcessMainDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION Ex
{
UNMOUNT_STRUCT *unmount = (UNMOUNT_STRUCT *) Irp->AssociatedIrp.SystemBuffer;
PDEVICE_OBJECT ListDevice = GetVirtualVolumeDeviceObject (unmount->nDosDriveNo);
- PIO_STACK_LOCATION irpSp = IoGetCurrentIrpStackLocation (Irp);
if (irpSp->Parameters.DeviceIoControl.InputBufferLength != sizeof (UNMOUNT_STRUCT))
{
@@ -2731,7 +2690,6 @@ NTSTATUS ProcessMainDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION Ex
if (ValidateIOBufferSize (Irp, sizeof (UNMOUNT_STRUCT), ValidateInputOutput))
{
UNMOUNT_STRUCT *unmount = (UNMOUNT_STRUCT *) Irp->AssociatedIrp.SystemBuffer;
- PIO_STACK_LOCATION irpSp = IoGetCurrentIrpStackLocation (Irp);
if (irpSp->Parameters.DeviceIoControl.InputBufferLength != sizeof (UNMOUNT_STRUCT))
{
@@ -2748,7 +2706,7 @@ NTSTATUS ProcessMainDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION Ex
break;
case VC_IOCTL_EMERGENCY_CLEAR_ALL_KEYS:
- EmergencyClearAllKeys (Irp, irpSp);
+ EmergencyClearAllKeys (Irp);
WipeCache();
break;
@@ -2763,7 +2721,7 @@ NTSTATUS ProcessMainDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION Ex
break;
case TC_IOCTL_GET_BOOT_ENCRYPTION_STATUS:
- GetBootEncryptionStatus (Irp, irpSp);
+ GetBootEncryptionStatus (Irp);
break;
case TC_IOCTL_GET_BOOT_ENCRYPTION_SETUP_RESULT:
@@ -2772,23 +2730,23 @@ NTSTATUS ProcessMainDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION Ex
break;
case TC_IOCTL_GET_BOOT_DRIVE_VOLUME_PROPERTIES:
- GetBootDriveVolumeProperties (Irp, irpSp);
+ GetBootDriveVolumeProperties (Irp);
break;
case TC_IOCTL_GET_BOOT_LOADER_VERSION:
- GetBootLoaderVersion (Irp, irpSp);
+ GetBootLoaderVersion (Irp);
break;
case TC_IOCTL_REOPEN_BOOT_VOLUME_HEADER:
- ReopenBootVolumeHeader (Irp, irpSp);
+ ReopenBootVolumeHeader (Irp);
break;
case VC_IOCTL_GET_BOOT_LOADER_FINGERPRINT:
- GetBootLoaderFingerprint (Irp, irpSp);
+ GetBootLoaderFingerprint (Irp);
break;
case TC_IOCTL_GET_BOOT_ENCRYPTION_ALGORITHM_NAME:
- GetBootEncryptionAlgorithmName (Irp, irpSp);
+ GetBootEncryptionAlgorithmName (Irp);
break;
case TC_IOCTL_IS_HIDDEN_SYSTEM_RUNNING:
@@ -2816,7 +2774,7 @@ NTSTATUS ProcessMainDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION Ex
break;
case TC_IOCTL_GET_DECOY_SYSTEM_WIPE_STATUS:
- GetDecoySystemWipeStatus (Irp, irpSp);
+ GetDecoySystemWipeStatus (Irp);
break;
case TC_IOCTL_WRITE_BOOT_DRIVE_SECTOR:
@@ -3505,11 +3463,13 @@ void TCDeleteDeviceObject (PDEVICE_OBJECT DeviceObject, PEXTENSION Extension)
if (Extension->SecurityClientContextValid)
{
- VOID (*PsDereferenceImpersonationTokenD) (PACCESS_TOKEN ImpersonationToken);
+ typedef VOID (*PsDereferenceImpersonationTokenDType) (PACCESS_TOKEN ImpersonationToken);
+
+ PsDereferenceImpersonationTokenDType PsDereferenceImpersonationTokenD;
UNICODE_STRING name;
RtlInitUnicodeString (&name, L"PsDereferenceImpersonationToken");
- PsDereferenceImpersonationTokenD = MmGetSystemRoutineAddress (&name);
+ PsDereferenceImpersonationTokenD = (PsDereferenceImpersonationTokenDType) MmGetSystemRoutineAddress (&name);
if (!PsDereferenceImpersonationTokenD)
TC_BUG_CHECK (STATUS_NOT_IMPLEMENTED);
@@ -3534,7 +3494,7 @@ void TCDeleteDeviceObject (PDEVICE_OBJECT DeviceObject, PEXTENSION Extension)
VOID TCUnloadDriver (PDRIVER_OBJECT DriverObject)
{
Dump ("TCUnloadDriver BEGIN\n");
-
+ UNREFERENCED_PARAMETER(DriverObject);
OnShutdownPending();
if (IsBootDriveMounted())
@@ -3568,6 +3528,7 @@ typedef struct
static VOID TCDeviceIoControlWorkItemRoutine (PDEVICE_OBJECT rootDeviceObject, TCDeviceIoControlWorkItemArgs *arg)
{
+ UNREFERENCED_PARAMETER(rootDeviceObject);
arg->Status = TCDeviceIoControl (arg->deviceName, arg->IoControlCode, arg->InputBuffer, arg->InputBufferSize, arg->OutputBuffer, arg->OutputBufferSize);
KeSetEvent (&arg->WorkItemCompletedEvent, IO_NO_INCREMENT, FALSE);
}
@@ -3654,6 +3615,7 @@ typedef struct
static VOID SendDeviceIoControlRequestWorkItemRoutine (PDEVICE_OBJECT rootDeviceObject, SendDeviceIoControlRequestWorkItemArgs *arg)
{
+ UNREFERENCED_PARAMETER(rootDeviceObject);
arg->Status = SendDeviceIoControlRequest (arg->deviceObject, arg->ioControlCode, arg->inputBuffer, arg->inputBufferSize, arg->outputBuffer, arg->outputBufferSize);
KeSetEvent (&arg->WorkItemCompletedEvent, IO_NO_INCREMENT, FALSE);
}
@@ -3998,6 +3960,7 @@ static NTSTATUS UpdateFsVolumeInformation (MOUNT_STRUCT* mount, PEXTENSION NewEx
static VOID UpdateFsVolumeInformationWorkItemRoutine (PDEVICE_OBJECT rootDeviceObject, UpdateFsVolumeInformationWorkItemArgs *arg)
{
+ UNREFERENCED_PARAMETER(rootDeviceObject);
arg->Status = UpdateFsVolumeInformation (arg->mount, arg->NewExtension);
KeSetEvent (&arg->WorkItemCompletedEvent, IO_NO_INCREMENT, FALSE);
}
@@ -4265,6 +4228,7 @@ typedef struct
static VOID UnmountDeviceWorkItemRoutine (PDEVICE_OBJECT rootDeviceObject, UnmountDeviceWorkItemArgs *arg)
{
+ UNREFERENCED_PARAMETER(rootDeviceObject);
arg->Status = UnmountDevice (arg->unmountRequest, arg->deviceObject, arg->ignoreOpenFiles);
KeSetEvent (&arg->WorkItemCompletedEvent, IO_NO_INCREMENT, FALSE);
}
diff --git a/src/Driver/Ntvol.c b/src/Driver/Ntvol.c
index 68f63f16..0486219e 100644
--- a/src/Driver/Ntvol.c
+++ b/src/Driver/Ntvol.c
@@ -53,7 +53,7 @@ NTSTATUS TCOpenVolume (PDEVICE_OBJECT DeviceObject,
LARGE_INTEGER lDiskLength = { 0 };
__int64 partitionStartingOffset = 0;
int volumeType;
- char *readBuffer = 0;
+ unsigned char *readBuffer = 0;
NTSTATUS ntStatus = 0;
BOOL forceAccessCheck = !bRawDevice;
BOOL disableBuffering = TRUE;
@@ -98,65 +98,62 @@ NTSTATUS TCOpenVolume (PDEVICE_OBJECT DeviceObject,
PARTITION_INFORMATION_EX pix;
LARGE_INTEGER diskLengthInfo;
DISK_GEOMETRY_EX dg;
- STORAGE_PROPERTY_QUERY storagePropertyQuery = {0};
+ STORAGE_PROPERTY_QUERY storagePropertyQuery = { 0 };
uint8* dgBuffer;
STORAGE_DEVICE_NUMBER storageDeviceNumber;
- ntStatus = IoGetDeviceObjectPointer (&FullFileName,
+ ntStatus = IoGetDeviceObjectPointer(&FullFileName,
FILE_READ_DATA | FILE_READ_ATTRIBUTES,
&Extension->pfoDeviceFile,
&Extension->pFsdDevice);
- if (!NT_SUCCESS (ntStatus))
+ if (!NT_SUCCESS(ntStatus))
goto error;
- dgBuffer = TCalloc (256);
+ dgBuffer = TCalloc(256);
if (!dgBuffer)
{
ntStatus = STATUS_INSUFFICIENT_RESOURCES;
goto error;
}
- ntStatus = TCSendHostDeviceIoControlRequest (DeviceObject, Extension, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, (char *) dgBuffer, 256);
- if (!NT_SUCCESS (ntStatus))
+ ntStatus = TCSendHostDeviceIoControlRequest(DeviceObject, Extension, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, (char*)dgBuffer, 256);
+ if (!NT_SUCCESS(ntStatus))
{
DISK_GEOMETRY geo;
- ntStatus = TCSendHostDeviceIoControlRequest (DeviceObject, Extension, IOCTL_DISK_GET_DRIVE_GEOMETRY, (char *) &geo, sizeof (geo));
- if (!NT_SUCCESS (ntStatus))
+ ntStatus = TCSendHostDeviceIoControlRequest(DeviceObject, Extension, IOCTL_DISK_GET_DRIVE_GEOMETRY, (char*)&geo, sizeof(geo));
+ if (!NT_SUCCESS(ntStatus))
{
- TCfree (dgBuffer);
+ TCfree(dgBuffer);
goto error;
}
- memset (&dg, 0, sizeof (dg));
- memcpy (&dg.Geometry, &geo, sizeof (geo));
+ memset(&dg, 0, sizeof(dg));
+ memcpy(&dg.Geometry, &geo, sizeof(geo));
dg.DiskSize.QuadPart = geo.Cylinders.QuadPart * geo.SectorsPerTrack * geo.TracksPerCylinder * geo.BytesPerSector;
- if (OsMajorVersion >= 6)
+ STORAGE_READ_CAPACITY storage = { 0 };
+ NTSTATUS lStatus;
+
+ storage.Version = sizeof(STORAGE_READ_CAPACITY);
+ storage.Size = sizeof(STORAGE_READ_CAPACITY);
+ lStatus = TCSendHostDeviceIoControlRequest(DeviceObject, Extension,
+ IOCTL_STORAGE_READ_CAPACITY,
+ (char*)&storage, sizeof(STORAGE_READ_CAPACITY));
+ if (NT_SUCCESS(lStatus)
+ && (storage.Size == sizeof(STORAGE_READ_CAPACITY))
+ )
{
- STORAGE_READ_CAPACITY storage = {0};
- NTSTATUS lStatus;
-
- storage.Version = sizeof (STORAGE_READ_CAPACITY);
- storage.Size = sizeof (STORAGE_READ_CAPACITY);
- lStatus = TCSendHostDeviceIoControlRequest (DeviceObject, Extension,
- IOCTL_STORAGE_READ_CAPACITY,
- (char*) &storage, sizeof (STORAGE_READ_CAPACITY));
- if ( NT_SUCCESS(lStatus)
- && (storage.Size == sizeof (STORAGE_READ_CAPACITY))
- )
- {
- dg.DiskSize.QuadPart = storage.DiskLength.QuadPart;
- }
+ dg.DiskSize.QuadPart = storage.DiskLength.QuadPart;
}
}
else
- memcpy (&dg, dgBuffer, sizeof (DISK_GEOMETRY_EX));
+ memcpy(&dg, dgBuffer, sizeof(DISK_GEOMETRY_EX));
- TCfree (dgBuffer);
+ TCfree(dgBuffer);
- if (NT_SUCCESS (TCSendHostDeviceIoControlRequest (DeviceObject, Extension,
- IOCTL_STORAGE_GET_DEVICE_NUMBER,
- (char*) &storageDeviceNumber, sizeof (storageDeviceNumber))))
+ if (NT_SUCCESS(TCSendHostDeviceIoControlRequest(DeviceObject, Extension,
+ IOCTL_STORAGE_GET_DEVICE_NUMBER,
+ (char*)&storageDeviceNumber, sizeof(storageDeviceNumber))))
{
Extension->DeviceNumber = storageDeviceNumber.DeviceNumber;
}
@@ -165,76 +162,72 @@ NTSTATUS TCOpenVolume (PDEVICE_OBJECT DeviceObject,
Extension->HostBytesPerSector = dg.Geometry.BytesPerSector;
Extension->HostBytesPerPhysicalSector = dg.Geometry.BytesPerSector;
- /* IOCTL_STORAGE_QUERY_PROPERTY supported only on Vista and above */
- if (OsMajorVersion >= 6)
- {
- STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR alignmentDesc = {0};
- STORAGE_ADAPTER_DESCRIPTOR adapterDesc = {0};
- DEVICE_SEEK_PENALTY_DESCRIPTOR penaltyDesc = {0};
- DEVICE_TRIM_DESCRIPTOR trimDesc = {0};
+ STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR alignmentDesc = { 0 };
+ STORAGE_ADAPTER_DESCRIPTOR adapterDesc = { 0 };
+ DEVICE_SEEK_PENALTY_DESCRIPTOR penaltyDesc = { 0 };
+ DEVICE_TRIM_DESCRIPTOR trimDesc = { 0 };
- storagePropertyQuery.PropertyId = StorageAccessAlignmentProperty;
- storagePropertyQuery.QueryType = PropertyStandardQuery;
+ storagePropertyQuery.PropertyId = StorageAccessAlignmentProperty;
+ storagePropertyQuery.QueryType = PropertyStandardQuery;
- alignmentDesc.Version = sizeof (STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR);
- alignmentDesc.Size = sizeof (STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR);
+ alignmentDesc.Version = sizeof(STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR);
+ alignmentDesc.Size = sizeof(STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR);
- if (NT_SUCCESS (TCSendHostDeviceIoControlRequestEx (DeviceObject, Extension, IOCTL_STORAGE_QUERY_PROPERTY,
- (char*) &storagePropertyQuery, sizeof(storagePropertyQuery),
- (char *) &alignmentDesc, sizeof (alignmentDesc))))
- {
- Extension->HostBytesPerPhysicalSector = alignmentDesc.BytesPerPhysicalSector;
- }
+ if (NT_SUCCESS(TCSendHostDeviceIoControlRequestEx(DeviceObject, Extension, IOCTL_STORAGE_QUERY_PROPERTY,
+ (char*)&storagePropertyQuery, sizeof(storagePropertyQuery),
+ (char*)&alignmentDesc, sizeof(alignmentDesc))))
+ {
+ Extension->HostBytesPerPhysicalSector = alignmentDesc.BytesPerPhysicalSector;
+ }
- storagePropertyQuery.PropertyId = StorageAdapterProperty;
- adapterDesc.Version = sizeof (STORAGE_ADAPTER_DESCRIPTOR);
- adapterDesc.Size = sizeof (STORAGE_ADAPTER_DESCRIPTOR);
+ storagePropertyQuery.PropertyId = StorageAdapterProperty;
+ adapterDesc.Version = sizeof(STORAGE_ADAPTER_DESCRIPTOR);
+ adapterDesc.Size = sizeof(STORAGE_ADAPTER_DESCRIPTOR);
- if (NT_SUCCESS (TCSendHostDeviceIoControlRequestEx (DeviceObject, Extension, IOCTL_STORAGE_QUERY_PROPERTY,
- (char*) &storagePropertyQuery, sizeof(storagePropertyQuery),
- (char *) &adapterDesc, sizeof (adapterDesc))))
- {
- Extension->HostMaximumTransferLength = adapterDesc.MaximumTransferLength;
- Extension->HostMaximumPhysicalPages = adapterDesc.MaximumPhysicalPages;
- Extension->HostAlignmentMask = adapterDesc.AlignmentMask;
- }
+ if (NT_SUCCESS(TCSendHostDeviceIoControlRequestEx(DeviceObject, Extension, IOCTL_STORAGE_QUERY_PROPERTY,
+ (char*)&storagePropertyQuery, sizeof(storagePropertyQuery),
+ (char*)&adapterDesc, sizeof(adapterDesc))))
+ {
+ Extension->HostMaximumTransferLength = adapterDesc.MaximumTransferLength;
+ Extension->HostMaximumPhysicalPages = adapterDesc.MaximumPhysicalPages;
+ Extension->HostAlignmentMask = adapterDesc.AlignmentMask;
+ }
- storagePropertyQuery.PropertyId = StorageDeviceSeekPenaltyProperty;
- penaltyDesc.Version = sizeof (DEVICE_SEEK_PENALTY_DESCRIPTOR);
- penaltyDesc.Size = sizeof (DEVICE_SEEK_PENALTY_DESCRIPTOR);
+ storagePropertyQuery.PropertyId = StorageDeviceSeekPenaltyProperty;
+ penaltyDesc.Version = sizeof(DEVICE_SEEK_PENALTY_DESCRIPTOR);
+ penaltyDesc.Size = sizeof(DEVICE_SEEK_PENALTY_DESCRIPTOR);
- if (NT_SUCCESS (TCSendHostDeviceIoControlRequestEx (DeviceObject, Extension, IOCTL_STORAGE_QUERY_PROPERTY,
- (char*) &storagePropertyQuery, sizeof(storagePropertyQuery),
- (char *) &penaltyDesc, sizeof (penaltyDesc))))
- {
- Extension->IncursSeekPenalty = penaltyDesc.IncursSeekPenalty;
- }
+ if (NT_SUCCESS(TCSendHostDeviceIoControlRequestEx(DeviceObject, Extension, IOCTL_STORAGE_QUERY_PROPERTY,
+ (char*)&storagePropertyQuery, sizeof(storagePropertyQuery),
+ (char*)&penaltyDesc, sizeof(penaltyDesc))))
+ {
+ Extension->IncursSeekPenalty = penaltyDesc.IncursSeekPenalty;
+ }
- storagePropertyQuery.PropertyId = StorageDeviceTrimProperty;
- trimDesc.Version = sizeof (DEVICE_TRIM_DESCRIPTOR);
- trimDesc.Size = sizeof (DEVICE_TRIM_DESCRIPTOR);
+ storagePropertyQuery.PropertyId = StorageDeviceTrimProperty;
+ trimDesc.Version = sizeof(DEVICE_TRIM_DESCRIPTOR);
+ trimDesc.Size = sizeof(DEVICE_TRIM_DESCRIPTOR);
- if (NT_SUCCESS (TCSendHostDeviceIoControlRequestEx (DeviceObject, Extension, IOCTL_STORAGE_QUERY_PROPERTY,
- (char*) &storagePropertyQuery, sizeof(storagePropertyQuery),
- (char *) &trimDesc, sizeof (trimDesc))))
- {
- Extension->TrimEnabled = trimDesc.TrimEnabled;
- }
+ if (NT_SUCCESS(TCSendHostDeviceIoControlRequestEx(DeviceObject, Extension, IOCTL_STORAGE_QUERY_PROPERTY,
+ (char*)&storagePropertyQuery, sizeof(storagePropertyQuery),
+ (char*)&trimDesc, sizeof(trimDesc))))
+ {
+ Extension->TrimEnabled = trimDesc.TrimEnabled;
}
// Drive geometry is used only when IOCTL_DISK_GET_PARTITION_INFO fails
- if (NT_SUCCESS (TCSendHostDeviceIoControlRequest (DeviceObject, Extension, IOCTL_DISK_GET_PARTITION_INFO_EX, (char *) &pix, sizeof (pix))))
+ if (NT_SUCCESS(TCSendHostDeviceIoControlRequest(DeviceObject, Extension, IOCTL_DISK_GET_PARTITION_INFO_EX, (char*)&pix, sizeof(pix))))
{
lDiskLength.QuadPart = pix.PartitionLength.QuadPart;
partitionStartingOffset = pix.StartingOffset.QuadPart;
}
// If IOCTL_DISK_GET_PARTITION_INFO_EX fails, switch to IOCTL_DISK_GET_PARTITION_INFO
- else if (NT_SUCCESS (TCSendHostDeviceIoControlRequest (DeviceObject, Extension, IOCTL_DISK_GET_PARTITION_INFO, (char *) &pi, sizeof (pi))))
+ else if (NT_SUCCESS(TCSendHostDeviceIoControlRequest(DeviceObject, Extension, IOCTL_DISK_GET_PARTITION_INFO, (char*)&pi, sizeof(pi))))
{
lDiskLength.QuadPart = pi.PartitionLength.QuadPart;
partitionStartingOffset = pi.StartingOffset.QuadPart;
}
- else if (NT_SUCCESS (TCSendHostDeviceIoControlRequest (DeviceObject, Extension, IOCTL_DISK_GET_LENGTH_INFO, &diskLengthInfo, sizeof (diskLengthInfo))))
+ else if (NT_SUCCESS(TCSendHostDeviceIoControlRequest(DeviceObject, Extension, IOCTL_DISK_GET_LENGTH_INFO, &diskLengthInfo, sizeof(diskLengthInfo))))
{
lDiskLength = diskLengthInfo;
}
@@ -242,7 +235,7 @@ NTSTATUS TCOpenVolume (PDEVICE_OBJECT DeviceObject,
ProbingHostDeviceForWrite = TRUE;
if (!mount->bMountReadOnly
- && TCSendHostDeviceIoControlRequest (DeviceObject, Extension,
+ && TCSendHostDeviceIoControlRequest(DeviceObject, Extension,
IsHiddenSystemRunning() ? TC_IOCTL_DISK_IS_WRITABLE : IOCTL_DISK_IS_WRITABLE, NULL, 0) == STATUS_MEDIA_WRITE_PROTECTED)
{
mount->bMountReadOnly = TRUE;
@@ -937,6 +930,7 @@ typedef struct
static VOID TCSendHostDeviceIoControlRequestExWorkItemRoutine (PDEVICE_OBJECT rootDeviceObject, TCSendHostDeviceIoControlRequestExWorkItemArgs *arg)
{
+ UNREFERENCED_PARAMETER(rootDeviceObject); /* Remove compiler warning */
arg->Status = TCSendHostDeviceIoControlRequestEx (arg->deviceObject, arg->Extension, arg->ioControlCode, arg->inputBuffer, arg->inputBufferSize, arg->outputBuffer, arg->outputBufferSize);
KeSetEvent (&arg->WorkItemCompletedEvent, IO_NO_INCREMENT, FALSE);
}
diff --git a/src/Driver/VolumeFilter.c b/src/Driver/VolumeFilter.c
index 29d02673..b4bc8d2e 100644
--- a/src/Driver/VolumeFilter.c
+++ b/src/Driver/VolumeFilter.c
@@ -155,6 +155,7 @@ static BOOL IsSystemVolumePartition (VolumeFilterExtension *Extension)
static NTSTATUS DispatchControl (PDEVICE_OBJECT DeviceObject, PIRP Irp, VolumeFilterExtension *Extension, PIO_STACK_LOCATION irpSp)
{
NTSTATUS status = IoAcquireRemoveLock (&Extension->Queue.RemoveLock, Irp);
+ UNREFERENCED_PARAMETER(DeviceObject);
if (!NT_SUCCESS (status))
return TCCompleteIrp (Irp, status, 0);
@@ -270,9 +271,10 @@ static NTSTATUS DispatchPnp (PDEVICE_OBJECT DeviceObject, PIRP Irp, VolumeFilter
}
-static NTSTATUS DispatchPower (PDEVICE_OBJECT DeviceObject, PIRP Irp, VolumeFilterExtension *Extension, PIO_STACK_LOCATION irpSp)
+static NTSTATUS DispatchPower (PDEVICE_OBJECT DeviceObject, PIRP Irp, VolumeFilterExtension *Extension)
{
NTSTATUS status;
+ UNREFERENCED_PARAMETER(DeviceObject);
PoStartNextPowerIrp (Irp);
status = IoAcquireRemoveLock (&Extension->Queue.RemoveLock, Irp);
@@ -304,7 +306,7 @@ NTSTATUS VolumeFilterDispatchIrp (PDEVICE_OBJECT DeviceObject, PIRP Irp)
return DispatchPnp (DeviceObject, Irp, Extension, irpSp);
case IRP_MJ_POWER:
- return DispatchPower (DeviceObject, Irp, Extension, irpSp);
+ return DispatchPower (DeviceObject, Irp, Extension);
default:
status = IoAcquireRemoveLock (&Extension->Queue.RemoveLock, Irp);