winstuff.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. /*
  2. * winstuff.h: Windows-specific inter-module stuff.
  3. */
  4. #ifndef PUTTY_WINSTUFF_H
  5. #define PUTTY_WINSTUFF_H
  6. #ifndef AUTO_WINSOCK
  7. #include <winsock2.h>
  8. #endif
  9. #include <windows.h>
  10. #include <stdio.h> /* for FILENAME_MAX */
  11. /* We use uintptr_t for Win32/Win64 portability, so we should in
  12. * principle include stdint.h, which defines it according to the C
  13. * standard. But older versions of Visual Studio - including the one
  14. * used for official PuTTY builds as of 2015-09-28 - 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. */
  18. #include <stddef.h>
  19. #if !defined _MSC_VER || _MSC_VER >= 1600 || defined __clang__
  20. #include <stdint.h>
  21. #endif
  22. #include "tree234.h"
  23. #include "winhelp.h"
  24. #define BUILDINFO_PLATFORM "Windows"
  25. struct Filename {
  26. char *path;
  27. };
  28. #define f_open(filename, mode, isprivate) ( fopen((filename)->path, (mode)) )
  29. struct FontSpec {
  30. char *name;
  31. int isbold;
  32. int height;
  33. int charset;
  34. };
  35. struct FontSpec *fontspec_new(const char *name,
  36. int bold, int height, int charset);
  37. #ifndef CLEARTYPE_QUALITY
  38. #define CLEARTYPE_QUALITY 5
  39. #endif
  40. #define FONT_QUALITY(fq) ( \
  41. (fq) == FQ_DEFAULT ? DEFAULT_QUALITY : \
  42. (fq) == FQ_ANTIALIASED ? ANTIALIASED_QUALITY : \
  43. (fq) == FQ_NONANTIALIASED ? NONANTIALIASED_QUALITY : \
  44. CLEARTYPE_QUALITY)
  45. #define PLATFORM_IS_UTF16 /* enable UTF-16 processing when exchanging
  46. * wchar_t strings with environment */
  47. /*
  48. * Where we can, we use GetWindowLongPtr and friends because they're
  49. * more useful on 64-bit platforms, but they're a relatively recent
  50. * innovation, missing from VC++ 6 and older MinGW. Degrade nicely.
  51. * (NB that on some systems, some of these things are available but
  52. * not others...)
  53. */
  54. #ifndef GCLP_HCURSOR
  55. /* GetClassLongPtr and friends */
  56. #undef GetClassLongPtr
  57. #define GetClassLongPtr GetClassLong
  58. #undef SetClassLongPtr
  59. #define SetClassLongPtr SetClassLong
  60. #define GCLP_HCURSOR GCL_HCURSOR
  61. /* GetWindowLongPtr and friends */
  62. #undef GetWindowLongPtr
  63. #define GetWindowLongPtr GetWindowLong
  64. #undef SetWindowLongPtr
  65. #define SetWindowLongPtr SetWindowLong
  66. #undef GWLP_USERDATA
  67. #define GWLP_USERDATA GWL_USERDATA
  68. #undef DWLP_MSGRESULT
  69. #define DWLP_MSGRESULT DWL_MSGRESULT
  70. /* Since we've clobbered the above functions, we should clobber the
  71. * associated type regardless of whether it's defined. */
  72. #undef LONG_PTR
  73. #define LONG_PTR LONG
  74. #endif
  75. #define BOXFLAGS DLGWINDOWEXTRA
  76. #define BOXRESULT (DLGWINDOWEXTRA + sizeof(LONG_PTR))
  77. #define DF_END 0x0001
  78. #ifdef __WINE__
  79. #define NO_SECUREZEROMEMORY /* winelib doesn't have this */
  80. #endif
  81. #ifndef NO_SECUREZEROMEMORY
  82. #define PLATFORM_HAS_SMEMCLR /* inhibit cross-platform one in misc.c */
  83. #endif
  84. #ifndef __WINE__
  85. /* Up-to-date Windows headers warn that the unprefixed versions of
  86. * these names are deprecated. */
  87. #define stricmp _stricmp
  88. #define strnicmp _strnicmp
  89. #else
  90. /* Compiling with winegcc, _neither_ version of these functions
  91. * exists. Use the POSIX names. */
  92. #define stricmp strcasecmp
  93. #define strnicmp strncasecmp
  94. #endif
  95. #define BROKEN_PIPE_ERROR_CODE ERROR_BROKEN_PIPE /* used in sshshare.c */
  96. /*
  97. * Dynamically linked functions. These come in two flavours:
  98. *
  99. * - GET_WINDOWS_FUNCTION does not expose "name" to the preprocessor,
  100. * so will always dynamically link against exactly what is specified
  101. * in "name". If you're not sure, use this one.
  102. *
  103. * - GET_WINDOWS_FUNCTION_PP allows "name" to be redirected via
  104. * preprocessor definitions like "#define foo bar"; this is principally
  105. * intended for the ANSI/Unicode DoSomething/DoSomethingA/DoSomethingW.
  106. * If your function has an argument of type "LPTSTR" or similar, this
  107. * is the variant to use.
  108. * (However, it can't always be used, as it trips over more complicated
  109. * macro trickery such as the WspiapiGetAddrInfo wrapper for getaddrinfo.)
  110. *
  111. * (DECL_WINDOWS_FUNCTION works with both these variants.)
  112. */
  113. #define TYPECHECK(to_check, to_return) \
  114. (sizeof(to_check) ? to_return : to_return)
  115. #define DECL_WINDOWS_FUNCTION(linkage, rettype, name, params) \
  116. typedef rettype (WINAPI *t_##name) params; \
  117. linkage t_##name p_##name
  118. #define STR1(x) #x
  119. #define STR(x) STR1(x)
  120. #define GET_WINDOWS_FUNCTION_PP(module, name) \
  121. TYPECHECK((t_##name)NULL == name, \
  122. (p_##name = module ? \
  123. (t_##name) GetProcAddress(module, STR(name)) : NULL))
  124. #define GET_WINDOWS_FUNCTION(module, name) \
  125. TYPECHECK((t_##name)NULL == name, \
  126. (p_##name = module ? \
  127. (t_##name) GetProcAddress(module, #name) : NULL))
  128. #define GET_WINDOWS_FUNCTION_NO_TYPECHECK(module, name) \
  129. (p_##name = module ? \
  130. (t_##name) GetProcAddress(module, #name) : NULL)
  131. /*
  132. * Global variables. Most modules declare these `extern', but
  133. * window.c will do `#define PUTTY_DO_GLOBALS' before including this
  134. * module, and so will get them properly defined.
  135. */
  136. #ifndef GLOBAL
  137. #ifdef PUTTY_DO_GLOBALS
  138. #define GLOBAL
  139. #else
  140. #define GLOBAL extern
  141. #endif
  142. #endif
  143. #ifndef DONE_TYPEDEFS
  144. #define DONE_TYPEDEFS
  145. typedef struct conf_tag Conf;
  146. typedef struct backend_tag Backend;
  147. typedef struct terminal_tag Terminal;
  148. #endif
  149. #define PUTTY_REG_POS "Software\\SimonTatham\\PuTTY"
  150. #define PUTTY_REG_PARENT "Software\\SimonTatham"
  151. #define PUTTY_REG_PARENT_CHILD "PuTTY"
  152. #define PUTTY_REG_GPARENT "Software"
  153. #define PUTTY_REG_GPARENT_CHILD "SimonTatham"
  154. /* Result values for the jumplist registry functions. */
  155. #define JUMPLISTREG_OK 0
  156. #define JUMPLISTREG_ERROR_INVALID_PARAMETER 1
  157. #define JUMPLISTREG_ERROR_KEYOPENCREATE_FAILURE 2
  158. #define JUMPLISTREG_ERROR_VALUEREAD_FAILURE 3
  159. #define JUMPLISTREG_ERROR_VALUEWRITE_FAILURE 4
  160. #define JUMPLISTREG_ERROR_INVALID_VALUE 5
  161. #define PUTTY_HELP_FILE "putty.hlp"
  162. #define PUTTY_CHM_FILE "putty.chm"
  163. #define PUTTY_HELP_CONTENTS "putty.cnt"
  164. #define GETTICKCOUNT GetTickCount
  165. #define CURSORBLINK GetCaretBlinkTime()
  166. #define TICKSPERSEC 1000 /* GetTickCount returns milliseconds */
  167. #define DEFAULT_CODEPAGE CP_ACP
  168. #define USES_VTLINE_HACK
  169. typedef HDC Context;
  170. typedef unsigned int uint32; /* int is 32-bits on Win32 and Win64. */
  171. #define PUTTY_UINT32_DEFINED
  172. #ifndef NO_GSSAPI
  173. /*
  174. * GSS-API stuff
  175. */
  176. #define GSS_CC CALLBACK
  177. /*
  178. typedef struct Ssh_gss_buf {
  179. size_t length;
  180. char *value;
  181. } Ssh_gss_buf;
  182. #define SSH_GSS_EMPTY_BUF (Ssh_gss_buf) {0,NULL}
  183. typedef void *Ssh_gss_name;
  184. */
  185. #endif
  186. /*
  187. * Window handles for the windows that can be running during a
  188. * PuTTY session.
  189. */
  190. GLOBAL HWND hwnd; /* the main terminal window */
  191. GLOBAL HWND logbox;
  192. /*
  193. * The all-important instance handle.
  194. */
  195. GLOBAL HINSTANCE hinst;
  196. /*
  197. * Help file stuff in winhelp.c.
  198. */
  199. void init_help(void);
  200. void shutdown_help(void);
  201. int has_help(void);
  202. void launch_help(HWND hwnd, const char *topic);
  203. void quit_help(HWND hwnd);
  204. /*
  205. * The terminal and logging context are notionally local to the
  206. * Windows front end, but they must be shared between window.c and
  207. * windlg.c. Likewise the saved-sessions list.
  208. */
  209. GLOBAL Terminal *term;
  210. GLOBAL void *logctx;
  211. #define WM_NETEVENT (WM_APP + 5)
  212. /*
  213. * On Windows, we send MA_2CLK as the only event marking the second
  214. * press of a mouse button. Compare unix.h.
  215. */
  216. #define MULTICLICK_ONLY_EVENT 1
  217. /*
  218. * On Windows, data written to the clipboard must be NUL-terminated.
  219. */
  220. #define SELECTION_NUL_TERMINATED 1
  221. /*
  222. * On Windows, copying to the clipboard terminates lines with CRLF.
  223. */
  224. #define SEL_NL { 13, 10 }
  225. /*
  226. * sk_getxdmdata() does not exist under Windows (not that I
  227. * couldn't write it if I wanted to, but I haven't bothered), so
  228. * it's a macro which always returns NULL. With any luck this will
  229. * cause the compiler to notice it can optimise away the
  230. * implementation of XDM-AUTHORIZATION-1 in x11fwd.c :-)
  231. */
  232. #define sk_getxdmdata(socket, lenp) (NULL)
  233. /*
  234. * File-selector filter strings used in the config box. On Windows,
  235. * these strings are of exactly the type needed to go in
  236. * `lpstrFilter' in an OPENFILENAME structure.
  237. */
  238. #define FILTER_KEY_FILES ("PuTTY Private Key Files (*.ppk)\0*.ppk\0" \
  239. "All Files (*.*)\0*\0\0\0")
  240. #define FILTER_WAVE_FILES ("Wave Files (*.wav)\0*.WAV\0" \
  241. "All Files (*.*)\0*\0\0\0")
  242. #define FILTER_DYNLIB_FILES ("Dynamic Library Files (*.dll)\0*.dll\0" \
  243. "All Files (*.*)\0*\0\0\0")
  244. /*
  245. * Exports from winnet.c.
  246. */
  247. extern void select_result(WPARAM, LPARAM);
  248. /*
  249. * winnet.c dynamically loads WinSock 2 or WinSock 1 depending on
  250. * what it can get, which means any WinSock routines used outside
  251. * that module must be exported from it as function pointers. So
  252. * here they are.
  253. */
  254. DECL_WINDOWS_FUNCTION(GLOBAL, int, WSAAsyncSelect,
  255. (SOCKET, HWND, u_int, long));
  256. DECL_WINDOWS_FUNCTION(GLOBAL, int, WSAEventSelect,
  257. (SOCKET, WSAEVENT, long));
  258. DECL_WINDOWS_FUNCTION(GLOBAL, int, WSAGetLastError, (void));
  259. DECL_WINDOWS_FUNCTION(GLOBAL, int, WSAEnumNetworkEvents,
  260. (SOCKET, WSAEVENT, LPWSANETWORKEVENTS));
  261. #ifdef NEED_DECLARATION_OF_SELECT
  262. /* This declaration is protected by an ifdef for the sake of building
  263. * against winelib, in which you have to include winsock2.h before
  264. * stdlib.h so that the right fd_set type gets defined. It would be a
  265. * pain to do that throughout this codebase, so instead I arrange that
  266. * only a modules actually needing to use (or define, or initialise)
  267. * this function pointer will see its declaration, and _those_ modules
  268. * - which will be Windows-specific anyway - can take more care. */
  269. DECL_WINDOWS_FUNCTION(GLOBAL, int, select,
  270. (int, fd_set FAR *, fd_set FAR *,
  271. fd_set FAR *, const struct timeval FAR *));
  272. #endif
  273. extern int socket_writable(SOCKET skt);
  274. extern void socket_reselect_all(void);
  275. /*
  276. * Exports from winctrls.c.
  277. */
  278. struct ctlpos {
  279. HWND hwnd;
  280. WPARAM font;
  281. int dlu4inpix;
  282. int ypos, width;
  283. int xoff;
  284. int boxystart, boxid;
  285. char *boxtext;
  286. };
  287. void init_common_controls(void); /* also does some DLL-loading */
  288. /*
  289. * Exports from winutils.c.
  290. */
  291. typedef struct filereq_tag filereq; /* cwd for file requester */
  292. BOOL request_file(filereq *state, OPENFILENAME *of, int preserve, int save);
  293. filereq *filereq_new(void);
  294. void filereq_free(filereq *state);
  295. int message_box(LPCTSTR text, LPCTSTR caption, DWORD style, DWORD helpctxid);
  296. char *GetDlgItemText_alloc(HWND hwnd, int id);
  297. void split_into_argv(char *, int *, char ***, char ***);
  298. /*
  299. * Private structure for prefslist state. Only in the header file
  300. * so that we can delegate allocation to callers.
  301. */
  302. struct prefslist {
  303. int listid, upbid, dnbid;
  304. int srcitem;
  305. int dummyitem;
  306. int dragging;
  307. };
  308. /*
  309. * This structure is passed to event handler functions as the `dlg'
  310. * parameter, and hence is passed back to winctrls access functions.
  311. */
  312. struct dlgparam {
  313. HWND hwnd; /* the hwnd of the dialog box */
  314. struct winctrls *controltrees[8]; /* can have several of these */
  315. int nctrltrees;
  316. char *wintitle; /* title of actual window */
  317. char *errtitle; /* title of error sub-messageboxes */
  318. void *data; /* data to pass in refresh events */
  319. union control *focused, *lastfocused; /* which ctrl has focus now/before */
  320. char shortcuts[128]; /* track which shortcuts in use */
  321. int coloursel_wanted; /* has an event handler asked for
  322. * a colour selector? */
  323. struct { unsigned char r, g, b, ok; } coloursel_result; /* 0-255 */
  324. tree234 *privdata; /* stores per-control private data */
  325. int ended, endresult; /* has the dialog been ended? */
  326. int fixed_pitch_fonts; /* are we constrained to fixed fonts? */
  327. };
  328. /*
  329. * Exports from winctrls.c.
  330. */
  331. void ctlposinit(struct ctlpos *cp, HWND hwnd,
  332. int leftborder, int rightborder, int topborder);
  333. HWND doctl(struct ctlpos *cp, RECT r,
  334. char *wclass, int wstyle, int exstyle, char *wtext, int wid);
  335. void bartitle(struct ctlpos *cp, char *name, int id);
  336. void beginbox(struct ctlpos *cp, char *name, int idbox);
  337. void endbox(struct ctlpos *cp);
  338. void editboxfw(struct ctlpos *cp, int password, char *text,
  339. int staticid, int editid);
  340. void radioline(struct ctlpos *cp, char *text, int id, int nacross, ...);
  341. void bareradioline(struct ctlpos *cp, int nacross, ...);
  342. void radiobig(struct ctlpos *cp, char *text, int id, ...);
  343. void checkbox(struct ctlpos *cp, char *text, int id);
  344. void statictext(struct ctlpos *cp, char *text, int lines, int id);
  345. void staticbtn(struct ctlpos *cp, char *stext, int sid,
  346. char *btext, int bid);
  347. void static2btn(struct ctlpos *cp, char *stext, int sid,
  348. char *btext1, int bid1, char *btext2, int bid2);
  349. void staticedit(struct ctlpos *cp, char *stext,
  350. int sid, int eid, int percentedit);
  351. void staticddl(struct ctlpos *cp, char *stext,
  352. int sid, int lid, int percentlist);
  353. void combobox(struct ctlpos *cp, char *text, int staticid, int listid);
  354. void staticpassedit(struct ctlpos *cp, char *stext,
  355. int sid, int eid, int percentedit);
  356. void bigeditctrl(struct ctlpos *cp, char *stext,
  357. int sid, int eid, int lines);
  358. void ersatztab(struct ctlpos *cp, char *stext, int sid, int lid, int s2id);
  359. void editbutton(struct ctlpos *cp, char *stext, int sid,
  360. int eid, char *btext, int bid);
  361. void sesssaver(struct ctlpos *cp, char *text,
  362. int staticid, int editid, int listid, ...);
  363. void envsetter(struct ctlpos *cp, char *stext, int sid,
  364. char *e1stext, int e1sid, int e1id,
  365. char *e2stext, int e2sid, int e2id,
  366. int listid, char *b1text, int b1id, char *b2text, int b2id);
  367. void charclass(struct ctlpos *cp, char *stext, int sid, int listid,
  368. char *btext, int bid, int eid, char *s2text, int s2id);
  369. void colouredit(struct ctlpos *cp, char *stext, int sid, int listid,
  370. char *btext, int bid, ...);
  371. void prefslist(struct prefslist *hdl, struct ctlpos *cp, int lines,
  372. char *stext, int sid, int listid, int upbid, int dnbid);
  373. int handle_prefslist(struct prefslist *hdl,
  374. int *array, int maxmemb,
  375. int is_dlmsg, HWND hwnd,
  376. WPARAM wParam, LPARAM lParam);
  377. void progressbar(struct ctlpos *cp, int id);
  378. void fwdsetter(struct ctlpos *cp, int listid, char *stext, int sid,
  379. char *e1stext, int e1sid, int e1id,
  380. char *e2stext, int e2sid, int e2id,
  381. char *btext, int bid,
  382. char *r1text, int r1id, char *r2text, int r2id);
  383. void dlg_auto_set_fixed_pitch_flag(void *dlg);
  384. int dlg_get_fixed_pitch_flag(void *dlg);
  385. void dlg_set_fixed_pitch_flag(void *dlg, int flag);
  386. #define MAX_SHORTCUTS_PER_CTRL 16
  387. /*
  388. * This structure is what's stored for each `union control' in the
  389. * portable-dialog interface.
  390. */
  391. struct winctrl {
  392. union control *ctrl;
  393. /*
  394. * The control may have several components at the Windows
  395. * level, with different dialog IDs. To avoid needing N
  396. * separate platformsidectrl structures (which could be stored
  397. * separately in a tree234 so that lookup by ID worked), we
  398. * impose the constraint that those IDs must be in a contiguous
  399. * block.
  400. */
  401. int base_id;
  402. int num_ids;
  403. /*
  404. * Remember what keyboard shortcuts were used by this control,
  405. * so that when we remove it again we can take them out of the
  406. * list in the dlgparam.
  407. */
  408. char shortcuts[MAX_SHORTCUTS_PER_CTRL];
  409. /*
  410. * Some controls need a piece of allocated memory in which to
  411. * store temporary data about the control.
  412. */
  413. void *data;
  414. };
  415. /*
  416. * And this structure holds a set of the above, in two separate
  417. * tree234s so that it can find an item by `union control' or by
  418. * dialog ID.
  419. */
  420. struct winctrls {
  421. tree234 *byctrl, *byid;
  422. };
  423. struct controlset;
  424. struct controlbox;
  425. void winctrl_init(struct winctrls *);
  426. void winctrl_cleanup(struct winctrls *);
  427. void winctrl_add(struct winctrls *, struct winctrl *);
  428. void winctrl_remove(struct winctrls *, struct winctrl *);
  429. struct winctrl *winctrl_findbyctrl(struct winctrls *, union control *);
  430. struct winctrl *winctrl_findbyid(struct winctrls *, int);
  431. struct winctrl *winctrl_findbyindex(struct winctrls *, int);
  432. void winctrl_layout(struct dlgparam *dp, struct winctrls *wc,
  433. struct ctlpos *cp, struct controlset *s, int *id);
  434. int winctrl_handle_command(struct dlgparam *dp, UINT msg,
  435. WPARAM wParam, LPARAM lParam);
  436. void winctrl_rem_shortcuts(struct dlgparam *dp, struct winctrl *c);
  437. int winctrl_context_help(struct dlgparam *dp, HWND hwnd, int id);
  438. void dp_init(struct dlgparam *dp);
  439. void dp_add_tree(struct dlgparam *dp, struct winctrls *tree);
  440. void dp_cleanup(struct dlgparam *dp);
  441. /*
  442. * Exports from wincfg.c.
  443. */
  444. void win_setup_config_box(struct controlbox *b, HWND *hwndp, int has_help,
  445. int midsession, int protocol);
  446. /*
  447. * Exports from windlg.c.
  448. */
  449. void defuse_showwindow(void);
  450. int do_config(void);
  451. int do_reconfig(HWND, int);
  452. void showeventlog(HWND);
  453. void showabout(HWND);
  454. void force_normal(HWND hwnd);
  455. void modal_about_box(HWND hwnd);
  456. void show_help(HWND hwnd);
  457. /*
  458. * Exports from winmisc.c.
  459. */
  460. extern OSVERSIONINFO osVersion;
  461. void dll_hijacking_protection(void);
  462. BOOL init_winver(void);
  463. HMODULE load_system32_dll(const char *libname);
  464. const char *win_strerror(int error);
  465. void restrict_process_acl(void);
  466. GLOBAL int restricted_acl;
  467. /* A few pieces of up-to-date Windows API definition needed for older
  468. * compilers. */
  469. #ifndef LOAD_LIBRARY_SEARCH_SYSTEM32
  470. #define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800
  471. #endif
  472. #ifndef LOAD_LIBRARY_SEARCH_USER_DIRS
  473. #define LOAD_LIBRARY_SEARCH_USER_DIRS 0x00000400
  474. #endif
  475. #ifndef LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR
  476. #define LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR 0x00000100
  477. #endif
  478. #ifndef DLL_DIRECTORY_COOKIE
  479. typedef PVOID DLL_DIRECTORY_COOKIE;
  480. DECLSPEC_IMPORT DLL_DIRECTORY_COOKIE WINAPI AddDllDirectory (PCWSTR NewDirectory);
  481. #endif
  482. /*
  483. * Exports from sizetip.c.
  484. */
  485. void UpdateSizeTip(HWND src, int cx, int cy);
  486. void EnableSizeTip(int bEnable);
  487. /*
  488. * Exports from unicode.c.
  489. */
  490. struct unicode_data;
  491. void init_ucs(Conf *, struct unicode_data *);
  492. /*
  493. * Exports from winhandl.c.
  494. */
  495. #define HANDLE_FLAG_OVERLAPPED 1
  496. #define HANDLE_FLAG_IGNOREEOF 2
  497. #define HANDLE_FLAG_UNITBUFFER 4
  498. struct handle;
  499. typedef int (*handle_inputfn_t)(struct handle *h, void *data, int len);
  500. typedef void (*handle_outputfn_t)(struct handle *h, int new_backlog);
  501. struct handle *handle_input_new(HANDLE handle, handle_inputfn_t gotdata,
  502. void *privdata, int flags);
  503. struct handle *handle_output_new(HANDLE handle, handle_outputfn_t sentdata,
  504. void *privdata, int flags);
  505. int handle_write(struct handle *h, const void *data, int len);
  506. void handle_write_eof(struct handle *h);
  507. HANDLE *handle_get_events(int *nevents);
  508. void handle_free(struct handle *h);
  509. void handle_got_event(HANDLE event);
  510. void handle_unthrottle(struct handle *h, int backlog);
  511. int handle_backlog(struct handle *h);
  512. void *handle_get_privdata(struct handle *h);
  513. struct handle *handle_add_foreign_event(HANDLE event,
  514. void (*callback)(void *), void *ctx);
  515. /*
  516. * winpgntc.c needs to schedule callbacks for asynchronous agent
  517. * requests. This has to be done differently in GUI and console, so
  518. * there's an exported function used for the purpose.
  519. *
  520. * Also, we supply FLAG_SYNCAGENT to force agent requests to be
  521. * synchronous in pscp and psftp.
  522. */
  523. void agent_schedule_callback(void (*callback)(void *, void *, int),
  524. void *callback_ctx, void *data, int len);
  525. #define FLAG_SYNCAGENT 0x1000
  526. /*
  527. * Exports from winser.c.
  528. */
  529. extern Backend serial_backend;
  530. /*
  531. * Exports from winjump.c.
  532. */
  533. #define JUMPLIST_SUPPORTED /* suppress #defines in putty.h */
  534. void add_session_to_jumplist(const char * const sessionname);
  535. void remove_session_from_jumplist(const char * const sessionname);
  536. void clear_jumplist(void);
  537. BOOL set_explicit_app_user_model_id();
  538. /*
  539. * Extra functions in winstore.c over and above the interface in
  540. * storage.h.
  541. *
  542. * These functions manipulate the Registry section which mirrors the
  543. * current Windows 7 jump list. (Because the real jump list storage is
  544. * write-only, we need to keep another copy of whatever we put in it,
  545. * so that we can put in a slightly modified version the next time.)
  546. */
  547. /* Adds a saved session to the registry jump list mirror. 'item' is a
  548. * string naming a saved session. */
  549. int add_to_jumplist_registry(const char *item);
  550. /* Removes an item from the registry jump list mirror. */
  551. int remove_from_jumplist_registry(const char *item);
  552. /* Returns the current jump list entries from the registry. Caller
  553. * must free the returned pointer, which points to a contiguous
  554. * sequence of NUL-terminated strings in memory, terminated with an
  555. * empty one. */
  556. char *get_jumplist_registry_entries(void);
  557. #endif