mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-07-06 23:32:59 +12:00
Clean up service intercepts
This commit is contained in:
parent
9932e58bf0
commit
162e73bfd2
6 changed files with 85 additions and 46 deletions
28
include/services/service_intercept.hpp
Normal file
28
include/services/service_intercept.hpp
Normal file
|
@ -0,0 +1,28 @@
|
|||
#pragma once
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
#include "helpers.hpp"
|
||||
|
||||
// We allow Lua scripts to intercept service calls and allow their own code to be ran on SyncRequests
|
||||
// For example, if we want to intercept dsp::DSP ReadPipe (Header: 0x000E00C0), the "serviceName" field would be "dsp::DSP"
|
||||
// and the "function" field would be 0x000E00C0
|
||||
struct InterceptedService {
|
||||
std::string serviceName; // Name of the service whose function
|
||||
u32 function; // Header of the function to intercept
|
||||
|
||||
InterceptedService(const std::string& name, u32 header) : serviceName(name), function(header) {}
|
||||
bool operator==(const InterceptedService& other) const { return serviceName == other.serviceName && function == other.function; }
|
||||
};
|
||||
|
||||
// Define hashing function for InterceptedService to use it with unordered_map
|
||||
namespace std {
|
||||
template <>
|
||||
struct hash<InterceptedService> {
|
||||
usize operator()(const InterceptedService& s) const noexcept {
|
||||
const usize hash1 = std::hash<std::string>{}(s.serviceName);
|
||||
const usize hash2 = std::hash<u32>{}(s.function);
|
||||
return hash1 ^ (hash2 << 1);
|
||||
}
|
||||
};
|
||||
} // namespace std
|
Loading…
Add table
Add a link
Reference in a new issue