|
| 1 | +# This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool> |
| 2 | +# Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh> |
| 3 | +# |
| 4 | +# This program is free software: you can redistribute it and/or modify |
| 5 | +# it under the terms of the GNU General Public License as published by |
| 6 | +# the Free Software Foundation, version 3. |
| 7 | +# |
| 8 | +# This program is distributed in the hope that it will be useful, but |
| 9 | +# WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 | +# General Public License for more details. |
| 12 | +# |
| 13 | +# You should have received a copy of the GNU General Public License |
| 14 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | + |
| 16 | +import sys |
| 17 | + |
| 18 | +allowedAPIs = { |
| 19 | + "getaddrinfo", |
| 20 | + "freeaddrinfo", |
| 21 | + "WSAPoll", |
| 22 | + "WSACreateEvent", |
| 23 | + "WSACloseEvent", |
| 24 | + "WSARecvFrom", |
| 25 | + "WSASend", |
| 26 | + "WSARecv", |
| 27 | + "WSADuplicateSocketW", |
| 28 | + "WSASocketW", |
| 29 | + "WSAIoctl", |
| 30 | + "getnameinfo", |
| 31 | + "WSASocketA", |
| 32 | + "GetAdaptersAddresses", |
| 33 | + "GetBestInterface", |
| 34 | + "DnsFree", |
| 35 | + "LoadLibraryExW", |
| 36 | + "RtlPcToFileHeader", |
| 37 | + "RtlUnwindEx", |
| 38 | + "GetCPInfo", |
| 39 | + "GetStringTypeW", |
| 40 | + "GetDriveTypeW", |
| 41 | + "DecodePointer", |
| 42 | + "EncodePointer", |
| 43 | + "FreeLibraryAndExitThread", |
| 44 | + "SystemTimeToTzSpecificLocalTime", |
| 45 | + "CreateThread", |
| 46 | + "LCMapStringEx", |
| 47 | + "ExitThread", |
| 48 | + "GetModuleHandleExW", |
| 49 | + "SetStdHandle", |
| 50 | + "FlsFree", |
| 51 | + "FlsSetValue", |
| 52 | + "FlsGetValue", |
| 53 | + "SetFilePointer", |
| 54 | + "SetEndOfFile", |
| 55 | + "UnmapViewOfFile", |
| 56 | + "GetLastError", |
| 57 | + "FlushViewOfFile", |
| 58 | + "CreateFileA", |
| 59 | + "CloseHandle", |
| 60 | + "CreateFileMappingA", |
| 61 | + "MapViewOfFile", |
| 62 | + "FlushFileBuffers", |
| 63 | + "GetStdHandle", |
| 64 | + "WriteConsoleA", |
| 65 | + "SetConsoleMode", |
| 66 | + "GetConsoleMode", |
| 67 | + "FormatMessageA", |
| 68 | + "SetThreadPriority", |
| 69 | + "GetCurrentThread", |
| 70 | + "SetThreadPriorityBoost", |
| 71 | + "IsDebuggerPresent", |
| 72 | + "Sleep", |
| 73 | + "RaiseException", |
| 74 | + "InitializeCriticalSection", |
| 75 | + "EnterCriticalSection", |
| 76 | + "LeaveCriticalSection", |
| 77 | + "DeleteCriticalSection", |
| 78 | + "QueryPerformanceCounter", |
| 79 | + "QueryPerformanceFrequency", |
| 80 | + "GetTickCount", |
| 81 | + "FreeLibrary", |
| 82 | + "GetProcAddress", |
| 83 | + "LoadLibraryA", |
| 84 | + "SetHandleInformation", |
| 85 | + "WaitForSingleObject", |
| 86 | + "GetCurrentThreadId", |
| 87 | + "TryEnterCriticalSection", |
| 88 | + "GetCurrentProcessId", |
| 89 | + "GetHandleInformation", |
| 90 | + "SetLastError", |
| 91 | + "CreateIoCompletionPort", |
| 92 | + "GetQueuedCompletionStatusEx", |
| 93 | + "InitializeSRWLock", |
| 94 | + "ReleaseSRWLockExclusive", |
| 95 | + "ReleaseSRWLockShared", |
| 96 | + "AcquireSRWLockExclusive", |
| 97 | + "AcquireSRWLockShared", |
| 98 | + "InitOnceExecuteOnce", |
| 99 | + "GetTickCount64", |
| 100 | + "GetModuleHandleW", |
| 101 | + "SetFileCompletionNotificationModes", |
| 102 | + "WideCharToMultiByte", |
| 103 | + "DuplicateHandle", |
| 104 | + "TryAcquireSRWLockShared", |
| 105 | + "InitializeConditionVariable", |
| 106 | + "WakeConditionVariable", |
| 107 | + "WakeAllConditionVariable", |
| 108 | + "SleepConditionVariableCS", |
| 109 | + "SetEvent", |
| 110 | + "ReleaseSemaphore", |
| 111 | + "CreateEventA", |
| 112 | + "GetCurrentProcess", |
| 113 | + "ResumeThread", |
| 114 | + "TlsAlloc", |
| 115 | + "TlsGetValue", |
| 116 | + "TlsSetValue", |
| 117 | + "TlsFree", |
| 118 | + "GetNativeSystemInfo", |
| 119 | + "CreateSemaphoreA", |
| 120 | + "GetFileType", |
| 121 | + "PostQueuedCompletionStatus", |
| 122 | + "CreateFileW", |
| 123 | + "ResetEvent", |
| 124 | + "QueueUserWorkItem", |
| 125 | + "GetFileAttributesExW", |
| 126 | + "UnregisterWait", |
| 127 | + "GetNumberOfConsoleInputEvents", |
| 128 | + "ReadConsoleInputW", |
| 129 | + "ReadConsoleW", |
| 130 | + "WriteConsoleW", |
| 131 | + "FillConsoleOutputCharacterW", |
| 132 | + "FillConsoleOutputAttribute", |
| 133 | + "GetConsoleCursorInfo", |
| 134 | + "SetConsoleCursorInfo", |
| 135 | + "GetConsoleScreenBufferInfo", |
| 136 | + "SetConsoleCursorPosition", |
| 137 | + "SetConsoleTextAttribute", |
| 138 | + "WriteConsoleInputW", |
| 139 | + "ReadFile", |
| 140 | + "WriteFile", |
| 141 | + "ConnectNamedPipe", |
| 142 | + "SetNamedPipeHandleState", |
| 143 | + "PeekNamedPipe", |
| 144 | + "CreateNamedPipeW", |
| 145 | + "CancelIoEx", |
| 146 | + "CancelSynchronousIo", |
| 147 | + "SwitchToThread", |
| 148 | + "LocalFree", |
| 149 | + "GetNamedPipeHandleStateA", |
| 150 | + "GetNamedPipeClientProcessId", |
| 151 | + "GetNamedPipeServerProcessId", |
| 152 | + "MultiByteToWideChar", |
| 153 | + "SetConsoleCtrlHandler", |
| 154 | + "SetErrorMode", |
| 155 | + "GetQueuedCompletionStatus", |
| 156 | + "CreateDirectoryW", |
| 157 | + "FindClose", |
| 158 | + "FindFirstFileW", |
| 159 | + "FindNextFileW", |
| 160 | + "RtlUnwind", |
| 161 | + "GetFileAttributesW", |
| 162 | + "GetFileInformationByHandle", |
| 163 | + "GetFileSizeEx", |
| 164 | + "GetFinalPathNameByHandleW", |
| 165 | + "GetFullPathNameW", |
| 166 | + "RemoveDirectoryW", |
| 167 | + "SetFilePointerEx", |
| 168 | + "SetFileTime", |
| 169 | + "DeviceIoControl", |
| 170 | + "GetSystemInfo", |
| 171 | + "GetSystemTimeAsFileTime", |
| 172 | + "ReOpenFile", |
| 173 | + "CopyFileW", |
| 174 | + "MoveFileExW", |
| 175 | + "CreateHardLinkW", |
| 176 | + "GetFileInformationByHandleEx", |
| 177 | + "CreateSymbolicLinkW", |
| 178 | + "CancelIo", |
| 179 | + "DebugBreak", |
| 180 | + "GetCurrentDirectoryW", |
| 181 | + "TerminateProcess", |
| 182 | + "GetExitCodeProcess", |
| 183 | + "UnregisterWaitEx", |
| 184 | + "LCMapStringW", |
| 185 | + "GetLongPathNameW", |
| 186 | + "ReadDirectoryChangesW", |
| 187 | + "GetEnvironmentStringsW", |
| 188 | + "FreeEnvironmentStringsW", |
| 189 | + "SetEnvironmentVariableW", |
| 190 | + "GetModuleFileNameW", |
| 191 | + "FileTimeToSystemTime", |
| 192 | + "GetModuleHandleA", |
| 193 | + "LoadLibraryExA", |
| 194 | + "GetStartupInfoW", |
| 195 | + "FormatMessageW", |
| 196 | + "InitializeCriticalSectionEx", |
| 197 | + "GetSystemDirectoryA", |
| 198 | + "WaitForSingleObjectEx", |
| 199 | + "GetEnvironmentVariableA", |
| 200 | + "SleepEx", |
| 201 | + "VerSetConditionMask", |
| 202 | + "VerifyVersionInfoW", |
| 203 | + "VirtualProtect", |
| 204 | + "VirtualFree", |
| 205 | + "VirtualAlloc", |
| 206 | + "GetLargePageMinimum", |
| 207 | + "HeapFree", |
| 208 | + "HeapAlloc", |
| 209 | + "GetProcessHeap", |
| 210 | + "FlsAlloc", |
| 211 | + "SleepConditionVariableSRW", |
| 212 | + "GetExitCodeThread", |
| 213 | + "InitializeSListHead", |
| 214 | + "CreateEventW", |
| 215 | + "InitializeCriticalSectionAndSpinCount", |
| 216 | + "IsProcessorFeaturePresent", |
| 217 | + "SetUnhandledExceptionFilter", |
| 218 | + "UnhandledExceptionFilter", |
| 219 | + "RtlVirtualUnwind", |
| 220 | + "RtlLookupFunctionEntry", |
| 221 | + "SetFileAttributesW", |
| 222 | + "GetConsoleOutputCP", |
| 223 | + "ExitProcess", |
| 224 | + "GetCommandLineA", |
| 225 | + "GetCommandLineW", |
| 226 | + "GetDateFormatW", |
| 227 | + "GetTimeFormatW", |
| 228 | + "CompareStringW", |
| 229 | + "GetLocaleInfoW", |
| 230 | + "IsValidLocale", |
| 231 | + "GetUserDefaultLCID", |
| 232 | + "EnumSystemLocalesW", |
| 233 | + "HeapReAlloc", |
| 234 | + "HeapSize", |
| 235 | + "FindFirstFileExW", |
| 236 | + "IsValidCodePage", |
| 237 | + "GetACP", |
| 238 | + "GetOEMCP", |
| 239 | + "GetTimeZoneInformation", |
| 240 | + "RegisterWaitForSingleObject", |
| 241 | + "GetDiskFreeSpaceW", |
| 242 | + "RtlCaptureContext", |
| 243 | + "GetMessageA", |
| 244 | + "GetSystemMetrics", |
| 245 | + "MapVirtualKeyW", |
| 246 | + "DispatchMessageA", |
| 247 | + "TranslateMessage", |
| 248 | + "AdjustTokenPrivileges", |
| 249 | + "LookupPrivilegeValueA", |
| 250 | + "CryptDestroyHash", |
| 251 | + "CryptHashData", |
| 252 | + "CryptCreateHash", |
| 253 | + "CryptGetHashParam", |
| 254 | + "CryptReleaseContext", |
| 255 | + "CryptAcquireContextA", |
| 256 | + "SystemFunction036", |
| 257 | + "OpenProcessToken", |
| 258 | + "SetSecurityDescriptorDacl", |
| 259 | + "InitializeSecurityDescriptor", |
| 260 | + "BCryptGenRandom", |
| 261 | + "GetConsoleCP", |
| 262 | +} |
| 263 | + |
| 264 | +f = open(sys.argv[1], 'r') |
| 265 | +lines = f.readlines() |
| 266 | +f.close() |
| 267 | + |
| 268 | +exit_code = 0 |
| 269 | +count = 0 |
| 270 | + |
| 271 | +for line in lines: |
| 272 | + count += 1 |
| 273 | + api = line[29:].strip() |
| 274 | + if api not in allowedAPIs: |
| 275 | + print('API call "{}" is not checked for Windows 7 compatibility. Check it and then add it to the list in tests/src/check_imports.py'.format(api)) |
| 276 | + exit_code = 1 |
| 277 | + |
| 278 | +if exit_code == 0: |
| 279 | + print('{} imports checked successfully'.format(count)) |
| 280 | + |
| 281 | +sys.exit(exit_code) |
0 commit comments