]> asedeno.scripts.mit.edu Git - PuTTY_svn.git/blob - windows/winsecur.h
57de5d1de8c5f7c7c44aee94b67363d6b9097156
[PuTTY_svn.git] / windows / winsecur.h
1 /*
2  * winsecur.h: some miscellaneous security-related helper functions,
3  * defined in winsecur.c, that use the advapi32 library. Also
4  * centralises the machinery for dynamically loading that library.
5  */
6
7 #if !defined NO_SECURITY
8
9 #include <aclapi.h>
10
11 #ifndef WINSECUR_GLOBAL
12 #define WINSECUR_GLOBAL extern
13 #endif
14
15 /*
16  * Functions loaded from advapi32.dll.
17  */
18 DECL_WINDOWS_FUNCTION(WINSECUR_GLOBAL, BOOL, OpenProcessToken,
19                       (HANDLE, DWORD, PHANDLE));
20 DECL_WINDOWS_FUNCTION(WINSECUR_GLOBAL, BOOL, GetTokenInformation,
21                       (HANDLE, TOKEN_INFORMATION_CLASS,
22                        LPVOID, DWORD, PDWORD));
23 DECL_WINDOWS_FUNCTION(WINSECUR_GLOBAL, BOOL, InitializeSecurityDescriptor,
24                       (PSECURITY_DESCRIPTOR, DWORD));
25 DECL_WINDOWS_FUNCTION(WINSECUR_GLOBAL, BOOL, SetSecurityDescriptorOwner,
26                       (PSECURITY_DESCRIPTOR, PSID, BOOL));
27 DECL_WINDOWS_FUNCTION(WINSECUR_GLOBAL, DWORD, GetSecurityInfo,
28                       (HANDLE, SE_OBJECT_TYPE, SECURITY_INFORMATION,
29                        PSID *, PSID *, PACL *, PACL *,
30                        PSECURITY_DESCRIPTOR *));
31 DECL_WINDOWS_FUNCTION(WINSECUR_GLOBAL, DWORD, SetEntriesInAclA,
32                       (ULONG, PEXPLICIT_ACCESS, PACL, PACL *));
33 int got_advapi(void);
34
35 /*
36  * Functions loaded from crypt32.dll.
37  */
38 DECL_WINDOWS_FUNCTION(WINSECUR_GLOBAL, BOOL, CryptProtectMemory,
39                       (LPVOID, DWORD, DWORD));
40 int got_crypt(void);
41
42 /*
43  * Find the SID describing the current user. The return value (if not
44  * NULL for some error-related reason) is smalloced.
45  */
46 PSID get_user_sid(void);
47
48 /*
49  * Construct a PSECURITY_DESCRIPTOR of the type used for named pipe
50  * servers, i.e. allowing access only to the current user id and also
51  * only local (i.e. not over SMB) connections.
52  *
53  * If this function returns TRUE, then 'psd', 'networksid' and 'acl'
54  * will all have been filled in with memory allocated using LocalAlloc
55  * (and hence must be freed later using LocalFree). If it returns
56  * FALSE, then instead 'error' has been filled with a dynamically
57  * allocated error message.
58  */
59 int make_private_security_descriptor(DWORD permissions,
60                                      PSECURITY_DESCRIPTOR *psd,
61                                      PSID *networksid,
62                                      PACL *acl,
63                                      char **error);
64
65 #endif