Example #1
0
static bool AskYesNo (const char *message)
{
	Print (message);
	Print ("? (y/n): ");
	while (true)
	{
		switch (GetKeyboardChar())
		{
		case 'y':
		case 'Y':
		case 'z':
		case 'Z':
			Print ("y\r\n");
			return true;

		case 'n':
		case 'N':
			Print ("n\r\n");
			return false;

		default:
			Beep();
		}
	}
}
Example #2
0
static byte AskPassword (Password &password)
{
	size_t pos = 0;
	byte scanCode;
	byte asciiCode;

	Print ("Enter password");
	Print (PreventNormalSystemBoot ? " for hidden system:\r\n" : ": ");

	while (true)
	{
		asciiCode = GetKeyboardChar (&scanCode);

		switch (scanCode)
		{
		case TC_BIOS_KEY_ENTER:
			ClearBiosKeystrokeBuffer();
			PrintEndl();

			password.Length = pos;
			return scanCode;

		case TC_BIOS_KEY_BACKSPACE:
			if (pos > 0)
			{
				if (pos < MAX_PASSWORD)
					PrintBackspace();
				else
					PrintCharAtCursor (' ');

				--pos;
			}
			continue;

		default:
			if (scanCode == TC_BIOS_KEY_ESC || IsMenuKey (scanCode))
			{
				burn (password.Text, sizeof (password.Text));
				ClearBiosKeystrokeBuffer();

				PrintEndl();
				return scanCode;
			}
		}

		if (!IsPrintable (asciiCode) || pos == MAX_PASSWORD)
		{
			Beep();
			continue;
		}

		password.Text[pos++] = asciiCode;
		if (pos < MAX_PASSWORD)
			PrintChar ('*');
		else
			PrintCharAtCursor ('*');
	}
}
Example #3
0
static byte AskPassword (Password &password, int& pin)
{
	size_t pos = 0;
	byte scanCode;
	byte asciiCode;
	byte hidePassword = 1;

	pin = 0;

	Print ("Enter password");
	Print (PreventNormalSystemBoot ? " for hidden system:\r\n" : ": ");

	while (true)
	{
		asciiCode = GetKeyboardChar (&scanCode);

		switch (scanCode)
		{
		case TC_BIOS_KEY_ENTER:
			ClearBiosKeystrokeBuffer();
			PrintEndl();

			password.Length = pos;
			break;

		case TC_BIOS_KEY_BACKSPACE:
			if (pos > 0)
			{
				if (pos < MAX_PASSWORD)
					PrintBackspace();
				else
					PrintCharAtCursor (' ');

				--pos;
			}
			continue;

		case TC_BIOS_KEY_F5:
			hidePassword ^= 0x01;
			continue;

		default:
			if (scanCode == TC_BIOS_KEY_ESC || IsMenuKey (scanCode))
			{
				burn (password.Text, sizeof (password.Text));
				ClearBiosKeystrokeBuffer();

				PrintEndl();
				return scanCode;
			}
		}

		if (TC_BIOS_KEY_ENTER == scanCode)
			break;

		if (!IsPrintable (asciiCode) || pos == MAX_PASSWORD)
		{
			Beep();
			continue;
		}

		password.Text[pos++] = asciiCode;
		if (hidePassword) asciiCode = '*';
		if (pos < MAX_PASSWORD)
			PrintChar (asciiCode);
		else
			PrintCharAtCursor (asciiCode);
	}

	pos = 0;
	Print ("PIM: ");

	while (true)
	{
		asciiCode = GetKeyboardChar (&scanCode);

		switch (scanCode)
		{
		case TC_BIOS_KEY_ENTER:
			ClearBiosKeystrokeBuffer();
			PrintEndl();

			return TC_BIOS_KEY_ENTER;

		case TC_BIOS_KEY_BACKSPACE:
			if (pos > 0)
			{
				if (pos < MAX_PIM)
					PrintBackspace();
				else
					PrintCharAtCursor (' ');

				--pos;
				pin /= 10;
			}
			continue;

		default:
			if (scanCode == TC_BIOS_KEY_ESC || IsMenuKey (scanCode))
			{
				burn (password.Text, sizeof (password.Text));
				ClearBiosKeystrokeBuffer();

				PrintEndl();
				return scanCode;
			}
		}

		if (!IsDigit (asciiCode) || pos == MAX_PIM)
		{
			Beep();
			continue;
		}

		pin = 10*pin + (asciiCode - '0');
		pos++;

		if (pos < MAX_PIM)
			PrintChar (asciiCode);
		else
			PrintCharAtCursor (asciiCode);
	}
}
Example #4
0
static byte AskPassword (Password &password, int& pim)
{
	size_t pos = 0;
	byte scanCode;
	byte asciiCode;
	byte hidePassword = 1;

	pim = 0;

	Print ("Enter password");
	Print (PreventNormalSystemBoot ? " for hidden system:\r\n" : ": ");

	while (true)
	{
		asciiCode = GetKeyboardChar (&scanCode);

		switch (scanCode)
		{
		case TC_BIOS_KEY_ENTER:
			password.Length = pos;
			Print ("\r");
			if (!PreventNormalSystemBoot)
				Print ("Enter password: "******"PIM: ");

		while (true)
		{
			asciiCode = GetKeyboardChar (&scanCode);

			switch (scanCode)
			{
			case TC_BIOS_KEY_ENTER:
				Print ("\rPIM: ");
				pos =0;
				while (pos < MAX_PIM)
				{
					PrintChar ('*');
					pos++;
				}

				ClearBiosKeystrokeBuffer();
				PrintEndl();

				return TC_BIOS_KEY_ENTER;

			case TC_BIOS_KEY_BACKSPACE:
				if (pos > 0)
				{
					if (pos < MAX_PIM)
						PrintBackspace();
					else
						PrintCharAtCursor (' ');

					--pos;
					pim /= 10;
				}
				continue;

			case TC_BIOS_KEY_F5:
				hidePassword ^= 0x01;
				continue;

			default:
				if (scanCode == TC_BIOS_KEY_ESC || IsMenuKey (scanCode))
				{
					burn (password.Text, sizeof (password.Text));
					ClearBiosKeystrokeBuffer();

					PrintEndl();
					return scanCode;
				}
			}

			if (!IsDigit (asciiCode) || pos == MAX_PIM)
			{
				Beep();
				continue;
			}

			pim = 10*pim + (asciiCode - '0');
			pos++;

			if (hidePassword) asciiCode = '*';
			if (pos < MAX_PIM)
				PrintChar (asciiCode);
			else
				PrintCharAtCursor (asciiCode);
		}
	}
}