mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-28 23:41:03 +00:00
Prepare 32 bit support
This commit is contained in:
@@ -130,7 +130,7 @@ namespace syscalls
|
||||
|
||||
auto& enum_state = *f->enumeration_state;
|
||||
|
||||
size_t current_offset{0};
|
||||
uint64_t current_offset{0};
|
||||
emulator_object<T> object{c.emu};
|
||||
|
||||
size_t current_index = enum_state.current_index;
|
||||
@@ -400,7 +400,8 @@ namespace syscalls
|
||||
std::cin.readsome(temp_buffer.data(), static_cast<std::streamsize>(temp_buffer.size()));
|
||||
const auto count = std::max(read_count, static_cast<std::streamsize>(0));
|
||||
|
||||
commit_file_data(std::string_view(temp_buffer.data(), count), c.emu, io_status_block, buffer);
|
||||
commit_file_data(std::string_view(temp_buffer.data(), static_cast<size_t>(count)), c.emu, io_status_block,
|
||||
buffer);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -848,4 +849,4 @@ namespace syscalls
|
||||
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace syscalls
|
||||
return STATUS_FILE_INVALID;
|
||||
}
|
||||
|
||||
const auto size = page_align_up(locale_file.size());
|
||||
const auto size = static_cast<size_t>(page_align_up(locale_file.size()));
|
||||
const auto base = c.win_emu.memory.allocate_memory(size, memory_permission::read);
|
||||
c.emu.write_memory(base, locale_file.data(), locale_file.size());
|
||||
|
||||
@@ -58,4 +58,4 @@ namespace syscalls
|
||||
{
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,8 +41,8 @@ namespace syscalls
|
||||
assert(!region_info.is_committed || region_info.is_reserved);
|
||||
const auto state = region_info.is_reserved ? MEM_RESERVE : MEM_FREE;
|
||||
image_info.State = region_info.is_committed ? MEM_COMMIT : state;
|
||||
image_info.BaseAddress = reinterpret_cast<void*>(region_info.start);
|
||||
image_info.AllocationBase = reinterpret_cast<void*>(region_info.allocation_base);
|
||||
image_info.BaseAddress = region_info.start;
|
||||
image_info.AllocationBase = region_info.allocation_base;
|
||||
image_info.PartitionId = 0;
|
||||
image_info.RegionSize = static_cast<int64_t>(region_info.length);
|
||||
|
||||
@@ -151,7 +151,8 @@ namespace syscalls
|
||||
|
||||
try
|
||||
{
|
||||
c.win_emu.memory.protect_memory(aligned_start, aligned_length, requested_protection, &old_protection_value);
|
||||
c.win_emu.memory.protect_memory(aligned_start, static_cast<size_t>(aligned_length), requested_protection,
|
||||
&old_protection_value);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
@@ -183,7 +184,7 @@ namespace syscalls
|
||||
auto potential_base = base_address.read();
|
||||
if (!potential_base)
|
||||
{
|
||||
potential_base = c.win_emu.memory.find_free_allocation_base(allocation_bytes);
|
||||
potential_base = c.win_emu.memory.find_free_allocation_base(static_cast<size_t>(allocation_bytes));
|
||||
}
|
||||
|
||||
if (!potential_base)
|
||||
@@ -203,7 +204,8 @@ namespace syscalls
|
||||
throw std::runtime_error("Unsupported allocation type!");
|
||||
}
|
||||
|
||||
if (commit && !reserve && c.win_emu.memory.commit_memory(potential_base, allocation_bytes, protection))
|
||||
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);
|
||||
@@ -214,7 +216,8 @@ namespace syscalls
|
||||
c.win_emu.log.print(color::dark_gray, "--> Allocated 0x%" PRIx64 " - 0x%" PRIx64 "\n", potential_base,
|
||||
potential_base + allocation_bytes);
|
||||
|
||||
return c.win_emu.memory.allocate_memory(potential_base, allocation_bytes, protection, !commit)
|
||||
return c.win_emu.memory.allocate_memory(potential_base, static_cast<size_t>(allocation_bytes), protection,
|
||||
!commit)
|
||||
? STATUS_SUCCESS
|
||||
: STATUS_MEMORY_NOT_ALLOCATED;
|
||||
}
|
||||
@@ -242,14 +245,16 @@ namespace syscalls
|
||||
|
||||
if (free_type & MEM_RELEASE)
|
||||
{
|
||||
return c.win_emu.memory.release_memory(allocation_base, allocation_size) ? STATUS_SUCCESS
|
||||
: STATUS_MEMORY_NOT_ALLOCATED;
|
||||
return c.win_emu.memory.release_memory(allocation_base, static_cast<size_t>(allocation_size))
|
||||
? STATUS_SUCCESS
|
||||
: STATUS_MEMORY_NOT_ALLOCATED;
|
||||
}
|
||||
|
||||
if (free_type & MEM_DECOMMIT)
|
||||
{
|
||||
return c.win_emu.memory.decommit_memory(allocation_base, allocation_size) ? STATUS_SUCCESS
|
||||
: STATUS_MEMORY_NOT_ALLOCATED;
|
||||
return c.win_emu.memory.decommit_memory(allocation_base, static_cast<size_t>(allocation_size))
|
||||
? STATUS_SUCCESS
|
||||
: STATUS_MEMORY_NOT_ALLOCATED;
|
||||
}
|
||||
|
||||
throw std::runtime_error("Bad free type");
|
||||
@@ -284,4 +289,4 @@ namespace syscalls
|
||||
{
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,8 @@ namespace syscalls
|
||||
}
|
||||
|
||||
client_shared_memory.access([&](PORT_VIEW64& view) {
|
||||
p.view_base = c.win_emu.memory.allocate_memory(view.ViewSize, memory_permission::read_write);
|
||||
p.view_base =
|
||||
c.win_emu.memory.allocate_memory(static_cast<size_t>(view.ViewSize), memory_permission::read_write);
|
||||
view.ViewBase = p.view_base;
|
||||
view.ViewRemoteBase = view.ViewBase;
|
||||
});
|
||||
@@ -76,4 +77,4 @@ namespace syscalls
|
||||
{
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ namespace syscalls
|
||||
|
||||
const auto reserve_only = section_entry->allocation_attributes == SEC_RESERVE;
|
||||
const auto protection = map_nt_to_emulator_protection(section_entry->section_page_protection);
|
||||
const auto address = c.win_emu.memory.allocate_memory(size, protection, reserve_only);
|
||||
const auto address = c.win_emu.memory.allocate_memory(static_cast<size_t>(size), protection, reserve_only);
|
||||
|
||||
if (!reserve_only && !file_data.empty())
|
||||
{
|
||||
@@ -289,4 +289,4 @@ namespace syscalls
|
||||
{
|
||||
return handle_NtUnmapViewOfSection(c, process_handle, base_address);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user