Quick & dirty thread switching support

This commit is contained in:
momo5502
2024-10-17 20:05:47 +02:00
parent 933bfcaaf3
commit 71c8177ee3
5 changed files with 95 additions and 2 deletions

View File

@@ -1967,6 +1967,10 @@ namespace
{
write_attribute(c.emu, attribute, thread->teb->ptr());
}
else
{
printf("Unsupported thread attribute type: %llX\n", type);
}
}, i);
}
@@ -1977,6 +1981,38 @@ namespace
{
return FALSE;
}
NTSTATUS handle_NtWaitForSingleObject(const syscall_context& c, const uint64_t handle_value,
const BOOLEAN alertable,
const emulator_object<LARGE_INTEGER> timeout)
{
if (timeout.value())
{
puts("NtWaitForSingleObject timeout not supported yet!");
return STATUS_NOT_SUPPORTED;
}
if (alertable)
{
puts("Alertable NtWaitForSingleObject not supported yet!");
return STATUS_NOT_SUPPORTED;
}
handle h{};
h.bits = handle_value;
if (h.value.type != handle_types::thread)
{
puts("NtWaitForSingleObject only supported with thread handles yet!");
return STATUS_NOT_SUPPORTED;
}
c.win_emu.current_thread().await_object = h;
c.win_emu.switch_thread = true;
c.emu.stop();
return STATUS_WAIT_0;
}
}
void syscall_dispatcher::setup(const exported_symbols& ntdll_exports, const exported_symbols& win32u_exports)
@@ -2077,6 +2113,7 @@ void syscall_dispatcher::add_handlers()
add_handler(NtQueryInformationFile);
add_handler(NtCreateThreadEx);
add_handler(NtQueryDebugFilterState);
add_handler(NtWaitForSingleObject);
#undef add_handler