Merge branch 'main' into new-index-but-better

This commit is contained in:
HJfod 2024-03-04 22:47:35 +02:00
commit 2105441f0c
4 changed files with 40 additions and 0 deletions

View file

@ -188,6 +188,18 @@ namespace geode {
*/
void setAutoEnable(bool autoEnable);
/**
* Get the bytes of the patch.
* @returns Bytes used to patch
*/
ByteVector const& getBytes() const;
/**
* Updates the bytes of the patch, disabling and then re-enabling if needed.
* @param bytes Bytes used to patch
*/
Result<> updateBytes(const ByteVector& bytes);
/**
* Get the address of the patch.
* @returns Address

View file

@ -34,6 +34,14 @@ void Patch::setAutoEnable(bool autoEnable) {
return m_impl->setAutoEnable(autoEnable);
}
ByteVector const& Patch::getBytes() const {
return m_impl->getBytes();
}
Result<> Patch::updateBytes(const ByteVector& bytes) {
return m_impl->updateBytes(bytes);
}
uintptr_t Patch::getAddress() const {
return m_impl->getAddress();
}

View file

@ -75,6 +75,23 @@ Result<> Patch::Impl::disable() {
return Ok();
}
ByteVector const& Patch::Impl::getBytes() const {
return m_patch;
}
Result<> Patch::Impl::updateBytes(const ByteVector& bytes) {
m_patch = bytes;
if (m_enabled) {
auto res = this->disable();
if (!res) return Err("Failed to update patch: {}", res.unwrapErr());
res = this->enable();
if (!res) return Err("Failed to update patch: {}", res.unwrapErr());
}
return Ok();
}
uintptr_t Patch::Impl::getAddress() const {
return reinterpret_cast<uintptr_t>(m_address);
}

View file

@ -24,6 +24,9 @@ public:
Result<> enable();
Result<> disable();
ByteVector const& getBytes() const;
Result<> updateBytes(const ByteVector& bytes);
uintptr_t getAddress() const;
matjson::Value getRuntimeInfo() const;