mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-18 19:23:56 +00:00
Support window creation
This commit is contained in:
@@ -161,6 +161,11 @@ class emulator_object
|
||||
return emulator_object<T>(*this->memory_, this->address_ + offset);
|
||||
}
|
||||
|
||||
memory_interface* get_memory_interface() const
|
||||
{
|
||||
return this->memory_;
|
||||
}
|
||||
|
||||
private:
|
||||
memory_interface* memory_{};
|
||||
uint64_t address_{};
|
||||
@@ -310,16 +315,22 @@ class emulator_allocator
|
||||
};
|
||||
|
||||
template <typename Element>
|
||||
std::basic_string<Element> read_string(memory_manager& mem, const uint64_t address)
|
||||
std::basic_string<Element> read_string(memory_interface& mem, const uint64_t address,
|
||||
const std::optional<size_t> size = {})
|
||||
{
|
||||
std::basic_string<Element> result{};
|
||||
|
||||
for (size_t i = 0;; ++i)
|
||||
{
|
||||
if (size && i >= *size)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
Element element{};
|
||||
mem.read_memory(address + (i * sizeof(element)), &element, sizeof(element));
|
||||
|
||||
if (!element)
|
||||
if (!size && !element)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -271,6 +271,7 @@ void process_context::serialize(utils::buffer_serializer& buffer) const
|
||||
buffer.write(this->semaphores);
|
||||
buffer.write(this->ports);
|
||||
buffer.write(this->mutants);
|
||||
buffer.write(this->windows);
|
||||
buffer.write(this->registry_keys);
|
||||
buffer.write_map(this->atoms);
|
||||
|
||||
@@ -309,6 +310,7 @@ void process_context::deserialize(utils::buffer_deserializer& buffer)
|
||||
buffer.read(this->semaphores);
|
||||
buffer.read(this->ports);
|
||||
buffer.read(this->mutants);
|
||||
buffer.read(this->windows);
|
||||
buffer.read(this->registry_keys);
|
||||
buffer.read_map(this->atoms);
|
||||
|
||||
|
||||
@@ -733,32 +733,41 @@ namespace syscalls
|
||||
return 0;
|
||||
}
|
||||
|
||||
hwnd handle_NtUserCreateWindowEx(const syscall_context& c, const DWORD ex_style,
|
||||
const emulator_object<LARGE_STRING> class_name,
|
||||
const emulator_object<LARGE_STRING> cls_version,
|
||||
const emulator_object<LARGE_STRING> window_name, const DWORD style, const int x,
|
||||
const int y, const int width, const int height, const hwnd parent,
|
||||
const hmenu menu, const hinstance instance, const pointer l_param,
|
||||
const DWORD flags, const pointer acbi_buffer)
|
||||
std::u16string read_large_string(const emulator_object<LARGE_STRING> str_obj)
|
||||
{
|
||||
(void)c;
|
||||
(void)ex_style;
|
||||
(void)class_name;
|
||||
(void)cls_version;
|
||||
(void)window_name;
|
||||
(void)style;
|
||||
(void)x;
|
||||
(void)y;
|
||||
(void)width;
|
||||
(void)height;
|
||||
(void)parent;
|
||||
(void)menu;
|
||||
(void)instance;
|
||||
(void)l_param;
|
||||
(void)flags;
|
||||
(void)acbi_buffer;
|
||||
if (!str_obj)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
return 1;
|
||||
const auto str = str_obj.read();
|
||||
if (!str.bAnsi)
|
||||
{
|
||||
return read_string<char16_t>(*str_obj.get_memory_interface(), str.Buffer, str.Length / 2);
|
||||
}
|
||||
|
||||
const auto ansi_string = read_string<char>(*str_obj.get_memory_interface(), str.Buffer, str.Length);
|
||||
return u8_to_u16(ansi_string);
|
||||
}
|
||||
|
||||
hwnd handle_NtUserCreateWindowEx(const syscall_context& c, const DWORD /*ex_style*/,
|
||||
const emulator_object<LARGE_STRING> class_name,
|
||||
const emulator_object<LARGE_STRING> /*cls_version*/,
|
||||
const emulator_object<LARGE_STRING> window_name, const DWORD /*style*/,
|
||||
const int x, const int y, const int width, const int height, const hwnd /*parent*/,
|
||||
const hmenu /*menu*/, const hinstance /*instance*/, const pointer /*l_param*/,
|
||||
const DWORD /*flags*/, const pointer /*acbi_buffer*/)
|
||||
{
|
||||
window win{};
|
||||
win.x = x;
|
||||
win.y = y;
|
||||
win.width = width;
|
||||
win.height = height;
|
||||
win.thread_id = c.win_emu.current_thread().id;
|
||||
win.class_name = read_large_string(class_name);
|
||||
win.name = read_large_string(window_name);
|
||||
|
||||
return c.proc.windows.store(std::move(win)).bits;
|
||||
}
|
||||
|
||||
ULONG handle_NtUserGetRawInputDeviceList()
|
||||
|
||||
@@ -44,10 +44,10 @@ struct window : ref_counted_object
|
||||
uint32_t thread_id{};
|
||||
std::u16string name{};
|
||||
std::u16string class_name{};
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t x;
|
||||
uint32_t y;
|
||||
int32_t width;
|
||||
int32_t height;
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
|
||||
void serialize_object(utils::buffer_serializer& buffer) const override
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user