Support more syscalls

This commit is contained in:
momo5502
2025-05-31 21:27:32 +02:00
parent 59576342d3
commit e763fdac54
6 changed files with 98 additions and 6 deletions

View File

@@ -32,6 +32,40 @@ namespace syscalls
return succeeded ? STATUS_SUCCESS : STATUS_MUTANT_NOT_OWNED;
}
NTSTATUS handle_NtOpenMutant(const syscall_context& c, const emulator_object<handle> mutant_handle,
const ACCESS_MASK /*desired_access*/,
const emulator_object<OBJECT_ATTRIBUTES<EmulatorTraits<Emu64>>> object_attributes)
{
std::u16string name{};
if (object_attributes)
{
const auto attributes = object_attributes.read();
if (attributes.ObjectName)
{
name = read_unicode_string(
c.emu, emulator_object<UNICODE_STRING<EmulatorTraits<Emu64>>>{c.emu, attributes.ObjectName});
c.win_emu.log.print(color::dark_gray, "--> Mutant name: %s\n", u16_to_u8(name).c_str());
}
}
if (name.empty())
{
return STATUS_OBJECT_NAME_NOT_FOUND;
}
for (auto& entry : c.proc.mutants)
{
if (entry.second.name == name)
{
++entry.second.ref_count;
mutant_handle.write(c.proc.mutants.make_handle(entry.first));
return STATUS_SUCCESS;
}
}
return STATUS_OBJECT_NAME_NOT_FOUND;
}
NTSTATUS handle_NtCreateMutant(const syscall_context& c, const emulator_object<handle> mutant_handle,
const ACCESS_MASK /*desired_access*/,
const emulator_object<OBJECT_ATTRIBUTES<EmulatorTraits<Emu64>>> object_attributes,
@@ -75,4 +109,4 @@ namespace syscalls
return STATUS_SUCCESS;
}
}
}