Support object types information query

This commit is contained in:
momo5502
2025-09-12 20:36:45 +02:00
parent 20a4df5632
commit c9c6b46ec2
3 changed files with 44 additions and 0 deletions

View File

@@ -1059,6 +1059,11 @@ struct EMU_GENERIC_MAPPING
ACCESS_MASK GenericAll;
};
struct OBJECT_TYPES_INFORMATION
{
ULONG NumberOfTypes;
};
struct OBJECT_TYPE_INFORMATION
{
STRING64 TypeName;

View File

@@ -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_{};

View File

@@ -159,6 +159,35 @@ namespace syscalls
return STATUS_SUCCESS;
}
if (object_information_class == ObjectTypesInformation)
{
const auto name = get_type_name(static_cast<handle_types::type>(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<ULONG>(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<OBJECT_TYPES_INFORMATION>();
types_info.access([&](OBJECT_TYPES_INFORMATION& i) {
i.NumberOfTypes = 1; //
});
allocator.skip_until(type_start_offset);
const auto info = allocator.reserve<OBJECT_TYPE_INFORMATION>();
info.access([&](OBJECT_TYPE_INFORMATION& i) {
allocator.make_unicode_string(i.TypeName, name); //
});
return STATUS_SUCCESS;
}
if (object_information_class == ObjectHandleFlagInformation)
{
return handle_query<OBJECT_HANDLE_FLAG_INFORMATION>(c.emu, object_information, object_information_length, return_length,