mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-30 00:01:02 +00:00
Merge branch 'main' of https://github.com/momo5502/sogen
This commit is contained in:
@@ -32,4 +32,4 @@ class named_pipe : public io_device_container
|
||||
void deserialize_object(utils::buffer_deserializer&) override
|
||||
{
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -51,8 +51,10 @@ namespace
|
||||
kusd.Cookie = 0;
|
||||
kusd.ConsoleSessionForegroundProcessId = 0x00000000000028f4;
|
||||
kusd.TimeUpdateLock = 0x0000000002b28586;
|
||||
kusd.BaselineSystemTimeQpc = 0x0000004b17cd596c;
|
||||
kusd.BaselineInterruptTimeQpc = 0x0000004b17cd596c;
|
||||
// This is the QPC time when `SystemTime` is set
|
||||
// We set it to UINT64_MAX, so `SystemTime` won't get adjusted in `RtlGetSystemTimePrecise`
|
||||
kusd.BaselineSystemTimeQpc = 0xFFFFFFFFFFFFFFFF;
|
||||
kusd.BaselineInterruptTimeQpc = 0xFFFFFFFFFFFFFFFF;
|
||||
kusd.QpcSystemTimeIncrement = 0x8000000000000000;
|
||||
kusd.QpcInterruptTimeIncrement = 0x8000000000000000;
|
||||
kusd.QpcSystemTimeIncrementShift = 0x01;
|
||||
|
||||
@@ -6,4 +6,4 @@ class windows_emulator;
|
||||
namespace minidump_loader
|
||||
{
|
||||
void load_minidump_into_emulator(windows_emulator& win_emu, const std::filesystem::path& minidump_path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace network
|
||||
const auto res = ::recvfrom(this->socket_.get_socket(), reinterpret_cast<char*>(data.data()), static_cast<send_size>(data.size()),
|
||||
0, &source.get_addr(), &source_length);
|
||||
|
||||
assert(source.get_size() == source_length);
|
||||
assert(res < 0 || source.get_size() == source_length);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -132,6 +132,7 @@ namespace syscalls
|
||||
emulator_pointer buffer, ULONG number_of_bytes_to_read,
|
||||
emulator_object<ULONG> number_of_bytes_read);
|
||||
NTSTATUS handle_NtSetInformationVirtualMemory();
|
||||
BOOL handle_NtLockVirtualMemory();
|
||||
|
||||
// syscalls/mutant.cpp:
|
||||
NTSTATUS handle_NtReleaseMutant(const syscall_context& c, handle mutant_handle, emulator_object<LONG> previous_count);
|
||||
@@ -961,6 +962,7 @@ void syscall_dispatcher::add_handlers(std::map<std::string, syscall_handler>& ha
|
||||
add_handler(NtQuerySystemInformation);
|
||||
add_handler(NtCreateEvent);
|
||||
add_handler(NtProtectVirtualMemory);
|
||||
add_handler(NtLockVirtualMemory);
|
||||
add_handler(NtOpenDirectoryObject);
|
||||
add_handler(NtTraceEvent);
|
||||
add_handler(NtAllocateVirtualMemoryEx);
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace syscalls
|
||||
const emulator_object<IO_STATUS_BLOCK<EmulatorTraits<Emu64>>> io_status_block,
|
||||
const uint64_t file_information, const ULONG length, const FILE_INFORMATION_CLASS info_class)
|
||||
{
|
||||
const auto* f = c.proc.files.get(file_handle);
|
||||
auto* f = c.proc.files.get(file_handle);
|
||||
if (!f)
|
||||
{
|
||||
if (c.proc.devices.get(file_handle))
|
||||
@@ -88,7 +88,22 @@ namespace syscalls
|
||||
|
||||
c.win_emu.log.warn("--> File rename requested: %s --> %s\n", u16_to_u8(f->name).c_str(), u16_to_u8(new_name).c_str());
|
||||
|
||||
return STATUS_ACCESS_DENIED;
|
||||
std::error_code ec{};
|
||||
bool file_exists = std::filesystem::exists(new_name, ec);
|
||||
|
||||
if (ec)
|
||||
{
|
||||
return STATUS_ACCESS_DENIED;
|
||||
}
|
||||
|
||||
if (!info.ReplaceIfExists && file_exists)
|
||||
{
|
||||
return STATUS_OBJECT_NAME_EXISTS;
|
||||
}
|
||||
|
||||
f->handle.defer_rename(c.win_emu.file_sys.translate(f->name), c.win_emu.file_sys.translate(new_name));
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (info_class == FileBasicInformation)
|
||||
@@ -886,6 +901,12 @@ namespace syscalls
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (filename == u"\\??\\CONOUT$")
|
||||
{
|
||||
file_handle.write(STDOUT_HANDLE);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
file f{};
|
||||
f.name = std::move(filename);
|
||||
|
||||
@@ -1022,8 +1043,19 @@ namespace syscalls
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
const auto filename =
|
||||
read_unicode_string(c.emu, emulator_object<UNICODE_STRING<EmulatorTraits<Emu64>>>{c.emu, attributes.ObjectName});
|
||||
auto filename = read_unicode_string(c.emu, emulator_object<UNICODE_STRING<EmulatorTraits<Emu64>>>{c.emu, attributes.ObjectName});
|
||||
|
||||
if (attributes.RootDirectory)
|
||||
{
|
||||
const auto* root = c.proc.files.get(attributes.RootDirectory);
|
||||
if (!root)
|
||||
{
|
||||
return STATUS_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
const auto has_separator = root->name.ends_with(u"\\") || root->name.ends_with(u"/");
|
||||
filename = root->name + (has_separator ? u"" : u"\\") + filename;
|
||||
}
|
||||
|
||||
c.win_emu.callbacks.on_generic_access("Querying file attributes", filename);
|
||||
|
||||
|
||||
@@ -295,4 +295,9 @@ namespace syscalls
|
||||
{
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
BOOL handle_NtLockVirtualMemory()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,4 +366,4 @@ namespace syscalls
|
||||
// puts("NtQuerySecurityAttributesToken not supported");
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,6 +186,7 @@ struct file : ref_counted_object
|
||||
utils::file_handle handle{};
|
||||
std::u16string name{};
|
||||
std::optional<file_enumeration_state> enumeration_state{};
|
||||
std::optional<std::u16string> deferred_rename;
|
||||
|
||||
bool is_file() const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user