diff --git a/src/common/platform/process.hpp b/src/common/platform/process.hpp index c42c2792..ecc9ce2f 100644 --- a/src/common/platform/process.hpp +++ b/src/common/platform/process.hpp @@ -1012,4 +1012,33 @@ _Struct_size_bytes_(Size) struct EMU_SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX64 }; }; +struct EMU_CACHE_DESCRIPTOR +{ + BYTE Level; + BYTE Associativity; + WORD LineSize; + DWORD Size; + PROCESSOR_CACHE_TYPE Type; +}; + +template +struct EMU_SYSTEM_LOGICAL_PROCESSOR_INFORMATION +{ + typename Traits::ULONG_PTR ProcessorMask; + LOGICAL_PROCESSOR_RELATIONSHIP Relationship; + union + { + struct + { + BYTE Flags; + } ProcessorCore; + struct + { + DWORD NodeNumber; + } NumaNode; + EMU_CACHE_DESCRIPTOR Cache; + ULONGLONG Reserved[2]; + } DUMMYUNIONNAME; +}; + // NOLINTEND(modernize-use-using,cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) diff --git a/src/windows-emulator/syscalls.cpp b/src/windows-emulator/syscalls.cpp index 511b8eb6..d9e90609 100644 --- a/src/windows-emulator/syscalls.cpp +++ b/src/windows-emulator/syscalls.cpp @@ -986,8 +986,9 @@ namespace const emulator_object info_obj{c.emu, system_information}; - info_obj.access( - [&](SYSTEM_RANGE_START_INFORMATION64& info) { info.SystemRangeStart = 0xFFFF800000000000; }); + info_obj.access([&](SYSTEM_RANGE_START_INFORMATION64& info) { + info.SystemRangeStart = 0xFFFF800000000000; // + }); return STATUS_SUCCESS; } @@ -1169,12 +1170,47 @@ namespace { if (info_class == SystemFlushInformation || info_class == SystemFeatureConfigurationInformation || info_class == SystemSupportedProcessorArchitectures2 || - info_class == SystemFeatureConfigurationSectionInformation || - info_class == SystemLogicalProcessorInformation) + info_class == SystemFeatureConfigurationSectionInformation) { return STATUS_NOT_SUPPORTED; } + if (info_class == SystemLogicalProcessorInformation) + { + if (input_buffer_length != sizeof(USHORT)) + { + return STATUS_INVALID_PARAMETER; + } + + using INFO_TYPE = EMU_SYSTEM_LOGICAL_PROCESSOR_INFORMATION>; + + const auto processor_group = c.emu.read_memory(input_buffer); + constexpr auto required_size = sizeof(INFO_TYPE); + + if (return_length) + { + return_length.write(required_size); + } + + if (system_information_length < required_size) + { + return STATUS_INFO_LENGTH_MISMATCH; + } + + INFO_TYPE information{}; + information.Relationship = RelationProcessorCore; + + if (processor_group == 0) + { + const auto active_processor_count = c.proc.kusd.get().ActiveProcessorCount; + information.ProcessorMask = + (static_cast(1) << active_processor_count) - 1; + } + + c.emu.write_memory(system_information, information); + return STATUS_SUCCESS; + } + if (info_class == SystemLogicalProcessorAndGroupInformation) { if (input_buffer_length != sizeof(LOGICAL_PROCESSOR_RELATIONSHIP))