diff --git a/src/common/platform/kernel_mapped.hpp b/src/common/platform/kernel_mapped.hpp index 10876cfe..a7309058 100644 --- a/src/common/platform/kernel_mapped.hpp +++ b/src/common/platform/kernel_mapped.hpp @@ -1059,6 +1059,11 @@ struct EMU_GENERIC_MAPPING ACCESS_MASK GenericAll; }; +struct OBJECT_TYPES_INFORMATION +{ + ULONG NumberOfTypes; +}; + struct OBJECT_TYPE_INFORMATION { STRING64 TypeName; diff --git a/src/windows-emulator/emulator_utils.hpp b/src/windows-emulator/emulator_utils.hpp index 97c07605..7ccd3129 100644 --- a/src/windows-emulator/emulator_utils.hpp +++ b/src/windows-emulator/emulator_utils.hpp @@ -308,6 +308,16 @@ class emulator_allocator } } + void skip(const uint64_t bytes) + { + this->active_address_ += bytes; + } + + void skip_until(const uint64_t offset) + { + this->active_address_ = offset; + } + private: memory_interface* memory_{}; uint64_t address_{}; diff --git a/src/windows-emulator/syscalls/object.cpp b/src/windows-emulator/syscalls/object.cpp index c7430c06..c1b9e5d4 100644 --- a/src/windows-emulator/syscalls/object.cpp +++ b/src/windows-emulator/syscalls/object.cpp @@ -159,6 +159,35 @@ namespace syscalls return STATUS_SUCCESS; } + if (object_information_class == ObjectTypesInformation) + { + const auto name = get_type_name(static_cast(handle.value.type)); + constexpr auto type_start_offset = align_up(sizeof(OBJECT_TYPES_INFORMATION), sizeof(uint64_t)); + + const auto required_size = type_start_offset + sizeof(OBJECT_TYPE_INFORMATION) + (name.size() + 1) * 2; + return_length.write_if_valid(static_cast(required_size)); + + if (required_size > object_information_length) + { + return STATUS_BUFFER_TOO_SMALL; + } + + emulator_allocator allocator(c.emu, object_information, object_information_length); + const auto types_info = allocator.reserve(); + types_info.access([&](OBJECT_TYPES_INFORMATION& i) { + i.NumberOfTypes = 1; // + }); + + allocator.skip_until(type_start_offset); + + const auto info = allocator.reserve(); + info.access([&](OBJECT_TYPE_INFORMATION& i) { + allocator.make_unicode_string(i.TypeName, name); // + }); + + return STATUS_SUCCESS; + } + if (object_information_class == ObjectHandleFlagInformation) { return handle_query(c.emu, object_information, object_information_length, return_length,