2 This file is part of GNUnet.
3 (C) 2001, 2002, 2003, 2004, 2005 Christian Grothoff (and other contributing authors)
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.
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.
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.
22 * @file include/winproc.h
23 * @brief Definitions for MS Windows
32 #include <sys/types.h>
34 #include <sys/timeb.h>
38 #define FD_SETSIZE 1024
47 #include <sys/param.h> /* #define BYTE_ORDER */
58 #ifndef MAX_NAME_LENGTH
59 #define MAX_NAME_LENGTH 25
62 typedef DWORD WINAPI (*TNtQuerySystemInformation) (int, PVOID, ULONG, PULONG);
63 typedef DWORD WINAPI (*TGetIfEntry) (PMIB_IFROW pIfRow);
64 typedef DWORD WINAPI (*TGetIpAddrTable) (PMIB_IPADDRTABLE pIpAddrTable,
65 PULONG pdwSize, BOOL bOrder);
66 typedef DWORD WINAPI (*TGetIfTable) (PMIB_IFTABLE pIfTable, PULONG pdwSize,
68 typedef DWORD WINAPI (*TGetBestInterfaceEx) (struct sockaddr *, PDWORD);
69 /* TODO: Explicitly import -A variants (i.e. TCreateHardLinkA) or -W
70 * variants (TCreateHardLinkW), etc.
72 typedef DWORD WINAPI (*TCreateHardLink) (LPCTSTR lpFileName,
73 LPCTSTR lpExistingFileName,
75 lpSecurityAttributes);
76 typedef SC_HANDLE WINAPI (*TOpenSCManager) (LPCTSTR lpMachineName,
77 LPCTSTR lpDatabaseName,
78 DWORD dwDesiredAccess);
79 typedef SC_HANDLE WINAPI (*TCreateService) (SC_HANDLE hSCManager,
80 LPCTSTR lpServiceName,
81 LPCTSTR lpDisplayName,
82 DWORD dwDesiredAccess,
86 LPCTSTR lpBinaryPathName,
87 LPCTSTR lpLoadOrderGroup,
89 LPCTSTR lpDependencies,
90 LPCTSTR lpServiceStartName,
92 typedef BOOL WINAPI (*TCloseServiceHandle) (SC_HANDLE hSCObject);
93 typedef BOOL WINAPI (*TDeleteService) (SC_HANDLE hService);
94 typedef SERVICE_STATUS_HANDLE WINAPI (*TRegisterServiceCtrlHandler) (LPCTSTR
98 typedef BOOL WINAPI (*TSetServiceStatus) (SERVICE_STATUS_HANDLE
100 LPSERVICE_STATUS lpServiceStatus);
101 typedef BOOL WINAPI (*TStartServiceCtrlDispatcher) (const
102 LPSERVICE_TABLE_ENTRY
104 typedef BOOL WINAPI (*TControlService) (SC_HANDLE hService, DWORD dwControl,
105 LPSERVICE_STATUS lpServiceStatus);
106 typedef SC_HANDLE WINAPI (*TOpenService) (SC_HANDLE hSCManager,
107 LPCTSTR lpServiceName,
108 DWORD dwDesiredAccess);
109 typedef DWORD WINAPI (*TGetAdaptersInfo) (PIP_ADAPTER_INFO pAdapterInfo,
111 typedef NET_API_STATUS WINAPI (*TNetUserAdd) (LPCWSTR, DWORD, PBYTE, PDWORD);
112 typedef NET_API_STATUS WINAPI (*TNetUserSetInfo) (LPCWSTR servername,
114 DWORD level, LPBYTE buf,
116 typedef NTSTATUS NTAPI (*TLsaOpenPolicy) (PLSA_UNICODE_STRING,
117 PLSA_OBJECT_ATTRIBUTES, ACCESS_MASK,
119 typedef NTSTATUS NTAPI (*TLsaAddAccountRights) (LSA_HANDLE, PSID,
120 PLSA_UNICODE_STRING, ULONG);
121 typedef NTSTATUS NTAPI (*TLsaRemoveAccountRights) (LSA_HANDLE, PSID, BOOLEAN,
124 typedef NTSTATUS NTAPI (*TLsaClose) (LSA_HANDLE);
125 typedef BOOL WINAPI (*TLookupAccountName) (LPCTSTR lpSystemName,
126 LPCTSTR lpAccountName, PSID Sid,
128 LPTSTR ReferencedDomainName,
129 LPDWORD cchReferencedDomainName,
130 PSID_NAME_USE peUse);
132 typedef BOOL WINAPI (*TGetFileSecurity) (LPCTSTR lpFileName,
134 RequestedInformation,
136 pSecurityDescriptor, DWORD nLength,
137 LPDWORD lpnLengthNeeded);
138 typedef BOOL WINAPI (*TInitializeSecurityDescriptor) (PSECURITY_DESCRIPTOR
141 typedef BOOL WINAPI (*TGetSecurityDescriptorDacl) (PSECURITY_DESCRIPTOR
143 LPBOOL lpbDaclPresent,
145 LPBOOL lpbDaclDefaulted);
146 typedef BOOL WINAPI (*TGetAclInformation) (PACL pAcl, LPVOID pAclInformation,
147 DWORD nAclInformationLength,
148 ACL_INFORMATION_CLASS
149 dwAclInformationClass);
150 typedef BOOL WINAPI (*TInitializeAcl) (PACL pAcl, DWORD nAclLength,
151 DWORD dwAclRevision);
152 typedef BOOL WINAPI (*TGetAce) (PACL pAcl, DWORD dwAceIndex, LPVOID * pAce);
153 typedef BOOL WINAPI (*TEqualSid) (PSID pSid1, PSID pSid2);
154 typedef BOOL WINAPI (*TAddAce) (PACL pAcl, DWORD dwAceRevision,
155 DWORD dwStartingAceIndex, LPVOID pAceList,
156 DWORD nAceListLength);
157 typedef BOOL WINAPI (*TAddAccessAllowedAce) (PACL pAcl, DWORD dwAceRevision,
158 DWORD AccessMask, PSID pSid);
159 typedef BOOL WINAPI (*TSetNamedSecurityInfo) (LPTSTR pObjectName,
160 SE_OBJECT_TYPE ObjectType,
162 SecurityInfo, PSID psidOwner,
163 PSID psidGroup, PACL pDacl,
166 extern TGetBestInterfaceEx GNGetBestInterfaceEx;
167 extern TNtQuerySystemInformation GNNtQuerySystemInformation;
168 extern TGetIfEntry GNGetIfEntry;
169 extern TGetIpAddrTable GNGetIpAddrTable;
170 extern TGetIfTable GNGetIfTable;
171 extern TCreateHardLink GNCreateHardLink;
172 extern TOpenSCManager GNOpenSCManager;
173 extern TCreateService GNCreateService;
174 extern TCloseServiceHandle GNCloseServiceHandle;
175 extern TDeleteService GNDeleteService;
176 extern TRegisterServiceCtrlHandler GNRegisterServiceCtrlHandler;
177 extern TSetServiceStatus GNSetServiceStatus;
178 extern TStartServiceCtrlDispatcher GNStartServiceCtrlDispatcher;
179 extern TControlService GNControlService;
180 extern TOpenService GNOpenService;
181 extern TGetAdaptersInfo GNGetAdaptersInfo;
182 extern TNetUserAdd GNNetUserAdd;
183 extern TNetUserSetInfo GNNetUserSetInfo;
184 extern TLsaOpenPolicy GNLsaOpenPolicy;
185 extern TLsaAddAccountRights GNLsaAddAccountRights;
186 extern TLsaRemoveAccountRights GNLsaRemoveAccountRights;
187 extern TLsaClose GNLsaClose;
188 extern TLookupAccountName GNLookupAccountName;
189 extern TGetFileSecurity GNGetFileSecurity;
190 extern TInitializeSecurityDescriptor GNInitializeSecurityDescriptor;
191 extern TGetSecurityDescriptorDacl GNGetSecurityDescriptorDacl;
192 extern TGetAclInformation GNGetAclInformation;
193 extern TInitializeAcl GNInitializeAcl;
194 extern TGetAce GNGetAce;
195 extern TEqualSid GNEqualSid;
196 extern TAddAce GNAddAce;
197 extern TAddAccessAllowedAce GNAddAccessAllowedAce;
198 extern TSetNamedSecurityInfo GNSetNamedSecurityInfo;
201 BOOL CreateShortcut (const char *pszSrc, const char *pszDest);
202 BOOL DereferenceShortcut (char *pszShortcut);
203 long QueryRegistry (HKEY hMainKey, const char *pszKey, const char *pszSubKey,
204 char *pszBuffer, long *pdLength);
205 int ListNICs (void (*callback) (void *, const char *, int), void *cls);
206 BOOL AddPathAccessRights (char *lpszFileName, char *lpszAccountName,
208 char *winErrorStr (const char *prefix, int dwErr);
209 void EnumNICs (PMIB_IFTABLE * pIfTable, PMIB_IPADDRTABLE * pAddrTable);
211 #define ENUMNICS3_MASK_OK 0x01
212 #define ENUMNICS3_BCAST_OK 0x02
214 struct EnumNICs3_results
218 char pretty_name[1001];
220 struct sockaddr address;
221 struct sockaddr mask;
222 struct sockaddr broadcast;
225 int EnumNICs3 (struct EnumNICs3_results **, int *EnumNICs3_results_count);
226 void EnumNICs3_free (struct EnumNICs3_results *);
228 void GNShutdownWinEnv ();