Prepare 32 bit support

This commit is contained in:
Maurice Heumann
2025-04-14 12:13:38 +02:00
parent 35945caeec
commit a6dd9251b8
29 changed files with 111 additions and 80 deletions

View File

@@ -12,7 +12,7 @@ if (NOT MOMO_BUILD_AS_LIBRARY)
add_subdirectory(fuzzing-engine)
add_subdirectory(fuzzer)
add_subdirectory(windows-emulator-test)
if(WIN32)
if(WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 8)
momo_add_subdirectory_and_get_targets("tools" TOOL_TARGETS)
momo_targets_set_folder("tools" ${TOOL_TARGETS})

View File

@@ -10,7 +10,7 @@ emulator_hook* watch_object(windows_emulator& emu, const std::set<std::string, s
const reflect_type_info<T> info{};
return emu.emu().hook_memory_read(
object.value(), object.size(),
object.value(), static_cast<size_t>(object.size()),
[i = std::move(info), object, &emu, cache_logging, modules](const uint64_t address, const void*, size_t) {
const auto rip = emu.emu().read_instruction_pointer();
const auto* mod = emu.mod_manager.find_by_address(rip);
@@ -33,6 +33,7 @@ emulator_hook* watch_object(windows_emulator& emu, const std::set<std::string, s
const auto offset = address - object.value();
emu.log.print(is_main_access ? color::green : color::dark_gray,
"Object access: %s - 0x%llX (%s) at 0x%llX (%s)\n", i.get_type_name().c_str(), offset,
i.get_member_name(offset).c_str(), rip, mod ? mod->name.c_str() : "<N/A>");
i.get_member_name(static_cast<size_t>(offset)).c_str(), rip,
mod ? mod->name.c_str() : "<N/A>");
});
}

View File

@@ -11,9 +11,18 @@
#pragma clang diagnostic ignored "-Wunused-private-field"
#endif
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4308)
#endif
#include "reflect_extension.hpp"
#include <reflect>
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#if defined(__clang__)
#pragma clang diagnostic pop
#endif

View File

@@ -13,7 +13,9 @@ endif()
set(CARGO_TRIPLE)
set(CARGO_OPTIONS)
if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
if(WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 4)
set(CARGO_TRIPLE "i686-pc-windows-msvc")
elseif(CMAKE_SYSTEM_NAME STREQUAL "iOS")
set(CARGO_TRIPLE "aarch64-apple-ios")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
if(CMAKE_ANDROID_ARCH_ABI STREQUAL "arm64-v8a")

View File

@@ -2,6 +2,13 @@
#if defined(_WIN32) || defined(_WIN64)
#define OS_WINDOWS
#if defined(_WIN64)
#define OS_WINDOWS_64
#else
#define OS_WINDOWS_32
#endif
#elif defined(__APPLE__) || defined(__MACH__)
#define OS_MAC
#elif defined(__linux__)

View File

@@ -583,7 +583,7 @@ typedef struct _TEB64
ARRAY_CONTAINER<ULONG, 2> Rcu;
} TEB64, *PTEB64;
#ifdef OS_WINDOWS
#if defined(OS_WINDOWS) && defined(_WIN64)
inline TEB64* NtCurrentTeb64()
{
return reinterpret_cast<TEB64*>(__readgsqword(FIELD_OFFSET(EMU_NT_TIB64, Self)));

View File

@@ -66,8 +66,8 @@ typedef enum _SECTION_INHERIT
typedef struct DECLSPEC_ALIGN(16) _EMU_MEMORY_BASIC_INFORMATION64
{
void* BaseAddress;
void* AllocationBase;
uint64_t BaseAddress;
uint64_t AllocationBase;
DWORD AllocationProtect;
WORD PartitionId;
std::int64_t RegionSize;

View File

@@ -553,13 +553,15 @@ struct SYSTEM_PROCESSOR_INFORMATION64
ULONG ProcessorFeatureBits;
};
#ifndef OS_WINDOWS
#if !defined(OS_WINDOWS) || !defined(_WIN64)
#if !defined(OS_WINDOWS)
typedef struct _M128A
{
ULONGLONG Low;
LONGLONG High;
} M128A, *PM128A;
#endif
typedef struct _XMM_SAVE_AREA32
{

View File

@@ -378,7 +378,7 @@ namespace utils
{
const auto size = this->read<uint64_t>();
result.clear();
result.reserve(size);
result.reserve(static_cast<size_t>(size));
for (uint64_t i = 0; i < size; ++i)
{
@@ -447,7 +447,7 @@ namespace utils
const auto size = this->read<uint64_t>();
result.clear();
result.reserve(size);
result.reserve(static_cast<size_t>(size));
for (uint64_t i = 0; i < size; ++i)
{

View File

@@ -5,6 +5,10 @@
#include "utils/finally.hpp"
#ifdef _MSC_VER
#pragma warning(disable : 4702)
#endif
bool use_gdb = false;
namespace
@@ -63,12 +67,6 @@ namespace
utils::buffer_deserializer deserializer{emulator_data};
emu.deserialize(deserializer);
emu.save_snapshot();
const auto ret = emu.emu().read_stack(0);
emu.emu().hook_memory_execution(ret, [&](uint64_t) {
emu.emu().stop(); //
});
}
void restore_emulator()
@@ -87,8 +85,9 @@ namespace
restore_emulator();
const auto memory = emu.memory.allocate_memory(page_align_up(std::max(data.size(), static_cast<size_t>(1))),
memory_permission::read_write);
const auto memory = emu.memory.allocate_memory(
static_cast<size_t>(page_align_up(std::max(data.size(), static_cast<size_t>(1)))),
memory_permission::read_write);
emu.emu().write_memory(memory, data.data(), data.size());
emu.emu().reg(x64_register::rcx, memory);

View File

@@ -16,7 +16,7 @@ target_link_libraries(windows-emulator-test PRIVATE
windows-emulator
)
if(WIN32)
if(WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 8)
add_dependencies(windows-emulator-test test-sample)
endif()

View File

@@ -34,7 +34,7 @@ namespace test
constexpr auto offset = 1;
const auto instructionsToExecute = executedInstructions - offset;
new_emu.start(instructionsToExecute);
new_emu.start(static_cast<size_t>(instructionsToExecute));
ASSERT_EQ(new_emu.get_executed_instructions(), instructionsToExecute);
ASSERT_NOT_TERMINATED(new_emu);

View File

@@ -155,7 +155,7 @@ namespace test
return s1.get_diff(s2).has_value();
};
if (!has_diff_after_count(limit))
if (!has_diff_after_count(static_cast<size_t>(limit)))
{
puts("Emulation has no diff");
}
@@ -170,7 +170,7 @@ namespace test
const auto diff = (upper_bound - lower_bound);
const auto pivot = lower_bound + (diff / 2);
const auto has_diff = has_diff_after_count(pivot);
const auto has_diff = has_diff_after_count(static_cast<size_t>(pivot));
auto* bound = has_diff ? &upper_bound : &lower_bound;
*bound = pivot;
@@ -178,7 +178,7 @@ namespace test
printf("Bounds: %" PRIx64 " - %" PRIx64 "\n", lower_bound, upper_bound);
}
(void)get_state_for_count(lower_bound);
(void)get_state_for_count(static_cast<size_t>(lower_bound));
const auto rip = emu.emu().read_instruction_pointer();

View File

@@ -57,7 +57,7 @@ namespace apiset
{
switch (location)
{
#ifdef OS_WINDOWS
#ifdef OS_WINDOWS_64
case location::host: {
const auto apiSetMap =
reinterpret_cast<const API_SET_NAMESPACE*>(NtCurrentTeb64()->ProcessEnvironmentBlock->ApiSetMap);

View File

@@ -93,7 +93,7 @@ emulator_thread::emulator_thread(memory_manager& memory, const process_context&
suspended(suspended),
last_registers(context.default_register_set)
{
this->stack_base = memory.allocate_memory(this->stack_size, memory_permission::read_write);
this->stack_base = memory.allocate_memory(static_cast<size_t>(this->stack_size), memory_permission::read_write);
this->gs_segment = emulator_allocator{
memory,
@@ -214,7 +214,7 @@ void emulator_thread::setup_registers(x64_emulator& emu, const process_context&
throw std::runtime_error("Missing GS segment");
}
setup_stack(emu, this->stack_base, this->stack_size);
setup_stack(emu, this->stack_base, static_cast<size_t>(this->stack_size));
emu.set_segment_base(x64_register::gs, this->gs_segment->get_base());
CONTEXT64 ctx{};

View File

@@ -227,7 +227,7 @@ class emulator_thread : public ref_counted_object
throw std::runtime_error("Emulator was never assigned!");
}
this->memory_ptr->release_memory(this->stack_base, this->stack_size);
this->memory_ptr->release_memory(this->stack_base, static_cast<size_t>(this->stack_size));
this->stack_base = 0;
}

View File

@@ -300,7 +300,8 @@ class emulator_allocator
{
if (this->address_ && this->size_)
{
manager.release_memory(this->address_, this->size_);
// TODO: Make all sizes uint64_t
manager.release_memory(this->address_, static_cast<size_t>(this->size_));
this->address_ = 0;
this->size_ = 0;
}

View File

@@ -109,7 +109,7 @@ namespace
assert(total_size >= allocation_size);
std::vector<uint8_t> zero_memory{};
zero_memory.resize(total_size, 0);
zero_memory.resize(static_cast<size_t>(total_size), 0);
emu.write_memory(new_sp, zero_memory.data(), zero_memory.size());

View File

@@ -144,7 +144,7 @@ void kusd_mmio::read(const uint64_t addr, void* data, const size_t size)
const auto real_size = valid_end - addr;
const auto* kusd_buffer = reinterpret_cast<uint8_t*>(&this->kusd_);
memcpy(data, kusd_buffer + addr, real_size);
memcpy(data, kusd_buffer + addr, static_cast<size_t>(real_size));
}
uint64_t kusd_mmio::address()

View File

@@ -22,9 +22,10 @@ namespace
const auto first_length = split_point - i->first;
const auto second_length = i->second.length - first_length;
i->second.length = first_length;
i->second.length = static_cast<size_t>(first_length);
regions[split_point] = memory_manager::committed_region{second_length, i->second.permissions};
regions[split_point] =
memory_manager::committed_region{static_cast<size_t>(second_length), i->second.permissions};
}
}
}
@@ -312,8 +313,8 @@ bool memory_manager::commit_memory(const uint64_t address, const size_t size, co
if (map_length > 0)
{
this->map_memory(map_start, map_length, permissions);
committed_regions[map_start] = committed_region{map_length, permissions};
this->map_memory(map_start, static_cast<size_t>(map_length), permissions);
committed_regions[map_start] = committed_region{static_cast<size_t>(map_length), permissions};
}
last_region_start = sub_region.first;
@@ -326,8 +327,8 @@ bool memory_manager::commit_memory(const uint64_t address, const size_t size, co
const auto map_start = last_region ? (last_region_start + last_region->length) : address;
const auto map_length = end - map_start;
this->map_memory(map_start, map_length, permissions);
committed_regions[map_start] = committed_region{map_length, permissions};
this->map_memory(map_start, static_cast<size_t>(map_length), permissions);
committed_regions[map_start] = committed_region{static_cast<size_t>(map_length), permissions};
}
merge_regions(committed_regions);
@@ -398,7 +399,7 @@ bool memory_manager::release_memory(const uint64_t address, size_t size)
size = entry->second.length;
}
size = page_align_up(size);
size = static_cast<size_t>(page_align_up(size));
if (size > entry->second.length)
{
@@ -498,7 +499,7 @@ region_info memory_manager::get_region_info(const uint64_t address)
{
region_info result{};
result.start = MIN_ALLOCATION_ADDRESS;
result.length = MAX_ALLOCATION_ADDRESS - result.start;
result.length = static_cast<size_t>(MAX_ALLOCATION_ADDRESS - result.start);
result.permissions = memory_permission::none;
result.initial_permissions = memory_permission::none;
result.allocation_base = {};
@@ -514,7 +515,7 @@ region_info memory_manager::get_region_info(const uint64_t address)
auto upper_bound = this->reserved_regions_.upper_bound(address);
if (upper_bound == this->reserved_regions_.begin())
{
result.length = upper_bound->first - result.start;
result.length = static_cast<size_t>(upper_bound->first - result.start);
return result;
}
@@ -523,7 +524,7 @@ region_info memory_manager::get_region_info(const uint64_t address)
if (lower_end <= address)
{
result.start = lower_end;
result.length = MAX_ALLOCATION_ADDRESS - result.start;
result.length = static_cast<size_t>(MAX_ALLOCATION_ADDRESS - result.start);
return result;
}
@@ -546,7 +547,7 @@ region_info memory_manager::get_region_info(const uint64_t address)
auto committed_bound = committed_regions.upper_bound(address);
if (committed_bound == committed_regions.begin())
{
result.length = committed_bound->first - result.start;
result.length = static_cast<size_t>(committed_bound->first - result.start);
return result;
}
@@ -555,7 +556,7 @@ region_info memory_manager::get_region_info(const uint64_t address)
if (committed_lower_end <= address)
{
result.start = committed_lower_end;
result.length = lower_end - result.start;
result.length = static_cast<size_t>(lower_end - result.start);
return result;
}

View File

@@ -10,9 +10,9 @@ namespace
uint64_t get_first_section_offset(const PENTHeaders_t<std::uint64_t>& nt_headers, const uint64_t nt_headers_offset)
{
const auto* nt_headers_addr = reinterpret_cast<const uint8_t*>(&nt_headers);
size_t optional_header_offset =
const size_t optional_header_offset =
reinterpret_cast<uintptr_t>(&(nt_headers.OptionalHeader)) - reinterpret_cast<uintptr_t>(&nt_headers);
size_t optional_header_size = nt_headers.FileHeader.SizeOfOptionalHeader;
const size_t optional_header_size = nt_headers.FileHeader.SizeOfOptionalHeader;
const auto* first_section_addr = nt_headers_addr + optional_header_offset + optional_header_size;
const auto first_section_absolute = reinterpret_cast<uint64_t>(first_section_addr);
@@ -23,7 +23,7 @@ namespace
std::vector<std::byte> read_mapped_memory(const memory_manager& memory, const mapped_module& binary)
{
std::vector<std::byte> mem{};
mem.resize(binary.size_of_image);
mem.resize(static_cast<size_t>(binary.size_of_image));
memory.read_memory(binary.image_base, mem.data(), mem.size());
return mem;
@@ -73,7 +73,7 @@ namespace
void apply_relocation(const utils::safe_buffer_accessor<std::byte> buffer, const uint64_t offset,
const uint64_t delta)
{
const auto obj = buffer.as<T>(offset);
const auto obj = buffer.as<T>(static_cast<size_t>(offset));
const auto value = obj.get();
const auto new_value = value + static_cast<T>(delta);
obj.set(new_value);
@@ -146,7 +146,7 @@ namespace
const PENTHeaders_t<std::uint64_t>& nt_headers, const uint64_t nt_headers_offset)
{
const auto first_section_offset = get_first_section_offset(nt_headers, nt_headers_offset);
const auto sections = buffer.as<IMAGE_SECTION_HEADER>(first_section_offset);
const auto sections = buffer.as<IMAGE_SECTION_HEADER>(static_cast<size_t>(first_section_offset));
for (size_t i = 0; i < nt_headers.FileHeader.NumberOfSections; ++i)
{
@@ -179,11 +179,11 @@ namespace
const auto size_of_section = page_align_up(std::max(section.SizeOfRawData, section.Misc.VirtualSize));
memory.protect_memory(target_ptr, size_of_section, permissions, nullptr);
memory.protect_memory(target_ptr, static_cast<size_t>(size_of_section), permissions, nullptr);
mapped_section section_info{};
section_info.region.start = target_ptr;
section_info.region.length = size_of_section;
section_info.region.length = static_cast<size_t>(size_of_section);
section_info.region.permissions = permissions;
for (size_t j = 0; j < sizeof(section.Name) && section.Name[j]; ++j)
@@ -219,21 +219,22 @@ mapped_module map_module_from_data(memory_manager& memory, const std::span<const
binary.image_base = optional_header.ImageBase;
binary.size_of_image = page_align_up(optional_header.SizeOfImage); // TODO: Sanitize
if (!memory.allocate_memory(binary.image_base, binary.size_of_image, memory_permission::all))
if (!memory.allocate_memory(binary.image_base, static_cast<size_t>(binary.size_of_image), memory_permission::all))
{
binary.image_base = memory.find_free_allocation_base(binary.size_of_image);
binary.image_base = memory.find_free_allocation_base(static_cast<size_t>(binary.size_of_image));
const auto is_dll = nt_headers.FileHeader.Characteristics & IMAGE_FILE_DLL;
const auto has_dynamic_base = optional_header.DllCharacteristics & IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE;
const auto is_relocatable = is_dll || has_dynamic_base;
if (!is_relocatable || !memory.allocate_memory(binary.image_base, binary.size_of_image, memory_permission::all))
if (!is_relocatable || !memory.allocate_memory(binary.image_base, static_cast<size_t>(binary.size_of_image),
memory_permission::all))
{
throw std::runtime_error("Memory range not allocatable");
}
}
// TODO: Make sure to match kernel allocation patterns to attain correct initial permissions!
memory.protect_memory(binary.image_base, binary.size_of_image, memory_permission::read);
memory.protect_memory(binary.image_base, static_cast<size_t>(binary.size_of_image), memory_permission::read);
binary.entry_point = binary.image_base + optional_header.AddressOfEntryPoint;
@@ -266,5 +267,5 @@ mapped_module map_module_from_file(memory_manager& memory, std::filesystem::path
bool unmap_module(memory_manager& memory, const mapped_module& mod)
{
return memory.release_memory(mod.image_base, mod.size_of_image);
return memory.release_memory(mod.image_base, static_cast<size_t>(mod.size_of_image));
}

View File

@@ -54,7 +54,8 @@ inline std::optional<uint32_t> extract_syscall_id(const exported_symbol& symbol,
const auto instruction_rva = symbol.rva + instruction_offset;
if (data.size() < (instruction_rva + instruction_size) || data[instruction_rva] != instruction_opcode)
if (data.size() < (instruction_rva + instruction_size) ||
data[static_cast<size_t>(instruction_rva)] != instruction_opcode)
{
return std::nullopt;
}

View File

@@ -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;
}
}
}

View File

@@ -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;
}
}
}

View File

@@ -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;
}
}
}

View File

@@ -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;
}
}
}

View File

@@ -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);
}
}
}

View File

@@ -341,8 +341,8 @@ void windows_emulator::setup_process(const application_settings& app_settings)
this->process.setup(this->emu(), this->memory, app_settings, *executable, *ntdll, apiset_data);
const auto ntdll_data = emu.read_memory(ntdll->image_base, ntdll->size_of_image);
const auto win32u_data = emu.read_memory(win32u->image_base, win32u->size_of_image);
const auto ntdll_data = emu.read_memory(ntdll->image_base, static_cast<size_t>(ntdll->size_of_image));
const auto win32u_data = emu.read_memory(win32u->image_base, static_cast<size_t>(win32u->size_of_image));
this->dispatcher.setup(ntdll->exports, ntdll_data, win32u->exports, win32u_data);
@@ -601,7 +601,7 @@ void windows_emulator::start(size_t count)
break;
}
count = target_instructions - current_instructions;
count = static_cast<size_t>(target_instructions - current_instructions);
}
}
}

View File

@@ -10,7 +10,7 @@
struct breakpoint_key
{
size_t addr{};
uint64_t addr{};
size_t size{};
gdb_stub::breakpoint_type type{};
@@ -25,7 +25,7 @@ struct std::hash<breakpoint_key>
{
std::size_t operator()(const breakpoint_key& k) const noexcept
{
return ((std::hash<size_t>()(k.addr) ^ (std::hash<size_t>()(k.size) << 1)) >> 1) ^
return ((std::hash<uint64_t>()(k.addr) ^ (std::hash<size_t>()(k.size) << 1)) >> 1) ^
(std::hash<size_t>()(static_cast<size_t>(k.type)) << 1);
}
};