Save/restore fs/gs segments when re-entering host code

This commit is contained in:
2025-10-05 13:58:40 -06:00
parent 04516b246c
commit cd7baffc5e
44 changed files with 669 additions and 20 deletions

View File

@@ -31,6 +31,7 @@ DWORD_PTR computeSystemProcessorMask(unsigned int cpuCount) {
namespace kernel32 {
void WIN_FUNC GetSystemInfo(LPSYSTEM_INFO lpSystemInfo) {
WIN_API_SEGMENT_GUARD();
DEBUG_LOG("GetSystemInfo(%p)\n", lpSystemInfo);
if (!lpSystemInfo) {
return;
@@ -67,6 +68,7 @@ void WIN_FUNC GetSystemInfo(LPSYSTEM_INFO lpSystemInfo) {
}
void WIN_FUNC GetSystemTime(LPSYSTEMTIME lpSystemTime) {
WIN_API_SEGMENT_GUARD();
DEBUG_LOG("GetSystemTime(%p)\n", lpSystemTime);
if (!lpSystemTime) {
return;
@@ -95,6 +97,7 @@ void WIN_FUNC GetSystemTime(LPSYSTEMTIME lpSystemTime) {
}
void WIN_FUNC GetLocalTime(LPSYSTEMTIME lpSystemTime) {
WIN_API_SEGMENT_GUARD();
DEBUG_LOG("GetLocalTime(%p)\n", lpSystemTime);
if (!lpSystemTime) {
return;
@@ -123,6 +126,7 @@ void WIN_FUNC GetLocalTime(LPSYSTEMTIME lpSystemTime) {
}
void WIN_FUNC GetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime) {
WIN_API_SEGMENT_GUARD();
DEBUG_LOG("GetSystemTimeAsFileTime(%p)\n", lpSystemTimeAsFileTime);
if (!lpSystemTimeAsFileTime) {
return;
@@ -154,6 +158,7 @@ void WIN_FUNC GetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime) {
}
DWORD WIN_FUNC GetTickCount() {
WIN_API_SEGMENT_GUARD();
DEBUG_LOG("GetTickCount()\n");
#if defined(CLOCK_MONOTONIC)
struct timespec ts{};
@@ -178,11 +183,13 @@ DWORD WIN_FUNC GetTickCount() {
}
DWORD WIN_FUNC GetVersion() {
WIN_API_SEGMENT_GUARD();
DEBUG_LOG("GetVersion()\n");
return kMajorVersion | (kMinorVersion << 8) | (5 << 16) | (kBuildNumber << 24);
}
BOOL WIN_FUNC GetVersionExA(LPOSVERSIONINFOA lpVersionInformation) {
WIN_API_SEGMENT_GUARD();
DEBUG_LOG("GetVersionExA(%p)\n", lpVersionInformation);
if (!lpVersionInformation) {
wibo::lastError = ERROR_INVALID_PARAMETER;