mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00:00
Stop using GLOBAL Windows API function pointers.
The declarations in header files now use ordinary 'extern'. That means I have to arrange to put definitions matching those declarations in the appropriate modules; so I've made a macro DEFINE_WINDOWS_FUNCTION which performs a definition matching a prior DECLARE_WINDOWS_FUNCTION (and reusing the typedef made by the latter). This applies not only to the batch of functions that were marked GLOBAL in winstuff.h, but also the auxiliary sets marked WINCAPI_GLOBAL and WINSECUR_GLOBAL in wincapi.h and winsecur.h respectively.
This commit is contained in:
parent
3bbbdaad60
commit
25f7f8c025
@ -9,9 +9,10 @@
|
||||
#include "putty.h"
|
||||
#include "ssh.h"
|
||||
|
||||
#define WINCAPI_GLOBAL
|
||||
#include "wincapi.h"
|
||||
|
||||
DEF_WINDOWS_FUNCTION(CryptProtectMemory);
|
||||
|
||||
bool got_crypt(void)
|
||||
{
|
||||
static bool attempted = false;
|
||||
|
@ -7,12 +7,7 @@
|
||||
|
||||
#if !defined NO_SECURITY
|
||||
|
||||
#ifndef WINCAPI_GLOBAL
|
||||
#define WINCAPI_GLOBAL extern
|
||||
#endif
|
||||
|
||||
DECL_WINDOWS_FUNCTION(WINCAPI_GLOBAL, BOOL, CryptProtectMemory,
|
||||
(LPVOID,DWORD,DWORD));
|
||||
DECL_WINDOWS_FUNCTION(extern, BOOL, CryptProtectMemory, (LPVOID,DWORD,DWORD));
|
||||
|
||||
bool got_crypt(void);
|
||||
|
||||
|
@ -224,12 +224,11 @@ static bool sk_startup(int hi, int lo)
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Actually define this function pointer, which won't have been
|
||||
* defined alongside all the others by PUTTY_DO_GLOBALS because of the
|
||||
* annoying winelib header-ordering issue. (See comment in winstuff.h.) */
|
||||
DECL_WINDOWS_FUNCTION(/* empty */, int, select,
|
||||
(int, fd_set FAR *, fd_set FAR *,
|
||||
fd_set FAR *, const struct timeval FAR *));
|
||||
DEF_WINDOWS_FUNCTION(WSAAsyncSelect);
|
||||
DEF_WINDOWS_FUNCTION(WSAEventSelect);
|
||||
DEF_WINDOWS_FUNCTION(WSAGetLastError);
|
||||
DEF_WINDOWS_FUNCTION(WSAEnumNetworkEvents);
|
||||
DEF_WINDOWS_FUNCTION(select);
|
||||
|
||||
void sk_init(void)
|
||||
{
|
||||
|
@ -9,12 +9,18 @@
|
||||
|
||||
#if !defined NO_SECURITY
|
||||
|
||||
#define WINSECUR_GLOBAL
|
||||
#include "winsecur.h"
|
||||
|
||||
/* Initialised once, then kept around to reuse forever */
|
||||
static PSID worldsid, networksid, usersid;
|
||||
|
||||
DEF_WINDOWS_FUNCTION(OpenProcessToken);
|
||||
DEF_WINDOWS_FUNCTION(GetTokenInformation);
|
||||
DEF_WINDOWS_FUNCTION(InitializeSecurityDescriptor);
|
||||
DEF_WINDOWS_FUNCTION(SetSecurityDescriptorOwner);
|
||||
DEF_WINDOWS_FUNCTION(GetSecurityInfo);
|
||||
DEF_WINDOWS_FUNCTION(SetSecurityInfo);
|
||||
DEF_WINDOWS_FUNCTION(SetEntriesInAclA);
|
||||
|
||||
bool got_advapi(void)
|
||||
{
|
||||
|
@ -8,30 +8,26 @@
|
||||
|
||||
#include <aclapi.h>
|
||||
|
||||
#ifndef WINSECUR_GLOBAL
|
||||
#define WINSECUR_GLOBAL extern
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Functions loaded from advapi32.dll.
|
||||
*/
|
||||
DECL_WINDOWS_FUNCTION(WINSECUR_GLOBAL, BOOL, OpenProcessToken,
|
||||
DECL_WINDOWS_FUNCTION(extern, BOOL, OpenProcessToken,
|
||||
(HANDLE, DWORD, PHANDLE));
|
||||
DECL_WINDOWS_FUNCTION(WINSECUR_GLOBAL, BOOL, GetTokenInformation,
|
||||
DECL_WINDOWS_FUNCTION(extern, BOOL, GetTokenInformation,
|
||||
(HANDLE, TOKEN_INFORMATION_CLASS,
|
||||
LPVOID, DWORD, PDWORD));
|
||||
DECL_WINDOWS_FUNCTION(WINSECUR_GLOBAL, BOOL, InitializeSecurityDescriptor,
|
||||
DECL_WINDOWS_FUNCTION(extern, BOOL, InitializeSecurityDescriptor,
|
||||
(PSECURITY_DESCRIPTOR, DWORD));
|
||||
DECL_WINDOWS_FUNCTION(WINSECUR_GLOBAL, BOOL, SetSecurityDescriptorOwner,
|
||||
DECL_WINDOWS_FUNCTION(extern, BOOL, SetSecurityDescriptorOwner,
|
||||
(PSECURITY_DESCRIPTOR, PSID, BOOL));
|
||||
DECL_WINDOWS_FUNCTION(WINSECUR_GLOBAL, DWORD, GetSecurityInfo,
|
||||
DECL_WINDOWS_FUNCTION(extern, DWORD, GetSecurityInfo,
|
||||
(HANDLE, SE_OBJECT_TYPE, SECURITY_INFORMATION,
|
||||
PSID *, PSID *, PACL *, PACL *,
|
||||
PSECURITY_DESCRIPTOR *));
|
||||
DECL_WINDOWS_FUNCTION(WINSECUR_GLOBAL, DWORD, SetSecurityInfo,
|
||||
DECL_WINDOWS_FUNCTION(extern, DWORD, SetSecurityInfo,
|
||||
(HANDLE, SE_OBJECT_TYPE, SECURITY_INFORMATION,
|
||||
PSID, PSID, PACL, PACL));
|
||||
DECL_WINDOWS_FUNCTION(WINSECUR_GLOBAL, DWORD, SetEntriesInAclA,
|
||||
DECL_WINDOWS_FUNCTION(extern, DWORD, SetEntriesInAclA,
|
||||
(ULONG, PEXPLICIT_ACCESS, PACL, PACL *));
|
||||
bool got_advapi(void);
|
||||
|
||||
|
@ -140,6 +140,9 @@ struct FontSpec *fontspec_new(
|
||||
#define DECL_WINDOWS_FUNCTION(linkage, rettype, name, params) \
|
||||
typedef rettype (WINAPI *t_##name) params; \
|
||||
linkage t_##name p_##name
|
||||
/* If you DECL_WINDOWS_FUNCTION as extern in a header file, use this to
|
||||
* define the function pointer in a source file */
|
||||
#define DEF_WINDOWS_FUNCTION(name) t_##name p_##name
|
||||
#define STR1(x) #x
|
||||
#define STR(x) STR1(x)
|
||||
#define GET_WINDOWS_FUNCTION_PP(module, name) \
|
||||
@ -320,12 +323,12 @@ const char *winsock_error_string(int error);
|
||||
* that module must be exported from it as function pointers. So
|
||||
* here they are.
|
||||
*/
|
||||
DECL_WINDOWS_FUNCTION(GLOBAL, int, WSAAsyncSelect,
|
||||
DECL_WINDOWS_FUNCTION(extern, int, WSAAsyncSelect,
|
||||
(SOCKET, HWND, u_int, long));
|
||||
DECL_WINDOWS_FUNCTION(GLOBAL, int, WSAEventSelect,
|
||||
DECL_WINDOWS_FUNCTION(extern, int, WSAEventSelect,
|
||||
(SOCKET, WSAEVENT, long));
|
||||
DECL_WINDOWS_FUNCTION(GLOBAL, int, WSAGetLastError, (void));
|
||||
DECL_WINDOWS_FUNCTION(GLOBAL, int, WSAEnumNetworkEvents,
|
||||
DECL_WINDOWS_FUNCTION(extern, int, WSAGetLastError, (void));
|
||||
DECL_WINDOWS_FUNCTION(extern, int, WSAEnumNetworkEvents,
|
||||
(SOCKET, WSAEVENT, LPWSANETWORKEVENTS));
|
||||
#ifdef NEED_DECLARATION_OF_SELECT
|
||||
/* This declaration is protected by an ifdef for the sake of building
|
||||
@ -335,7 +338,7 @@ DECL_WINDOWS_FUNCTION(GLOBAL, int, WSAEnumNetworkEvents,
|
||||
* only a modules actually needing to use (or define, or initialise)
|
||||
* this function pointer will see its declaration, and _those_ modules
|
||||
* - which will be Windows-specific anyway - can take more care. */
|
||||
DECL_WINDOWS_FUNCTION(GLOBAL, int, select,
|
||||
DECL_WINDOWS_FUNCTION(extern, int, select,
|
||||
(int, fd_set FAR *, fd_set FAR *,
|
||||
fd_set FAR *, const struct timeval FAR *));
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user