2 * windows/platform.h: Windows-specific inter-module stuff.
5 #ifndef PUTTY_WINDOWS_PLATFORM_H
6 #define PUTTY_WINDOWS_PLATFORM_H
10 #include <stdio.h> /* for FILENAME_MAX */
12 /* We use uintptr_t for Win32/Win64 portability, so we should in
13 * principle include stdint.h, which defines it according to the C
14 * standard. But older versions of Visual Studio don't provide
15 * stdint.h at all, but do (non-standardly) define uintptr_t in
16 * stddef.h. So here we try to make sure _some_ standard header is
17 * included which defines uintptr_t. */
30 #if defined _M_IX86 || defined _M_AMD64
31 #define BUILDINFO_PLATFORM "x86 Windows"
32 #elif defined _M_ARM || defined _M_ARM64
33 #define BUILDINFO_PLATFORM "Arm Windows"
35 #define BUILDINFO_PLATFORM "Windows"
38 #if defined __GNUC__ || defined __clang__
39 #define THREADLOCAL __thread
40 #elif defined _MSC_VER
41 #define THREADLOCAL __declspec(thread)
43 #error Do not know how to declare thread-local storage with this toolchain
46 /* Randomly-chosen dwData value identifying a WM_COPYDATA message as
47 * being a Pageant transaction */
48 #define AGENT_COPYDATA_ID 0x804e50ba
53 static inline FILE *f_open(const Filename
*filename
, const char *mode
,
56 return fopen(filename
->path
, mode
);
65 struct FontSpec
*fontspec_new(
66 const char *name
, bool bold
, int height
, int charset
);
68 #ifndef CLEARTYPE_QUALITY
69 #define CLEARTYPE_QUALITY 5
71 #define FONT_QUALITY(fq) ( \
72 (fq) == FQ_DEFAULT ? DEFAULT_QUALITY : \
73 (fq) == FQ_ANTIALIASED ? ANTIALIASED_QUALITY : \
74 (fq) == FQ_NONANTIALIASED ? NONANTIALIASED_QUALITY : \
77 #define PLATFORM_IS_UTF16 /* enable UTF-16 processing when exchanging
78 * wchar_t strings with environment */
80 #define PLATFORM_CLIPBOARDS(X) \
81 X(CLIP_SYSTEM, "system clipboard") \
85 * Where we can, we use GetWindowLongPtr and friends because they're
86 * more useful on 64-bit platforms, but they're a relatively recent
87 * innovation, missing from VC++ 6 and older MinGW. Degrade nicely.
88 * (NB that on some systems, some of these things are available but
93 /* GetClassLongPtr and friends */
94 #undef GetClassLongPtr
95 #define GetClassLongPtr GetClassLong
96 #undef SetClassLongPtr
97 #define SetClassLongPtr SetClassLong
98 #define GCLP_HCURSOR GCL_HCURSOR
99 /* GetWindowLongPtr and friends */
100 #undef GetWindowLongPtr
101 #define GetWindowLongPtr GetWindowLong
102 #undef SetWindowLongPtr
103 #define SetWindowLongPtr SetWindowLong
105 #define GWLP_USERDATA GWL_USERDATA
106 #undef DWLP_MSGRESULT
107 #define DWLP_MSGRESULT DWL_MSGRESULT
108 /* Since we've clobbered the above functions, we should clobber the
109 * associated type regardless of whether it's defined. */
111 #define LONG_PTR LONG
115 /* Work around lack of strtoumax in older MSVC libraries */
116 static inline uintmax_t strtoumax(const char *nptr
, char **endptr
, int base
)
117 { return _strtoui64(nptr
, endptr
, base
); }
120 typedef INT_PTR (*ShinyDlgProc
)(HWND hwnd
, UINT msg
, WPARAM wParam
,
121 LPARAM lParam
, void *ctx
);
122 int ShinyDialogBox(HINSTANCE hinst
, LPCTSTR tmpl
, const char *winclass
,
123 HWND hwndparent
, ShinyDlgProc proc
, void *ctx
);
124 void ShinyEndDialog(HWND hwnd
, int ret
);
126 void centre_window(HWND hwnd
);
129 /* Up-to-date Windows headers warn that the unprefixed versions of
130 * these names are deprecated. */
131 #define stricmp _stricmp
132 #define strnicmp _strnicmp
134 /* Compiling with winegcc, _neither_ version of these functions
135 * exists. Use the POSIX names. */
136 #define stricmp strcasecmp
137 #define strnicmp strncasecmp
141 * Dynamically linked functions. These come in two flavours:
143 * - GET_WINDOWS_FUNCTION does not expose "name" to the preprocessor,
144 * so will always dynamically link against exactly what is specified
145 * in "name". If you're not sure, use this one.
147 * - GET_WINDOWS_FUNCTION_PP allows "name" to be redirected via
148 * preprocessor definitions like "#define foo bar"; this is principally
149 * intended for the ANSI/Unicode DoSomething/DoSomethingA/DoSomethingW.
150 * If your function has an argument of type "LPTSTR" or similar, this
151 * is the variant to use.
152 * (However, it can't always be used, as it trips over more complicated
153 * macro trickery such as the WspiapiGetAddrInfo wrapper for getaddrinfo.)
155 * (DECL_WINDOWS_FUNCTION works with both these variants.)
157 #define DECL_WINDOWS_FUNCTION(linkage, rettype, name, params) \
158 typedef rettype (WINAPI *t_##name) params; \
159 linkage t_##name p_##name
160 /* If you DECL_WINDOWS_FUNCTION as extern in a header file, use this to
161 * define the function pointer in a source file */
162 #define DEF_WINDOWS_FUNCTION(name) t_##name p_##name
163 #define GET_WINDOWS_FUNCTION_PP(module, name) \
164 TYPECHECK((t_##name)NULL == name, \
165 (p_##name = module ? \
166 (t_##name) GetProcAddress(module, STR(name)) : NULL))
167 #define GET_WINDOWS_FUNCTION(module, name) \
168 TYPECHECK((t_##name)NULL == name, \
169 (p_##name = module ? \
170 (t_##name) GetProcAddress(module, #name) : NULL))
171 #define GET_WINDOWS_FUNCTION_NO_TYPECHECK(module, name) \
172 (p_##name = module ? \
173 (t_##name) GetProcAddress(module, #name) : NULL)
175 #define PUTTY_REG_POS "Software\\SimonTatham\\PuTTY"
176 #define PUTTY_REG_PARENT "Software\\SimonTatham"
177 #define PUTTY_REG_PARENT_CHILD "PuTTY"
178 #define PUTTY_REG_GPARENT "Software"
179 #define PUTTY_REG_GPARENT_CHILD "SimonTatham"
181 /* Result values for the jumplist registry functions. */
182 #define JUMPLISTREG_OK 0
183 #define JUMPLISTREG_ERROR_INVALID_PARAMETER 1
184 #define JUMPLISTREG_ERROR_KEYOPENCREATE_FAILURE 2
185 #define JUMPLISTREG_ERROR_VALUEREAD_FAILURE 3
186 #define JUMPLISTREG_ERROR_VALUEWRITE_FAILURE 4
187 #define JUMPLISTREG_ERROR_INVALID_VALUE 5
189 #define PUTTY_CHM_FILE "putty.chm"
191 #define GETTICKCOUNT GetTickCount
192 #define CURSORBLINK GetCaretBlinkTime()
193 #define TICKSPERSEC 1000 /* GetTickCount returns milliseconds */
195 #define DEFAULT_CODEPAGE CP_ACP
196 #define USES_VTLINE_HACK
202 #define GSS_CC CALLBACK
204 typedef struct Ssh_gss_buf {
209 #define SSH_GSS_EMPTY_BUF (Ssh_gss_buf) {0,NULL}
210 typedef void *Ssh_gss_name;
215 * The all-important instance handle, saved from WinMain in every GUI
216 * program and exported for other GUI code to pass back to the Windows
219 extern HINSTANCE hinst
;
222 * Help file stuff in help.c.
224 void init_help(void);
225 void shutdown_help(void);
227 void launch_help(HWND hwnd
, const char *topic
);
228 void quit_help(HWND hwnd
);
229 int has_embedded_chm(void); /* 1 = yes, 0 = no, -1 = N/A */
232 * GUI seat methods in dialog.c, so that the vtable definition in
233 * window.c can refer to them.
235 SeatPromptResult
win_seat_confirm_ssh_host_key(
236 Seat
*seat
, const char *host
, int port
, const char *keytype
,
237 char *keystr
, SeatDialogText
*text
, HelpCtx helpctx
,
238 void (*callback
)(void *ctx
, SeatPromptResult result
), void *ctx
);
239 SeatPromptResult
win_seat_confirm_weak_crypto_primitive(
240 Seat
*seat
, SeatDialogText
*text
,
241 void (*callback
)(void *ctx
, SeatPromptResult result
), void *ctx
);
242 SeatPromptResult
win_seat_confirm_weak_cached_hostkey(
243 Seat
*seat
, SeatDialogText
*text
,
244 void (*callback
)(void *ctx
, SeatPromptResult result
), void *ctx
);
245 const SeatDialogPromptDescriptions
*win_seat_prompt_descriptions(Seat
*seat
);
248 * Windows-specific clipboard helper function shared with dialog.c,
249 * which takes the data string in the system code page instead of
252 void write_aclip(int clipboard
, char *, int, bool);
254 #define WM_NETEVENT (WM_APP + 5)
257 * On Windows, we send MA_2CLK as the only event marking the second
258 * press of a mouse button. Compare unix/platform.h.
260 #define MULTICLICK_ONLY_EVENT 1
263 * On Windows, data written to the clipboard must be NUL-terminated.
265 #define SELECTION_NUL_TERMINATED 1
268 * On Windows, copying to the clipboard terminates lines with CRLF.
270 #define SEL_NL { 13, 10 }
273 * sk_getxdmdata() does not exist under Windows (not that I
274 * couldn't write it if I wanted to, but I haven't bothered), so
275 * it's a macro which always returns NULL. With any luck this will
276 * cause the compiler to notice it can optimise away the
277 * implementation of XDM-AUTHORIZATION-1 in ssh/x11fwd.c :-)
279 #define sk_getxdmdata(socket, lenp) (NULL)
282 * File-selector filter strings used in the config box. On Windows,
283 * these strings are of exactly the type needed to go in
284 * `lpstrFilter' in an OPENFILENAME structure.
286 #define FILTER_KEY_FILES ("PuTTY Private Key Files (*.ppk)\0*.ppk\0" \
287 "All Files (*.*)\0*\0\0\0")
288 #define FILTER_WAVE_FILES ("Wave Files (*.wav)\0*.WAV\0" \
289 "All Files (*.*)\0*\0\0\0")
290 #define FILTER_DYNLIB_FILES ("Dynamic Library Files (*.dll)\0*.dll\0" \
291 "All Files (*.*)\0*\0\0\0")
294 * Exports from network.c.
296 /* Report an event notification from WSA*Select */
297 void select_result(WPARAM
, LPARAM
);
298 /* Enumerate all currently live OS-level SOCKETs */
299 SOCKET
first_socket(int *);
300 SOCKET
next_socket(int *);
301 /* Ask network.c whether we currently want to try to write to a SOCKET */
302 bool socket_writable(SOCKET skt
);
303 /* Force a refresh of the SOCKET list by re-calling do_select for each one */
304 void socket_reselect_all(void);
305 /* Make a SockAddr which just holds a named pipe address. */
306 SockAddr
*sk_namedpipe_addr(const char *pipename
);
307 /* Turn a WinSock error code into a string. */
308 const char *winsock_error_string(int error
);
309 Socket
*sk_newlistener_unix(const char *socketpath
, Plug
*plug
);
312 * network.c dynamically loads WinSock 2 or WinSock 1 depending on
313 * what it can get, which means any WinSock routines used outside
314 * that module must be exported from it as function pointers. So
317 DECL_WINDOWS_FUNCTION(extern, int, WSAAsyncSelect
,
318 (SOCKET
, HWND
, u_int
, LONG
));
319 DECL_WINDOWS_FUNCTION(extern, int, WSAEventSelect
,
320 (SOCKET
, WSAEVENT
, LONG
));
321 DECL_WINDOWS_FUNCTION(extern, int, WSAGetLastError
, (void));
322 DECL_WINDOWS_FUNCTION(extern, int, WSAEnumNetworkEvents
,
323 (SOCKET
, WSAEVENT
, LPWSANETWORKEVENTS
));
324 #ifdef NEED_DECLARATION_OF_SELECT
325 /* This declaration is protected by an ifdef for the sake of building
326 * against winelib, in which you have to include winsock2.h before
327 * stdlib.h so that the right fd_set type gets defined. It would be a
328 * pain to do that throughout this codebase, so instead I arrange that
329 * only a modules actually needing to use (or define, or initialise)
330 * this function pointer will see its declaration, and _those_ modules
331 * - which will be Windows-specific anyway - can take more care. */
332 DECL_WINDOWS_FUNCTION(extern, int, select
,
333 (int, fd_set FAR
*, fd_set FAR
*,
334 fd_set FAR
*, const struct timeval FAR
*));
338 * Implemented differently depending on the client of network.c, and
339 * called by network.c to turn on or off WSA*Select for a given socket.
341 const char *do_select(SOCKET skt
, bool enable
);
344 * Exports from select-{gui,cli}.c, each of which provides an
345 * implementation of do_select.
347 void winselgui_set_hwnd(HWND hwnd
);
348 void winselgui_clear_hwnd(void);
349 void winselgui_response(WPARAM wParam
, LPARAM lParam
);
351 void winselcli_setup(void);
352 SOCKET
winselcli_unique_socket(void);
353 extern HANDLE winselcli_event
;
356 * Network-subsystem-related functions provided in other Windows modules.
358 Socket
*make_handle_socket(HANDLE send_H
, HANDLE recv_H
, HANDLE stderr_H
,
359 SockAddr
*addr
, int port
, Plug
*plug
,
360 bool overlapped
); /* winhsock */
361 Socket
*make_deferred_handle_socket(DeferredSocketOpener
*opener
,
362 SockAddr
*addr
, int port
, Plug
*plug
);
363 void setup_handle_socket(Socket
*s
, HANDLE send_H
, HANDLE recv_H
,
364 HANDLE stderr_H
, bool overlapped
);
365 void handle_socket_set_psb_prefix(Socket
*s
, const char *prefix
);
366 Socket
*new_named_pipe_client(const char *pipename
, Plug
*plug
); /* winnpc */
367 Socket
*new_named_pipe_listener(const char *pipename
, Plug
*plug
); /* winnps */
369 /* A lower-level function in named-pipe-client.c, which does most of
370 * the work of new_named_pipe_client (including checking the ownership
371 * of what it's connected to), but returns a plain HANDLE instead of
372 * wrapping it into a Socket. */
373 HANDLE
connect_to_named_pipe(const char *pipename
, char **err
);
376 * Exports from controls.c.
385 int boxystart
, boxid
;
388 void init_common_controls(void); /* also does some DLL-loading */
391 * Exports from utils.
393 typedef struct filereq_tag filereq
; /* cwd for file requester */
394 bool request_file(filereq
*state
, OPENFILENAME
*of
, bool preserve
, bool save
);
395 filereq
*filereq_new(void);
396 void filereq_free(filereq
*state
);
397 void pgp_fingerprints_msgbox(HWND owner
);
398 int message_box(HWND owner
, LPCTSTR text
, LPCTSTR caption
,
399 DWORD style
, DWORD helpctxid
);
400 void MakeDlgItemBorderless(HWND parent
, int id
);
401 char *GetDlgItemText_alloc(HWND hwnd
, int id
);
402 void split_into_argv(char *, int *, char ***, char ***);
405 * Private structure for prefslist state. Only in the header file
406 * so that we can delegate allocation to callers.
409 int listid
, upbid
, dnbid
;
416 * This structure is passed to event handler functions as the `dlg'
417 * parameter, and hence is passed back to winctrls access functions.
420 HWND hwnd
; /* the hwnd of the dialog box */
421 struct winctrls
*controltrees
[8]; /* can have several of these */
423 char *wintitle
; /* title of actual window */
424 char *errtitle
; /* title of error sub-messageboxes */
425 void *data
; /* data to pass in refresh events */
426 dlgcontrol
*focused
, *lastfocused
; /* which ctrl has focus now/before */
427 bool shortcuts
[128]; /* track which shortcuts in use */
428 bool coloursel_wanted
; /* has an event handler asked for
429 * a colour selector? */
431 unsigned char r
, g
, b
; /* 0-255 */
434 tree234
*privdata
; /* stores per-control private data */
435 bool ended
; /* has the dialog been ended? */
436 int endresult
; /* and if so, what was the result? */
437 bool fixed_pitch_fonts
; /* are we constrained to fixed fonts? */
441 * Exports from controls.c.
443 void ctlposinit(struct ctlpos
*cp
, HWND hwnd
,
444 int leftborder
, int rightborder
, int topborder
);
445 HWND
doctl(struct ctlpos
*cp
, RECT r
, const char *wclass
, int wstyle
,
446 int exstyle
, const char *wtext
, int wid
);
447 void bartitle(struct ctlpos
*cp
, const char *name
, int id
);
448 void beginbox(struct ctlpos
*cp
, const char *name
, int idbox
);
449 void endbox(struct ctlpos
*cp
);
450 void editboxfw(struct ctlpos
*cp
, bool password
, bool readonly
,
451 const char *text
, int staticid
, int editid
);
452 void radioline(struct ctlpos
*cp
, const char *text
, int id
, int nacross
, ...);
453 void bareradioline(struct ctlpos
*cp
, int nacross
, ...);
454 void radiobig(struct ctlpos
*cp
, const char *text
, int id
, ...);
455 void checkbox(struct ctlpos
*cp
, const char *text
, int id
);
456 void button(struct ctlpos
*cp
, const char *btext
, int bid
, bool defbtn
);
457 void statictext(struct ctlpos
*cp
, const char *text
, int lines
, int id
);
458 void staticbtn(struct ctlpos
*cp
, const char *stext
, int sid
,
459 const char *btext
, int bid
);
460 void static2btn(struct ctlpos
*cp
, const char *stext
, int sid
,
461 const char *btext1
, int bid1
, const char *btext2
, int bid2
);
462 void staticedit(struct ctlpos
*cp
, const char *stext
,
463 int sid
, int eid
, int percentedit
);
464 void staticddl(struct ctlpos
*cp
, const char *stext
,
465 int sid
, int lid
, int percentlist
);
466 void combobox(struct ctlpos
*cp
, const char *text
, int staticid
, int listid
);
467 void staticpassedit(struct ctlpos
*cp
, const char *stext
,
468 int sid
, int eid
, int percentedit
);
469 void bigeditctrl(struct ctlpos
*cp
, const char *stext
,
470 int sid
, int eid
, int lines
);
471 void ersatztab(struct ctlpos
*cp
, const char *stext
, int sid
, int lid
,
473 void editbutton(struct ctlpos
*cp
, const char *stext
, int sid
,
474 int eid
, const char *btext
, int bid
);
475 void sesssaver(struct ctlpos
*cp
, const char *text
,
476 int staticid
, int editid
, int listid
, ...);
477 void envsetter(struct ctlpos
*cp
, const char *stext
, int sid
,
478 const char *e1stext
, int e1sid
, int e1id
,
479 const char *e2stext
, int e2sid
, int e2id
,
480 int listid
, const char *b1text
, int b1id
,
481 const char *b2text
, int b2id
);
482 void charclass(struct ctlpos
*cp
, const char *stext
, int sid
, int listid
,
483 const char *btext
, int bid
, int eid
, const char *s2text
,
485 void colouredit(struct ctlpos
*cp
, const char *stext
, int sid
, int listid
,
486 const char *btext
, int bid
, ...);
487 void prefslist(struct prefslist
*hdl
, struct ctlpos
*cp
, int lines
,
488 const char *stext
, int sid
, int listid
, int upbid
, int dnbid
);
489 int handle_prefslist(struct prefslist
*hdl
,
490 int *array
, int maxmemb
,
491 bool is_dlmsg
, HWND hwnd
,
492 WPARAM wParam
, LPARAM lParam
);
493 void progressbar(struct ctlpos
*cp
, int id
);
494 void fwdsetter(struct ctlpos
*cp
, int listid
, const char *stext
, int sid
,
495 const char *e1stext
, int e1sid
, int e1id
,
496 const char *e2stext
, int e2sid
, int e2id
,
497 const char *btext
, int bid
,
498 const char *r1text
, int r1id
, const char *r2text
, int r2id
);
500 void dlg_auto_set_fixed_pitch_flag(dlgparam
*dlg
);
501 bool dlg_get_fixed_pitch_flag(dlgparam
*dlg
);
502 void dlg_set_fixed_pitch_flag(dlgparam
*dlg
, bool flag
);
504 #define MAX_SHORTCUTS_PER_CTRL 16
507 * This structure is what's stored for each `dlgcontrol' in the
508 * portable-dialog interface.
513 * The control may have several components at the Windows
514 * level, with different dialog IDs. To avoid needing N
515 * separate platformsidectrl structures (which could be stored
516 * separately in a tree234 so that lookup by ID worked), we
517 * impose the constraint that those IDs must be in a contiguous
523 * For vertical alignment, the id of a particular representative
524 * control that has the y-extent of the sensible part of the
529 * Remember what keyboard shortcuts were used by this control,
530 * so that when we remove it again we can take them out of the
531 * list in the dlgparam.
533 char shortcuts
[MAX_SHORTCUTS_PER_CTRL
];
535 * Some controls need a piece of allocated memory in which to
536 * store temporary data about the control.
541 * And this structure holds a set of the above, in two separate
542 * tree234s so that it can find an item by `dlgcontrol' or by
546 tree234
*byctrl
, *byid
;
551 void winctrl_init(struct winctrls
*);
552 void winctrl_cleanup(struct winctrls
*);
553 void winctrl_add(struct winctrls
*, struct winctrl
*);
554 void winctrl_remove(struct winctrls
*, struct winctrl
*);
555 struct winctrl
*winctrl_findbyctrl(struct winctrls
*, dlgcontrol
*);
556 struct winctrl
*winctrl_findbyid(struct winctrls
*, int);
557 struct winctrl
*winctrl_findbyindex(struct winctrls
*, int);
558 void winctrl_layout(struct dlgparam
*dp
, struct winctrls
*wc
,
559 struct ctlpos
*cp
, struct controlset
*s
, int *id
);
560 bool winctrl_handle_command(struct dlgparam
*dp
, UINT msg
,
561 WPARAM wParam
, LPARAM lParam
);
562 void winctrl_rem_shortcuts(struct dlgparam
*dp
, struct winctrl
*c
);
563 bool winctrl_context_help(struct dlgparam
*dp
, HWND hwnd
, int id
);
565 void dp_init(struct dlgparam
*dp
);
566 void dp_add_tree(struct dlgparam
*dp
, struct winctrls
*tree
);
567 void dp_cleanup(struct dlgparam
*dp
);
570 * Exports from config.c.
572 void win_setup_config_box(struct controlbox
*b
, HWND
*hwndp
, bool has_help
,
573 bool midsession
, int protocol
);
576 * Exports from dialog.c.
578 void defuse_showwindow(void);
579 bool do_config(Conf
*);
580 bool do_reconfig(HWND
, Conf
*, int);
581 void showeventlog(HWND
);
582 void showabout(HWND
);
583 void force_normal(HWND hwnd
);
584 void modal_about_box(HWND hwnd
);
585 void show_help(HWND hwnd
);
586 HWND
event_log_window(void);
589 * Exports from utils.
591 extern DWORD osMajorVersion
, osMinorVersion
, osPlatformId
;
592 void init_winver(void);
593 void dll_hijacking_protection(void);
594 const char *get_system_dir(void);
595 HMODULE
load_system32_dll(const char *libname
);
596 const char *win_strerror(int error
);
597 bool should_have_security(void);
598 void restrict_process_acl(void);
599 bool restricted_acl(void);
600 void escape_registry_key(const char *in
, strbuf
*out
);
601 void unescape_registry_key(const char *in
, strbuf
*out
);
603 bool is_console_handle(HANDLE
);
605 /* A few pieces of up-to-date Windows API definition needed for older
607 #ifndef LOAD_LIBRARY_SEARCH_SYSTEM32
608 #define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800
610 #ifndef LOAD_LIBRARY_SEARCH_USER_DIRS
611 #define LOAD_LIBRARY_SEARCH_USER_DIRS 0x00000400
613 #ifndef LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR
614 #define LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR 0x00000100
616 #ifndef DLL_DIRECTORY_COOKIE
617 typedef PVOID DLL_DIRECTORY_COOKIE
;
618 DECLSPEC_IMPORT DLL_DIRECTORY_COOKIE WINAPI
AddDllDirectory (PCWSTR NewDirectory
);
622 * Exports from sizetip.c.
624 void UpdateSizeTip(HWND src
, int cx
, int cy
);
625 void EnableSizeTip(bool bEnable
);
628 * Exports from unicode.c.
630 void init_ucs(Conf
*, struct unicode_data
*);
633 * Exports from handle-io.c.
635 #define HANDLE_FLAG_OVERLAPPED 1
636 #define HANDLE_FLAG_IGNOREEOF 2
637 #define HANDLE_FLAG_UNITBUFFER 4
639 typedef size_t (*handle_inputfn_t
)(
640 struct handle
*h
, const void *data
, size_t len
, int err
);
641 typedef void (*handle_outputfn_t
)(
642 struct handle
*h
, size_t new_backlog
, int err
, bool close
);
643 struct handle
*handle_input_new(HANDLE handle
, handle_inputfn_t gotdata
,
644 void *privdata
, int flags
);
645 struct handle
*handle_output_new(HANDLE handle
, handle_outputfn_t sentdata
,
646 void *privdata
, int flags
);
647 size_t handle_write(struct handle
*h
, const void *data
, size_t len
);
648 void handle_write_eof(struct handle
*h
);
649 void handle_free(struct handle
*h
);
650 void handle_unthrottle(struct handle
*h
, size_t backlog
);
651 size_t handle_backlog(struct handle
*h
);
652 void *handle_get_privdata(struct handle
*h
);
653 /* Analogue of stdio_sink in marshal.h, for a Windows handle */
656 BinarySink_IMPLEMENTATION
;
658 void handle_sink_init(handle_sink
*sink
, struct handle
*h
);
661 * Exports from handle-wait.c.
663 typedef struct HandleWait HandleWait
;
664 typedef void (*handle_wait_callback_fn_t
)(void *);
665 HandleWait
*add_handle_wait(HANDLE h
, handle_wait_callback_fn_t callback
,
667 void delete_handle_wait(HandleWait
*hw
);
669 typedef struct HandleWaitList
{
670 HANDLE handles
[MAXIMUM_WAIT_OBJECTS
];
673 HandleWaitList
*get_handle_wait_list(void);
674 void handle_wait_activate(HandleWaitList
*hwl
, int index
);
675 void handle_wait_list_free(HandleWaitList
*hwl
);
678 * Pageant-related pathnames.
680 char *agent_mutex_name(void);
681 char *agent_named_pipe_name(void);
684 * Exports from serial.c.
686 extern const struct BackendVtable serial_backend
;
689 * Exports from jump-list.c.
691 #define JUMPLIST_SUPPORTED /* suppress #defines in putty.h */
692 void add_session_to_jumplist(const char * const sessionname
);
693 void remove_session_from_jumplist(const char * const sessionname
);
694 void clear_jumplist(void);
695 bool set_explicit_app_user_model_id(void);
698 * Exports from noise.c.
700 bool win_read_random(void *buf
, unsigned wanted
); /* returns true on success */
703 * Extra functions in storage.c over and above the interface in
706 * These functions manipulate the Registry section which mirrors the
707 * current Windows 7 jump list. (Because the real jump list storage is
708 * write-only, we need to keep another copy of whatever we put in it,
709 * so that we can put in a slightly modified version the next time.)
712 /* Adds a saved session to the registry jump list mirror. 'item' is a
713 * string naming a saved session. */
714 int add_to_jumplist_registry(const char *item
);
716 /* Removes an item from the registry jump list mirror. */
717 int remove_from_jumplist_registry(const char *item
);
719 /* Returns the current jump list entries from the registry. Caller
720 * must free the returned pointer, which points to a contiguous
721 * sequence of NUL-terminated strings in memory, terminated with an
723 char *get_jumplist_registry_entries(void);
726 * Windows clipboard-UI wording.
728 #define CLIPNAME_IMPLICIT "Last selected text"
729 #define CLIPNAME_EXPLICIT "System clipboard"
730 #define CLIPNAME_EXPLICIT_OBJECT "system clipboard"
731 /* These defaults are the ones PuTTY has historically had */
732 #define CLIPUI_DEFAULT_AUTOCOPY true
733 #define CLIPUI_DEFAULT_MOUSE CLIPUI_EXPLICIT
734 #define CLIPUI_DEFAULT_INS CLIPUI_EXPLICIT
737 HKEY
open_regkey_fn(bool create
, bool write
, HKEY base
, const char *path
, ...);
738 #define open_regkey_ro(base, ...) \
739 open_regkey_fn(false, false, base, __VA_ARGS__, (const char *)NULL)
740 #define open_regkey_rw(base, ...) \
741 open_regkey_fn(false, true, base, __VA_ARGS__, (const char *)NULL)
742 #define create_regkey(base, ...) \
743 open_regkey_fn(true, true, base, __VA_ARGS__, (const char *)NULL)
744 void close_regkey(HKEY key
);
745 void del_regkey(HKEY key
, const char *name
);
746 char *enum_regkey(HKEY key
, int index
);
747 bool get_reg_dword(HKEY key
, const char *name
, DWORD
*out
);
748 bool put_reg_dword(HKEY key
, const char *name
, DWORD value
);
749 char *get_reg_sz(HKEY key
, const char *name
);
750 bool put_reg_sz(HKEY key
, const char *name
, const char *str
);
751 strbuf
*get_reg_multi_sz(HKEY key
, const char *name
);
752 bool put_reg_multi_sz(HKEY key
, const char *name
, strbuf
*str
);
754 char *get_reg_sz_simple(HKEY key
, const char *name
, const char *leaf
);
757 typedef bool (*cliloop_pre_t
)(void *vctx
, const HANDLE
**extra_handles
,
758 size_t *n_extra_handles
);
759 typedef bool (*cliloop_post_t
)(void *vctx
, size_t extra_handle_index
);
760 void cli_main_loop(cliloop_pre_t pre
, cliloop_post_t post
, void *ctx
);
761 bool cliloop_null_pre(void *vctx
, const HANDLE
**, size_t *);
762 bool cliloop_null_post(void *vctx
, size_t);
764 extern const struct BackendVtable conpty_backend
;
766 /* Functions that parametrise window.c between PuTTY and pterm */
767 void gui_term_process_cmdline(Conf
*conf
, char *cmdline
);
768 const struct BackendVtable
*backend_vt_from_conf(Conf
*conf
);
769 const wchar_t *get_app_user_model_id(void);
770 /* And functions in window.c that those files call back to */
771 char *handle_restrict_acl_cmdline_prefix(char *cmdline
);
772 bool handle_special_sessionname_cmdline(char *cmdline
, Conf
*conf
);
773 bool handle_special_filemapping_cmdline(char *cmdline
, Conf
*conf
);
775 /* network.c: network error reporting helpers taking OS error code */
776 void plug_closing_system_error(Plug
*plug
, DWORD error
);
777 void plug_closing_winsock_error(Plug
*plug
, DWORD error
);
779 SeatPromptResult
make_spr_sw_abort_winerror(const char *prefix
, DWORD error
);
781 HANDLE
lock_interprocess_mutex(const char *mutexname
, char **error
);
782 void unlock_interprocess_mutex(HANDLE mutex
);
784 typedef void (*aux_opt_error_fn_t
)(const char *, ...);
785 typedef struct AuxMatchOpt
{
789 aux_opt_error_fn_t error
;
791 AuxMatchOpt
aux_match_opt_init(int argc
, char **argv
, int start_index
,
792 aux_opt_error_fn_t opt_error
);
793 bool aux_match_arg(AuxMatchOpt
*amo
, char **val
);
794 bool aux_match_opt(AuxMatchOpt
*amo
, char **val
, const char *optname
, ...);
795 bool aux_match_done(AuxMatchOpt
*amo
);
797 char *save_screenshot(HWND hwnd
, const char *outfile
);
798 void gui_terminal_ready(HWND hwnd
, Seat
*seat
, Backend
*backend
);
800 #endif /* PUTTY_WINDOWS_PLATFORM_H */