mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-01 03:22:48 -05:00
Add a TermWin method to draw a 'trust sigil'.
This is not yet used by anything, but the idea is that it'll be a graphic in the terminal window that can't be replicated by a server sending escape sequences, and hence can be used as a reliable indication that the text on a particular terminal line is generated by PuTTY itself and not passed through from the server. This will make it possible to detect a malicious server trying to mimic local prompts to trick you out of information that shouldn't be sent over the wire (such as private-key passphrases). The trust sigil I've picked is a small copy of the PuTTY icon, which is thematically nice (it can be read as if the PuTTY icon is the name of the speaker in a dialogue) and also convenient because we had that graphic available already on all platforms. (Though the contortions I had to go through to make the GTK 1 code draw it were quite annoying.) The trust sigil has the same dimensions as a CJK double-width character, i.e. it's 2 character cells wide by 1 high.
This commit is contained in:
@ -231,6 +231,7 @@ static void wintw_draw_text(TermWin *, int x, int y, wchar_t *text, int len,
|
||||
unsigned long attrs, int lattrs, truecolour tc);
|
||||
static void wintw_draw_cursor(TermWin *, int x, int y, wchar_t *text, int len,
|
||||
unsigned long attrs, int lattrs, truecolour tc);
|
||||
static void wintw_draw_trust_sigil(TermWin *, int x, int y);
|
||||
static int wintw_char_width(TermWin *, int uc);
|
||||
static void wintw_free_draw_ctx(TermWin *);
|
||||
static void wintw_set_cursor_pos(TermWin *, int x, int y);
|
||||
@ -262,6 +263,7 @@ static const TermWinVtable windows_termwin_vt = {
|
||||
wintw_setup_draw_ctx,
|
||||
wintw_draw_text,
|
||||
wintw_draw_cursor,
|
||||
wintw_draw_trust_sigil,
|
||||
wintw_char_width,
|
||||
wintw_free_draw_ctx,
|
||||
wintw_set_cursor_pos,
|
||||
@ -291,6 +293,8 @@ static const TermWinVtable windows_termwin_vt = {
|
||||
static TermWin wintw[1];
|
||||
static HDC wintw_hdc;
|
||||
|
||||
static HICON icon;
|
||||
|
||||
const bool share_can_be_downstream = true;
|
||||
const bool share_can_be_upstream = true;
|
||||
|
||||
@ -674,6 +678,8 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
|
||||
prepare_session(conf);
|
||||
}
|
||||
|
||||
icon = LoadIcon(inst, MAKEINTRESOURCE(IDI_MAINICON));
|
||||
|
||||
if (!prev) {
|
||||
WNDCLASSW wndclass;
|
||||
|
||||
@ -682,7 +688,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
|
||||
wndclass.cbClsExtra = 0;
|
||||
wndclass.cbWndExtra = 0;
|
||||
wndclass.hInstance = inst;
|
||||
wndclass.hIcon = LoadIcon(inst, MAKEINTRESOURCE(IDI_MAINICON));
|
||||
wndclass.hIcon = icon;
|
||||
wndclass.hCursor = LoadCursor(NULL, IDC_IBEAM);
|
||||
wndclass.hbrBackground = NULL;
|
||||
wndclass.lpszMenuName = NULL;
|
||||
@ -3986,6 +3992,17 @@ static void wintw_draw_cursor(
|
||||
}
|
||||
}
|
||||
|
||||
static void wintw_draw_trust_sigil(TermWin *tw, int x, int y)
|
||||
{
|
||||
x *= font_width;
|
||||
y *= font_height;
|
||||
x += offset_width;
|
||||
y += offset_height;
|
||||
|
||||
DrawIconEx(wintw_hdc, x, y, icon, font_width * 2, font_height,
|
||||
0, NULL, DI_NORMAL);
|
||||
}
|
||||
|
||||
/* This function gets the actual width of a character in the normal font.
|
||||
*/
|
||||
static int wintw_char_width(TermWin *tw, int uc)
|
||||
|
Reference in New Issue
Block a user