diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2017-08-02 17:25:06 +0200 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2017-08-02 17:31:19 +0200 |
commit | 2fde7f0b4738494ff58bf2bc3fe5810c1d2546d8 (patch) | |
tree | 611061f0962e0d424cd7f266af149371c45fafa6 /src/Boot | |
parent | 21fc5a8750f5dfbb33f6830d7520cd799cd2b930 (diff) | |
download | VeraCrypt-2fde7f0b4738494ff58bf2bc3fe5810c1d2546d8.tar.gz VeraCrypt-2fde7f0b4738494ff58bf2bc3fe5810c1d2546d8.zip |
Windows MBR bootloader: reduce CPU usage during password prompt (Credit: Jason Pyeron of CipherShed project https://github.com/CipherShed/CipherShed/commit/00ea00e8e6a23a4243316f860aa07ed59203ab97)
Diffstat (limited to 'src/Boot')
-rw-r--r-- | src/Boot/Windows/BootConsoleIo.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/Boot/Windows/BootConsoleIo.cpp b/src/Boot/Windows/BootConsoleIo.cpp index b03098f0..9148f5c9 100644 --- a/src/Boot/Windows/BootConsoleIo.cpp +++ b/src/Boot/Windows/BootConsoleIo.cpp @@ -238,11 +238,32 @@ byte GetKeyboardChar () return GetKeyboardChar (nullptr); } +/* +inline void Sleep () +{ + __asm + { + mov al, 0 + mov ah, 0x86 + // Sleep for 250 milliseconds = 250 000 microseconds = 0x0003D090 + mov cx, 0x0003 + mov dx, 0xD090 + int 0x15 + } +} +*/ byte GetKeyboardChar (byte *scanCode) { // Work around potential BIOS bugs (Windows boot manager polls the keystroke buffer) - while (!IsKeyboardCharAvailable()); + while (!IsKeyboardCharAvailable()) + { + // reduce CPU usage by halting CPU until the next external interrupt is fired + __asm + { + hlt + } + } byte asciiCode; byte scan; |