mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-11 16:46:16 +00:00
Some GDI fixes
This commit is contained in:
@@ -289,7 +289,7 @@ typedef struct _PEB64
|
||||
ULONG MaximumNumberOfHeaps;
|
||||
std::uint64_t** ProcessHeaps; // PHEAP
|
||||
|
||||
std::uint64_t* GdiSharedHandleTable; // PGDI_SHARED_MEMORY
|
||||
std::uint64_t GdiSharedHandleTable; // PGDI_SHARED_MEMORY
|
||||
std::uint64_t* ProcessStarterHelper;
|
||||
ULONG GdiDCAttributeList;
|
||||
|
||||
|
||||
@@ -846,8 +846,13 @@ struct GDI_HANDLE_ENTRY64
|
||||
struct GDI_SHARED_MEMORY64
|
||||
{
|
||||
GDI_HANDLE_ENTRY64 Handles[GDI_MAX_HANDLE_COUNT];
|
||||
char pad[0xC8];
|
||||
uint64_t Objects[0x20];
|
||||
uint64_t Data[0x200]; // ?
|
||||
};
|
||||
|
||||
static_assert(offsetof(GDI_SHARED_MEMORY64, Objects) == 0x1800B0);
|
||||
|
||||
struct CLIENT_ID64
|
||||
{
|
||||
DWORD64 UniqueProcess;
|
||||
|
||||
@@ -116,15 +116,25 @@ class emulator_object
|
||||
}
|
||||
}
|
||||
|
||||
template <typename F>
|
||||
void access_safe(const F& accessor, const size_t index = 0) const
|
||||
{
|
||||
auto obj = std::make_unique<T>();
|
||||
this->access_object(accessor, *obj, index);
|
||||
}
|
||||
|
||||
template <typename F>
|
||||
void access(const F& accessor, const size_t index = 0) const
|
||||
{
|
||||
T obj{};
|
||||
this->memory_->read_memory(this->address_ + index * this->size(), &obj, sizeof(obj));
|
||||
|
||||
accessor(obj);
|
||||
|
||||
this->write(obj, index);
|
||||
if constexpr (sizeof(T) < 0x4000)
|
||||
{
|
||||
T obj{};
|
||||
this->access_object(accessor, obj, index);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->access_safe(accessor, index);
|
||||
}
|
||||
}
|
||||
|
||||
void serialize(utils::buffer_serializer& buffer) const
|
||||
@@ -145,6 +155,16 @@ class emulator_object
|
||||
private:
|
||||
memory_interface* memory_{};
|
||||
uint64_t address_{};
|
||||
|
||||
template <typename F>
|
||||
void access_object(const F& accessor, T& obj, const size_t index = 0) const
|
||||
{
|
||||
this->memory_->read_memory(this->address_ + index * this->size(), &obj, sizeof(obj));
|
||||
|
||||
accessor(obj);
|
||||
|
||||
this->write(obj, index);
|
||||
}
|
||||
};
|
||||
|
||||
// TODO: warning emulator_utils is hardcoded for 64bit unicode_string usage
|
||||
|
||||
@@ -2669,8 +2669,14 @@ namespace
|
||||
c.proc.peb.access([&](PEB64& peb) {
|
||||
if (!peb.GdiSharedHandleTable)
|
||||
{
|
||||
peb.GdiSharedHandleTable = reinterpret_cast<EmulatorTraits<Emu64>::PVOID*>(
|
||||
c.proc.base_allocator.reserve<GDI_SHARED_MEMORY64>().ptr());
|
||||
const auto shared_memory = c.proc.base_allocator.reserve<GDI_SHARED_MEMORY64>();
|
||||
|
||||
shared_memory.access([](GDI_SHARED_MEMORY64& mem) {
|
||||
mem.Objects[0x12] = 1;
|
||||
mem.Objects[0x13] = 1;
|
||||
});
|
||||
|
||||
peb.GdiSharedHandleTable = shared_memory.value();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user