mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-20 12:13:57 +00:00
More UI syscalls
This commit is contained in:
@@ -24,6 +24,7 @@ typedef struct _LARGE_STRING
|
||||
pointer Buffer;
|
||||
} LARGE_STRING;
|
||||
|
||||
using hdc = pointer;
|
||||
using hwnd = pointer;
|
||||
using hmenu = pointer;
|
||||
using hinstance = pointer;
|
||||
|
||||
@@ -363,6 +363,20 @@ handle process_context::create_thread(memory_manager& memory, const uint64_t sta
|
||||
return h;
|
||||
}
|
||||
|
||||
std::optional<uint16_t> process_context::find_atom(const std::u16string_view name)
|
||||
{
|
||||
for (auto& entry : this->atoms)
|
||||
{
|
||||
if (entry.second.name == name)
|
||||
{
|
||||
++entry.second.ref_count;
|
||||
return entry.first;
|
||||
}
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
uint16_t process_context::add_or_find_atom(std::u16string name)
|
||||
{
|
||||
uint16_t index = 1;
|
||||
|
||||
@@ -67,6 +67,7 @@ struct process_context
|
||||
handle create_thread(memory_manager& memory, uint64_t start_address, uint64_t argument, uint64_t stack_size,
|
||||
bool suspended);
|
||||
|
||||
std::optional<uint16_t> find_atom(std::u16string_view name);
|
||||
uint16_t add_or_find_atom(std::u16string name);
|
||||
bool delete_atom(const std::u16string& name);
|
||||
bool delete_atom(uint16_t atom_id);
|
||||
|
||||
@@ -574,6 +574,24 @@ namespace syscalls
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS handle_NtFindAtom(const syscall_context& c, const uint64_t atom_name, const ULONG length,
|
||||
const emulator_object<uint16_t> atom)
|
||||
{
|
||||
const auto name = read_string<char16_t>(c.emu, atom_name, length / 2);
|
||||
const auto index = c.proc.find_atom(name);
|
||||
if (!index)
|
||||
{
|
||||
return STATUS_OBJECT_NAME_NOT_FOUND;
|
||||
}
|
||||
|
||||
if (atom)
|
||||
{
|
||||
atom.write(*index);
|
||||
}
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS handle_NtUserGetAtomName(const syscall_context& c, const RTL_ATOM atom,
|
||||
const emulator_object<UNICODE_STRING<EmulatorTraits<Emu64>>> atom_name)
|
||||
{
|
||||
@@ -611,14 +629,15 @@ namespace syscalls
|
||||
return 96;
|
||||
}
|
||||
|
||||
NTSTATUS handle_NtUserGetDCEx()
|
||||
hdc handle_NtUserGetDCEx(const syscall_context& /*c*/, const hwnd window, const uint64_t /*clip_region*/,
|
||||
const ULONG /*flags*/)
|
||||
{
|
||||
return 1;
|
||||
return window;
|
||||
}
|
||||
|
||||
NTSTATUS handle_NtUserGetDC()
|
||||
hdc handle_NtUserGetDC(const syscall_context& c, const hwnd window)
|
||||
{
|
||||
return handle_NtUserGetDCEx();
|
||||
return handle_NtUserGetDCEx(c, window, 0, 0);
|
||||
}
|
||||
|
||||
NTSTATUS handle_NtUserGetWindowDC()
|
||||
@@ -770,6 +789,11 @@ namespace syscalls
|
||||
return c.proc.windows.store(std::move(win)).bits;
|
||||
}
|
||||
|
||||
BOOL handle_NtUserDestroyWindow(const syscall_context& c, const hwnd window)
|
||||
{
|
||||
return c.proc.windows.erase(window);
|
||||
}
|
||||
|
||||
BOOL handle_NtUserSetProp(const syscall_context& c, const hwnd window, const uint16_t atom, const uint64_t data)
|
||||
{
|
||||
auto* win = c.proc.windows.get(window);
|
||||
@@ -942,6 +966,7 @@ void syscall_dispatcher::add_handlers(std::map<std::string, syscall_handler>& ha
|
||||
add_handler(NtDxgkIsFeatureEnabled);
|
||||
add_handler(NtAddAtomEx);
|
||||
add_handler(NtAddAtom);
|
||||
add_handler(NtFindAtom);
|
||||
add_handler(NtDeleteAtom);
|
||||
add_handler(NtUserGetAtomName);
|
||||
add_handler(NtInitializeNlsFiles);
|
||||
@@ -1050,6 +1075,7 @@ void syscall_dispatcher::add_handlers(std::map<std::string, syscall_handler>& ha
|
||||
add_handler(NtUserSetProp);
|
||||
add_handler(NtUserSetProp2);
|
||||
add_handler(NtUserChangeWindowMessageFilterEx);
|
||||
add_handler(NtUserDestroyWindow);
|
||||
|
||||
#undef add_handler
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user