--- truecrypt/boot/windows/bootconsoleio.cpp 2018/04/24 16:49:04 1.1 +++ truecrypt/boot/windows/bootconsoleio.cpp 2018/04/24 17:03:42 1.1.1.7 @@ -1,7 +1,7 @@ /* Copyright (c) 2008 TrueCrypt Foundation. All rights reserved. - Governed by the TrueCrypt License 2.4 the full text of which is contained + Governed by the TrueCrypt License 2.7 the full text of which is contained in the file License.txt included in TrueCrypt binary and source code distribution packages. */ @@ -28,7 +28,7 @@ void EnableScreenOutput () void PrintChar (char c) { -#ifdef TC_TRACING_ENABLED +#ifdef TC_BOOT_TRACING_ENABLED WriteDebugPort (c); #endif @@ -37,7 +37,7 @@ void PrintChar (char c) __asm { - xor bx, bx + mov bx, 7 mov al, c mov ah, 0xe int 0x10 @@ -45,11 +45,14 @@ void PrintChar (char c) } -void PrintCharAtCusor (char c) +void PrintCharAtCursor (char c) { + if (ScreenOutputDisabled) + return; + __asm { - xor bx, bx + mov bx, 7 mov al, c mov cx, 1 mov ah, 0xa @@ -144,16 +147,39 @@ void Beep () } +void InitVideoMode () +{ + if (ScreenOutputDisabled) + return; + + __asm + { + // Text mode 80x25 + mov ax, 3 + int 0x10 + + // Page 0 + mov ax, 0x500 + int 0x10 + } +} + + void ClearScreen () { + if (ScreenOutputDisabled) + return; + __asm { + // White text on black mov bh, 7 xor cx, cx mov dx, 0x184f mov ax, 0x600 int 0x10 + // Cursor at 0,0 xor bh, bh xor dx, dx mov ah, 2 @@ -165,7 +191,7 @@ void ClearScreen () void PrintBackspace () { PrintChar (TC_BIOS_CHAR_BACKSPACE); - PrintCharAtCusor (' '); + PrintCharAtCursor (' '); } @@ -198,6 +224,9 @@ byte GetShiftFlags () byte GetKeyboardChar (byte *scanCode) { + // Work around a bug in the Apple BIOS + while (!IsKeyboardCharAvailable()); + byte asciiCode; byte scan; __asm @@ -231,6 +260,35 @@ bool IsKeyboardCharAvailable () } +bool EscKeyPressed () +{ + if (IsKeyboardCharAvailable ()) + { + byte keyScanCode; + GetKeyboardChar (&keyScanCode); + return keyScanCode == TC_BIOS_KEY_ESC; + } + + return false; +} + + +void ClearBiosKeystrokeBuffer () +{ + __asm + { + push es + xor ax, ax + mov es, ax + mov di, 0x41e + mov cx, 32 + cld + rep stosb + pop es + } +} + + bool IsPrintable (char c) { return c >= ' ' && c <= '~';