diff --git a/src/xenia/emulator.cc b/src/xenia/emulator.cc index ccfec481e..b96078a75 100644 --- a/src/xenia/emulator.cc +++ b/src/xenia/emulator.cc @@ -35,6 +35,7 @@ #include "xenia/vfs/devices/host_path_device.h" #include "xenia/vfs/devices/stfs_container_device.h" #include "xenia/vfs/virtual_file_system.h" +#include "xenia/xdbf/xdbf_utils.h" DEFINE_double(time_scalar, 1.0, "Scalar used to speed or slow time (1x, 2x, 1/2x, etc)."); @@ -498,7 +499,7 @@ X_STATUS Emulator::CompleteLaunch(const std::wstring& path, // Allow xam to request module loads. auto xam = kernel_state()->GetKernelModule("xam.xex"); - int result = 0; + X_STATUS result = X_STATUS_SUCCESS; auto next_module = module_path; while (next_module != "") { XELOGI("Launching module %s", next_module.c_str()); @@ -513,6 +514,24 @@ X_STATUS Emulator::CompleteLaunch(const std::wstring& path, if (!main_xthread) { return X_STATUS_UNSUCCESSFUL; } + + // Try and load the resource database (xex only) + char title[9] = { 0 }; + sprintf(title, "%08X", module->title_id()); + + uint32_t resource_data = 0; + uint32_t resource_size = 0; + if (XSUCCEEDED(module->GetSection(title, &resource_data, &resource_size))) { + auto xdb_ptr = module->memory()->TranslateVirtual(resource_data); + if (xdb_ptr != nullptr) { + xe::xdbf::XdbfWrapper db; + if (db.initialize(xdb_ptr, static_cast(resource_size))) { + // TODO(x1nixmzeng): Set the application icon + std::wstring title(xe::to_wstring(xe::xdbf::get_title(db))); + display_window_->set_title(title); + } + } + } main_thread_ = main_xthread->thread(); WaitUntilExit(); diff --git a/src/xenia/kernel/user_module.cc b/src/xenia/kernel/user_module.cc index 07894984d..955acac46 100644 --- a/src/xenia/kernel/user_module.cc +++ b/src/xenia/kernel/user_module.cc @@ -208,7 +208,7 @@ X_STATUS UserModule::GetSection(const char* name, uint32_t* out_section_data, return X_STATUS_NOT_FOUND; } - uint32_t count = (resource_header->size - 4) / 16; + uint32_t count = (resource_header->size - 4) / sizeof(xex2_resource); for (uint32_t i = 0; i < count; i++) { auto& res = resource_header->resources[i]; if (std::strncmp(name, res.name, 8) == 0) {