"Fossies" - the Fresh Open Source Software Archive

Member "putty-0.73/windows/winstuff.h" (22 Sep 2019, 24618 Bytes) of package /linux/misc/putty-0.73.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "winstuff.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 0.72_vs_0.73.

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