mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-31 00:11:02 +00:00
Merge remote-tracking branch 'origin/main' into multi-platform-support
# Conflicts: # src/analyzer/main.cpp # src/emulator/memory_region.hpp # src/windows-emulator/io_device.cpp # src/windows-emulator/module/module_mapping.cpp # src/windows-emulator/process_context.hpp # src/windows-emulator/syscalls.cpp # src/windows-emulator/windows_emulator.cpp
This commit is contained in:
@@ -15,6 +15,8 @@ struct handle_types
|
||||
port,
|
||||
thread,
|
||||
registry,
|
||||
mutant,
|
||||
token,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -24,7 +26,8 @@ struct handle_value
|
||||
{
|
||||
uint64_t id : 32;
|
||||
uint64_t type : 16;
|
||||
uint64_t padding : 15;
|
||||
uint64_t padding : 14;
|
||||
uint64_t is_system : 1;
|
||||
uint64_t is_pseudo : 1;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
@@ -73,11 +76,19 @@ constexpr handle make_handle(const uint32_t id, const handle_types::type type, c
|
||||
value.padding = 0;
|
||||
value.id = id;
|
||||
value.type = type;
|
||||
value.is_system = false;
|
||||
value.is_pseudo = is_pseudo;
|
||||
|
||||
return {value};
|
||||
}
|
||||
|
||||
constexpr handle make_handle(const uint64_t value)
|
||||
{
|
||||
handle h{};
|
||||
h.bits = value;
|
||||
return h;
|
||||
}
|
||||
|
||||
constexpr handle make_pseudo_handle(const uint32_t id, const handle_types::type type)
|
||||
{
|
||||
return make_handle(id, type, true);
|
||||
@@ -97,9 +108,15 @@ namespace handle_detail
|
||||
};
|
||||
}
|
||||
|
||||
struct generic_handle_store
|
||||
{
|
||||
virtual ~generic_handle_store() = default;
|
||||
virtual bool erase(const handle h) = 0;
|
||||
};
|
||||
|
||||
template <handle_types::type Type, typename T, uint32_t IndexShift = 0>
|
||||
requires(utils::Serializable<T>)
|
||||
class handle_store
|
||||
class handle_store : public generic_handle_store
|
||||
{
|
||||
public:
|
||||
using index_type = uint32_t;
|
||||
@@ -199,7 +216,7 @@ public:
|
||||
return this->erase(entry);
|
||||
}
|
||||
|
||||
bool erase(const handle h)
|
||||
bool erase(const handle h) override
|
||||
{
|
||||
return this->erase(h.value);
|
||||
}
|
||||
@@ -328,10 +345,21 @@ private:
|
||||
value_map store_{};
|
||||
};
|
||||
|
||||
constexpr auto KNOWN_DLLS_DIRECTORY = make_pseudo_handle(0x1337, handle_types::directory);
|
||||
constexpr auto KNOWN_DLLS_SYMLINK = make_pseudo_handle(0x1337, handle_types::symlink);
|
||||
constexpr auto SHARED_SECTION = make_pseudo_handle(0x1337, handle_types::section);
|
||||
constexpr auto KNOWN_DLLS_DIRECTORY = make_pseudo_handle(0x1, handle_types::directory);
|
||||
constexpr auto BASE_NAMED_OBJECTS_DIRECTORY = make_pseudo_handle(0x2, handle_types::directory);
|
||||
|
||||
constexpr auto KNOWN_DLLS_SYMLINK = make_pseudo_handle(0x1, handle_types::symlink);
|
||||
constexpr auto SHARED_SECTION = make_pseudo_handle(0x1, handle_types::section);
|
||||
|
||||
constexpr auto CONSOLE_HANDLE = make_pseudo_handle(0x1, handle_types::file);
|
||||
constexpr auto STDOUT_HANDLE = make_pseudo_handle(0x2, handle_types::file);
|
||||
constexpr auto STDIN_HANDLE = make_pseudo_handle(0x3, handle_types::file);
|
||||
|
||||
constexpr auto DUMMY_IMPERSONATION_TOKEN = make_pseudo_handle(0x1, handle_types::token);
|
||||
|
||||
constexpr auto CURRENT_PROCESS = make_handle(~0ULL);
|
||||
constexpr auto CURRENT_THREAD = make_handle(~1ULL);
|
||||
|
||||
constexpr auto CURRENT_PROCESS_TOKEN = make_handle(~3ULL);
|
||||
constexpr auto CURRENT_THREAD_TOKEN = make_handle(~4ULL);
|
||||
constexpr auto CURRENT_THREAD_EFFECTIVE_TOKEN = make_handle(~5ULL);
|
||||
|
||||
Reference in New Issue
Block a user