Skip to content

Commit c0cabc9

Browse files
committed
Check for Windows 7 compatibility
1 parent 9a1da5b commit c0cabc9

File tree

2 files changed

+296
-7
lines changed

2 files changed

+296
-7
lines changed

.github/workflows/c-cpp.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -405,9 +405,9 @@ jobs:
405405
strategy:
406406
matrix:
407407
config:
408-
- {vs: Visual Studio 16 2019, os: 2019, msbuild: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\MSBuild\\Current\\Bin\\amd64\\", rx: "ON", upnp: "ON"}
409-
- {vs: Visual Studio 16 2019, os: 2019, msbuild: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\MSBuild\\Current\\Bin\\amd64\\", rx: "OFF", upnp: "ON"}
410-
- {vs: Visual Studio 16 2019, os: 2019, msbuild: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\MSBuild\\Current\\Bin\\amd64\\", rx: "OFF", upnp: "OFF"}
408+
- {vs: Visual Studio 16 2019, os: 2019, vspath: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise", rx: "ON", upnp: "ON"}
409+
- {vs: Visual Studio 16 2019, os: 2019, vspath: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise", rx: "OFF", upnp: "ON"}
410+
- {vs: Visual Studio 16 2019, os: 2019, vspath: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise", rx: "OFF", upnp: "OFF"}
411411

412412
steps:
413413
- name: Checkout repository
@@ -423,14 +423,22 @@ jobs:
423423
mkdir build
424424
cd build
425425
cmake .. -G "${{ matrix.config.vs }}" -DWITH_RANDOMX=${{ matrix.config.rx }} -DWITH_UPNP=${{ matrix.config.upnp }}
426-
& "${{ matrix.config.msbuild }}msbuild" -v:m /m /p:Configuration=Release p2pool.vcxproj
426+
& "${{ matrix.config.vspath }}\\MSBuild\\Current\\Bin\\amd64\\msbuild" -v:m /m /p:Configuration=Release p2pool.vcxproj
427+
428+
- name: Check Windows 7 compatibility
429+
shell: cmd
430+
run: |
431+
call "${{ matrix.config.vspath }}\\VC\\Auxiliary\\Build\\vcvarsall.bat" amd64
432+
dumpbin /IMPORTS build/Release/p2pool.exe > 1.txt
433+
findstr /R /C:"^ *[0-9A-F][0-9A-F]* [a-zA-Z][a-zA-Z0-9]*$" 1.txt > 2.txt
434+
python tests/src/check_win7.py 2.txt
427435
428436
- name: Run RandomX tests
429437
if: matrix.config.rx == 'ON'
430438
run: |
431439
build/Release/p2pool.exe --test
432440
cd build/external/src/RandomX
433-
& "${{ matrix.config.msbuild }}msbuild" -v:m /m /p:Configuration=Release randomx-tests.vcxproj
441+
& "${{ matrix.config.vspath }}\\MSBuild\\Current\\Bin\\amd64\\msbuild" -v:m /m /p:Configuration=Release randomx-tests.vcxproj
434442
Release/randomx-tests.exe
435443
436444
- name: Build tests
@@ -439,7 +447,7 @@ jobs:
439447
mkdir build
440448
cd build
441449
cmake .. -G "${{ matrix.config.vs }}"
442-
& "${{ matrix.config.msbuild }}msbuild" -v:m /m /p:Configuration=Debug p2pool_tests.vcxproj
450+
& "${{ matrix.config.vspath }}\\MSBuild\\Current\\Bin\\amd64\\msbuild" -v:m /m /p:Configuration=Debug p2pool_tests.vcxproj
443451
444452
- name: Run tests
445453
run: |
@@ -450,7 +458,7 @@ jobs:
450458
- name: Archive binary
451459
uses: actions/upload-artifact@v3
452460
with:
453-
name: p2pool-msbuild-${{ matrix.config.os }}-randomx-${{ matrix.config.rx }}-upnp-${{ matrix.config.upnp }}.exe
461+
name: p2pool-vs-${{ matrix.config.os }}-randomx-${{ matrix.config.rx }}-upnp-${{ matrix.config.upnp }}.exe
454462
path: build/Release/p2pool.exe
455463

456464
build-macos:

tests/src/check_win7.py

Lines changed: 281 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,281 @@
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

Comments
 (0)