 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 |
- #!/usr/bin/env python3
-
- import argparse
- import os
- import platform
- import subprocess
-
- """
- 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, we do not want create a real xp sp2 env or
- create a wine xp sp2 env to test load_and_run, as a workround, we test target pe file import functions
- are in KERNEL32.dll export function lists or not!
- """
-
- # cmd.exe /c "dumpbin /exports KERNEL32.dll"
- # KERNEL32.dll from Windows xp sp2 2002 C:\WINDOWS\system32
- # please do not modify KERNEL32_XP_SP2_EXPORT_SYMBOLS when your MR failed
- KERNEL32_XP_SP2_EXPORT_SYMBOLS = [
- "ActivateActCtx",
- "AddAtomA",
- "AddAtomW",
- "AddConsoleAliasA",
- "AddConsoleAliasW",
- "AddLocalAlternateComputerNameA",
- "AddLocalAlternateComputerNameW",
- "AddRefActCtx",
- "AddVectoredExceptionHandler",
- "AllocConsole",
- "AllocateUserPhysicalPages",
- "AreFileApisANSI",
- "AssignProcessToJobObject",
- "AttachConsole",
- "BackupRead",
- "BackupSeek",
- "BackupWrite",
- "BaseCheckAppcompatCache",
- "BaseCleanupAppcompatCache",
- "BaseCleanupAppcompatCacheSupport",
- "BaseDumpAppcompatCache",
- "BaseFlushAppcompatCache",
- "BaseInitAppcompatCache",
- "BaseInitAppcompatCacheSupport",
- "BaseProcessInitPostImport",
- "BaseQueryModuleData",
- "BaseUpdateAppcompatCache",
- "BasepCheckWinSaferRestrictions",
- "Beep",
- "BeginUpdateResourceA",
- "BeginUpdateResourceW",
- "BindIoCompletionCallback",
- "BuildCommDCBA",
- "BuildCommDCBAndTimeoutsA",
- "BuildCommDCBAndTimeoutsW",
- "BuildCommDCBW",
- "CallNamedPipeA",
- "CallNamedPipeW",
- "CancelDeviceWakeupRequest",
- "CancelIo",
- "CancelTimerQueueTimer",
- "CancelWaitableTimer",
- "ChangeTimerQueueTimer",
- "CheckNameLegalDOS8Dot3A",
- "CheckNameLegalDOS8Dot3W",
- "CheckRemoteDebuggerPresent",
- "ClearCommBreak",
- "ClearCommError",
- "CloseConsoleHandle",
- "CloseHandle",
- "CloseProfileUserMapping",
- "CmdBatNotification",
- "CommConfigDialogA",
- "CommConfigDialogW",
- "CompareFileTime",
- "CompareStringA",
- "CompareStringW",
- "ConnectNamedPipe",
- "ConsoleMenuControl",
- "ContinueDebugEvent",
- "ConvertDefaultLocale",
- "ConvertFiberToThread",
- "ConvertThreadToFiber",
- "CopyFileA",
- "CopyFileExA",
- "CopyFileExW",
- "CopyFileW",
- "CopyLZFile",
- "CreateActCtxA",
- "CreateActCtxW",
- "CreateConsoleScreenBuffer",
- "CreateDirectoryA",
- "CreateDirectoryExA",
- "CreateDirectoryExW",
- "CreateDirectoryW",
- "CreateEventA",
- "CreateEventW",
- "CreateFiber",
- "CreateFiberEx",
- "CreateFileA",
- "CreateFileMappingA",
- "CreateFileMappingW",
- "CreateFileW",
- "CreateHardLinkA",
- "CreateHardLinkW",
- "CreateIoCompletionPort",
- "CreateJobObjectA",
- "CreateJobObjectW",
- "CreateJobSet",
- "CreateMailslotA",
- "CreateMailslotW",
- "CreateMemoryResourceNotification",
- "CreateMutexA",
- "CreateMutexW",
- "CreateNamedPipeA",
- "CreateNamedPipeW",
- "CreateNlsSecurityDescriptor",
- "CreatePipe",
- "CreateProcessA",
- "CreateProcessInternalA",
- "CreateProcessInternalW",
- "CreateProcessInternalWSecure",
- "CreateProcessW",
- "CreateRemoteThread",
- "CreateSemaphoreA",
- "CreateSemaphoreW",
- "CreateSocketHandle",
- "CreateTapePartition",
- "CreateThread",
- "CreateTimerQueue",
- "CreateTimerQueueTimer",
- "CreateToolhelp32Snapshot",
- "CreateVirtualBuffer",
- "CreateWaitableTimerA",
- "CreateWaitableTimerW",
- "DeactivateActCtx",
- "DebugActiveProcess",
- "DebugActiveProcessStop",
- "DebugBreak",
- "DebugBreakProcess",
- "DebugSetProcessKillOnExit",
- "DecodePointer",
- "DecodeSystemPointer",
- "DefineDosDeviceA",
- "DefineDosDeviceW",
- "DelayLoadFailureHook",
- "DeleteAtom",
- "DeleteCriticalSection",
- "DeleteFiber",
- "DeleteFileA",
- "DeleteFileW",
- "DeleteTimerQueue",
- "DeleteTimerQueueEx",
- "DeleteTimerQueueTimer",
- "DeleteVolumeMountPointA",
- "DeleteVolumeMountPointW",
- "DeviceIoControl",
- "DisableThreadLibraryCalls",
- "DisconnectNamedPipe",
- "DnsHostnameToComputerNameA",
- "DnsHostnameToComputerNameW",
- "DosDateTimeToFileTime",
- "DosPathToSessionPathA",
- "DosPathToSessionPathW",
- "DuplicateConsoleHandle",
- "DuplicateHandle",
- "EncodePointer",
- "EncodeSystemPointer",
- "EndUpdateResourceA",
- "EndUpdateResourceW",
- "EnterCriticalSection",
- "EnumCalendarInfoA",
- "EnumCalendarInfoExA",
- "EnumCalendarInfoExW",
- "EnumCalendarInfoW",
- "EnumDateFormatsA",
- "EnumDateFormatsExA",
- "EnumDateFormatsExW",
- "EnumDateFormatsW",
- "EnumLanguageGroupLocalesA",
- "EnumLanguageGroupLocalesW",
- "EnumResourceLanguagesA",
- "EnumResourceLanguagesW",
- "EnumResourceNamesA",
- "EnumResourceNamesW",
- "EnumResourceTypesA",
- "EnumResourceTypesW",
- "EnumSystemCodePagesA",
- "EnumSystemCodePagesW",
- "EnumSystemGeoID",
- "EnumSystemLanguageGroupsA",
- "EnumSystemLanguageGroupsW",
- "EnumSystemLocalesA",
- "EnumSystemLocalesW",
- "EnumTimeFormatsA",
- "EnumTimeFormatsW",
- "EnumUILanguagesA",
- "EnumUILanguagesW",
- "EnumerateLocalComputerNamesA",
- "EnumerateLocalComputerNamesW",
- "EraseTape",
- "EscapeCommFunction",
- "ExitProcess",
- "ExitThread",
- "ExitVDM",
- "ExpandEnvironmentStringsA",
- "ExpandEnvironmentStringsW",
- "ExpungeConsoleCommandHistoryA",
- "ExpungeConsoleCommandHistoryW",
- "ExtendVirtualBuffer",
- "FatalAppExitA",
- "FatalAppExitW",
- "FatalExit",
- "FileTimeToDosDateTime",
- "FileTimeToLocalFileTime",
- "FileTimeToSystemTime",
- "FillConsoleOutputAttribute",
- "FillConsoleOutputCharacterA",
- "FillConsoleOutputCharacterW",
- "FindActCtxSectionGuid",
- "FindActCtxSectionStringA",
- "FindActCtxSectionStringW",
- "FindAtomA",
- "FindAtomW",
- "FindClose",
- "FindCloseChangeNotification",
- "FindFirstChangeNotificationA",
- "FindFirstChangeNotificationW",
- "FindFirstFileA",
- "FindFirstFileExA",
- "FindFirstFileExW",
- "FindFirstFileW",
- "FindFirstVolumeA",
- "FindFirstVolumeMountPointA",
- "FindFirstVolumeMountPointW",
- "FindFirstVolumeW",
- "FindNextChangeNotification",
- "FindNextFileA",
- "FindNextFileW",
- "FindNextVolumeA",
- "FindNextVolumeMountPointA",
- "FindNextVolumeMountPointW",
- "FindNextVolumeW",
- "FindResourceA",
- "FindResourceExA",
- "FindResourceExW",
- "FindResourceW",
- "FindVolumeClose",
- "FindVolumeMountPointClose",
- "FlushConsoleInputBuffer",
- "FlushFileBuffers",
- "FlushInstructionCache",
- "FlushViewOfFile",
- "FoldStringA",
- "FoldStringW",
- "FormatMessageA",
- "FormatMessageW",
- "FreeConsole",
- "FreeEnvironmentStringsA",
- "FreeEnvironmentStringsW",
- "FreeLibrary",
- "FreeLibraryAndExitThread",
- "FreeResource",
- "FreeUserPhysicalPages",
- "FreeVirtualBuffer",
- "GenerateConsoleCtrlEvent",
- "GetACP",
- "GetAtomNameA",
- "GetAtomNameW",
- "GetBinaryType",
- "GetBinaryTypeA",
- "GetBinaryTypeW",
- "GetCPFileNameFromRegistry",
- "GetCPInfo",
- "GetCPInfoExA",
- "GetCPInfoExW",
- "GetCalendarInfoA",
- "GetCalendarInfoW",
- "GetComPlusPackageInstallStatus",
- "GetCommConfig",
- "GetCommMask",
- "GetCommModemStatus",
- "GetCommProperties",
- "GetCommState",
- "GetCommTimeouts",
- "GetCommandLineA",
- "GetCommandLineW",
- "GetCompressedFileSizeA",
- "GetCompressedFileSizeW",
- "GetComputerNameA",
- "GetComputerNameExA",
- "GetComputerNameExW",
- "GetComputerNameW",
- "GetConsoleAliasA",
- "GetConsoleAliasExesA",
- "GetConsoleAliasExesLengthA",
- "GetConsoleAliasExesLengthW",
- "GetConsoleAliasExesW",
- "GetConsoleAliasW",
- "GetConsoleAliasesA",
- "GetConsoleAliasesLengthA",
- "GetConsoleAliasesLengthW",
- "GetConsoleAliasesW",
- "GetConsoleCP",
- "GetConsoleCharType",
- "GetConsoleCommandHistoryA",
- "GetConsoleCommandHistoryLengthA",
- "GetConsoleCommandHistoryLengthW",
- "GetConsoleCommandHistoryW",
- "GetConsoleCursorInfo",
- "GetConsoleCursorMode",
- "GetConsoleDisplayMode",
- "GetConsoleFontInfo",
- "GetConsoleFontSize",
- "GetConsoleHardwareState",
- "GetConsoleInputExeNameA",
- "GetConsoleInputExeNameW",
- "GetConsoleInputWaitHandle",
- "GetConsoleKeyboardLayoutNameA",
- "GetConsoleKeyboardLayoutNameW",
- "GetConsoleMode",
- "GetConsoleNlsMode",
- "GetConsoleOutputCP",
- "GetConsoleProcessList",
- "GetConsoleScreenBufferInfo",
- "GetConsoleSelectionInfo",
- "GetConsoleTitleA",
- "GetConsoleTitleW",
- "GetConsoleWindow",
- "GetCurrencyFormatA",
- "GetCurrencyFormatW",
- "GetCurrentActCtx",
- "GetCurrentConsoleFont",
- "GetCurrentDirectoryA",
- "GetCurrentDirectoryW",
- "GetCurrentProcess",
- "GetCurrentProcessId",
- "GetCurrentThread",
- "GetCurrentThreadId",
- "GetDateFormatA",
- "GetDateFormatW",
- "GetDefaultCommConfigA",
- "GetDefaultCommConfigW",
- "GetDefaultSortkeySize",
- "GetDevicePowerState",
- "GetDiskFreeSpaceA",
- "GetDiskFreeSpaceExA",
- "GetDiskFreeSpaceExW",
- "GetDiskFreeSpaceW",
- "GetDllDirectoryA",
- "GetDllDirectoryW",
- "GetDriveTypeA",
- "GetDriveTypeW",
- "GetEnvironmentStrings",
- "GetEnvironmentStringsA",
- "GetEnvironmentStringsW",
- "GetEnvironmentVariableA",
- "GetEnvironmentVariableW",
- "GetExitCodeProcess",
- "GetExitCodeThread",
- "GetExpandedNameA",
- "GetExpandedNameW",
- "GetFileAttributesA",
- "GetFileAttributesExA",
- "GetFileAttributesExW",
- "GetFileAttributesW",
- "GetFileInformationByHandle",
- "GetFileSize",
- "GetFileSizeEx",
- "GetFileTime",
- "GetFileType",
- "GetFirmwareEnvironmentVariableA",
- "GetFirmwareEnvironmentVariableW",
- "GetFullPathNameA",
- "GetFullPathNameW",
- "GetGeoInfoA",
- "GetGeoInfoW",
- "GetHandleContext",
- "GetHandleInformation",
- "GetLargestConsoleWindowSize",
- "GetLastError",
- "GetLinguistLangSize",
- "GetLocalTime",
- "GetLocaleInfoA",
- "GetLocaleInfoW",
- "GetLogicalDriveStringsA",
- "GetLogicalDriveStringsW",
- "GetLogicalDrives",
- "GetLongPathNameA",
- "GetLongPathNameW",
- "GetMailslotInfo",
- "GetModuleFileNameA",
- "GetModuleFileNameW",
- "GetModuleHandleA",
- "GetModuleHandleExA",
- "GetModuleHandleExW",
- "GetModuleHandleW",
- "GetNamedPipeHandleStateA",
- "GetNamedPipeHandleStateW",
- "GetNamedPipeInfo",
- "GetNativeSystemInfo",
- "GetNextVDMCommand",
- "GetNlsSectionName",
- "GetNumaAvailableMemory",
- "GetNumaAvailableMemoryNode",
- "GetNumaHighestNodeNumber",
- "GetNumaNodeProcessorMask",
- "GetNumaProcessorMap",
- "GetNumaProcessorNode",
- "GetNumberFormatA",
- "GetNumberFormatW",
- "GetNumberOfConsoleFonts",
- "GetNumberOfConsoleInputEvents",
- "GetNumberOfConsoleMouseButtons",
- "GetOEMCP",
- "GetOverlappedResult",
- "GetPriorityClass",
- "GetPrivateProfileIntA",
- "GetPrivateProfileIntW",
- "GetPrivateProfileSectionA",
- "GetPrivateProfileSectionNamesA",
- "GetPrivateProfileSectionNamesW",
- "GetPrivateProfileSectionW",
- "GetPrivateProfileStringA",
- "GetPrivateProfileStringW",
- "GetPrivateProfileStructA",
- "GetPrivateProfileStructW",
- "GetProcAddress",
- "GetProcessAffinityMask",
- "GetProcessHandleCount",
- "GetProcessHeap",
- "GetProcessHeaps",
- "GetProcessId",
- "GetProcessIoCounters",
- "GetProcessPriorityBoost",
- "GetProcessShutdownParameters",
- "GetProcessTimes",
- "GetProcessVersion",
- "GetProcessWorkingSetSize",
- "GetProfileIntA",
- "GetProfileIntW",
- "GetProfileSectionA",
- "GetProfileSectionW",
- "GetProfileStringA",
- "GetProfileStringW",
- "GetQueuedCompletionStatus",
- "GetShortPathNameA",
- "GetShortPathNameW",
- "GetStartupInfoA",
- "GetStartupInfoW",
- "GetStdHandle",
- "GetStringTypeA",
- "GetStringTypeExA",
- "GetStringTypeExW",
- "GetStringTypeW",
- "GetSystemDefaultLCID",
- "GetSystemDefaultLangID",
- "GetSystemDefaultUILanguage",
- "GetSystemDirectoryA",
- "GetSystemDirectoryW",
- "GetSystemInfo",
- "GetSystemPowerStatus",
- "GetSystemRegistryQuota",
- "GetSystemTime",
- "GetSystemTimeAdjustment",
- "GetSystemTimeAsFileTime",
- "GetSystemTimes",
- "GetSystemWindowsDirectoryA",
- "GetSystemWindowsDirectoryW",
- "GetSystemWow64DirectoryA",
- "GetSystemWow64DirectoryW",
- "GetTapeParameters",
- "GetTapePosition",
- "GetTapeStatus",
- "GetTempFileNameA",
- "GetTempFileNameW",
- "GetTempPathA",
- "GetTempPathW",
- "GetThreadContext",
- "GetThreadIOPendingFlag",
- "GetThreadLocale",
- "GetThreadPriority",
- "GetThreadPriorityBoost",
- "GetThreadSelectorEntry",
- "GetThreadTimes",
- "GetTickCount",
- "GetTimeFormatA",
- "GetTimeFormatW",
- "GetTimeZoneInformation",
- "GetUserDefaultLCID",
- "GetUserDefaultLangID",
- "GetUserDefaultUILanguage",
- "GetUserGeoID",
- "GetVDMCurrentDirectories",
- "GetVersion",
- "GetVersionExA",
- "GetVersionExW",
- "GetVolumeInformationA",
- "GetVolumeInformationW",
- "GetVolumeNameForVolumeMountPointA",
- "GetVolumeNameForVolumeMountPointW",
- "GetVolumePathNameA",
- "GetVolumePathNameW",
- "GetVolumePathNamesForVolumeNameA",
- "GetVolumePathNamesForVolumeNameW",
- "GetWindowsDirectoryA",
- "GetWindowsDirectoryW",
- "GetWriteWatch",
- "GlobalAddAtomA",
- "GlobalAddAtomW",
- "GlobalAlloc",
- "GlobalCompact",
- "GlobalDeleteAtom",
- "GlobalFindAtomA",
- "GlobalFindAtomW",
- "GlobalFix",
- "GlobalFlags",
- "GlobalFree",
- "GlobalGetAtomNameA",
- "GlobalGetAtomNameW",
- "GlobalHandle",
- "GlobalLock",
- "GlobalMemoryStatus",
- "GlobalMemoryStatusEx",
- "GlobalReAlloc",
- "GlobalSize",
- "GlobalUnWire",
- "GlobalUnfix",
- "GlobalUnlock",
- "GlobalWire",
- "Heap32First",
- "Heap32ListFirst",
- "Heap32ListNext",
- "Heap32Next",
- "HeapAlloc",
- "HeapCompact",
- "HeapCreate",
- "HeapCreateTagsW",
- "HeapDestroy",
- "HeapExtend",
- "HeapFree",
- "HeapLock",
- "HeapQueryInformation",
- "HeapQueryTagW",
- "HeapReAlloc",
- "HeapSetInformation",
- "HeapSize",
- "HeapSummary",
- "HeapUnlock",
- "HeapUsage",
- "HeapValidate",
- "HeapWalk",
- "InitAtomTable",
- "InitializeCriticalSection",
- "InitializeCriticalSectionAndSpinCount",
- "InitializeSListHead",
- "InterlockedCompareExchange",
- "InterlockedDecrement",
- "InterlockedExchange",
- "InterlockedExchangeAdd",
- "InterlockedFlushSList",
- "InterlockedIncrement",
- "InterlockedPopEntrySList",
- "InterlockedPushEntrySList",
- "InvalidateConsoleDIBits",
- "IsBadCodePtr",
- "IsBadHugeReadPtr",
- "IsBadHugeWritePtr",
- "IsBadReadPtr",
- "IsBadStringPtrA",
- "IsBadStringPtrW",
- "IsBadWritePtr",
- "IsDBCSLeadByte",
- "IsDBCSLeadByteEx",
- "IsDebuggerPresent",
- "IsProcessInJob",
- "IsProcessorFeaturePresent",
- "IsSystemResumeAutomatic",
- "IsValidCodePage",
- "IsValidLanguageGroup",
- "IsValidLocale",
- "IsValidUILanguage",
- "IsWow64Process",
- "LCMapStringA",
- "LCMapStringW",
- "LZClose",
- "LZCloseFile",
- "LZCopy",
- "LZCreateFileW",
- "LZDone",
- "LZInit",
- "LZOpenFileA",
- "LZOpenFileW",
- "LZRead",
- "LZSeek",
- "LZStart",
- "LeaveCriticalSection",
- "LoadLibraryA",
- "LoadLibraryExA",
- "LoadLibraryExW",
- "LoadLibraryW",
- "LoadModule",
- "LoadResource",
- "LocalAlloc",
- "LocalCompact",
- "LocalFileTimeToFileTime",
- "LocalFlags",
- "LocalFree",
- "LocalHandle",
- "LocalLock",
- "LocalReAlloc",
- "LocalShrink",
- "LocalSize",
- "LocalUnlock",
- "LockFile",
- "LockFileEx",
- "LockResource",
- "MapUserPhysicalPages",
- "MapUserPhysicalPagesScatter",
- "MapViewOfFile",
- "MapViewOfFileEx",
- "Module32First",
- "Module32FirstW",
- "Module32Next",
- "Module32NextW",
- "MoveFileA",
- "MoveFileExA",
- "MoveFileExW",
- "MoveFileW",
- "MoveFileWithProgressA",
- "MoveFileWithProgressW",
- "MulDiv",
- "MultiByteToWideChar",
- "NlsConvertIntegerToString",
- "NlsGetCacheUpdateCount",
- "NlsResetProcessLocale",
- "NumaVirtualQueryNode",
- "OpenConsoleW",
- "OpenDataFile",
- "OpenEventA",
- "OpenEventW",
- "OpenFile",
- "OpenFileMappingA",
- "OpenFileMappingW",
- "OpenJobObjectA",
- "OpenJobObjectW",
- "OpenMutexA",
- "OpenMutexW",
- "OpenProcess",
- "OpenProfileUserMapping",
- "OpenSemaphoreA",
- "OpenSemaphoreW",
- "OpenThread",
- "OpenWaitableTimerA",
- "OpenWaitableTimerW",
- "OutputDebugStringA",
- "OutputDebugStringW",
- "PeekConsoleInputA",
- "PeekConsoleInputW",
- "PeekNamedPipe",
- "PostQueuedCompletionStatus",
- "PrepareTape",
- "PrivCopyFileExW",
- "PrivMoveFileIdentityW",
- "Process32First",
- "Process32FirstW",
- "Process32Next",
- "Process32NextW",
- "ProcessIdToSessionId",
- "PulseEvent",
- "PurgeComm",
- "QueryActCtxW",
- "QueryDepthSList",
- "QueryDosDeviceA",
- "QueryDosDeviceW",
- "QueryInformationJobObject",
- "QueryMemoryResourceNotification",
- "QueryPerformanceCounter",
- "QueryPerformanceFrequency",
- "QueryWin31IniFilesMappedToRegistry",
- "QueueUserAPC",
- "QueueUserWorkItem",
- "RaiseException",
- "ReadConsoleA",
- "ReadConsoleInputA",
- "ReadConsoleInputExA",
- "ReadConsoleInputExW",
- "ReadConsoleInputW",
- "ReadConsoleOutputA",
- "ReadConsoleOutputAttribute",
- "ReadConsoleOutputCharacterA",
- "ReadConsoleOutputCharacterW",
- "ReadConsoleOutputW",
- "ReadConsoleW",
- "ReadDirectoryChangesW",
- "ReadFile",
- "ReadFileEx",
- "ReadFileScatter",
- "ReadProcessMemory",
- "RegisterConsoleIME",
- "RegisterConsoleOS2",
- "RegisterConsoleVDM",
- "RegisterWaitForInputIdle",
- "RegisterWaitForSingleObject",
- "RegisterWaitForSingleObjectEx",
- "RegisterWowBaseHandlers",
- "RegisterWowExec",
- "ReleaseActCtx",
- "ReleaseMutex",
- "ReleaseSemaphore",
- "RemoveDirectoryA",
- "RemoveDirectoryW",
- "RemoveLocalAlternateComputerNameA",
- "RemoveLocalAlternateComputerNameW",
- "RemoveVectoredExceptionHandler",
- "ReplaceFile",
- "ReplaceFileA",
- "ReplaceFileW",
- "RequestDeviceWakeup",
- "RequestWakeupLatency",
- "ResetEvent",
- "ResetWriteWatch",
- "RestoreLastError",
- "ResumeThread",
- "RtlCaptureContext",
- "RtlCaptureStackBackTrace",
- "RtlFillMemory",
- "RtlMoveMemory",
- "RtlUnwind",
- "RtlZeroMemory",
- "ScrollConsoleScreenBufferA",
- "ScrollConsoleScreenBufferW",
- "SearchPathA",
- "SearchPathW",
- "SetCPGlobal",
- "SetCalendarInfoA",
- "SetCalendarInfoW",
- "SetClientTimeZoneInformation",
- "SetComPlusPackageInstallStatus",
- "SetCommBreak",
- "SetCommConfig",
- "SetCommMask",
- "SetCommState",
- "SetCommTimeouts",
- "SetComputerNameA",
- "SetComputerNameExA",
- "SetComputerNameExW",
- "SetComputerNameW",
- "SetConsoleActiveScreenBuffer",
- "SetConsoleCP",
- "SetConsoleCommandHistoryMode",
- "SetConsoleCtrlHandler",
- "SetConsoleCursor",
- "SetConsoleCursorInfo",
- "SetConsoleCursorMode",
- "SetConsoleCursorPosition",
- "SetConsoleDisplayMode",
- "SetConsoleFont",
- "SetConsoleHardwareState",
- "SetConsoleIcon",
- "SetConsoleInputExeNameA",
- "SetConsoleInputExeNameW",
- "SetConsoleKeyShortcuts",
- "SetConsoleLocalEUDC",
- "SetConsoleMaximumWindowSize",
- "SetConsoleMenuClose",
- "SetConsoleMode",
- "SetConsoleNlsMode",
- "SetConsoleNumberOfCommandsA",
- "SetConsoleNumberOfCommandsW",
- "SetConsoleOS2OemFormat",
- "SetConsoleOutputCP",
- "SetConsolePalette",
- "SetConsoleScreenBufferSize",
- "SetConsoleTextAttribute",
- "SetConsoleTitleA",
- "SetConsoleTitleW",
- "SetConsoleWindowInfo",
- "SetCriticalSectionSpinCount",
- "SetCurrentDirectoryA",
- "SetCurrentDirectoryW",
- "SetDefaultCommConfigA",
- "SetDefaultCommConfigW",
- "SetDllDirectoryA",
- "SetDllDirectoryW",
- "SetEndOfFile",
- "SetEnvironmentVariableA",
- "SetEnvironmentVariableW",
- "SetErrorMode",
- "SetEvent",
- "SetFileApisToANSI",
- "SetFileApisToOEM",
- "SetFileAttributesA",
- "SetFileAttributesW",
- "SetFilePointer",
- "SetFilePointerEx",
- "SetFileShortNameA",
- "SetFileShortNameW",
- "SetFileTime",
- "SetFileValidData",
- "SetFirmwareEnvironmentVariableA",
- "SetFirmwareEnvironmentVariableW",
- "SetHandleContext",
- "SetHandleCount",
- "SetHandleInformation",
- "SetInformationJobObject",
- "SetLastConsoleEventActive",
- "SetLastError",
- "SetLocalPrimaryComputerNameA",
- "SetLocalPrimaryComputerNameW",
- "SetLocalTime",
- "SetLocaleInfoA",
- "SetLocaleInfoW",
- "SetMailslotInfo",
- "SetMessageWaitingIndicator",
- "SetNamedPipeHandleState",
- "SetPriorityClass",
- "SetProcessAffinityMask",
- "SetProcessPriorityBoost",
- "SetProcessShutdownParameters",
- "SetProcessWorkingSetSize",
- "SetStdHandle",
- "SetSystemPowerState",
- "SetSystemTime",
- "SetSystemTimeAdjustment",
- "SetTapeParameters",
- "SetTapePosition",
- "SetTermsrvAppInstallMode",
- "SetThreadAffinityMask",
- "SetThreadContext",
- "SetThreadExecutionState",
- "SetThreadIdealProcessor",
- "SetThreadLocale",
- "SetThreadPriority",
- "SetThreadPriorityBoost",
- "SetThreadUILanguage",
- "SetTimeZoneInformation",
- "SetTimerQueueTimer",
- "SetUnhandledExceptionFilter",
- "SetUserGeoID",
- "SetVDMCurrentDirectories",
- "SetVolumeLabelA",
- "SetVolumeLabelW",
- "SetVolumeMountPointA",
- "SetVolumeMountPointW",
- "SetWaitableTimer",
- "SetupComm",
- "ShowConsoleCursor",
- "SignalObjectAndWait",
- "SizeofResource",
- "Sleep",
- "SleepEx",
- "SuspendThread",
- "SwitchToFiber",
- "SwitchToThread",
- "SystemTimeToFileTime",
- "SystemTimeToTzSpecificLocalTime",
- "TerminateJobObject",
- "TerminateProcess",
- "TerminateThread",
- "TermsrvAppInstallMode",
- "Thread32First",
- "Thread32Next",
- "TlsAlloc",
- "TlsFree",
- "TlsGetValue",
- "TlsSetValue",
- "Toolhelp32ReadProcessMemory",
- "TransactNamedPipe",
- "TransmitCommChar",
- "TrimVirtualBuffer",
- "TryEnterCriticalSection",
- "TzSpecificLocalTimeToSystemTime",
- "UTRegister",
- "UTUnRegister",
- "UnhandledExceptionFilter",
- "UnlockFile",
- "UnlockFileEx",
- "UnmapViewOfFile",
- "UnregisterConsoleIME",
- "UnregisterWait",
- "UnregisterWaitEx",
- "UpdateResourceA",
- "UpdateResourceW",
- "VDMConsoleOperation",
- "VDMOperationStarted",
- "ValidateLCType",
- "ValidateLocale",
- "VerLanguageNameA",
- "VerLanguageNameW",
- "VerSetConditionMask",
- "VerifyConsoleIoHandle",
- "VerifyVersionInfoA",
- "VerifyVersionInfoW",
- "VirtualAlloc",
- "VirtualAllocEx",
- "VirtualBufferExceptionHandler",
- "VirtualFree",
- "VirtualFreeEx",
- "VirtualLock",
- "VirtualProtect",
- "VirtualProtectEx",
- "VirtualQuery",
- "VirtualQueryEx",
- "VirtualUnlock",
- "WTSGetActiveConsoleSessionId",
- "WaitCommEvent",
- "WaitForDebugEvent",
- "WaitForMultipleObjects",
- "WaitForMultipleObjectsEx",
- "WaitForSingleObject",
- "WaitForSingleObjectEx",
- "WaitNamedPipeA",
- "WaitNamedPipeW",
- "WideCharToMultiByte",
- "WinExec",
- "WriteConsoleA",
- "WriteConsoleInputA",
- "WriteConsoleInputVDMA",
- "WriteConsoleInputVDMW",
- "WriteConsoleInputW",
- "WriteConsoleOutputA",
- "WriteConsoleOutputAttribute",
- "WriteConsoleOutputCharacterA",
- "WriteConsoleOutputCharacterW",
- "WriteConsoleOutputW",
- "WriteConsoleW",
- "WriteFile",
- "WriteFileEx",
- "WriteFileGather",
- "WritePrivateProfileSectionA",
- "WritePrivateProfileSectionW",
- "WritePrivateProfileStringA",
- "WritePrivateProfileStringW",
- "WritePrivateProfileStructA",
- "WritePrivateProfileStructW",
- "WriteProcessMemory",
- "WriteProfileSectionA",
- "WriteProfileSectionW",
- "WriteProfileStringA",
- "WriteProfileStringW",
- "WriteTapemark",
- "ZombifyActCtx",
- "_hread",
- "_hwrite",
- "_lclose",
- "_lcreat",
- "_llseek",
- "_lopen",
- "_lread",
- "_lwrite",
- "lstrcat",
- "lstrcatA",
- "lstrcatW",
- "lstrcmp",
- "lstrcmpA",
- "lstrcmpW",
- "lstrcmpi",
- "lstrcmpiA",
- "lstrcmpiW",
- "lstrcpy",
- "lstrcpyA",
- "lstrcpyW",
- "lstrcpyn",
- "lstrcpynA",
- "lstrcpynW",
- "lstrlen",
- "lstrlenA",
- "lstrlenW",
- ]
- # please do not modify KERNEL32_XP_SP2_EXPORT_SYMBOLS when your MR failed
-
-
- # please do not add function in STRIP_LINES when your MR failed
- STRIP_LINES = [
- "Dumper Version",
- "Microsoft Corporation",
- "Dump of file",
- "File Type",
- "Section contains the",
- "Import Address Table",
- "Import Name Table",
- "time date stamp",
- "Index of first forwarder reference",
- "Summary",
- ".data",
- ".gfids",
- ".rdata",
- ".reloc",
- ".text",
- ".tls",
- ".rsrc",
- ".00cfg",
- ".idata",
- "KERNEL32.dll",
- "dbghelp.dll",
- ]
- # please do not add function in STRIP_LINES when your MR failed
-
- # please do not modify CONSOLE_LINES and CONSOLE_VERSION when your MR failed
- CONSOLE_LINES = [
- "operating system version",
- "subsystem version",
- ]
- CONSOLE_VERSION = [
- "5.01",
- ]
- # please do not modify CONSOLE_LINES and CONSOLE_VERSION when your MR failed
-
-
- def main():
- parser = argparse.ArgumentParser()
-
- parser.add_argument(
- "-p",
- "--windows_pe_file",
- help="pe file check runnable on Windows xp sp2",
- dest="pe_file",
- type=str,
- required=True,
- )
-
- args = parser.parse_args()
-
- if not os.path.isfile(args.pe_file):
- print("ERROR: can not find file:{}".format(args.pe_file))
- exit(-1)
-
- cmd = 'cmd.exe /c "dumpbin /imports {}"'.format(args.pe_file)
- raw_log = subprocess.check_output(cmd)
- raw_log = raw_log.decode("utf-8").split("\r\n")
-
- import_function = []
- for log in raw_log:
- is_in_strip = False
- if log != "":
- for strip_line in STRIP_LINES:
- if log.find(strip_line) >= 0:
- is_in_strip = True
- break
- if not is_in_strip:
- import_function.append(log.split()[1])
-
- assert len(import_function) > 0, "import function should not be zero"
-
- # now check import_function is in KERNEL32_XP_SP2_EXPORT_SYMBOLS
- # if you MR failed!, please ref 65ac48b95e99f2c510fe5db449cc8182d682e113
- # to refine your MR
-
- for i in import_function:
- msg = (
- "target import function: '{}' can not find in KERNEL32_XP_SP2_EXPORT_SYMBOLS\n"
- "please check your MR modify, possible reasons:\n"
- "1: use std::thread/std::this_thread in inference code, put this code under #if !__DEPLOY_ON_XP_SP2__\n"
- "2: use std::mutex in inference code, replace it to DNN_MUTEX/MGB_MUTEX/LITE_MUTEX\n"
- "3: more detail please do git show 65ac48b95e99f2c510fe5db449cc8182d682e113 to refine your MR".format(
- i
- )
- )
- assert i in KERNEL32_XP_SP2_EXPORT_SYMBOLS, "{}".format(msg)
- print("check import fuction: '{}' success".format(i))
-
- print("check pe file: {} import function success!!!".format(args.pe_file))
-
- cmd = 'cmd.exe /c "dumpbin /HEADERS {}"'.format(args.pe_file)
- raw_log = subprocess.check_output(cmd)
- raw_log = raw_log.decode("utf-8").split("\r\n")
-
- console_version = []
- for log in raw_log:
- for console_line in CONSOLE_LINES:
- if log.find(console_line) >= 0:
- console_version.append(log.split()[0])
-
- assert len(console_version) > 0, "console version should not be zero"
-
- # now check console version
-
- for i in console_version:
- msg = (
- "check console version: '{}' failed\n"
- "please check your MR modify, possible reasons:\n"
- "1: need add /SUBSYSTEM:CONSOLE,5.01 for linker when (cmake)define MGE_DEPLOY_INFERENCE_ON_WINDOWS_XP_SP2\n"
- ' bazel --copt "-D__DEPLOY_ON_XP_SP2__=1"'.format(i)
- )
- assert i in CONSOLE_VERSION, "{}".format(msg)
- print("check console version: '{}' success".format(i))
-
- print("check pe file: {} console version success!!!".format(args.pe_file))
-
-
- if __name__ == "__main__":
- assert platform.system() == "Windows", "can only run at windows env!!!"
- main()
|