mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-07 03:38:31 +00:00
Experiment with supporting Windows Arm64 natively
So far I haven't found any way to run native Arm64 code on Windows Arm64 without using MSVC. When I build a PE binary from scratch that should be a valid Windows Arm64 program, the OS refuses to run it. Possibly due to requiring additional content like XML manifests or relocation or control flow integrity data that isn't normally required on x64. I've also tried using VirtualAlloc2() to JIT an Arm64 native function, but VirtualAlloc2 always fails with invalid parameter. I tried using MSVC to create an ARM DLL that my x64 emulated program can link at runtime, to pass a function pointer with ARM code, but LoadLibrary() rejects ARM DLLs as invalid exe The only option left, is likely to write a new program like ape/ape-m1.c which can be compiled by MSVC to load and run an AARCH64 ELF executable. The emulated x64 binary would detect emulation using IsWow64Process2 and then drop the loader executable in a temporary folder, and re-launch the original executable, using the Arm64 segments of the cosmocc fat binary.
This commit is contained in:
parent
1671283f1a
commit
5bd22aef12
12 changed files with 88 additions and 16 deletions
|
@ -113,6 +113,7 @@ imp 'GetCurrentProcessId' GetCurrentProcessId kernel32 0
|
|||
imp 'GetCurrentProcessorNumberEx' GetCurrentProcessorNumberEx kernel32 1
|
||||
imp 'GetCurrentThread' GetCurrentThread kernel32 0
|
||||
imp 'GetCurrentThreadId' GetCurrentThreadId kernel32 0
|
||||
imp 'GetDynamicTimeZoneInformation' GetDynamicTimeZoneInformation kernel32 1
|
||||
imp 'GetEnvironmentStrings' GetEnvironmentStringsW kernel32 1
|
||||
imp 'GetEnvironmentVariable' GetEnvironmentVariableW kernel32 3
|
||||
imp 'GetExitCodeThread' GetExitCodeThread kernel32 2
|
||||
|
@ -168,8 +169,6 @@ imp 'GetSystemTimePreciseAsFileTime' GetSystemTimePreciseAsFileTime kernel3
|
|||
imp 'GetSystemTimes' GetSystemTimes kernel32 3
|
||||
imp 'GetTempPath' GetTempPathW kernel32 2
|
||||
imp 'GetTempPathA' GetTempPathA kernel32 2
|
||||
imp 'GetDynamicTimeZoneInformation' GetDynamicTimeZoneInformation kernel32 1
|
||||
imp 'GetTimeZoneInformation' GetTimeZoneInformation kernel32 1
|
||||
imp 'GetThreadContext' GetThreadContext kernel32 2
|
||||
imp 'GetThreadDescription' GetThreadDescription kernel32 2
|
||||
imp 'GetThreadIOPendingFlag' GetThreadIOPendingFlag kernel32 2
|
||||
|
@ -178,6 +177,7 @@ imp 'GetThreadPriority' GetThreadPriority kernel32 1
|
|||
imp 'GetThreadPriorityBoost' GetThreadPriorityBoost kernel32 2
|
||||
imp 'GetThreadTimes' GetThreadTimes kernel32 5
|
||||
imp 'GetTickCount64' GetTickCount64 kernel32 0
|
||||
imp 'GetTimeZoneInformation' GetTimeZoneInformation kernel32 1
|
||||
imp 'GetVersionEx' GetVersionExW kernel32 1
|
||||
imp 'GetVolumeInformationByHandle' GetVolumeInformationByHandleW kernel32 8
|
||||
imp 'GetVolumePathName' GetVolumePathNameW kernel32 3
|
||||
|
@ -197,6 +197,7 @@ imp 'InitializeCriticalSection' InitializeCriticalSection kernel32 1
|
|||
imp 'InitializeCriticalSectionAndSpinCount' InitializeCriticalSectionAndSpinCount kernel32 2
|
||||
imp 'InitializeProcThreadAttributeList' InitializeProcThreadAttributeList kernel32 4
|
||||
imp 'InitializeSRWLock' InitializeSRWLock kernel32 1
|
||||
imp 'IsWow64Process2' IsWow64Process2 kernel32 3
|
||||
imp 'LeaveCriticalSection' LeaveCriticalSection kernel32 1
|
||||
imp 'LoadLibrary' LoadLibraryW kernel32 1
|
||||
imp 'LoadLibraryA' LoadLibraryA kernel32 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue