mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-18 19:23:56 +00:00
Fix computername
This commit is contained in:
@@ -678,6 +678,13 @@ namespace
|
||||
printf("Time: %lld\n", std::chrono::duration_cast<std::chrono::nanoseconds>(epoch_time).count());
|
||||
}
|
||||
|
||||
bool test_apis()
|
||||
{
|
||||
wchar_t buffer[0x100];
|
||||
DWORD size = sizeof(buffer) / 2;
|
||||
return GetComputerNameExW(ComputerNameNetBIOS, buffer, &size);
|
||||
}
|
||||
|
||||
bool test_apc()
|
||||
{
|
||||
int executions = 0;
|
||||
@@ -721,6 +728,7 @@ int main(const int argc, const char* argv[])
|
||||
|
||||
RUN_TEST(test_io, "I/O")
|
||||
RUN_TEST(test_dir_io, "Dir I/O")
|
||||
RUN_TEST(test_apis, "APIs")
|
||||
RUN_TEST(test_working_directory, "Working Directory")
|
||||
RUN_TEST(test_registry, "Registry")
|
||||
RUN_TEST(test_system_info, "System Info")
|
||||
|
||||
@@ -28,6 +28,25 @@ namespace
|
||||
{
|
||||
hives[key] = std::make_unique<hive_parser>(file);
|
||||
}
|
||||
|
||||
std::pair<utils::path_key, bool> perform_path_substitution(
|
||||
const std::unordered_map<utils::path_key, utils::path_key>& path_mapping, utils::path_key path)
|
||||
{
|
||||
for (const auto& mapping : path_mapping)
|
||||
{
|
||||
if (path == mapping.first)
|
||||
{
|
||||
return {mapping.second, true};
|
||||
}
|
||||
|
||||
if (is_subpath(mapping.first.get(), path.get()))
|
||||
{
|
||||
return {mapping.second.get() / path.get().lexically_relative(mapping.first.get()), true};
|
||||
}
|
||||
}
|
||||
|
||||
return {std::move(path), false};
|
||||
}
|
||||
}
|
||||
|
||||
registry_manager::registry_manager() = default;
|
||||
@@ -59,15 +78,20 @@ void registry_manager::setup()
|
||||
register_hive(this->hives_, root / "user", this->hive_path_ / "NTUSER.DAT");
|
||||
|
||||
this->add_path_mapping(machine / "system" / "CurrentControlSet", machine / "system" / "ControlSet001");
|
||||
this->add_path_mapping(machine / "system" / "ControlSet001" / "Control" / "ComputerName" / "ActiveComputerName",
|
||||
machine / "system" / "ControlSet001" / "Control" / "ComputerName" / "ComputerName");
|
||||
}
|
||||
|
||||
utils::path_key registry_manager::normalize_path(const utils::path_key& path) const
|
||||
utils::path_key registry_manager::normalize_path(utils::path_key path) const
|
||||
{
|
||||
for (const auto& mapping : this->path_mapping_)
|
||||
for (size_t i = 0; i < 10; ++i)
|
||||
{
|
||||
if (is_subpath(mapping.first.get(), path.get()))
|
||||
auto [new_path, changed] = perform_path_substitution(this->path_mapping_, std::move(path));
|
||||
path = std::move(new_path);
|
||||
|
||||
if (!changed)
|
||||
{
|
||||
return mapping.second.get() / path.get().lexically_relative(mapping.first.get());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ class registry_manager
|
||||
hive_map hives_{};
|
||||
std::unordered_map<utils::path_key, utils::path_key> path_mapping_{};
|
||||
|
||||
utils::path_key normalize_path(const utils::path_key& path) const;
|
||||
utils::path_key normalize_path(utils::path_key path) const;
|
||||
void add_path_mapping(const utils::path_key& key, const utils::path_key& value);
|
||||
|
||||
hive_map::iterator find_hive(const utils::path_key& key);
|
||||
|
||||
@@ -129,6 +129,8 @@ namespace syscalls
|
||||
}
|
||||
|
||||
const auto query_name = read_unicode_string(c.emu, value_name);
|
||||
c.win_emu.log.print(color::dark_gray, "--> Query value key: %s (%s\\%s)\n", u16_to_u8(query_name).c_str(),
|
||||
key->hive.get().string().c_str(), key->path.get().string().c_str());
|
||||
|
||||
const auto value = c.win_emu.registry.get_value(*key, u16_to_u8(query_name));
|
||||
if (!value)
|
||||
|
||||
Reference in New Issue
Block a user