mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-11 16:46:16 +00:00
Add more syscalls
This commit is contained in:
@@ -957,4 +957,39 @@ struct PROCESS_TLS_INFO
|
||||
|
||||
static_assert(sizeof(PROCESS_TLS_INFO) - sizeof(THREAD_TLS_INFO) == 0x10);
|
||||
|
||||
struct EMU_GENERIC_MAPPING
|
||||
{
|
||||
ACCESS_MASK GenericRead;
|
||||
ACCESS_MASK GenericWrite;
|
||||
ACCESS_MASK GenericExecute;
|
||||
ACCESS_MASK GenericAll;
|
||||
};
|
||||
|
||||
struct OBJECT_TYPE_INFORMATION
|
||||
{
|
||||
STRING64 TypeName;
|
||||
ULONG TotalNumberOfObjects;
|
||||
ULONG TotalNumberOfHandles;
|
||||
ULONG TotalPagedPoolUsage;
|
||||
ULONG TotalNonPagedPoolUsage;
|
||||
ULONG TotalNamePoolUsage;
|
||||
ULONG TotalHandleTableUsage;
|
||||
ULONG HighWaterNumberOfObjects;
|
||||
ULONG HighWaterNumberOfHandles;
|
||||
ULONG HighWaterPagedPoolUsage;
|
||||
ULONG HighWaterNonPagedPoolUsage;
|
||||
ULONG HighWaterNamePoolUsage;
|
||||
ULONG HighWaterHandleTableUsage;
|
||||
ULONG InvalidAttributes;
|
||||
EMU_GENERIC_MAPPING GenericMapping;
|
||||
ULONG ValidAccessMask;
|
||||
BOOLEAN SecurityRequired;
|
||||
BOOLEAN MaintainHandleCount;
|
||||
UCHAR TypeIndex; // since WINBLUE
|
||||
CHAR ReservedByte;
|
||||
ULONG PoolType;
|
||||
ULONG DefaultPagedPoolCharge;
|
||||
ULONG DefaultNonPagedPoolCharge;
|
||||
};
|
||||
|
||||
// NOLINTEND(modernize-use-using,cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
|
||||
|
||||
@@ -611,6 +611,11 @@ namespace syscalls
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
NTSTATUS handle_NtCreateDebugObject()
|
||||
{
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
NTSTATUS handle_NtAddAtomEx(const syscall_context& c, const uint64_t atom_name, const ULONG length,
|
||||
const emulator_object<RTL_ATOM> atom, const ULONG /*flags*/)
|
||||
{
|
||||
@@ -1179,6 +1184,7 @@ void syscall_dispatcher::add_handlers(std::map<std::string, syscall_handler>& ha
|
||||
add_handler(NtQuerySecurityObject);
|
||||
add_handler(NtQueryEvent);
|
||||
add_handler(NtRemoveIoCompletionEx);
|
||||
add_handler(NtCreateDebugObject);
|
||||
|
||||
#undef add_handler
|
||||
}
|
||||
|
||||
@@ -63,6 +63,43 @@ namespace syscalls
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
std::u16string get_type_name(const handle_types::type type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case handle_types::file:
|
||||
return u"File";
|
||||
case handle_types::device:
|
||||
return u"Device";
|
||||
case handle_types::event:
|
||||
return u"Event";
|
||||
case handle_types::section:
|
||||
return u"Section";
|
||||
case handle_types::symlink:
|
||||
return u"Symlink";
|
||||
case handle_types::directory:
|
||||
return u"Directory";
|
||||
case handle_types::semaphore:
|
||||
return u"Semaphore";
|
||||
case handle_types::port:
|
||||
return u"Port";
|
||||
case handle_types::thread:
|
||||
return u"Thread";
|
||||
case handle_types::registry:
|
||||
return u"Registry";
|
||||
case handle_types::mutant:
|
||||
return u"Mutant";
|
||||
case handle_types::token:
|
||||
return u"Token";
|
||||
case handle_types::window:
|
||||
return u"Window";
|
||||
case handle_types::timer:
|
||||
return u"Timer";
|
||||
default:
|
||||
return u"";
|
||||
}
|
||||
}
|
||||
|
||||
NTSTATUS handle_NtQueryObject(const syscall_context& c, const handle handle,
|
||||
const OBJECT_INFORMATION_CLASS object_information_class,
|
||||
const emulator_pointer object_information, const ULONG object_information_length,
|
||||
@@ -100,7 +137,7 @@ namespace syscalls
|
||||
}
|
||||
|
||||
const auto required_size = sizeof(UNICODE_STRING<EmulatorTraits<Emu64>>) + (device_path.size() + 1) * 2;
|
||||
return_length.write(static_cast<ULONG>(required_size));
|
||||
return_length.write_if_valid(static_cast<ULONG>(required_size));
|
||||
|
||||
if (required_size > object_information_length)
|
||||
{
|
||||
@@ -113,6 +150,27 @@ namespace syscalls
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (object_information_class == ObjectTypeInformation)
|
||||
{
|
||||
const auto name = get_type_name(static_cast<handle_types::type>(handle.value.type));
|
||||
|
||||
const auto required_size = 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 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,
|
||||
|
||||
Reference in New Issue
Block a user