You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

check_windows_xp_sp2_deploy.py 29 kB

feat(cmake/windows/xp/sp2/inference): implement inference on windows xp (os vesion >= sp2) build with cmake * cmake build support(xp sp2): (dbg)EXTRA_CMAKE_ARGS="-DMGE_DEPLOY_INFERENCE_ON_WINDOWS_XP_SP2=ON" ./scripts/cmake-build/host_build.sh -m -d (opt)EXTRA_CMAKE_ARGS="-DMGE_DEPLOY_INFERENCE_ON_WINDOWS_XP_SP2=ON" ./scripts/cmake-build/host_build.sh -m * cmake build support(xp sp3): (dbg)EXTRA_CMAKE_ARGS="-DMGE_DEPLOY_INFERENCE_ON_WINDOWS_XP=ON" ./scripts/cmake-build/host_build.sh -m -d (opt)EXTRA_CMAKE_ARGS="-DMGE_DEPLOY_INFERENCE_ON_WINDOWS_XP=ON" ./scripts/cmake-build/host_build.sh -m * internal behavior: will define MGB_HAVE_THREAD=0 when enable -DMGE_DEPLOY_INFERENCE_ON_WINDOWS_XP_SP2=ON * refer to https://docs.microsoft.com/en-us/cpp/build/configuring-programs-for-windows-xp?view=msvc-160 xp sp2(x86) do not support vc runtime fully, casused by KERNEL32.dll do not implement some base apis for c++ std function, for example, std::mutex/std::thread/std::condition_variable as a workround, we will disable some MegEngine features on xp sp2 env, for exampe, multi-thread etc! * about DNN_MUTEX/MGB_MUTEX/LITE_MUTEX, if your code will build in inference code (even CPU backends), please replace std::mutex to DNN_MUTEX/MGB_MUTEX, * about multi-thread, if you code need multi-thread support, please enable it when MGB_HAVE_THREAD=1 * about test build env status 1: Visual Studio 2019(MSVC version <= 14.26.28801)---- pass 2: Visual Studio 2019(MSVC version > 14.26.28801) ---- failed caused by this 'new' version will put VCR depends on win7 KERNEL32.DLL, this may be fixed at Visual Studio 2019 later version but we do not test at this MR merge point 3: Visual Studio 2017 ---------- pass 4: Visual Studio 2014 ---------- pass GitOrigin-RevId: ea6e1f8b4fea9aa03594e3af8d59708b4cdf7bdc
3 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093
  1. #!/usr/bin/env python3
  2. import argparse
  3. import os
  4. import platform
  5. import subprocess
  6. """
  7. refer to https://docs.microsoft.com/en-us/cpp/build/configuring-programs-for-windows-xp?view=msvc-160
  8. xp sp2(x86) do not support vc runtime fully, casused by KERNEL32.dll do not implement some base apis
  9. for c++ std function, for example, std::mutex/std::thread, we do not want create a real xp sp2 env or
  10. create a wine xp sp2 env to test load_and_run, as a workround, we test target pe file import functions
  11. are in KERNEL32.dll export function lists or not!
  12. """
  13. # cmd.exe /c "dumpbin /exports KERNEL32.dll"
  14. # KERNEL32.dll from Windows xp sp2 2002 C:\WINDOWS\system32
  15. # please do not modify KERNEL32_XP_SP2_EXPORT_SYMBOLS when your MR failed
  16. KERNEL32_XP_SP2_EXPORT_SYMBOLS = [
  17. "ActivateActCtx",
  18. "AddAtomA",
  19. "AddAtomW",
  20. "AddConsoleAliasA",
  21. "AddConsoleAliasW",
  22. "AddLocalAlternateComputerNameA",
  23. "AddLocalAlternateComputerNameW",
  24. "AddRefActCtx",
  25. "AddVectoredExceptionHandler",
  26. "AllocConsole",
  27. "AllocateUserPhysicalPages",
  28. "AreFileApisANSI",
  29. "AssignProcessToJobObject",
  30. "AttachConsole",
  31. "BackupRead",
  32. "BackupSeek",
  33. "BackupWrite",
  34. "BaseCheckAppcompatCache",
  35. "BaseCleanupAppcompatCache",
  36. "BaseCleanupAppcompatCacheSupport",
  37. "BaseDumpAppcompatCache",
  38. "BaseFlushAppcompatCache",
  39. "BaseInitAppcompatCache",
  40. "BaseInitAppcompatCacheSupport",
  41. "BaseProcessInitPostImport",
  42. "BaseQueryModuleData",
  43. "BaseUpdateAppcompatCache",
  44. "BasepCheckWinSaferRestrictions",
  45. "Beep",
  46. "BeginUpdateResourceA",
  47. "BeginUpdateResourceW",
  48. "BindIoCompletionCallback",
  49. "BuildCommDCBA",
  50. "BuildCommDCBAndTimeoutsA",
  51. "BuildCommDCBAndTimeoutsW",
  52. "BuildCommDCBW",
  53. "CallNamedPipeA",
  54. "CallNamedPipeW",
  55. "CancelDeviceWakeupRequest",
  56. "CancelIo",
  57. "CancelTimerQueueTimer",
  58. "CancelWaitableTimer",
  59. "ChangeTimerQueueTimer",
  60. "CheckNameLegalDOS8Dot3A",
  61. "CheckNameLegalDOS8Dot3W",
  62. "CheckRemoteDebuggerPresent",
  63. "ClearCommBreak",
  64. "ClearCommError",
  65. "CloseConsoleHandle",
  66. "CloseHandle",
  67. "CloseProfileUserMapping",
  68. "CmdBatNotification",
  69. "CommConfigDialogA",
  70. "CommConfigDialogW",
  71. "CompareFileTime",
  72. "CompareStringA",
  73. "CompareStringW",
  74. "ConnectNamedPipe",
  75. "ConsoleMenuControl",
  76. "ContinueDebugEvent",
  77. "ConvertDefaultLocale",
  78. "ConvertFiberToThread",
  79. "ConvertThreadToFiber",
  80. "CopyFileA",
  81. "CopyFileExA",
  82. "CopyFileExW",
  83. "CopyFileW",
  84. "CopyLZFile",
  85. "CreateActCtxA",
  86. "CreateActCtxW",
  87. "CreateConsoleScreenBuffer",
  88. "CreateDirectoryA",
  89. "CreateDirectoryExA",
  90. "CreateDirectoryExW",
  91. "CreateDirectoryW",
  92. "CreateEventA",
  93. "CreateEventW",
  94. "CreateFiber",
  95. "CreateFiberEx",
  96. "CreateFileA",
  97. "CreateFileMappingA",
  98. "CreateFileMappingW",
  99. "CreateFileW",
  100. "CreateHardLinkA",
  101. "CreateHardLinkW",
  102. "CreateIoCompletionPort",
  103. "CreateJobObjectA",
  104. "CreateJobObjectW",
  105. "CreateJobSet",
  106. "CreateMailslotA",
  107. "CreateMailslotW",
  108. "CreateMemoryResourceNotification",
  109. "CreateMutexA",
  110. "CreateMutexW",
  111. "CreateNamedPipeA",
  112. "CreateNamedPipeW",
  113. "CreateNlsSecurityDescriptor",
  114. "CreatePipe",
  115. "CreateProcessA",
  116. "CreateProcessInternalA",
  117. "CreateProcessInternalW",
  118. "CreateProcessInternalWSecure",
  119. "CreateProcessW",
  120. "CreateRemoteThread",
  121. "CreateSemaphoreA",
  122. "CreateSemaphoreW",
  123. "CreateSocketHandle",
  124. "CreateTapePartition",
  125. "CreateThread",
  126. "CreateTimerQueue",
  127. "CreateTimerQueueTimer",
  128. "CreateToolhelp32Snapshot",
  129. "CreateVirtualBuffer",
  130. "CreateWaitableTimerA",
  131. "CreateWaitableTimerW",
  132. "DeactivateActCtx",
  133. "DebugActiveProcess",
  134. "DebugActiveProcessStop",
  135. "DebugBreak",
  136. "DebugBreakProcess",
  137. "DebugSetProcessKillOnExit",
  138. "DecodePointer",
  139. "DecodeSystemPointer",
  140. "DefineDosDeviceA",
  141. "DefineDosDeviceW",
  142. "DelayLoadFailureHook",
  143. "DeleteAtom",
  144. "DeleteCriticalSection",
  145. "DeleteFiber",
  146. "DeleteFileA",
  147. "DeleteFileW",
  148. "DeleteTimerQueue",
  149. "DeleteTimerQueueEx",
  150. "DeleteTimerQueueTimer",
  151. "DeleteVolumeMountPointA",
  152. "DeleteVolumeMountPointW",
  153. "DeviceIoControl",
  154. "DisableThreadLibraryCalls",
  155. "DisconnectNamedPipe",
  156. "DnsHostnameToComputerNameA",
  157. "DnsHostnameToComputerNameW",
  158. "DosDateTimeToFileTime",
  159. "DosPathToSessionPathA",
  160. "DosPathToSessionPathW",
  161. "DuplicateConsoleHandle",
  162. "DuplicateHandle",
  163. "EncodePointer",
  164. "EncodeSystemPointer",
  165. "EndUpdateResourceA",
  166. "EndUpdateResourceW",
  167. "EnterCriticalSection",
  168. "EnumCalendarInfoA",
  169. "EnumCalendarInfoExA",
  170. "EnumCalendarInfoExW",
  171. "EnumCalendarInfoW",
  172. "EnumDateFormatsA",
  173. "EnumDateFormatsExA",
  174. "EnumDateFormatsExW",
  175. "EnumDateFormatsW",
  176. "EnumLanguageGroupLocalesA",
  177. "EnumLanguageGroupLocalesW",
  178. "EnumResourceLanguagesA",
  179. "EnumResourceLanguagesW",
  180. "EnumResourceNamesA",
  181. "EnumResourceNamesW",
  182. "EnumResourceTypesA",
  183. "EnumResourceTypesW",
  184. "EnumSystemCodePagesA",
  185. "EnumSystemCodePagesW",
  186. "EnumSystemGeoID",
  187. "EnumSystemLanguageGroupsA",
  188. "EnumSystemLanguageGroupsW",
  189. "EnumSystemLocalesA",
  190. "EnumSystemLocalesW",
  191. "EnumTimeFormatsA",
  192. "EnumTimeFormatsW",
  193. "EnumUILanguagesA",
  194. "EnumUILanguagesW",
  195. "EnumerateLocalComputerNamesA",
  196. "EnumerateLocalComputerNamesW",
  197. "EraseTape",
  198. "EscapeCommFunction",
  199. "ExitProcess",
  200. "ExitThread",
  201. "ExitVDM",
  202. "ExpandEnvironmentStringsA",
  203. "ExpandEnvironmentStringsW",
  204. "ExpungeConsoleCommandHistoryA",
  205. "ExpungeConsoleCommandHistoryW",
  206. "ExtendVirtualBuffer",
  207. "FatalAppExitA",
  208. "FatalAppExitW",
  209. "FatalExit",
  210. "FileTimeToDosDateTime",
  211. "FileTimeToLocalFileTime",
  212. "FileTimeToSystemTime",
  213. "FillConsoleOutputAttribute",
  214. "FillConsoleOutputCharacterA",
  215. "FillConsoleOutputCharacterW",
  216. "FindActCtxSectionGuid",
  217. "FindActCtxSectionStringA",
  218. "FindActCtxSectionStringW",
  219. "FindAtomA",
  220. "FindAtomW",
  221. "FindClose",
  222. "FindCloseChangeNotification",
  223. "FindFirstChangeNotificationA",
  224. "FindFirstChangeNotificationW",
  225. "FindFirstFileA",
  226. "FindFirstFileExA",
  227. "FindFirstFileExW",
  228. "FindFirstFileW",
  229. "FindFirstVolumeA",
  230. "FindFirstVolumeMountPointA",
  231. "FindFirstVolumeMountPointW",
  232. "FindFirstVolumeW",
  233. "FindNextChangeNotification",
  234. "FindNextFileA",
  235. "FindNextFileW",
  236. "FindNextVolumeA",
  237. "FindNextVolumeMountPointA",
  238. "FindNextVolumeMountPointW",
  239. "FindNextVolumeW",
  240. "FindResourceA",
  241. "FindResourceExA",
  242. "FindResourceExW",
  243. "FindResourceW",
  244. "FindVolumeClose",
  245. "FindVolumeMountPointClose",
  246. "FlushConsoleInputBuffer",
  247. "FlushFileBuffers",
  248. "FlushInstructionCache",
  249. "FlushViewOfFile",
  250. "FoldStringA",
  251. "FoldStringW",
  252. "FormatMessageA",
  253. "FormatMessageW",
  254. "FreeConsole",
  255. "FreeEnvironmentStringsA",
  256. "FreeEnvironmentStringsW",
  257. "FreeLibrary",
  258. "FreeLibraryAndExitThread",
  259. "FreeResource",
  260. "FreeUserPhysicalPages",
  261. "FreeVirtualBuffer",
  262. "GenerateConsoleCtrlEvent",
  263. "GetACP",
  264. "GetAtomNameA",
  265. "GetAtomNameW",
  266. "GetBinaryType",
  267. "GetBinaryTypeA",
  268. "GetBinaryTypeW",
  269. "GetCPFileNameFromRegistry",
  270. "GetCPInfo",
  271. "GetCPInfoExA",
  272. "GetCPInfoExW",
  273. "GetCalendarInfoA",
  274. "GetCalendarInfoW",
  275. "GetComPlusPackageInstallStatus",
  276. "GetCommConfig",
  277. "GetCommMask",
  278. "GetCommModemStatus",
  279. "GetCommProperties",
  280. "GetCommState",
  281. "GetCommTimeouts",
  282. "GetCommandLineA",
  283. "GetCommandLineW",
  284. "GetCompressedFileSizeA",
  285. "GetCompressedFileSizeW",
  286. "GetComputerNameA",
  287. "GetComputerNameExA",
  288. "GetComputerNameExW",
  289. "GetComputerNameW",
  290. "GetConsoleAliasA",
  291. "GetConsoleAliasExesA",
  292. "GetConsoleAliasExesLengthA",
  293. "GetConsoleAliasExesLengthW",
  294. "GetConsoleAliasExesW",
  295. "GetConsoleAliasW",
  296. "GetConsoleAliasesA",
  297. "GetConsoleAliasesLengthA",
  298. "GetConsoleAliasesLengthW",
  299. "GetConsoleAliasesW",
  300. "GetConsoleCP",
  301. "GetConsoleCharType",
  302. "GetConsoleCommandHistoryA",
  303. "GetConsoleCommandHistoryLengthA",
  304. "GetConsoleCommandHistoryLengthW",
  305. "GetConsoleCommandHistoryW",
  306. "GetConsoleCursorInfo",
  307. "GetConsoleCursorMode",
  308. "GetConsoleDisplayMode",
  309. "GetConsoleFontInfo",
  310. "GetConsoleFontSize",
  311. "GetConsoleHardwareState",
  312. "GetConsoleInputExeNameA",
  313. "GetConsoleInputExeNameW",
  314. "GetConsoleInputWaitHandle",
  315. "GetConsoleKeyboardLayoutNameA",
  316. "GetConsoleKeyboardLayoutNameW",
  317. "GetConsoleMode",
  318. "GetConsoleNlsMode",
  319. "GetConsoleOutputCP",
  320. "GetConsoleProcessList",
  321. "GetConsoleScreenBufferInfo",
  322. "GetConsoleSelectionInfo",
  323. "GetConsoleTitleA",
  324. "GetConsoleTitleW",
  325. "GetConsoleWindow",
  326. "GetCurrencyFormatA",
  327. "GetCurrencyFormatW",
  328. "GetCurrentActCtx",
  329. "GetCurrentConsoleFont",
  330. "GetCurrentDirectoryA",
  331. "GetCurrentDirectoryW",
  332. "GetCurrentProcess",
  333. "GetCurrentProcessId",
  334. "GetCurrentThread",
  335. "GetCurrentThreadId",
  336. "GetDateFormatA",
  337. "GetDateFormatW",
  338. "GetDefaultCommConfigA",
  339. "GetDefaultCommConfigW",
  340. "GetDefaultSortkeySize",
  341. "GetDevicePowerState",
  342. "GetDiskFreeSpaceA",
  343. "GetDiskFreeSpaceExA",
  344. "GetDiskFreeSpaceExW",
  345. "GetDiskFreeSpaceW",
  346. "GetDllDirectoryA",
  347. "GetDllDirectoryW",
  348. "GetDriveTypeA",
  349. "GetDriveTypeW",
  350. "GetEnvironmentStrings",
  351. "GetEnvironmentStringsA",
  352. "GetEnvironmentStringsW",
  353. "GetEnvironmentVariableA",
  354. "GetEnvironmentVariableW",
  355. "GetExitCodeProcess",
  356. "GetExitCodeThread",
  357. "GetExpandedNameA",
  358. "GetExpandedNameW",
  359. "GetFileAttributesA",
  360. "GetFileAttributesExA",
  361. "GetFileAttributesExW",
  362. "GetFileAttributesW",
  363. "GetFileInformationByHandle",
  364. "GetFileSize",
  365. "GetFileSizeEx",
  366. "GetFileTime",
  367. "GetFileType",
  368. "GetFirmwareEnvironmentVariableA",
  369. "GetFirmwareEnvironmentVariableW",
  370. "GetFullPathNameA",
  371. "GetFullPathNameW",
  372. "GetGeoInfoA",
  373. "GetGeoInfoW",
  374. "GetHandleContext",
  375. "GetHandleInformation",
  376. "GetLargestConsoleWindowSize",
  377. "GetLastError",
  378. "GetLinguistLangSize",
  379. "GetLocalTime",
  380. "GetLocaleInfoA",
  381. "GetLocaleInfoW",
  382. "GetLogicalDriveStringsA",
  383. "GetLogicalDriveStringsW",
  384. "GetLogicalDrives",
  385. "GetLongPathNameA",
  386. "GetLongPathNameW",
  387. "GetMailslotInfo",
  388. "GetModuleFileNameA",
  389. "GetModuleFileNameW",
  390. "GetModuleHandleA",
  391. "GetModuleHandleExA",
  392. "GetModuleHandleExW",
  393. "GetModuleHandleW",
  394. "GetNamedPipeHandleStateA",
  395. "GetNamedPipeHandleStateW",
  396. "GetNamedPipeInfo",
  397. "GetNativeSystemInfo",
  398. "GetNextVDMCommand",
  399. "GetNlsSectionName",
  400. "GetNumaAvailableMemory",
  401. "GetNumaAvailableMemoryNode",
  402. "GetNumaHighestNodeNumber",
  403. "GetNumaNodeProcessorMask",
  404. "GetNumaProcessorMap",
  405. "GetNumaProcessorNode",
  406. "GetNumberFormatA",
  407. "GetNumberFormatW",
  408. "GetNumberOfConsoleFonts",
  409. "GetNumberOfConsoleInputEvents",
  410. "GetNumberOfConsoleMouseButtons",
  411. "GetOEMCP",
  412. "GetOverlappedResult",
  413. "GetPriorityClass",
  414. "GetPrivateProfileIntA",
  415. "GetPrivateProfileIntW",
  416. "GetPrivateProfileSectionA",
  417. "GetPrivateProfileSectionNamesA",
  418. "GetPrivateProfileSectionNamesW",
  419. "GetPrivateProfileSectionW",
  420. "GetPrivateProfileStringA",
  421. "GetPrivateProfileStringW",
  422. "GetPrivateProfileStructA",
  423. "GetPrivateProfileStructW",
  424. "GetProcAddress",
  425. "GetProcessAffinityMask",
  426. "GetProcessHandleCount",
  427. "GetProcessHeap",
  428. "GetProcessHeaps",
  429. "GetProcessId",
  430. "GetProcessIoCounters",
  431. "GetProcessPriorityBoost",
  432. "GetProcessShutdownParameters",
  433. "GetProcessTimes",
  434. "GetProcessVersion",
  435. "GetProcessWorkingSetSize",
  436. "GetProfileIntA",
  437. "GetProfileIntW",
  438. "GetProfileSectionA",
  439. "GetProfileSectionW",
  440. "GetProfileStringA",
  441. "GetProfileStringW",
  442. "GetQueuedCompletionStatus",
  443. "GetShortPathNameA",
  444. "GetShortPathNameW",
  445. "GetStartupInfoA",
  446. "GetStartupInfoW",
  447. "GetStdHandle",
  448. "GetStringTypeA",
  449. "GetStringTypeExA",
  450. "GetStringTypeExW",
  451. "GetStringTypeW",
  452. "GetSystemDefaultLCID",
  453. "GetSystemDefaultLangID",
  454. "GetSystemDefaultUILanguage",
  455. "GetSystemDirectoryA",
  456. "GetSystemDirectoryW",
  457. "GetSystemInfo",
  458. "GetSystemPowerStatus",
  459. "GetSystemRegistryQuota",
  460. "GetSystemTime",
  461. "GetSystemTimeAdjustment",
  462. "GetSystemTimeAsFileTime",
  463. "GetSystemTimes",
  464. "GetSystemWindowsDirectoryA",
  465. "GetSystemWindowsDirectoryW",
  466. "GetSystemWow64DirectoryA",
  467. "GetSystemWow64DirectoryW",
  468. "GetTapeParameters",
  469. "GetTapePosition",
  470. "GetTapeStatus",
  471. "GetTempFileNameA",
  472. "GetTempFileNameW",
  473. "GetTempPathA",
  474. "GetTempPathW",
  475. "GetThreadContext",
  476. "GetThreadIOPendingFlag",
  477. "GetThreadLocale",
  478. "GetThreadPriority",
  479. "GetThreadPriorityBoost",
  480. "GetThreadSelectorEntry",
  481. "GetThreadTimes",
  482. "GetTickCount",
  483. "GetTimeFormatA",
  484. "GetTimeFormatW",
  485. "GetTimeZoneInformation",
  486. "GetUserDefaultLCID",
  487. "GetUserDefaultLangID",
  488. "GetUserDefaultUILanguage",
  489. "GetUserGeoID",
  490. "GetVDMCurrentDirectories",
  491. "GetVersion",
  492. "GetVersionExA",
  493. "GetVersionExW",
  494. "GetVolumeInformationA",
  495. "GetVolumeInformationW",
  496. "GetVolumeNameForVolumeMountPointA",
  497. "GetVolumeNameForVolumeMountPointW",
  498. "GetVolumePathNameA",
  499. "GetVolumePathNameW",
  500. "GetVolumePathNamesForVolumeNameA",
  501. "GetVolumePathNamesForVolumeNameW",
  502. "GetWindowsDirectoryA",
  503. "GetWindowsDirectoryW",
  504. "GetWriteWatch",
  505. "GlobalAddAtomA",
  506. "GlobalAddAtomW",
  507. "GlobalAlloc",
  508. "GlobalCompact",
  509. "GlobalDeleteAtom",
  510. "GlobalFindAtomA",
  511. "GlobalFindAtomW",
  512. "GlobalFix",
  513. "GlobalFlags",
  514. "GlobalFree",
  515. "GlobalGetAtomNameA",
  516. "GlobalGetAtomNameW",
  517. "GlobalHandle",
  518. "GlobalLock",
  519. "GlobalMemoryStatus",
  520. "GlobalMemoryStatusEx",
  521. "GlobalReAlloc",
  522. "GlobalSize",
  523. "GlobalUnWire",
  524. "GlobalUnfix",
  525. "GlobalUnlock",
  526. "GlobalWire",
  527. "Heap32First",
  528. "Heap32ListFirst",
  529. "Heap32ListNext",
  530. "Heap32Next",
  531. "HeapAlloc",
  532. "HeapCompact",
  533. "HeapCreate",
  534. "HeapCreateTagsW",
  535. "HeapDestroy",
  536. "HeapExtend",
  537. "HeapFree",
  538. "HeapLock",
  539. "HeapQueryInformation",
  540. "HeapQueryTagW",
  541. "HeapReAlloc",
  542. "HeapSetInformation",
  543. "HeapSize",
  544. "HeapSummary",
  545. "HeapUnlock",
  546. "HeapUsage",
  547. "HeapValidate",
  548. "HeapWalk",
  549. "InitAtomTable",
  550. "InitializeCriticalSection",
  551. "InitializeCriticalSectionAndSpinCount",
  552. "InitializeSListHead",
  553. "InterlockedCompareExchange",
  554. "InterlockedDecrement",
  555. "InterlockedExchange",
  556. "InterlockedExchangeAdd",
  557. "InterlockedFlushSList",
  558. "InterlockedIncrement",
  559. "InterlockedPopEntrySList",
  560. "InterlockedPushEntrySList",
  561. "InvalidateConsoleDIBits",
  562. "IsBadCodePtr",
  563. "IsBadHugeReadPtr",
  564. "IsBadHugeWritePtr",
  565. "IsBadReadPtr",
  566. "IsBadStringPtrA",
  567. "IsBadStringPtrW",
  568. "IsBadWritePtr",
  569. "IsDBCSLeadByte",
  570. "IsDBCSLeadByteEx",
  571. "IsDebuggerPresent",
  572. "IsProcessInJob",
  573. "IsProcessorFeaturePresent",
  574. "IsSystemResumeAutomatic",
  575. "IsValidCodePage",
  576. "IsValidLanguageGroup",
  577. "IsValidLocale",
  578. "IsValidUILanguage",
  579. "IsWow64Process",
  580. "LCMapStringA",
  581. "LCMapStringW",
  582. "LZClose",
  583. "LZCloseFile",
  584. "LZCopy",
  585. "LZCreateFileW",
  586. "LZDone",
  587. "LZInit",
  588. "LZOpenFileA",
  589. "LZOpenFileW",
  590. "LZRead",
  591. "LZSeek",
  592. "LZStart",
  593. "LeaveCriticalSection",
  594. "LoadLibraryA",
  595. "LoadLibraryExA",
  596. "LoadLibraryExW",
  597. "LoadLibraryW",
  598. "LoadModule",
  599. "LoadResource",
  600. "LocalAlloc",
  601. "LocalCompact",
  602. "LocalFileTimeToFileTime",
  603. "LocalFlags",
  604. "LocalFree",
  605. "LocalHandle",
  606. "LocalLock",
  607. "LocalReAlloc",
  608. "LocalShrink",
  609. "LocalSize",
  610. "LocalUnlock",
  611. "LockFile",
  612. "LockFileEx",
  613. "LockResource",
  614. "MapUserPhysicalPages",
  615. "MapUserPhysicalPagesScatter",
  616. "MapViewOfFile",
  617. "MapViewOfFileEx",
  618. "Module32First",
  619. "Module32FirstW",
  620. "Module32Next",
  621. "Module32NextW",
  622. "MoveFileA",
  623. "MoveFileExA",
  624. "MoveFileExW",
  625. "MoveFileW",
  626. "MoveFileWithProgressA",
  627. "MoveFileWithProgressW",
  628. "MulDiv",
  629. "MultiByteToWideChar",
  630. "NlsConvertIntegerToString",
  631. "NlsGetCacheUpdateCount",
  632. "NlsResetProcessLocale",
  633. "NumaVirtualQueryNode",
  634. "OpenConsoleW",
  635. "OpenDataFile",
  636. "OpenEventA",
  637. "OpenEventW",
  638. "OpenFile",
  639. "OpenFileMappingA",
  640. "OpenFileMappingW",
  641. "OpenJobObjectA",
  642. "OpenJobObjectW",
  643. "OpenMutexA",
  644. "OpenMutexW",
  645. "OpenProcess",
  646. "OpenProfileUserMapping",
  647. "OpenSemaphoreA",
  648. "OpenSemaphoreW",
  649. "OpenThread",
  650. "OpenWaitableTimerA",
  651. "OpenWaitableTimerW",
  652. "OutputDebugStringA",
  653. "OutputDebugStringW",
  654. "PeekConsoleInputA",
  655. "PeekConsoleInputW",
  656. "PeekNamedPipe",
  657. "PostQueuedCompletionStatus",
  658. "PrepareTape",
  659. "PrivCopyFileExW",
  660. "PrivMoveFileIdentityW",
  661. "Process32First",
  662. "Process32FirstW",
  663. "Process32Next",
  664. "Process32NextW",
  665. "ProcessIdToSessionId",
  666. "PulseEvent",
  667. "PurgeComm",
  668. "QueryActCtxW",
  669. "QueryDepthSList",
  670. "QueryDosDeviceA",
  671. "QueryDosDeviceW",
  672. "QueryInformationJobObject",
  673. "QueryMemoryResourceNotification",
  674. "QueryPerformanceCounter",
  675. "QueryPerformanceFrequency",
  676. "QueryWin31IniFilesMappedToRegistry",
  677. "QueueUserAPC",
  678. "QueueUserWorkItem",
  679. "RaiseException",
  680. "ReadConsoleA",
  681. "ReadConsoleInputA",
  682. "ReadConsoleInputExA",
  683. "ReadConsoleInputExW",
  684. "ReadConsoleInputW",
  685. "ReadConsoleOutputA",
  686. "ReadConsoleOutputAttribute",
  687. "ReadConsoleOutputCharacterA",
  688. "ReadConsoleOutputCharacterW",
  689. "ReadConsoleOutputW",
  690. "ReadConsoleW",
  691. "ReadDirectoryChangesW",
  692. "ReadFile",
  693. "ReadFileEx",
  694. "ReadFileScatter",
  695. "ReadProcessMemory",
  696. "RegisterConsoleIME",
  697. "RegisterConsoleOS2",
  698. "RegisterConsoleVDM",
  699. "RegisterWaitForInputIdle",
  700. "RegisterWaitForSingleObject",
  701. "RegisterWaitForSingleObjectEx",
  702. "RegisterWowBaseHandlers",
  703. "RegisterWowExec",
  704. "ReleaseActCtx",
  705. "ReleaseMutex",
  706. "ReleaseSemaphore",
  707. "RemoveDirectoryA",
  708. "RemoveDirectoryW",
  709. "RemoveLocalAlternateComputerNameA",
  710. "RemoveLocalAlternateComputerNameW",
  711. "RemoveVectoredExceptionHandler",
  712. "ReplaceFile",
  713. "ReplaceFileA",
  714. "ReplaceFileW",
  715. "RequestDeviceWakeup",
  716. "RequestWakeupLatency",
  717. "ResetEvent",
  718. "ResetWriteWatch",
  719. "RestoreLastError",
  720. "ResumeThread",
  721. "RtlCaptureContext",
  722. "RtlCaptureStackBackTrace",
  723. "RtlFillMemory",
  724. "RtlMoveMemory",
  725. "RtlUnwind",
  726. "RtlZeroMemory",
  727. "ScrollConsoleScreenBufferA",
  728. "ScrollConsoleScreenBufferW",
  729. "SearchPathA",
  730. "SearchPathW",
  731. "SetCPGlobal",
  732. "SetCalendarInfoA",
  733. "SetCalendarInfoW",
  734. "SetClientTimeZoneInformation",
  735. "SetComPlusPackageInstallStatus",
  736. "SetCommBreak",
  737. "SetCommConfig",
  738. "SetCommMask",
  739. "SetCommState",
  740. "SetCommTimeouts",
  741. "SetComputerNameA",
  742. "SetComputerNameExA",
  743. "SetComputerNameExW",
  744. "SetComputerNameW",
  745. "SetConsoleActiveScreenBuffer",
  746. "SetConsoleCP",
  747. "SetConsoleCommandHistoryMode",
  748. "SetConsoleCtrlHandler",
  749. "SetConsoleCursor",
  750. "SetConsoleCursorInfo",
  751. "SetConsoleCursorMode",
  752. "SetConsoleCursorPosition",
  753. "SetConsoleDisplayMode",
  754. "SetConsoleFont",
  755. "SetConsoleHardwareState",
  756. "SetConsoleIcon",
  757. "SetConsoleInputExeNameA",
  758. "SetConsoleInputExeNameW",
  759. "SetConsoleKeyShortcuts",
  760. "SetConsoleLocalEUDC",
  761. "SetConsoleMaximumWindowSize",
  762. "SetConsoleMenuClose",
  763. "SetConsoleMode",
  764. "SetConsoleNlsMode",
  765. "SetConsoleNumberOfCommandsA",
  766. "SetConsoleNumberOfCommandsW",
  767. "SetConsoleOS2OemFormat",
  768. "SetConsoleOutputCP",
  769. "SetConsolePalette",
  770. "SetConsoleScreenBufferSize",
  771. "SetConsoleTextAttribute",
  772. "SetConsoleTitleA",
  773. "SetConsoleTitleW",
  774. "SetConsoleWindowInfo",
  775. "SetCriticalSectionSpinCount",
  776. "SetCurrentDirectoryA",
  777. "SetCurrentDirectoryW",
  778. "SetDefaultCommConfigA",
  779. "SetDefaultCommConfigW",
  780. "SetDllDirectoryA",
  781. "SetDllDirectoryW",
  782. "SetEndOfFile",
  783. "SetEnvironmentVariableA",
  784. "SetEnvironmentVariableW",
  785. "SetErrorMode",
  786. "SetEvent",
  787. "SetFileApisToANSI",
  788. "SetFileApisToOEM",
  789. "SetFileAttributesA",
  790. "SetFileAttributesW",
  791. "SetFilePointer",
  792. "SetFilePointerEx",
  793. "SetFileShortNameA",
  794. "SetFileShortNameW",
  795. "SetFileTime",
  796. "SetFileValidData",
  797. "SetFirmwareEnvironmentVariableA",
  798. "SetFirmwareEnvironmentVariableW",
  799. "SetHandleContext",
  800. "SetHandleCount",
  801. "SetHandleInformation",
  802. "SetInformationJobObject",
  803. "SetLastConsoleEventActive",
  804. "SetLastError",
  805. "SetLocalPrimaryComputerNameA",
  806. "SetLocalPrimaryComputerNameW",
  807. "SetLocalTime",
  808. "SetLocaleInfoA",
  809. "SetLocaleInfoW",
  810. "SetMailslotInfo",
  811. "SetMessageWaitingIndicator",
  812. "SetNamedPipeHandleState",
  813. "SetPriorityClass",
  814. "SetProcessAffinityMask",
  815. "SetProcessPriorityBoost",
  816. "SetProcessShutdownParameters",
  817. "SetProcessWorkingSetSize",
  818. "SetStdHandle",
  819. "SetSystemPowerState",
  820. "SetSystemTime",
  821. "SetSystemTimeAdjustment",
  822. "SetTapeParameters",
  823. "SetTapePosition",
  824. "SetTermsrvAppInstallMode",
  825. "SetThreadAffinityMask",
  826. "SetThreadContext",
  827. "SetThreadExecutionState",
  828. "SetThreadIdealProcessor",
  829. "SetThreadLocale",
  830. "SetThreadPriority",
  831. "SetThreadPriorityBoost",
  832. "SetThreadUILanguage",
  833. "SetTimeZoneInformation",
  834. "SetTimerQueueTimer",
  835. "SetUnhandledExceptionFilter",
  836. "SetUserGeoID",
  837. "SetVDMCurrentDirectories",
  838. "SetVolumeLabelA",
  839. "SetVolumeLabelW",
  840. "SetVolumeMountPointA",
  841. "SetVolumeMountPointW",
  842. "SetWaitableTimer",
  843. "SetupComm",
  844. "ShowConsoleCursor",
  845. "SignalObjectAndWait",
  846. "SizeofResource",
  847. "Sleep",
  848. "SleepEx",
  849. "SuspendThread",
  850. "SwitchToFiber",
  851. "SwitchToThread",
  852. "SystemTimeToFileTime",
  853. "SystemTimeToTzSpecificLocalTime",
  854. "TerminateJobObject",
  855. "TerminateProcess",
  856. "TerminateThread",
  857. "TermsrvAppInstallMode",
  858. "Thread32First",
  859. "Thread32Next",
  860. "TlsAlloc",
  861. "TlsFree",
  862. "TlsGetValue",
  863. "TlsSetValue",
  864. "Toolhelp32ReadProcessMemory",
  865. "TransactNamedPipe",
  866. "TransmitCommChar",
  867. "TrimVirtualBuffer",
  868. "TryEnterCriticalSection",
  869. "TzSpecificLocalTimeToSystemTime",
  870. "UTRegister",
  871. "UTUnRegister",
  872. "UnhandledExceptionFilter",
  873. "UnlockFile",
  874. "UnlockFileEx",
  875. "UnmapViewOfFile",
  876. "UnregisterConsoleIME",
  877. "UnregisterWait",
  878. "UnregisterWaitEx",
  879. "UpdateResourceA",
  880. "UpdateResourceW",
  881. "VDMConsoleOperation",
  882. "VDMOperationStarted",
  883. "ValidateLCType",
  884. "ValidateLocale",
  885. "VerLanguageNameA",
  886. "VerLanguageNameW",
  887. "VerSetConditionMask",
  888. "VerifyConsoleIoHandle",
  889. "VerifyVersionInfoA",
  890. "VerifyVersionInfoW",
  891. "VirtualAlloc",
  892. "VirtualAllocEx",
  893. "VirtualBufferExceptionHandler",
  894. "VirtualFree",
  895. "VirtualFreeEx",
  896. "VirtualLock",
  897. "VirtualProtect",
  898. "VirtualProtectEx",
  899. "VirtualQuery",
  900. "VirtualQueryEx",
  901. "VirtualUnlock",
  902. "WTSGetActiveConsoleSessionId",
  903. "WaitCommEvent",
  904. "WaitForDebugEvent",
  905. "WaitForMultipleObjects",
  906. "WaitForMultipleObjectsEx",
  907. "WaitForSingleObject",
  908. "WaitForSingleObjectEx",
  909. "WaitNamedPipeA",
  910. "WaitNamedPipeW",
  911. "WideCharToMultiByte",
  912. "WinExec",
  913. "WriteConsoleA",
  914. "WriteConsoleInputA",
  915. "WriteConsoleInputVDMA",
  916. "WriteConsoleInputVDMW",
  917. "WriteConsoleInputW",
  918. "WriteConsoleOutputA",
  919. "WriteConsoleOutputAttribute",
  920. "WriteConsoleOutputCharacterA",
  921. "WriteConsoleOutputCharacterW",
  922. "WriteConsoleOutputW",
  923. "WriteConsoleW",
  924. "WriteFile",
  925. "WriteFileEx",
  926. "WriteFileGather",
  927. "WritePrivateProfileSectionA",
  928. "WritePrivateProfileSectionW",
  929. "WritePrivateProfileStringA",
  930. "WritePrivateProfileStringW",
  931. "WritePrivateProfileStructA",
  932. "WritePrivateProfileStructW",
  933. "WriteProcessMemory",
  934. "WriteProfileSectionA",
  935. "WriteProfileSectionW",
  936. "WriteProfileStringA",
  937. "WriteProfileStringW",
  938. "WriteTapemark",
  939. "ZombifyActCtx",
  940. "_hread",
  941. "_hwrite",
  942. "_lclose",
  943. "_lcreat",
  944. "_llseek",
  945. "_lopen",
  946. "_lread",
  947. "_lwrite",
  948. "lstrcat",
  949. "lstrcatA",
  950. "lstrcatW",
  951. "lstrcmp",
  952. "lstrcmpA",
  953. "lstrcmpW",
  954. "lstrcmpi",
  955. "lstrcmpiA",
  956. "lstrcmpiW",
  957. "lstrcpy",
  958. "lstrcpyA",
  959. "lstrcpyW",
  960. "lstrcpyn",
  961. "lstrcpynA",
  962. "lstrcpynW",
  963. "lstrlen",
  964. "lstrlenA",
  965. "lstrlenW",
  966. ]
  967. # please do not modify KERNEL32_XP_SP2_EXPORT_SYMBOLS when your MR failed
  968. # please do not add function in STRIP_LINES when your MR failed
  969. STRIP_LINES = [
  970. "Dumper Version",
  971. "Microsoft Corporation",
  972. "Dump of file",
  973. "File Type",
  974. "Section contains the",
  975. "Import Address Table",
  976. "Import Name Table",
  977. "time date stamp",
  978. "Index of first forwarder reference",
  979. "Summary",
  980. ".data",
  981. ".gfids",
  982. ".rdata",
  983. ".reloc",
  984. ".text",
  985. ".tls",
  986. ".rsrc",
  987. ".00cfg",
  988. ".idata",
  989. "KERNEL32.dll",
  990. "dbghelp.dll",
  991. ]
  992. # please do not add function in STRIP_LINES when your MR failed
  993. # please do not modify CONSOLE_LINES and CONSOLE_VERSION when your MR failed
  994. CONSOLE_LINES = [
  995. "operating system version",
  996. "subsystem version",
  997. ]
  998. CONSOLE_VERSION = [
  999. "5.01",
  1000. ]
  1001. # please do not modify CONSOLE_LINES and CONSOLE_VERSION when your MR failed
  1002. def main():
  1003. parser = argparse.ArgumentParser()
  1004. parser.add_argument(
  1005. "-p",
  1006. "--windows_pe_file",
  1007. help="pe file check runnable on Windows xp sp2",
  1008. dest="pe_file",
  1009. type=str,
  1010. required=True,
  1011. )
  1012. args = parser.parse_args()
  1013. if not os.path.isfile(args.pe_file):
  1014. print("ERROR: can not find file:{}".format(args.pe_file))
  1015. exit(-1)
  1016. cmd = 'cmd.exe /c "dumpbin /imports {}"'.format(args.pe_file)
  1017. raw_log = subprocess.check_output(cmd)
  1018. raw_log = raw_log.decode("utf-8").split("\r\n")
  1019. import_function = []
  1020. for log in raw_log:
  1021. is_in_strip = False
  1022. if log != "":
  1023. for strip_line in STRIP_LINES:
  1024. if log.find(strip_line) >= 0:
  1025. is_in_strip = True
  1026. break
  1027. if not is_in_strip:
  1028. import_function.append(log.split()[1])
  1029. assert len(import_function) > 0, "import function should not be zero"
  1030. # now check import_function is in KERNEL32_XP_SP2_EXPORT_SYMBOLS
  1031. # if you MR failed!, please ref 65ac48b95e99f2c510fe5db449cc8182d682e113
  1032. # to refine your MR
  1033. for i in import_function:
  1034. msg = (
  1035. "target import function: '{}' can not find in KERNEL32_XP_SP2_EXPORT_SYMBOLS\n"
  1036. "please check your MR modify, possible reasons:\n"
  1037. "1: use std::thread/std::this_thread in inference code, put this code under #if !__DEPLOY_ON_XP_SP2__\n"
  1038. "2: use std::mutex in inference code, replace it to DNN_MUTEX/MGB_MUTEX/LITE_MUTEX\n"
  1039. "3: more detail please do git show 65ac48b95e99f2c510fe5db449cc8182d682e113 to refine your MR".format(
  1040. i
  1041. )
  1042. )
  1043. assert i in KERNEL32_XP_SP2_EXPORT_SYMBOLS, "{}".format(msg)
  1044. print("check import fuction: '{}' success".format(i))
  1045. print("check pe file: {} import function success!!!".format(args.pe_file))
  1046. cmd = 'cmd.exe /c "dumpbin /HEADERS {}"'.format(args.pe_file)
  1047. raw_log = subprocess.check_output(cmd)
  1048. raw_log = raw_log.decode("utf-8").split("\r\n")
  1049. console_version = []
  1050. for log in raw_log:
  1051. for console_line in CONSOLE_LINES:
  1052. if log.find(console_line) >= 0:
  1053. console_version.append(log.split()[0])
  1054. assert len(console_version) > 0, "console version should not be zero"
  1055. # now check console version
  1056. for i in console_version:
  1057. msg = (
  1058. "check console version: '{}' failed\n"
  1059. "please check your MR modify, possible reasons:\n"
  1060. "1: need add /SUBSYSTEM:CONSOLE,5.01 for linker when (cmake)define MGE_DEPLOY_INFERENCE_ON_WINDOWS_XP_SP2\n"
  1061. ' bazel --copt "-D__DEPLOY_ON_XP_SP2__=1"'.format(i)
  1062. )
  1063. assert i in CONSOLE_VERSION, "{}".format(msg)
  1064. print("check console version: '{}' success".format(i))
  1065. print("check pe file: {} console version success!!!".format(args.pe_file))
  1066. if __name__ == "__main__":
  1067. assert platform.system() == "Windows", "can only run at windows env!!!"
  1068. main()