Adapt more printing

This commit is contained in:
momo5502
2025-06-07 07:29:30 +02:00
parent 9372e27453
commit 802e295bcc
6 changed files with 49 additions and 22 deletions

View File

@@ -361,7 +361,7 @@ handle process_context::create_thread(memory_manager& memory, const uint64_t sta
{
emulator_thread t{memory, *this, start_address, argument, stack_size, suspended, ++this->spawned_thread_count};
auto [h, thr] = this->threads.store_and_get(std::move(t));
this->callbacks_->on_create_thread(h, *thr);
this->callbacks_->on_thread_create(h, *thr);
return h;
}

View File

@@ -32,9 +32,10 @@ struct process_context
{
struct callbacks
{
utils::optional_function<void(handle h, emulator_thread& thr)> on_create_thread{};
utils::optional_function<void(handle h, emulator_thread& thr)> on_thread_create{};
utils::optional_function<void(handle h, emulator_thread& thr)> on_thread_terminated{};
utils::optional_function<void(emulator_thread& current_thread, emulator_thread& new_thread)> on_thread_switch{};
utils::optional_function<void(emulator_thread& current_thread)> on_thread_set_name{};
};
struct atom_entry

View File

@@ -146,9 +146,7 @@ namespace syscalls
const auto requested_protection = map_nt_to_emulator_protection(protection);
c.win_emu.log.print(color::dark_gray, "--> Changing protection at 0x%" PRIx64 "-0x%" PRIx64 " to %s\n",
aligned_start, aligned_start + aligned_length,
get_permission_string(requested_protection).c_str());
c.win_emu.callbacks.on_memory_protect(aligned_start, aligned_length, requested_protection);
memory_permission old_protection_value{};
@@ -208,16 +206,11 @@ 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(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());
c.win_emu.callbacks.on_memory_allocate(potential_base, allocation_bytes, protection, true);
return STATUS_SUCCESS;
}
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());
c.win_emu.callbacks.on_memory_allocate(potential_base, allocation_bytes, protection, false);
return c.win_emu.memory.allocate_memory(potential_base, static_cast<size_t>(allocation_bytes), protection,
!commit)

View File

@@ -41,8 +41,7 @@ namespace syscalls
const auto i = info.read();
thread->name = read_unicode_string(c.emu, i.ThreadName);
c.win_emu.log.print(color::blue, "Setting thread (%d) name: %s\n", thread->id,
u16_to_u8(thread->name).c_str());
c.win_emu.callbacks.on_thread_set_name(*thread);
return STATUS_SUCCESS;
}

View File

@@ -15,17 +15,22 @@
struct io_device;
#define opt_func utils::optional_function
struct emulator_callbacks : module_manager::callbacks, process_context::callbacks
{
using continuation = instruction_hook_continuation;
utils::optional_function<continuation(uint32_t syscall_id, std::string_view syscall_name)> on_syscall{};
utils::optional_function<void(std::string_view data)> on_stdout{};
utils::optional_function<void(std::string_view type, std::u16string_view name)> on_generic_access{};
utils::optional_function<void(std::string_view description)> on_generic_activity{};
utils::optional_function<void(std::string_view description)> on_suspicious_activity{};
utils::optional_function<void(uint64_t address)> on_instruction{};
utils::optional_function<void(io_device& device, std::u16string_view device_name, ULONG code)> on_ioctrl{};
opt_func<void(uint64_t address, uint64_t length, memory_permission)> on_memory_protect{};
opt_func<void(uint64_t address, uint64_t length, memory_permission, bool commit)> on_memory_allocate{};
opt_func<continuation(uint32_t syscall_id, std::string_view syscall_name)> on_syscall{};
opt_func<void(std::string_view data)> on_stdout{};
opt_func<void(std::string_view type, std::u16string_view name)> on_generic_access{};
opt_func<void(std::string_view description)> on_generic_activity{};
opt_func<void(std::string_view description)> on_suspicious_activity{};
opt_func<void(uint64_t address)> on_instruction{};
opt_func<void(io_device& device, std::u16string_view device_name, ULONG code)> on_ioctrl{};
};
struct application_settings