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 util/winproc.h
23 * @brief Definitions for MS Windows
32 #include <sys/types.h>
34 #include <sys/timeb.h>
43 #include <sys/param.h> /* #define BYTE_ORDER */
54 #ifndef MAX_NAME_LENGTH
55 #define MAX_NAME_LENGTH 25
58 typedef DWORD WINAPI (*TNtQuerySystemInformation) (int, PVOID, ULONG,
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,
65 typedef DWORD WINAPI (*TCreateHardLink) (LPCTSTR lpFileName,
66 LPCTSTR lpExistingFileName,
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,
79 LPCTSTR lpBinaryPathName,
80 LPCTSTR lpLoadOrderGroup,
82 LPCTSTR lpDependencies,
83 LPCTSTR lpServiceStartName,
85 typedef BOOL WINAPI (*TCloseServiceHandle) (SC_HANDLE hSCObject);
86 typedef BOOL WINAPI (*TDeleteService) (SC_HANDLE hService);
87 typedef SERVICE_STATUS_HANDLE WINAPI (*TRegisterServiceCtrlHandler) (LPCTSTR
91 typedef BOOL WINAPI (*TSetServiceStatus) (SERVICE_STATUS_HANDLE
93 LPSERVICE_STATUS lpServiceStatus);
94 typedef BOOL WINAPI (*TStartServiceCtrlDispatcher) (const
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,
106 typedef NET_API_STATUS WINAPI (*TNetUserAdd) (LPCWSTR, DWORD, PBYTE,
108 typedef NET_API_STATUS WINAPI (*TNetUserSetInfo) (LPCWSTR servername,
110 DWORD level, LPBYTE buf,
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,
121 typedef NTSTATUS NTAPI (*TLsaClose) (LSA_HANDLE);
122 typedef BOOL WINAPI (*TLookupAccountName) (LPCTSTR lpSystemName,
123 LPCTSTR lpAccountName, PSID Sid,
125 LPTSTR ReferencedDomainName,
126 LPDWORD cchReferencedDomainName,
127 PSID_NAME_USE peUse);
129 typedef BOOL WINAPI (*TGetFileSecurity) (LPCTSTR lpFileName,
131 RequestedInformation,
133 pSecurityDescriptor, DWORD nLength,
134 LPDWORD lpnLengthNeeded);
135 typedef BOOL WINAPI (*TInitializeSecurityDescriptor) (PSECURITY_DESCRIPTOR
138 typedef BOOL WINAPI (*TGetSecurityDescriptorDacl) (PSECURITY_DESCRIPTOR
140 LPBOOL lpbDaclPresent,
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,
160 SecurityInfo, PSID psidOwner,
161 PSID psidGroup, PACL pDacl,
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;
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,
206 char *winErrorStr (const char *prefix, int dwErr);
208 void GNInitWinEnv ();
209 void GNShutdownWinEnv ();