diff options
Diffstat (limited to 'src/Boot/Windows/BootConsoleIo.cpp')
-rw-r--r-- | src/Boot/Windows/BootConsoleIo.cpp | 55 |
1 files changed, 39 insertions, 16 deletions
diff --git a/src/Boot/Windows/BootConsoleIo.cpp b/src/Boot/Windows/BootConsoleIo.cpp index 60305ea1..046f580b 100644 --- a/src/Boot/Windows/BootConsoleIo.cpp +++ b/src/Boot/Windows/BootConsoleIo.cpp @@ -3,9 +3,9 @@ Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0. Modifications and additions to the original source code (contained in this file) - and all other portions of this file are Copyright (c) 2013-2016 IDRIX + and all other portions of this file are Copyright (c) 2013-2017 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source code distribution packages. */ @@ -18,19 +18,21 @@ static int ScreenOutputDisabled = 0; +#if defined(TC_TRACE_INT13) || !defined(TC_WINDOWS_BOOT_RESCUE_DISK_MODE) void DisableScreenOutput () { ++ScreenOutputDisabled; } +#endif - +#ifdef TC_TRACE_INT13 void EnableScreenOutput () { --ScreenOutputDisabled; } - +#endif void PrintChar (char c) { #ifdef TC_BOOT_TRACING_ENABLED @@ -98,19 +100,19 @@ void Print (const uint64 &number) PrintHex (number); } -void PrintHex (byte b) +void PrintHex (uint8 b) { PrintChar (((b >> 4) >= 0xA ? 'A' - 0xA : '0') + (b >> 4)); PrintChar (((b & 0xF) >= 0xA ? 'A' - 0xA : '0') + (b & 0xF)); } void PrintHex (uint16 data) { - PrintHex (byte (data >> 8)); - PrintHex (byte (data)); + PrintHex (uint8 (data >> 8)); + PrintHex (uint8 (data)); } void PrintHex (uint32 data) @@ -216,11 +218,11 @@ void PrintErrorNoEndl (const char *message) Beep(); } -byte GetShiftFlags () +uint8 GetShiftFlags () { - byte flags; + uint8 flags; __asm { mov ah, 2 int 0x16 @@ -230,21 +232,42 @@ byte GetShiftFlags () return flags; } -byte GetKeyboardChar () +uint8 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) +uint8 GetKeyboardChar (uint8 *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; + uint8 asciiCode; + uint8 scan; __asm { mov ah, 0 int 0x16 @@ -278,9 +301,9 @@ bool IsKeyboardCharAvailable () bool EscKeyPressed () { if (IsKeyboardCharAvailable ()) { - byte keyScanCode; + uint8 keyScanCode; GetKeyboardChar (&keyScanCode); return keyScanCode == TC_BIOS_KEY_ESC; } @@ -322,10 +345,10 @@ bool IsDigit (char c) int GetString (char *buffer, size_t bufferSize) { - byte c; - byte scanCode; + uint8 c; + uint8 scanCode; size_t pos = 0; while (pos < bufferSize) { |