Files
Xenia-Canary/src/xenia/patcher/plugin_loader.h
Michael Oliver 9555e7bde4 [Patcher] Ensure hash is checked when loading title plugins
Fixes bug where plugin loader would load all defined plugins if at least one was valid
2025-02-26 15:25:26 +01:00

58 lines
1.7 KiB
C++

/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2023 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#ifndef XENIA_PLUGIN_LOADER_H_
#define XENIA_PLUGIN_LOADER_H_
#include "third_party/tomlplusplus/toml.hpp"
#include "xenia/kernel/kernel_state.h"
#include "xenia/memory.h"
namespace xe {
namespace patcher {
struct PluginInfoEntry {
std::string name;
std::string file;
std::vector<uint64_t> hashes;
uint32_t title_id;
std::string desc;
bool is_enabled;
};
class PluginLoader {
public:
PluginLoader(kernel::KernelState* kernel_state,
const std::filesystem::path plugins_root);
void LoadTitlePlugins(const uint32_t title_id, const uint64_t module_hash);
bool IsAnyPluginForTitleAvailable(const uint32_t title_id,
const uint64_t module_hash) const;
bool IsAnyPluginLoaded() { return is_any_plugin_loaded_; }
private:
void LoadConfigs();
void LoadTitleConfig(const uint32_t title_id);
void CreatePluginDevice(const uint32_t title_id);
void LoadTitlePlugin(const PluginInfoEntry& entry);
std::vector<uint64_t> GetHashes(const toml::node* toml_entry) const;
kernel::KernelState* kernel_state_;
std::filesystem::path plugins_root_;
std::vector<PluginInfoEntry> plugin_configs_;
bool is_any_plugin_loaded_;
};
} // namespace patcher
} // namespace xe
#endif