2 This file is part of GNUnet.
3 Copyright (C) 2001, 2002, 2003, 2004, 2005 GNUnet e.V.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your 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 Affero General Public License for more details.
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 * Definitions for MS Windows
31 #include <sys/types.h>
33 #include <sys/timeb.h>
37 #define FD_SETSIZE 1024
46 #include <sys/param.h> /* #define BYTE_ORDER */
57 #ifndef MAX_NAME_LENGTH
58 #define MAX_NAME_LENGTH 25
61 typedef DWORD WINAPI (*TNtQuerySystemInformation) (int, PVOID, ULONG, PULONG);
62 typedef DWORD WINAPI (*TGetIfEntry) (PMIB_IFROW pIfRow);
63 typedef DWORD WINAPI (*TGetIpAddrTable) (PMIB_IPADDRTABLE pIpAddrTable,
64 PULONG pdwSize, BOOL bOrder);
65 typedef DWORD WINAPI (*TGetIfTable) (PMIB_IFTABLE pIfTable, PULONG pdwSize,
67 typedef DWORD WINAPI (*TGetBestInterfaceEx) (struct sockaddr *, PDWORD);
68 /* TODO: Explicitly import -A variants (i.e. TCreateHardLinkA) or -W
69 * variants (TCreateHardLinkW), etc.
71 typedef DWORD WINAPI (*TCreateHardLink) (LPCTSTR lpFileName,
72 LPCTSTR lpExistingFileName,
74 lpSecurityAttributes);
75 typedef SC_HANDLE WINAPI (*TOpenSCManager) (LPCTSTR lpMachineName,
76 LPCTSTR lpDatabaseName,
77 DWORD dwDesiredAccess);
78 typedef SC_HANDLE WINAPI (*TCreateService) (SC_HANDLE hSCManager,
79 LPCTSTR lpServiceName,
80 LPCTSTR lpDisplayName,
81 DWORD dwDesiredAccess,
85 LPCTSTR lpBinaryPathName,
86 LPCTSTR lpLoadOrderGroup,
88 LPCTSTR lpDependencies,
89 LPCTSTR lpServiceStartName,
91 typedef BOOL WINAPI (*TCloseServiceHandle) (SC_HANDLE hSCObject);
92 typedef BOOL WINAPI (*TDeleteService) (SC_HANDLE hService);
93 typedef SERVICE_STATUS_HANDLE WINAPI (*TRegisterServiceCtrlHandler) (LPCTSTR
97 typedef BOOL WINAPI (*TSetServiceStatus) (SERVICE_STATUS_HANDLE
99 LPSERVICE_STATUS lpServiceStatus);
100 typedef BOOL WINAPI (*TStartServiceCtrlDispatcher) (const
101 LPSERVICE_TABLE_ENTRY
103 typedef BOOL WINAPI (*TControlService) (SC_HANDLE hService, DWORD dwControl,
104 LPSERVICE_STATUS lpServiceStatus);
105 typedef SC_HANDLE WINAPI (*TOpenService) (SC_HANDLE hSCManager,
106 LPCTSTR lpServiceName,
107 DWORD dwDesiredAccess);
108 typedef DWORD WINAPI (*TGetAdaptersInfo) (PIP_ADAPTER_INFO pAdapterInfo,
110 typedef NET_API_STATUS WINAPI (*TNetUserAdd) (LPCWSTR, DWORD, PBYTE, PDWORD);
111 typedef NET_API_STATUS WINAPI (*TNetUserSetInfo) (LPCWSTR servername,
113 DWORD level, LPBYTE buf,
115 typedef NTSTATUS NTAPI (*TLsaOpenPolicy) (PLSA_UNICODE_STRING,
116 PLSA_OBJECT_ATTRIBUTES, ACCESS_MASK,
118 typedef NTSTATUS NTAPI (*TLsaAddAccountRights) (LSA_HANDLE, PSID,
119 PLSA_UNICODE_STRING, ULONG);
120 typedef NTSTATUS NTAPI (*TLsaRemoveAccountRights) (LSA_HANDLE, PSID, BOOLEAN,
123 typedef NTSTATUS NTAPI (*TLsaClose) (LSA_HANDLE);
124 typedef BOOL WINAPI (*TLookupAccountName) (LPCTSTR lpSystemName,
125 LPCTSTR lpAccountName, PSID Sid,
127 LPTSTR ReferencedDomainName,
128 LPDWORD cchReferencedDomainName,
129 PSID_NAME_USE peUse);
131 typedef BOOL WINAPI (*TGetFileSecurity) (LPCTSTR lpFileName,
133 RequestedInformation,
135 pSecurityDescriptor, DWORD nLength,
136 LPDWORD lpnLengthNeeded);
137 typedef BOOL WINAPI (*TInitializeSecurityDescriptor) (PSECURITY_DESCRIPTOR
140 typedef BOOL WINAPI (*TGetSecurityDescriptorDacl) (PSECURITY_DESCRIPTOR
142 LPBOOL lpbDaclPresent,
144 LPBOOL lpbDaclDefaulted);
145 typedef BOOL WINAPI (*TGetAclInformation) (PACL pAcl, LPVOID pAclInformation,
146 DWORD nAclInformationLength,
147 ACL_INFORMATION_CLASS
148 dwAclInformationClass);
149 typedef BOOL WINAPI (*TInitializeAcl) (PACL pAcl, DWORD nAclLength,
150 DWORD dwAclRevision);
151 typedef BOOL WINAPI (*TGetAce) (PACL pAcl, DWORD dwAceIndex, LPVOID * pAce);
152 typedef BOOL WINAPI (*TEqualSid) (PSID pSid1, PSID pSid2);
153 typedef BOOL WINAPI (*TAddAce) (PACL pAcl, DWORD dwAceRevision,
154 DWORD dwStartingAceIndex, LPVOID pAceList,
155 DWORD nAceListLength);
156 typedef BOOL WINAPI (*TAddAccessAllowedAce) (PACL pAcl, DWORD dwAceRevision,
157 DWORD AccessMask, PSID pSid);
158 typedef BOOL WINAPI (*TSetNamedSecurityInfo) (LPTSTR pObjectName,
159 SE_OBJECT_TYPE ObjectType,
161 SecurityInfo, PSID psidOwner,
162 PSID psidGroup, PACL pDacl,
165 extern TGetBestInterfaceEx GNGetBestInterfaceEx;
166 extern TNtQuerySystemInformation GNNtQuerySystemInformation;
167 extern TGetIfEntry GNGetIfEntry;
168 extern TGetIpAddrTable GNGetIpAddrTable;
169 extern TGetIfTable GNGetIfTable;
170 extern TCreateHardLink GNCreateHardLink;
171 extern TOpenSCManager GNOpenSCManager;
172 extern TCreateService GNCreateService;
173 extern TCloseServiceHandle GNCloseServiceHandle;
174 extern TDeleteService GNDeleteService;
175 extern TRegisterServiceCtrlHandler GNRegisterServiceCtrlHandler;
176 extern TSetServiceStatus GNSetServiceStatus;
177 extern TStartServiceCtrlDispatcher GNStartServiceCtrlDispatcher;
178 extern TControlService GNControlService;
179 extern TOpenService GNOpenService;
180 extern TGetAdaptersInfo GNGetAdaptersInfo;
181 extern TNetUserAdd GNNetUserAdd;
182 extern TNetUserSetInfo GNNetUserSetInfo;
183 extern TLsaOpenPolicy GNLsaOpenPolicy;
184 extern TLsaAddAccountRights GNLsaAddAccountRights;
185 extern TLsaRemoveAccountRights GNLsaRemoveAccountRights;
186 extern TLsaClose GNLsaClose;
187 extern TLookupAccountName GNLookupAccountName;
188 extern TGetFileSecurity GNGetFileSecurity;
189 extern TInitializeSecurityDescriptor GNInitializeSecurityDescriptor;
190 extern TGetSecurityDescriptorDacl GNGetSecurityDescriptorDacl;
191 extern TGetAclInformation GNGetAclInformation;
192 extern TInitializeAcl GNInitializeAcl;
193 extern TGetAce GNGetAce;
194 extern TEqualSid GNEqualSid;
195 extern TAddAce GNAddAce;
196 extern TAddAccessAllowedAce GNAddAccessAllowedAce;
197 extern TSetNamedSecurityInfo GNSetNamedSecurityInfo;
200 BOOL CreateShortcut (const char *pszSrc, const char *pszDest);
201 BOOL DereferenceShortcut (char *pszShortcut);
202 long QueryRegistry (HKEY hMainKey, const char *pszKey, const char *pszSubKey,
203 char *pszBuffer, long *pdLength);
204 int ListNICs (void (*callback) (void *, const char *, int), void *cls);
205 BOOL AddPathAccessRights (char *lpszFileName, char *lpszAccountName,
207 char *winErrorStr (const char *prefix, int dwErr);
208 void EnumNICs (PMIB_IFTABLE * pIfTable, PMIB_IPADDRTABLE * pAddrTable);
210 #define ENUMNICS3_MASK_OK 0x01
211 #define ENUMNICS3_BCAST_OK 0x02
213 struct EnumNICs3_results
217 char pretty_name[1001];
219 SOCKADDR_STORAGE address;
220 SOCKADDR_STORAGE mask;
221 SOCKADDR_STORAGE broadcast;
224 int EnumNICs3 (struct EnumNICs3_results **, int *EnumNICs3_results_count);
225 void EnumNICs3_free (struct EnumNICs3_results *);
227 void GNShutdownWinEnv ();
229 BOOL SafeTerminateProcess (HANDLE hProcess, UINT uExitCode, DWORD dwTimeout);