mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-11 16:46:16 +00:00
Prepare UI support (#291)
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#include "registry.hpp"
|
||||
#include "network.hpp"
|
||||
#include "threading.hpp"
|
||||
#include "window.hpp"
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
@@ -22,6 +22,7 @@ using ULONG = DWORD;
|
||||
using DWORD64 = std::uint64_t;
|
||||
using ULONGLONG = DWORD64;
|
||||
using LONGLONG = std::int64_t;
|
||||
using UINT = std::uint32_t;
|
||||
|
||||
typedef union _ULARGE_INTEGER
|
||||
{
|
||||
|
||||
44
src/common/platform/window.hpp
Normal file
44
src/common/platform/window.hpp
Normal file
@@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
|
||||
// NOLINTBEGIN(modernize-use-using,cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
|
||||
|
||||
using pointer = uint64_t;
|
||||
|
||||
#ifndef OS_WINDOWS
|
||||
typedef struct tagPOINT
|
||||
{
|
||||
LONG x;
|
||||
LONG y;
|
||||
} POINT;
|
||||
#endif
|
||||
|
||||
using wparam = pointer;
|
||||
using lparam = pointer;
|
||||
using lresult = pointer;
|
||||
|
||||
typedef struct _LARGE_STRING
|
||||
{
|
||||
ULONG Length;
|
||||
ULONG MaximumLength : 31;
|
||||
ULONG bAnsi : 1;
|
||||
pointer Buffer;
|
||||
} LARGE_STRING;
|
||||
|
||||
using hwnd = pointer;
|
||||
using hmenu = pointer;
|
||||
using hinstance = pointer;
|
||||
|
||||
struct msg
|
||||
{
|
||||
hwnd window;
|
||||
UINT message;
|
||||
wparam wParam;
|
||||
lparam lParam;
|
||||
DWORD time;
|
||||
POINT pt;
|
||||
#ifdef _MAC
|
||||
DWORD lPrivate;
|
||||
#endif
|
||||
};
|
||||
|
||||
// NOLINTEND(modernize-use-using,cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
|
||||
@@ -139,11 +139,11 @@ T resolve_indexed_argument(x86_64_emulator& emu, size_t& index)
|
||||
return resolve_argument<T>(emu, index++);
|
||||
}
|
||||
|
||||
inline void write_syscall_status(const syscall_context& c, const NTSTATUS status, const uint64_t initial_ip)
|
||||
inline void write_syscall_result(const syscall_context& c, const uint64_t result, const uint64_t initial_ip)
|
||||
{
|
||||
if (c.write_status && !c.retrigger_syscall)
|
||||
{
|
||||
c.emu.reg<uint64_t>(x86_register::rax, static_cast<uint64_t>(status));
|
||||
c.emu.reg<uint64_t>(x86_register::rax, result);
|
||||
}
|
||||
|
||||
const auto new_ip = c.emu.read_instruction_pointer();
|
||||
@@ -158,11 +158,11 @@ inline void forward_syscall(const syscall_context& c, NTSTATUS (*handler)())
|
||||
const auto ip = c.emu.read_instruction_pointer();
|
||||
|
||||
const auto ret = handler();
|
||||
write_syscall_status(c, ret, ip);
|
||||
write_syscall_result(c, static_cast<uint64_t>(ret), ip);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void forward_syscall(const syscall_context& c, NTSTATUS (*handler)(const syscall_context&, Args...))
|
||||
template <typename Result, typename... Args>
|
||||
void forward_syscall(const syscall_context& c, Result (*handler)(const syscall_context&, Args...))
|
||||
{
|
||||
const auto ip = c.emu.read_instruction_pointer();
|
||||
|
||||
@@ -173,7 +173,7 @@ void forward_syscall(const syscall_context& c, NTSTATUS (*handler)(const syscall
|
||||
(void)index;
|
||||
|
||||
const auto ret = std::apply(handler, std::move(func_args));
|
||||
write_syscall_status(c, ret, ip);
|
||||
write_syscall_result(c, ret, ip);
|
||||
}
|
||||
|
||||
template <auto Handler>
|
||||
|
||||
@@ -718,18 +718,51 @@ namespace syscalls
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
NTSTATUS handle_NtUserCreateWindowEx()
|
||||
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)
|
||||
{
|
||||
(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;
|
||||
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
NTSTATUS handle_NtUserShowWindow()
|
||||
NTSTATUS handle_NtUserShowWindow(const syscall_context& c, const hwnd hwnd, const LONG cmd_show)
|
||||
{
|
||||
(void)c;
|
||||
(void)hwnd;
|
||||
(void)cmd_show;
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
NTSTATUS handle_NtUserGetMessage()
|
||||
NTSTATUS handle_NtUserGetMessage(const syscall_context& c, const emulator_object<msg> message, const hwnd hwnd,
|
||||
const UINT msg_filter_min, const UINT msg_filter_max)
|
||||
{
|
||||
(void)c;
|
||||
(void)message;
|
||||
(void)hwnd;
|
||||
(void)msg_filter_min;
|
||||
(void)msg_filter_max;
|
||||
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user