fixing types
[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 <windows.h>
38 #include <winsock.h>
39 #include <winerror.h>
40 #include <iphlpapi.h>
41 #include <shlobj.h>
42 #include <objbase.h>
43 #include <sys/param.h>          /* #define BYTE_ORDER */
44 #include <Ntsecapi.h>
45 #include <lm.h>
46 #include <Aclapi.h>
47
48
49 #ifdef __cplusplus
50 extern "C"
51 {
52 #endif
53
54 #ifndef MAX_NAME_LENGTH
55 #define MAX_NAME_LENGTH 25
56 #endif
57
58   typedef DWORD WINAPI (*TNtQuerySystemInformation) (int, PVOID, ULONG,
59                                                      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,
107                                                 PDWORD);
108   typedef NET_API_STATUS WINAPI (*TNetUserSetInfo) (LPCWSTR servername,
109                                                     LPCWSTR username,
110                                                     DWORD level, LPBYTE buf,
111                                                     LPDWORD parm_err);
112   typedef NTSTATUS NTAPI (*TLsaOpenPolicy) (PLSA_UNICODE_STRING,
113                                             PLSA_OBJECT_ATTRIBUTES,
114                                             ACCESS_MASK, PLSA_HANDLE);
115   typedef NTSTATUS NTAPI (*TLsaAddAccountRights) (LSA_HANDLE, PSID,
116                                                   PLSA_UNICODE_STRING, ULONG);
117   typedef NTSTATUS NTAPI (*TLsaRemoveAccountRights) (LSA_HANDLE, PSID,
118                                                      BOOLEAN,
119                                                      PLSA_UNICODE_STRING,
120                                                      ULONG);
121   typedef NTSTATUS NTAPI (*TLsaClose) (LSA_HANDLE);
122   typedef BOOL WINAPI (*TLookupAccountName) (LPCTSTR lpSystemName,
123                                              LPCTSTR lpAccountName, PSID Sid,
124                                              LPDWORD cbSid,
125                                              LPTSTR ReferencedDomainName,
126                                              LPDWORD cchReferencedDomainName,
127                                              PSID_NAME_USE peUse);
128
129   typedef BOOL WINAPI (*TGetFileSecurity) (LPCTSTR lpFileName,
130                                            SECURITY_INFORMATION
131                                            RequestedInformation,
132                                            PSECURITY_DESCRIPTOR
133                                            pSecurityDescriptor, DWORD nLength,
134                                            LPDWORD lpnLengthNeeded);
135   typedef BOOL WINAPI (*TInitializeSecurityDescriptor) (PSECURITY_DESCRIPTOR
136                                                         pSecurityDescriptor,
137                                                         DWORD dwRevision);
138   typedef BOOL WINAPI (*TGetSecurityDescriptorDacl) (PSECURITY_DESCRIPTOR
139                                                      pSecurityDescriptor,
140                                                      LPBOOL lpbDaclPresent,
141                                                      PACL * pDacl,
142                                                      LPBOOL lpbDaclDefaulted);
143   typedef BOOL WINAPI (*TGetAclInformation) (PACL pAcl,
144                                              LPVOID pAclInformation,
145                                              DWORD nAclInformationLength,
146                                              ACL_INFORMATION_CLASS
147                                              dwAclInformationClass);
148   typedef BOOL WINAPI (*TInitializeAcl) (PACL pAcl, DWORD nAclLength,
149                                          DWORD dwAclRevision);
150   typedef BOOL WINAPI (*TGetAce) (PACL pAcl, DWORD dwAceIndex, LPVOID * pAce);
151   typedef BOOL WINAPI (*TEqualSid) (PSID pSid1, PSID pSid2);
152   typedef BOOL WINAPI (*TAddAce) (PACL pAcl, DWORD dwAceRevision,
153                                   DWORD dwStartingAceIndex, LPVOID pAceList,
154                                   DWORD nAceListLength);
155   typedef BOOL WINAPI (*TAddAccessAllowedAce) (PACL pAcl, DWORD dwAceRevision,
156                                                DWORD AccessMask, PSID pSid);
157   typedef BOOL WINAPI (*TSetNamedSecurityInfo) (LPTSTR pObjectName,
158                                                 SE_OBJECT_TYPE ObjectType,
159                                                 SECURITY_INFORMATION
160                                                 SecurityInfo, PSID psidOwner,
161                                                 PSID psidGroup, PACL pDacl,
162                                                 PACL pSacl);
163
164   extern TNtQuerySystemInformation GNNtQuerySystemInformation;
165   extern TGetIfEntry GNGetIfEntry;
166   extern TGetIpAddrTable GNGetIpAddrTable;
167   extern TGetIfTable GNGetIfTable;
168   extern TCreateHardLink GNCreateHardLink;
169   extern TOpenSCManager GNOpenSCManager;
170   extern TCreateService GNCreateService;
171   extern TCloseServiceHandle GNCloseServiceHandle;
172   extern TDeleteService GNDeleteService;
173   extern TRegisterServiceCtrlHandler GNRegisterServiceCtrlHandler;
174   extern TSetServiceStatus GNSetServiceStatus;
175   extern TStartServiceCtrlDispatcher GNStartServiceCtrlDispatcher;
176   extern TControlService GNControlService;
177   extern TOpenService GNOpenService;
178   extern TGetBestInterface GNGetBestInterface;
179   extern TGetAdaptersInfo GGetAdaptersInfo;
180   extern TNetUserAdd GNNetUserAdd;
181   extern TNetUserSetInfo GNNetUserSetInfo;
182   extern TLsaOpenPolicy GNLsaOpenPolicy;
183   extern TLsaAddAccountRights GNLsaAddAccountRights;
184   extern TLsaRemoveAccountRights GNLsaRemoveAccountRights;
185   extern TLsaClose GNLsaClose;
186   extern TLookupAccountName GNLookupAccountName;
187   extern TGetFileSecurity GNGetFileSecurity;
188   extern TInitializeSecurityDescriptor GNInitializeSecurityDescriptor;
189   extern TGetSecurityDescriptorDacl GNGetSecurityDescriptorDacl;
190   extern TGetAclInformation GNGetAclInformation;
191   extern TInitializeAcl GNInitializeAcl;
192   extern TGetAce GNGetAce;
193   extern TEqualSid GNEqualSid;
194   extern TAddAce GNAddAce;
195   extern TAddAccessAllowedAce GNAddAccessAllowedAce;
196   extern TSetNamedSecurityInfo GNSetNamedSecurityInfo;
197
198
199   BOOL CreateShortcut (const char *pszSrc, const char *pszDest);
200   BOOL DereferenceShortcut (char *pszShortcut);
201   long QueryRegistry (HKEY hMainKey, char *pszKey, char *pszSubKey,
202                       char *pszBuffer, long *pdLength);
203   int ListNICs (void (*callback) (const char *, int, void *), void *cls);
204   BOOL AddPathAccessRights (char *lpszFileName, char *lpszAccountName,
205                             DWORD dwAccessMask);
206   char *winErrorStr (const char *prefix, int dwErr);
207
208   void GNInitWinEnv ();
209   void GNShutdownWinEnv ();
210
211 #ifdef __cplusplus
212 }
213 #endif
214
215 #endif