2 This file is part of GNUnet.
3 Copyright (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 3, 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., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
25 * Definitions for MS Windows
33 #include <sys/types.h>
35 #include <sys/timeb.h>
39 #define FD_SETSIZE 1024
48 #include <sys/param.h> /* #define BYTE_ORDER */
59 #ifndef MAX_NAME_LENGTH
60 #define MAX_NAME_LENGTH 25
63 typedef DWORD WINAPI (*TNtQuerySystemInformation) (int, PVOID, ULONG, PULONG);
64 typedef DWORD WINAPI (*TGetIfEntry) (PMIB_IFROW pIfRow);
65 typedef DWORD WINAPI (*TGetIpAddrTable) (PMIB_IPADDRTABLE pIpAddrTable,
66 PULONG pdwSize, BOOL bOrder);
67 typedef DWORD WINAPI (*TGetIfTable) (PMIB_IFTABLE pIfTable, PULONG pdwSize,
69 typedef DWORD WINAPI (*TGetBestInterfaceEx) (struct sockaddr *, PDWORD);
70 /* TODO: Explicitly import -A variants (i.e. TCreateHardLinkA) or -W
71 * variants (TCreateHardLinkW), etc.
73 typedef DWORD WINAPI (*TCreateHardLink) (LPCTSTR lpFileName,
74 LPCTSTR lpExistingFileName,
76 lpSecurityAttributes);
77 typedef SC_HANDLE WINAPI (*TOpenSCManager) (LPCTSTR lpMachineName,
78 LPCTSTR lpDatabaseName,
79 DWORD dwDesiredAccess);
80 typedef SC_HANDLE WINAPI (*TCreateService) (SC_HANDLE hSCManager,
81 LPCTSTR lpServiceName,
82 LPCTSTR lpDisplayName,
83 DWORD dwDesiredAccess,
87 LPCTSTR lpBinaryPathName,
88 LPCTSTR lpLoadOrderGroup,
90 LPCTSTR lpDependencies,
91 LPCTSTR lpServiceStartName,
93 typedef BOOL WINAPI (*TCloseServiceHandle) (SC_HANDLE hSCObject);
94 typedef BOOL WINAPI (*TDeleteService) (SC_HANDLE hService);
95 typedef SERVICE_STATUS_HANDLE WINAPI (*TRegisterServiceCtrlHandler) (LPCTSTR
99 typedef BOOL WINAPI (*TSetServiceStatus) (SERVICE_STATUS_HANDLE
101 LPSERVICE_STATUS lpServiceStatus);
102 typedef BOOL WINAPI (*TStartServiceCtrlDispatcher) (const
103 LPSERVICE_TABLE_ENTRY
105 typedef BOOL WINAPI (*TControlService) (SC_HANDLE hService, DWORD dwControl,
106 LPSERVICE_STATUS lpServiceStatus);
107 typedef SC_HANDLE WINAPI (*TOpenService) (SC_HANDLE hSCManager,
108 LPCTSTR lpServiceName,
109 DWORD dwDesiredAccess);
110 typedef DWORD WINAPI (*TGetAdaptersInfo) (PIP_ADAPTER_INFO pAdapterInfo,
112 typedef NET_API_STATUS WINAPI (*TNetUserAdd) (LPCWSTR, DWORD, PBYTE, PDWORD);
113 typedef NET_API_STATUS WINAPI (*TNetUserSetInfo) (LPCWSTR servername,
115 DWORD level, LPBYTE buf,
117 typedef NTSTATUS NTAPI (*TLsaOpenPolicy) (PLSA_UNICODE_STRING,
118 PLSA_OBJECT_ATTRIBUTES, ACCESS_MASK,
120 typedef NTSTATUS NTAPI (*TLsaAddAccountRights) (LSA_HANDLE, PSID,
121 PLSA_UNICODE_STRING, ULONG);
122 typedef NTSTATUS NTAPI (*TLsaRemoveAccountRights) (LSA_HANDLE, PSID, BOOLEAN,
125 typedef NTSTATUS NTAPI (*TLsaClose) (LSA_HANDLE);
126 typedef BOOL WINAPI (*TLookupAccountName) (LPCTSTR lpSystemName,
127 LPCTSTR lpAccountName, PSID Sid,
129 LPTSTR ReferencedDomainName,
130 LPDWORD cchReferencedDomainName,
131 PSID_NAME_USE peUse);
133 typedef BOOL WINAPI (*TGetFileSecurity) (LPCTSTR lpFileName,
135 RequestedInformation,
137 pSecurityDescriptor, DWORD nLength,
138 LPDWORD lpnLengthNeeded);
139 typedef BOOL WINAPI (*TInitializeSecurityDescriptor) (PSECURITY_DESCRIPTOR
142 typedef BOOL WINAPI (*TGetSecurityDescriptorDacl) (PSECURITY_DESCRIPTOR
144 LPBOOL lpbDaclPresent,
146 LPBOOL lpbDaclDefaulted);
147 typedef BOOL WINAPI (*TGetAclInformation) (PACL pAcl, LPVOID pAclInformation,
148 DWORD nAclInformationLength,
149 ACL_INFORMATION_CLASS
150 dwAclInformationClass);
151 typedef BOOL WINAPI (*TInitializeAcl) (PACL pAcl, DWORD nAclLength,
152 DWORD dwAclRevision);
153 typedef BOOL WINAPI (*TGetAce) (PACL pAcl, DWORD dwAceIndex, LPVOID * pAce);
154 typedef BOOL WINAPI (*TEqualSid) (PSID pSid1, PSID pSid2);
155 typedef BOOL WINAPI (*TAddAce) (PACL pAcl, DWORD dwAceRevision,
156 DWORD dwStartingAceIndex, LPVOID pAceList,
157 DWORD nAceListLength);
158 typedef BOOL WINAPI (*TAddAccessAllowedAce) (PACL pAcl, DWORD dwAceRevision,
159 DWORD AccessMask, PSID pSid);
160 typedef BOOL WINAPI (*TSetNamedSecurityInfo) (LPTSTR pObjectName,
161 SE_OBJECT_TYPE ObjectType,
163 SecurityInfo, PSID psidOwner,
164 PSID psidGroup, PACL pDacl,
167 extern TGetBestInterfaceEx GNGetBestInterfaceEx;
168 extern TNtQuerySystemInformation GNNtQuerySystemInformation;
169 extern TGetIfEntry GNGetIfEntry;
170 extern TGetIpAddrTable GNGetIpAddrTable;
171 extern TGetIfTable GNGetIfTable;
172 extern TCreateHardLink GNCreateHardLink;
173 extern TOpenSCManager GNOpenSCManager;
174 extern TCreateService GNCreateService;
175 extern TCloseServiceHandle GNCloseServiceHandle;
176 extern TDeleteService GNDeleteService;
177 extern TRegisterServiceCtrlHandler GNRegisterServiceCtrlHandler;
178 extern TSetServiceStatus GNSetServiceStatus;
179 extern TStartServiceCtrlDispatcher GNStartServiceCtrlDispatcher;
180 extern TControlService GNControlService;
181 extern TOpenService GNOpenService;
182 extern TGetAdaptersInfo GNGetAdaptersInfo;
183 extern TNetUserAdd GNNetUserAdd;
184 extern TNetUserSetInfo GNNetUserSetInfo;
185 extern TLsaOpenPolicy GNLsaOpenPolicy;
186 extern TLsaAddAccountRights GNLsaAddAccountRights;
187 extern TLsaRemoveAccountRights GNLsaRemoveAccountRights;
188 extern TLsaClose GNLsaClose;
189 extern TLookupAccountName GNLookupAccountName;
190 extern TGetFileSecurity GNGetFileSecurity;
191 extern TInitializeSecurityDescriptor GNInitializeSecurityDescriptor;
192 extern TGetSecurityDescriptorDacl GNGetSecurityDescriptorDacl;
193 extern TGetAclInformation GNGetAclInformation;
194 extern TInitializeAcl GNInitializeAcl;
195 extern TGetAce GNGetAce;
196 extern TEqualSid GNEqualSid;
197 extern TAddAce GNAddAce;
198 extern TAddAccessAllowedAce GNAddAccessAllowedAce;
199 extern TSetNamedSecurityInfo GNSetNamedSecurityInfo;
202 BOOL CreateShortcut (const char *pszSrc, const char *pszDest);
203 BOOL DereferenceShortcut (char *pszShortcut);
204 long QueryRegistry (HKEY hMainKey, const char *pszKey, const char *pszSubKey,
205 char *pszBuffer, long *pdLength);
206 int ListNICs (void (*callback) (void *, const char *, int), void *cls);
207 BOOL AddPathAccessRights (char *lpszFileName, char *lpszAccountName,
209 char *winErrorStr (const char *prefix, int dwErr);
210 void EnumNICs (PMIB_IFTABLE * pIfTable, PMIB_IPADDRTABLE * pAddrTable);
212 #define ENUMNICS3_MASK_OK 0x01
213 #define ENUMNICS3_BCAST_OK 0x02
215 struct EnumNICs3_results
219 char pretty_name[1001];
221 SOCKADDR_STORAGE address;
222 SOCKADDR_STORAGE mask;
223 SOCKADDR_STORAGE broadcast;
226 int EnumNICs3 (struct EnumNICs3_results **, int *EnumNICs3_results_count);
227 void EnumNICs3_free (struct EnumNICs3_results *);
229 void GNShutdownWinEnv ();
231 BOOL SafeTerminateProcess (HANDLE hProcess, UINT uExitCode, DWORD dwTimeout);