diff options
Diffstat (limited to 'src/include/winproc.h')
-rw-r--r-- | src/include/winproc.h | 331 |
1 files changed, 165 insertions, 166 deletions
diff --git a/src/include/winproc.h b/src/include/winproc.h index 3910321d7..139f07e61 100644 --- a/src/include/winproc.h +++ b/src/include/winproc.h | |||
@@ -11,12 +11,12 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 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/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @author Nils Durner | 22 | * @author Nils Durner |
@@ -60,175 +60,174 @@ extern "C" | |||
60 | #define MAX_NAME_LENGTH 25 | 60 | #define MAX_NAME_LENGTH 25 |
61 | #endif | 61 | #endif |
62 | 62 | ||
63 | typedef DWORD WINAPI (*TNtQuerySystemInformation) (int, PVOID, ULONG, PULONG); | 63 | typedef DWORD WINAPI (*TNtQuerySystemInformation) (int, PVOID, ULONG, PULONG); |
64 | typedef DWORD WINAPI (*TGetIfEntry) (PMIB_IFROW pIfRow); | 64 | typedef DWORD WINAPI (*TGetIfEntry) (PMIB_IFROW pIfRow); |
65 | typedef DWORD WINAPI (*TGetIpAddrTable) (PMIB_IPADDRTABLE pIpAddrTable, | 65 | typedef DWORD WINAPI (*TGetIpAddrTable) (PMIB_IPADDRTABLE pIpAddrTable, |
66 | PULONG pdwSize, BOOL bOrder); | 66 | PULONG pdwSize, BOOL bOrder); |
67 | typedef DWORD WINAPI (*TGetIfTable) (PMIB_IFTABLE pIfTable, PULONG pdwSize, | 67 | typedef DWORD WINAPI (*TGetIfTable) (PMIB_IFTABLE pIfTable, PULONG pdwSize, |
68 | BOOL bOrder); | 68 | BOOL bOrder); |
69 | typedef DWORD WINAPI (*TGetBestInterfaceEx) (struct sockaddr *, PDWORD); | 69 | typedef DWORD WINAPI (*TGetBestInterfaceEx) (struct sockaddr *, PDWORD); |
70 | /* TODO: Explicitly import -A variants (i.e. TCreateHardLinkA) or -W | 70 | /* TODO: Explicitly import -A variants (i.e. TCreateHardLinkA) or -W |
71 | * variants (TCreateHardLinkW), etc. | 71 | * variants (TCreateHardLinkW), etc. |
72 | */ | 72 | */ |
73 | typedef DWORD WINAPI (*TCreateHardLink) (LPCTSTR lpFileName, | 73 | typedef DWORD WINAPI (*TCreateHardLink) (LPCTSTR lpFileName, |
74 | LPCTSTR lpExistingFileName, | 74 | LPCTSTR lpExistingFileName, |
75 | LPSECURITY_ATTRIBUTES | 75 | LPSECURITY_ATTRIBUTES |
76 | lpSecurityAttributes); | 76 | lpSecurityAttributes); |
77 | typedef SC_HANDLE WINAPI (*TOpenSCManager) (LPCTSTR lpMachineName, | 77 | typedef SC_HANDLE WINAPI (*TOpenSCManager) (LPCTSTR lpMachineName, |
78 | LPCTSTR lpDatabaseName, | 78 | LPCTSTR lpDatabaseName, |
79 | DWORD dwDesiredAccess); | ||
80 | typedef SC_HANDLE WINAPI (*TCreateService) (SC_HANDLE hSCManager, | ||
81 | LPCTSTR lpServiceName, | ||
82 | LPCTSTR lpDisplayName, | ||
83 | DWORD dwDesiredAccess, | ||
84 | DWORD dwServiceType, | ||
85 | DWORD dwStartType, | ||
86 | DWORD dwErrorControl, | ||
87 | LPCTSTR lpBinaryPathName, | ||
88 | LPCTSTR lpLoadOrderGroup, | ||
89 | LPDWORD lpdwTagId, | ||
90 | LPCTSTR lpDependencies, | ||
91 | LPCTSTR lpServiceStartName, | ||
92 | LPCTSTR lpPassword); | ||
93 | typedef BOOL WINAPI (*TCloseServiceHandle) (SC_HANDLE hSCObject); | ||
94 | typedef BOOL WINAPI (*TDeleteService) (SC_HANDLE hService); | ||
95 | typedef SERVICE_STATUS_HANDLE WINAPI (*TRegisterServiceCtrlHandler) (LPCTSTR | ||
96 | lpServiceName, | ||
97 | LPHANDLER_FUNCTION | ||
98 | lpHandlerProc); | ||
99 | typedef BOOL WINAPI (*TSetServiceStatus) (SERVICE_STATUS_HANDLE | ||
100 | hServiceStatus, | ||
101 | LPSERVICE_STATUS lpServiceStatus); | ||
102 | typedef BOOL WINAPI (*TStartServiceCtrlDispatcher) (const | ||
103 | LPSERVICE_TABLE_ENTRY | ||
104 | lpServiceTable); | ||
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); | 79 | DWORD dwDesiredAccess); |
110 | typedef DWORD WINAPI (*TGetAdaptersInfo) (PIP_ADAPTER_INFO pAdapterInfo, | 80 | typedef SC_HANDLE WINAPI (*TCreateService) (SC_HANDLE hSCManager, |
111 | PULONG pOutBufLen); | 81 | LPCTSTR lpServiceName, |
112 | typedef NET_API_STATUS WINAPI (*TNetUserAdd) (LPCWSTR, DWORD, PBYTE, PDWORD); | 82 | LPCTSTR lpDisplayName, |
113 | typedef NET_API_STATUS WINAPI (*TNetUserSetInfo) (LPCWSTR servername, | 83 | DWORD dwDesiredAccess, |
114 | LPCWSTR username, | 84 | DWORD dwServiceType, |
115 | DWORD level, LPBYTE buf, | 85 | DWORD dwStartType, |
116 | LPDWORD param_err); | 86 | DWORD dwErrorControl, |
117 | typedef NTSTATUS NTAPI (*TLsaOpenPolicy) (PLSA_UNICODE_STRING, | 87 | LPCTSTR lpBinaryPathName, |
118 | PLSA_OBJECT_ATTRIBUTES, ACCESS_MASK, | 88 | LPCTSTR lpLoadOrderGroup, |
119 | PLSA_HANDLE); | 89 | LPDWORD lpdwTagId, |
120 | typedef NTSTATUS NTAPI (*TLsaAddAccountRights) (LSA_HANDLE, PSID, | 90 | LPCTSTR lpDependencies, |
121 | PLSA_UNICODE_STRING, ULONG); | 91 | LPCTSTR lpServiceStartName, |
122 | typedef NTSTATUS NTAPI (*TLsaRemoveAccountRights) (LSA_HANDLE, PSID, BOOLEAN, | 92 | LPCTSTR lpPassword); |
123 | PLSA_UNICODE_STRING, | 93 | typedef BOOL WINAPI (*TCloseServiceHandle) (SC_HANDLE hSCObject); |
124 | ULONG); | 94 | typedef BOOL WINAPI (*TDeleteService) (SC_HANDLE hService); |
125 | typedef NTSTATUS NTAPI (*TLsaClose) (LSA_HANDLE); | 95 | typedef SERVICE_STATUS_HANDLE WINAPI (*TRegisterServiceCtrlHandler) (LPCTSTR |
126 | typedef BOOL WINAPI (*TLookupAccountName) (LPCTSTR lpSystemName, | 96 | lpServiceName, |
127 | LPCTSTR lpAccountName, PSID Sid, | 97 | LPHANDLER_FUNCTION |
128 | LPDWORD cbSid, | 98 | lpHandlerProc); |
129 | LPTSTR ReferencedDomainName, | 99 | typedef BOOL WINAPI (*TSetServiceStatus) (SERVICE_STATUS_HANDLE |
130 | LPDWORD cchReferencedDomainName, | 100 | hServiceStatus, |
131 | PSID_NAME_USE peUse); | 101 | LPSERVICE_STATUS lpServiceStatus); |
132 | 102 | typedef BOOL WINAPI (*TStartServiceCtrlDispatcher) (const | |
133 | typedef BOOL WINAPI (*TGetFileSecurity) (LPCTSTR lpFileName, | 103 | LPSERVICE_TABLE_ENTRY |
134 | SECURITY_INFORMATION | 104 | lpServiceTable); |
135 | RequestedInformation, | 105 | typedef BOOL WINAPI (*TControlService) (SC_HANDLE hService, DWORD dwControl, |
136 | PSECURITY_DESCRIPTOR | 106 | LPSERVICE_STATUS lpServiceStatus); |
137 | pSecurityDescriptor, DWORD nLength, | 107 | typedef SC_HANDLE WINAPI (*TOpenService) (SC_HANDLE hSCManager, |
138 | LPDWORD lpnLengthNeeded); | 108 | LPCTSTR lpServiceName, |
139 | typedef BOOL WINAPI (*TInitializeSecurityDescriptor) (PSECURITY_DESCRIPTOR | 109 | DWORD dwDesiredAccess); |
140 | pSecurityDescriptor, | 110 | typedef DWORD WINAPI (*TGetAdaptersInfo) (PIP_ADAPTER_INFO pAdapterInfo, |
141 | DWORD dwRevision); | 111 | PULONG pOutBufLen); |
142 | typedef BOOL WINAPI (*TGetSecurityDescriptorDacl) (PSECURITY_DESCRIPTOR | 112 | typedef NET_API_STATUS WINAPI (*TNetUserAdd) (LPCWSTR, DWORD, PBYTE, PDWORD); |
143 | pSecurityDescriptor, | 113 | typedef NET_API_STATUS WINAPI (*TNetUserSetInfo) (LPCWSTR servername, |
144 | LPBOOL lpbDaclPresent, | 114 | LPCWSTR username, |
145 | PACL * pDacl, | 115 | DWORD level, LPBYTE buf, |
146 | LPBOOL lpbDaclDefaulted); | 116 | LPDWORD param_err); |
147 | typedef BOOL WINAPI (*TGetAclInformation) (PACL pAcl, LPVOID pAclInformation, | 117 | typedef NTSTATUS NTAPI (*TLsaOpenPolicy) (PLSA_UNICODE_STRING, |
148 | DWORD nAclInformationLength, | 118 | PLSA_OBJECT_ATTRIBUTES, ACCESS_MASK, |
149 | ACL_INFORMATION_CLASS | 119 | PLSA_HANDLE); |
150 | dwAclInformationClass); | 120 | typedef NTSTATUS NTAPI (*TLsaAddAccountRights) (LSA_HANDLE, PSID, |
151 | typedef BOOL WINAPI (*TInitializeAcl) (PACL pAcl, DWORD nAclLength, | 121 | PLSA_UNICODE_STRING, ULONG); |
152 | DWORD dwAclRevision); | 122 | typedef NTSTATUS NTAPI (*TLsaRemoveAccountRights) (LSA_HANDLE, PSID, BOOLEAN, |
153 | typedef BOOL WINAPI (*TGetAce) (PACL pAcl, DWORD dwAceIndex, LPVOID * pAce); | 123 | PLSA_UNICODE_STRING, |
154 | typedef BOOL WINAPI (*TEqualSid) (PSID pSid1, PSID pSid2); | 124 | ULONG); |
155 | typedef BOOL WINAPI (*TAddAce) (PACL pAcl, DWORD dwAceRevision, | 125 | typedef NTSTATUS NTAPI (*TLsaClose) (LSA_HANDLE); |
156 | DWORD dwStartingAceIndex, LPVOID pAceList, | 126 | typedef BOOL WINAPI (*TLookupAccountName) (LPCTSTR lpSystemName, |
157 | DWORD nAceListLength); | 127 | LPCTSTR lpAccountName, PSID Sid, |
158 | typedef BOOL WINAPI (*TAddAccessAllowedAce) (PACL pAcl, DWORD dwAceRevision, | 128 | LPDWORD cbSid, |
159 | DWORD AccessMask, PSID pSid); | 129 | LPTSTR ReferencedDomainName, |
160 | typedef BOOL WINAPI (*TSetNamedSecurityInfo) (LPTSTR pObjectName, | 130 | LPDWORD cchReferencedDomainName, |
161 | SE_OBJECT_TYPE ObjectType, | 131 | PSID_NAME_USE peUse); |
162 | SECURITY_INFORMATION | 132 | |
163 | SecurityInfo, PSID psidOwner, | 133 | typedef BOOL WINAPI (*TGetFileSecurity) (LPCTSTR lpFileName, |
164 | PSID psidGroup, PACL pDacl, | 134 | SECURITY_INFORMATION |
165 | PACL pSacl); | 135 | RequestedInformation, |
166 | 136 | PSECURITY_DESCRIPTOR | |
167 | extern TGetBestInterfaceEx GNGetBestInterfaceEx; | 137 | pSecurityDescriptor, DWORD nLength, |
168 | extern TNtQuerySystemInformation GNNtQuerySystemInformation; | 138 | LPDWORD lpnLengthNeeded); |
169 | extern TGetIfEntry GNGetIfEntry; | 139 | typedef BOOL WINAPI (*TInitializeSecurityDescriptor) (PSECURITY_DESCRIPTOR |
170 | extern TGetIpAddrTable GNGetIpAddrTable; | 140 | pSecurityDescriptor, |
171 | extern TGetIfTable GNGetIfTable; | 141 | DWORD dwRevision); |
172 | extern TCreateHardLink GNCreateHardLink; | 142 | typedef BOOL WINAPI (*TGetSecurityDescriptorDacl) (PSECURITY_DESCRIPTOR |
173 | extern TOpenSCManager GNOpenSCManager; | 143 | pSecurityDescriptor, |
174 | extern TCreateService GNCreateService; | 144 | LPBOOL lpbDaclPresent, |
175 | extern TCloseServiceHandle GNCloseServiceHandle; | 145 | PACL * pDacl, |
176 | extern TDeleteService GNDeleteService; | 146 | LPBOOL lpbDaclDefaulted); |
177 | extern TRegisterServiceCtrlHandler GNRegisterServiceCtrlHandler; | 147 | typedef BOOL WINAPI (*TGetAclInformation) (PACL pAcl, LPVOID pAclInformation, |
178 | extern TSetServiceStatus GNSetServiceStatus; | 148 | DWORD nAclInformationLength, |
179 | extern TStartServiceCtrlDispatcher GNStartServiceCtrlDispatcher; | 149 | ACL_INFORMATION_CLASS |
180 | extern TControlService GNControlService; | 150 | dwAclInformationClass); |
181 | extern TOpenService GNOpenService; | 151 | typedef BOOL WINAPI (*TInitializeAcl) (PACL pAcl, DWORD nAclLength, |
182 | extern TGetAdaptersInfo GNGetAdaptersInfo; | 152 | DWORD dwAclRevision); |
183 | extern TNetUserAdd GNNetUserAdd; | 153 | typedef BOOL WINAPI (*TGetAce) (PACL pAcl, DWORD dwAceIndex, LPVOID * pAce); |
184 | extern TNetUserSetInfo GNNetUserSetInfo; | 154 | typedef BOOL WINAPI (*TEqualSid) (PSID pSid1, PSID pSid2); |
185 | extern TLsaOpenPolicy GNLsaOpenPolicy; | 155 | typedef BOOL WINAPI (*TAddAce) (PACL pAcl, DWORD dwAceRevision, |
186 | extern TLsaAddAccountRights GNLsaAddAccountRights; | 156 | DWORD dwStartingAceIndex, LPVOID pAceList, |
187 | extern TLsaRemoveAccountRights GNLsaRemoveAccountRights; | 157 | DWORD nAceListLength); |
188 | extern TLsaClose GNLsaClose; | 158 | typedef BOOL WINAPI (*TAddAccessAllowedAce) (PACL pAcl, DWORD dwAceRevision, |
189 | extern TLookupAccountName GNLookupAccountName; | 159 | DWORD AccessMask, PSID pSid); |
190 | extern TGetFileSecurity GNGetFileSecurity; | 160 | typedef BOOL WINAPI (*TSetNamedSecurityInfo) (LPTSTR pObjectName, |
191 | extern TInitializeSecurityDescriptor GNInitializeSecurityDescriptor; | 161 | SE_OBJECT_TYPE ObjectType, |
192 | extern TGetSecurityDescriptorDacl GNGetSecurityDescriptorDacl; | 162 | SECURITY_INFORMATION |
193 | extern TGetAclInformation GNGetAclInformation; | 163 | SecurityInfo, PSID psidOwner, |
194 | extern TInitializeAcl GNInitializeAcl; | 164 | PSID psidGroup, PACL pDacl, |
195 | extern TGetAce GNGetAce; | 165 | PACL pSacl); |
196 | extern TEqualSid GNEqualSid; | 166 | |
197 | extern TAddAce GNAddAce; | 167 | extern TGetBestInterfaceEx GNGetBestInterfaceEx; |
198 | extern TAddAccessAllowedAce GNAddAccessAllowedAce; | 168 | extern TNtQuerySystemInformation GNNtQuerySystemInformation; |
199 | extern TSetNamedSecurityInfo GNSetNamedSecurityInfo; | 169 | extern TGetIfEntry GNGetIfEntry; |
200 | 170 | extern TGetIpAddrTable GNGetIpAddrTable; | |
201 | 171 | extern TGetIfTable GNGetIfTable; | |
202 | BOOL CreateShortcut (const char *pszSrc, const char *pszDest); | 172 | extern TCreateHardLink GNCreateHardLink; |
203 | BOOL DereferenceShortcut (char *pszShortcut); | 173 | extern TOpenSCManager GNOpenSCManager; |
204 | long QueryRegistry (HKEY hMainKey, const char *pszKey, const char *pszSubKey, | 174 | extern TCreateService GNCreateService; |
205 | char *pszBuffer, long *pdLength); | 175 | extern TCloseServiceHandle GNCloseServiceHandle; |
206 | int ListNICs (void (*callback) (void *, const char *, int), void *cls); | 176 | extern TDeleteService GNDeleteService; |
207 | BOOL AddPathAccessRights (char *lpszFileName, char *lpszAccountName, | 177 | extern TRegisterServiceCtrlHandler GNRegisterServiceCtrlHandler; |
208 | DWORD dwAccessMask); | 178 | extern TSetServiceStatus GNSetServiceStatus; |
209 | char *winErrorStr (const char *prefix, int dwErr); | 179 | extern TStartServiceCtrlDispatcher GNStartServiceCtrlDispatcher; |
210 | void EnumNICs (PMIB_IFTABLE * pIfTable, PMIB_IPADDRTABLE * pAddrTable); | 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; | ||
200 | |||
201 | |||
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, | ||
208 | DWORD dwAccessMask); | ||
209 | char *winErrorStr(const char *prefix, int dwErr); | ||
210 | void EnumNICs(PMIB_IFTABLE * pIfTable, PMIB_IPADDRTABLE * pAddrTable); | ||
211 | 211 | ||
212 | #define ENUMNICS3_MASK_OK 0x01 | 212 | #define ENUMNICS3_MASK_OK 0x01 |
213 | #define ENUMNICS3_BCAST_OK 0x02 | 213 | #define ENUMNICS3_BCAST_OK 0x02 |
214 | 214 | ||
215 | struct EnumNICs3_results | 215 | struct EnumNICs3_results { |
216 | { | 216 | unsigned char flags; |
217 | unsigned char flags; | 217 | int is_default; |
218 | int is_default; | 218 | char pretty_name[1001]; |
219 | char pretty_name[1001]; | 219 | size_t addr_size; |
220 | size_t addr_size; | 220 | SOCKADDR_STORAGE address; |
221 | SOCKADDR_STORAGE address; | 221 | SOCKADDR_STORAGE mask; |
222 | SOCKADDR_STORAGE mask; | 222 | SOCKADDR_STORAGE broadcast; |
223 | SOCKADDR_STORAGE broadcast; | 223 | }; |
224 | }; | 224 | |
225 | 225 | int EnumNICs3(struct EnumNICs3_results **, int *EnumNICs3_results_count); | |
226 | int EnumNICs3 (struct EnumNICs3_results **, int *EnumNICs3_results_count); | 226 | void EnumNICs3_free(struct EnumNICs3_results *); |
227 | void EnumNICs3_free (struct EnumNICs3_results *); | 227 | int GNInitWinEnv(); |
228 | int GNInitWinEnv (); | 228 | void GNShutdownWinEnv(); |
229 | void GNShutdownWinEnv (); | 229 | |
230 | 230 | BOOL SafeTerminateProcess(HANDLE hProcess, UINT uExitCode, DWORD dwTimeout); | |
231 | BOOL SafeTerminateProcess (HANDLE hProcess, UINT uExitCode, DWORD dwTimeout); | ||
232 | #ifdef __cplusplus | 231 | #ifdef __cplusplus |
233 | } | 232 | } |
234 | #endif | 233 | #endif |