mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-27 07:11:01 +00:00
Prepare timer support
This commit is contained in:
@@ -63,6 +63,7 @@ namespace syscalls
|
||||
if (attributes.ObjectName)
|
||||
{
|
||||
name = read_unicode_string(c.emu, attributes.ObjectName);
|
||||
c.win_emu.log.print(color::dark_gray, "--> Event name: %s\n", u16_to_u8(name).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -210,14 +210,16 @@ namespace syscalls
|
||||
if (commit && !reserve &&
|
||||
c.win_emu.memory.commit_memory(potential_base, static_cast<size_t>(allocation_bytes), protection))
|
||||
{
|
||||
c.win_emu.log.print(color::dark_gray, "--> Committed 0x%" PRIx64 " - 0x%" PRIx64 "\n", potential_base,
|
||||
potential_base + allocation_bytes);
|
||||
c.win_emu.log.print(is_executable(protection) ? color::gray : color::dark_gray,
|
||||
"--> Committed 0x%" PRIx64 " - 0x%" PRIx64 " (%s)\n", potential_base,
|
||||
potential_base + allocation_bytes, get_permission_string(protection).c_str());
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
c.win_emu.log.print(color::dark_gray, "--> Allocated 0x%" PRIx64 " - 0x%" PRIx64 "\n", potential_base,
|
||||
potential_base + allocation_bytes);
|
||||
c.win_emu.log.print(is_executable(protection) ? color::gray : color::dark_gray,
|
||||
"--> Allocated 0x%" PRIx64 " - 0x%" PRIx64 " (%s)\n", potential_base,
|
||||
potential_base + allocation_bytes, get_permission_string(protection).c_str());
|
||||
|
||||
return c.win_emu.memory.allocate_memory(potential_base, static_cast<size_t>(allocation_bytes), protection,
|
||||
!commit)
|
||||
|
||||
@@ -77,8 +77,7 @@ namespace syscalls
|
||||
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});
|
||||
name = read_unicode_string(c.emu, attributes.ObjectName);
|
||||
c.win_emu.log.print(color::dark_gray, "--> Mutant name: %s\n", u16_to_u8(name).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,4 +30,43 @@ namespace syscalls
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
NTSTATUS handle_NtCreateTimer2(const syscall_context& c, const emulator_object<handle> timer_handle,
|
||||
uint64_t /*reserved*/,
|
||||
const emulator_object<OBJECT_ATTRIBUTES<EmulatorTraits<Emu64>>> object_attributes,
|
||||
ULONG /*attributes*/, ACCESS_MASK /*desired_access*/)
|
||||
{
|
||||
std::u16string name{};
|
||||
if (object_attributes)
|
||||
{
|
||||
const auto attributes = object_attributes.read();
|
||||
if (attributes.ObjectName)
|
||||
{
|
||||
name = read_unicode_string(c.emu, attributes.ObjectName);
|
||||
c.win_emu.log.print(color::dark_gray, "--> Timer name: %s\n", u16_to_u8(name).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
if (!name.empty())
|
||||
{
|
||||
for (auto& entry : c.proc.timers)
|
||||
{
|
||||
if (entry.second.name == name)
|
||||
{
|
||||
++entry.second.ref_count;
|
||||
timer_handle.write(c.proc.timers.make_handle(entry.first));
|
||||
return STATUS_OBJECT_NAME_EXISTS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
timer t{};
|
||||
t.name = std::move(name);
|
||||
|
||||
const auto h = c.proc.timers.store(std::move(t));
|
||||
timer_handle.write(h);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user