More syscalls

This commit is contained in:
momo5502
2024-09-22 11:21:49 +02:00
parent ba386a7928
commit 1f5e5c1fad
3 changed files with 38 additions and 1 deletions

View File

@@ -394,6 +394,7 @@ region_info memory_manager::get_region_info(const uint64_t address)
result.length = MAX_ALLOCATION_ADDRESS - result.start;
result.pemissions = memory_permission::none;
result.allocation_base = {};
result.allocation_length = result.length;
result.is_committed = false;
result.is_reserved = false;
@@ -424,8 +425,9 @@ region_info memory_manager::get_region_info(const uint64_t address)
result.is_reserved = true;
result.allocation_base = entry->first;
result.allocation_length = reserved_region.length;
result.start = result.allocation_base;
result.length = reserved_region.length;
result.length = result.allocation_length;
if (committed_regions.empty())
{

View File

@@ -8,6 +8,7 @@
struct region_info : basic_memory_region
{
uint64_t allocation_base{};
size_t allocation_length{};
bool is_reserved{};
bool is_committed{};
};

View File

@@ -644,6 +644,40 @@ namespace
return STATUS_SUCCESS;
}
if (info_class == MemoryRegionInformation)
{
if (return_length)
{
return_length.write(sizeof(MEMORY_REGION_INFORMATION));
}
if (memory_information_length != sizeof(MEMORY_REGION_INFORMATION))
{
return STATUS_BUFFER_OVERFLOW;
}
const auto region_info = c.emu.get_region_info(base_address);
if(!region_info.is_reserved)
{
return STATUS_INVALID_ADDRESS;
}
const emulator_object<MEMORY_REGION_INFORMATION> info{c.emu, memory_information};
info.access([&](MEMORY_REGION_INFORMATION& image_info)
{
memset(&image_info, 0, sizeof(image_info));
image_info.AllocationBase = reinterpret_cast<void*>(region_info.allocation_base);
image_info.AllocationProtect = 0;
image_info.PartitionId = 0;
image_info.RegionSize = region_info.allocation_length;
image_info.Reserved = 0x10;
});
return STATUS_SUCCESS;
}
printf("Unsupported memory info class: %X\n", info_class);
c.emu.stop();
return STATUS_NOT_SUPPORTED;