diff options
| author | Yang Liu <liuyang22@iscas.ac.cn> | 2025-04-17 18:30:59 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-17 12:30:59 +0200 |
| commit | 882d933d8494a44cb03c0db8705ca0c96117aeeb (patch) | |
| tree | 844683440aaac55697b8829e9f0bf6f7b19d81f8 /src/os | |
| parent | 9579dd9ff14282cb9674e8cf08064220013fb46b (diff) | |
| download | box64-882d933d8494a44cb03c0db8705ca0c96117aeeb.tar.gz box64-882d933d8494a44cb03c0db8705ca0c96117aeeb.zip | |
[WOW64] Finished skeleton code for PE build (#2542)
* [WOW64] Finished skeleton code for PE build * move musl to external
Diffstat (limited to 'src/os')
| -rw-r--r-- | src/os/os_wine.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/os/os_wine.c b/src/os/os_wine.c index e2cdba2e..949d7731 100644 --- a/src/os/os_wine.c +++ b/src/os/os_wine.c @@ -6,6 +6,14 @@ #define HandleToULong(h) ((ULONG)(ULONG_PTR)(h)) +NTSTATUS WINAPI NtYieldExecution(void); + +static HANDLE myGetProcessHeap(void) +{ + return ((HANDLE**)NtCurrentTeb())[12][6]; +} + + int GetTID(void) { return HandleToULong(((HANDLE*)NtCurrentTeb())[9]); @@ -13,7 +21,7 @@ int GetTID(void) int SchedYield(void) { - return SwitchToThread(); + return (NtYieldExecution() != STATUS_NO_YIELD_PERFORMED); } int IsBridgeSignature(char s, char c) @@ -151,7 +159,7 @@ int InternalMunmap(void* addr, unsigned long length) void* WinMalloc(size_t size) { void* ret; - ret = RtlAllocateHeap(GetProcessHeap(), 0, size); + ret = RtlAllocateHeap(myGetProcessHeap(), 0, size); return ret; } @@ -160,18 +168,23 @@ void* WinRealloc(void* ptr, size_t size) void* ret; if (!ptr) return WinMalloc(size); - ret = RtlReAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY, ptr, size); + ret = RtlReAllocateHeap(myGetProcessHeap(), HEAP_ZERO_MEMORY, ptr, size); return ret; } void* WinCalloc(size_t nmemb, size_t size) { void* ret; - ret = RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY, nmemb * size); + ret = RtlAllocateHeap(myGetProcessHeap(), HEAP_ZERO_MEMORY, nmemb * size); return ret; } void WinFree(void* ptr) { - RtlFreeHeap(GetProcessHeap(), 0, ptr); + RtlFreeHeap(myGetProcessHeap(), 0, ptr); +} + +void free(void* ptr) +{ + RtlFreeHeap(myGetProcessHeap(), 0, ptr); } \ No newline at end of file |