Add NestedPatchCounter

This commit is contained in:
Silent 2020-10-26 18:50:54 +01:00
parent 3b82af621d
commit acff986fe1
No known key found for this signature in database
GPG Key ID: AE53149BB0C45AF1
1 changed files with 22 additions and 0 deletions

View File

@ -56,4 +56,26 @@ void* GetXboxFunctionPointer(std::string functionName);
void VerifyHLEDataBase();
#endif
// A helper class to allow code patches to detect nested calls (patches called from patches)
class NestedPatchCounter
{
public:
explicit NestedPatchCounter(uint32_t& counter) noexcept
: m_counter(counter), m_level(counter)
{
m_counter++;
}
~NestedPatchCounter() noexcept
{
m_counter--;
}
uint32_t GetLevel() const noexcept { return m_level; }
public:
uint32_t& m_counter;
const uint32_t m_level;
};
#endif