winstuff.h 22 KB

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