indentation
[oweals/gnunet.git] / src / include / winproc.h
1 /*
2      This file is part of GNUnet.
3      (C) 2001, 2002, 2003, 2004, 2005 Christian Grothoff (and other contributing authors)
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 2, or (at your
8      option) any later version.
9
10      GNUnet is distributed in the hope that it will be useful, but
11      WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19 */
20
21 /**
22  * @file include/winproc.h
23  * @brief Definitions for MS Windows
24  * @author Nils Durner
25  */
26
27 #ifndef _WINPROC_H
28 #define _WINPROC_H
29
30 #include <io.h>
31 #include <stdio.h>
32 #include <sys/types.h>
33 #include <sys/stat.h>
34 #include <sys/timeb.h>
35 #include <time.h>
36 #include <dirent.h>
37 #include <winsock2.h>
38 #include <ws2tcpip.h>
39 #include <windows.h>
40 #include <winerror.h>
41 #include <iphlpapi.h>
42 #include <shlobj.h>
43 #include <objbase.h>
44 #include <sys/param.h>          /* #define BYTE_ORDER */
45 #include <ntsecapi.h>
46 #include <lm.h>
47 #include <aclapi.h>
48
49
50 #ifdef __cplusplus
51 extern "C"
52 {
53 #endif
54
55 #ifndef MAX_NAME_LENGTH
56 #define MAX_NAME_LENGTH 25
57 #endif
58
59   typedef DWORD WINAPI (*TNtQuerySystemInformation) (int, PVOID, ULONG, PULONG);
60   typedef DWORD WINAPI (*TGetIfEntry) (PMIB_IFROW pIfRow);
61   typedef DWORD WINAPI (*TGetIpAddrTable) (PMIB_IPADDRTABLE pIpAddrTable,
62                                            PULONG pdwSize, BOOL bOrder);
63   typedef DWORD WINAPI (*TGetIfTable) (PMIB_IFTABLE pIfTable, PULONG pdwSize,
64                                        BOOL bOrder);
65   typedef DWORD WINAPI (*TCreateHardLink) (LPCTSTR lpFileName,
66                                            LPCTSTR lpExistingFileName,
67                                            LPSECURITY_ATTRIBUTES
68                                            lpSecurityAttributes);
69   typedef SC_HANDLE WINAPI (*TOpenSCManager) (LPCTSTR lpMachineName,
70                                               LPCTSTR lpDatabaseName,
71                                               DWORD dwDesiredAccess);
72   typedef SC_HANDLE WINAPI (*TCreateService) (SC_HANDLE hSCManager,
73                                               LPCTSTR lpServiceName,
74                                               LPCTSTR lpDisplayName,
75                                               DWORD dwDesiredAccess,
76                                               DWORD dwServiceType,
77                                               DWORD dwStartType,
78                                               DWORD dwErrorControl,
79                                               LPCTSTR lpBinaryPathName,
80                                               LPCTSTR lpLoadOrderGroup,
81                                               LPDWORD lpdwTagId,
82                                               LPCTSTR lpDependencies,
83                                               LPCTSTR lpServiceStartName,
84                                               LPCTSTR lpPassword);
85   typedef BOOL WINAPI (*TCloseServiceHandle) (SC_HANDLE hSCObject);
86   typedef BOOL WINAPI (*TDeleteService) (SC_HANDLE hService);
87   typedef SERVICE_STATUS_HANDLE WINAPI (*TRegisterServiceCtrlHandler) (LPCTSTR
88                                                                        lpServiceName,
89                                                                        LPHANDLER_FUNCTION
90                                                                        lpHandlerProc);
91   typedef BOOL WINAPI (*TSetServiceStatus) (SERVICE_STATUS_HANDLE
92                                             hServiceStatus,
93                                             LPSERVICE_STATUS lpServiceStatus);
94   typedef BOOL WINAPI (*TStartServiceCtrlDispatcher) (const
95                                                       LPSERVICE_TABLE_ENTRY
96                                                       lpServiceTable);
97   typedef BOOL WINAPI (*TControlService) (SC_HANDLE hService, DWORD dwControl,
98                                           LPSERVICE_STATUS lpServiceStatus);
99   typedef SC_HANDLE WINAPI (*TOpenService) (SC_HANDLE hSCManager,
100                                             LPCTSTR lpServiceName,
101                                             DWORD dwDesiredAccess);
102   typedef DWORD WINAPI (*TGetBestInterface) (IPAddr dwDestAddr,
103                                              PDWORD pdwBestIfIndex);
104   typedef DWORD WINAPI (*TGetAdaptersInfo) (PIP_ADAPTER_INFO pAdapterInfo,
105                                             PULONG pOutBufLen);
106   typedef NET_API_STATUS WINAPI (*TNetUserAdd) (LPCWSTR, DWORD, PBYTE, PDWORD);
107   typedef NET_API_STATUS WINAPI (*TNetUserSetInfo) (LPCWSTR servername,
108                                                     LPCWSTR username,
109                                                     DWORD level, LPBYTE buf,
110                                                     LPDWORD parm_err);
111   typedef NTSTATUS NTAPI (*TLsaOpenPolicy) (PLSA_UNICODE_STRING,
112                                             PLSA_OBJECT_ATTRIBUTES, ACCESS_MASK,
113                                             PLSA_HANDLE);
114   typedef NTSTATUS NTAPI (*TLsaAddAccountRights) (LSA_HANDLE, PSID,
115                                                   PLSA_UNICODE_STRING, ULONG);
116   typedef NTSTATUS NTAPI (*TLsaRemoveAccountRights) (LSA_HANDLE, PSID, BOOLEAN,
117                                                      PLSA_UNICODE_STRING,
118                                                      ULONG);
119   typedef NTSTATUS NTAPI (*TLsaClose) (LSA_HANDLE);
120   typedef BOOL WINAPI (*TLookupAccountName) (LPCTSTR lpSystemName,
121                                              LPCTSTR lpAccountName, PSID Sid,
122                                              LPDWORD cbSid,
123                                              LPTSTR ReferencedDomainName,
124                                              LPDWORD cchReferencedDomainName,
125                                              PSID_NAME_USE peUse);
126
127   typedef BOOL WINAPI (*TGetFileSecurity) (LPCTSTR lpFileName,
128                                            SECURITY_INFORMATION
129                                            RequestedInformation,
130                                            PSECURITY_DESCRIPTOR
131                                            pSecurityDescriptor, DWORD nLength,
132                                            LPDWORD lpnLengthNeeded);
133   typedef BOOL WINAPI (*TInitializeSecurityDescriptor) (PSECURITY_DESCRIPTOR
134                                                         pSecurityDescriptor,
135                                                         DWORD dwRevision);
136   typedef BOOL WINAPI (*TGetSecurityDescriptorDacl) (PSECURITY_DESCRIPTOR
137                                                      pSecurityDescriptor,
138                                                      LPBOOL lpbDaclPresent,
139                                                      PACL * pDacl,
140                                                      LPBOOL lpbDaclDefaulted);
141   typedef BOOL WINAPI (*TGetAclInformation) (PACL pAcl, LPVOID pAclInformation,
142                                              DWORD nAclInformationLength,
143                                              ACL_INFORMATION_CLASS
144                                              dwAclInformationClass);
145   typedef BOOL WINAPI (*TInitializeAcl) (PACL pAcl, DWORD nAclLength,
146                                          DWORD dwAclRevision);
147   typedef BOOL WINAPI (*TGetAce) (PACL pAcl, DWORD dwAceIndex, LPVOID * pAce);
148   typedef BOOL WINAPI (*TEqualSid) (PSID pSid1, PSID pSid2);
149   typedef BOOL WINAPI (*TAddAce) (PACL pAcl, DWORD dwAceRevision,
150                                   DWORD dwStartingAceIndex, LPVOID pAceList,
151                                   DWORD nAceListLength);
152   typedef BOOL WINAPI (*TAddAccessAllowedAce) (PACL pAcl, DWORD dwAceRevision,
153                                                DWORD AccessMask, PSID pSid);
154   typedef BOOL WINAPI (*TSetNamedSecurityInfo) (LPTSTR pObjectName,
155                                                 SE_OBJECT_TYPE ObjectType,
156                                                 SECURITY_INFORMATION
157                                                 SecurityInfo, PSID psidOwner,
158                                                 PSID psidGroup, PACL pDacl,
159                                                 PACL pSacl);
160
161   extern TNtQuerySystemInformation GNNtQuerySystemInformation;
162   extern TGetIfEntry GNGetIfEntry;
163   extern TGetIpAddrTable GNGetIpAddrTable;
164   extern TGetIfTable GNGetIfTable;
165   extern TCreateHardLink GNCreateHardLink;
166   extern TOpenSCManager GNOpenSCManager;
167   extern TCreateService GNCreateService;
168   extern TCloseServiceHandle GNCloseServiceHandle;
169   extern TDeleteService GNDeleteService;
170   extern TRegisterServiceCtrlHandler GNRegisterServiceCtrlHandler;
171   extern TSetServiceStatus GNSetServiceStatus;
172   extern TStartServiceCtrlDispatcher GNStartServiceCtrlDispatcher;
173   extern TControlService GNControlService;
174   extern TOpenService GNOpenService;
175   extern TGetBestInterface GNGetBestInterface;
176   extern TGetAdaptersInfo GGetAdaptersInfo;
177   extern TNetUserAdd GNNetUserAdd;
178   extern TNetUserSetInfo GNNetUserSetInfo;
179   extern TLsaOpenPolicy GNLsaOpenPolicy;
180   extern TLsaAddAccountRights GNLsaAddAccountRights;
181   extern TLsaRemoveAccountRights GNLsaRemoveAccountRights;
182   extern TLsaClose GNLsaClose;
183   extern TLookupAccountName GNLookupAccountName;
184   extern TGetFileSecurity GNGetFileSecurity;
185   extern TInitializeSecurityDescriptor GNInitializeSecurityDescriptor;
186   extern TGetSecurityDescriptorDacl GNGetSecurityDescriptorDacl;
187   extern TGetAclInformation GNGetAclInformation;
188   extern TInitializeAcl GNInitializeAcl;
189   extern TGetAce GNGetAce;
190   extern TEqualSid GNEqualSid;
191   extern TAddAce GNAddAce;
192   extern TAddAccessAllowedAce GNAddAccessAllowedAce;
193   extern TSetNamedSecurityInfo GNSetNamedSecurityInfo;
194
195
196   BOOL CreateShortcut (const char *pszSrc, const char *pszDest);
197   BOOL DereferenceShortcut (char *pszShortcut);
198   long QueryRegistry (HKEY hMainKey, const char *pszKey, const char *pszSubKey,
199                       char *pszBuffer, long *pdLength);
200   int ListNICs (void (*callback) (void *, const char *, int), void *cls);
201   BOOL AddPathAccessRights (char *lpszFileName, char *lpszAccountName,
202                             DWORD dwAccessMask);
203   char *winErrorStr (const char *prefix, int dwErr);
204   void EnumNICs (PMIB_IFTABLE * pIfTable, PMIB_IPADDRTABLE * pAddrTable);
205   int GNInitWinEnv ();
206   void GNShutdownWinEnv ();
207
208 #ifdef __cplusplus
209 }
210 #endif
211
212 #endif