mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-19 11:43:56 +00:00
Various fixes and additions (#135)
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr auto ALLOCATION_GRANULARITY = 0x0000000000010000ULL;
|
||||
constexpr auto MIN_ALLOCATION_ADDRESS = 0x0000000000010000ULL;
|
||||
constexpr auto MAX_ALLOCATION_ADDRESS = 0x00007ffffffeffffULL;
|
||||
|
||||
@@ -446,6 +447,7 @@ void memory_manager::unmap_all_memory()
|
||||
uint64_t memory_manager::find_free_allocation_base(const size_t size, const uint64_t start) const
|
||||
{
|
||||
uint64_t start_address = std::max(MIN_ALLOCATION_ADDRESS, start ? start : 0x100000000ULL);
|
||||
start_address = align_up(start_address, ALLOCATION_GRANULARITY);
|
||||
|
||||
for (const auto& region : this->reserved_regions_)
|
||||
{
|
||||
@@ -460,7 +462,7 @@ uint64_t memory_manager::find_free_allocation_base(const size_t size, const uint
|
||||
return start_address;
|
||||
}
|
||||
|
||||
start_address = page_align_up(region_end);
|
||||
start_address = align_up(region_end, ALLOCATION_GRANULARITY);
|
||||
}
|
||||
|
||||
if (start_address + size <= MAX_ALLOCATION_ADDRESS)
|
||||
|
||||
@@ -2102,6 +2102,8 @@ namespace
|
||||
|
||||
if (!potential_base)
|
||||
{
|
||||
c.win_emu.log.print(color::dark_gray, "--> Not allocated\n");
|
||||
|
||||
return STATUS_MEMORY_NOT_ALLOCATED;
|
||||
}
|
||||
|
||||
@@ -2117,9 +2119,15 @@ namespace
|
||||
|
||||
if (commit && !reserve && c.emu.commit_memory(potential_base, allocation_bytes, protection))
|
||||
{
|
||||
c.win_emu.log.print(color::dark_gray, "--> Committed 0x%" PRIx64 " - 0x%" PRIx64 "\n", potential_base,
|
||||
potential_base + allocation_bytes);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
c.win_emu.log.print(color::dark_gray, "--> Allocated 0x%" PRIx64 " - 0x%" PRIx64 "\n", potential_base,
|
||||
potential_base + allocation_bytes);
|
||||
|
||||
return c.emu.allocate_memory(potential_base, allocation_bytes, protection, !commit)
|
||||
? STATUS_SUCCESS
|
||||
: STATUS_MEMORY_NOT_ALLOCATED;
|
||||
@@ -2733,6 +2741,13 @@ namespace
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS handle_NtQueryDefaultLocale(const syscall_context&, BOOLEAN /*user_profile*/,
|
||||
const emulator_object<LCID> default_locale_id)
|
||||
{
|
||||
default_locale_id.write(0x407);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS handle_NtContinue(const syscall_context& c, const emulator_object<CONTEXT64> thread_context,
|
||||
const BOOLEAN /*raise_alert*/)
|
||||
{
|
||||
@@ -2818,12 +2833,13 @@ namespace
|
||||
io_status_block.write(block);
|
||||
}
|
||||
|
||||
c.win_emu.callbacks().stdout_callback(temp_buffer);
|
||||
|
||||
if (!temp_buffer.ends_with("\n"))
|
||||
{
|
||||
temp_buffer.push_back('\n');
|
||||
}
|
||||
|
||||
c.win_emu.callbacks().stdout_callback(temp_buffer);
|
||||
c.win_emu.log.info("%.*s", static_cast<int>(temp_buffer.size()), temp_buffer.data());
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
@@ -3902,6 +3918,7 @@ void syscall_dispatcher::add_handlers(std::map<std::string, syscall_handler>& ha
|
||||
add_handler(NtUserMoveWindow);
|
||||
add_handler(NtSystemDebugControl);
|
||||
add_handler(NtRequestWaitReplyPort);
|
||||
add_handler(NtQueryDefaultLocale);
|
||||
|
||||
#undef add_handler
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user