winstuff.h 21 KB

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