mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-14 19:15:05 -05:00
Merge branch 'geode-sdk:main' into main
This commit is contained in:
commit
bce9d3a013
4 changed files with 32 additions and 21 deletions
|
@ -77,8 +77,10 @@ set(GEODE_CODEGEN_BINARY_OUT ${CMAKE_CURRENT_BINARY_DIR}/codegen)
|
|||
ExternalProject_Add(CodegenProject
|
||||
BUILD_ALWAYS ON
|
||||
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/codegen
|
||||
CMAKE_CACHE_ARGS "-DCMAKE_INSTALL_PREFIX:STRING=${GEODE_CODEGEN_BINARY_OUT}"
|
||||
CMAKE_ARGS ${GEODE_CODEGEN_CMAKE_ARGS}
|
||||
# manually set configure command as to not inherit generator used by geode,
|
||||
# this should hopefully fix generator cache mismatch between different projects, however
|
||||
# it causes a warning to be shown every time. if you know a better solution please tell us ok thx
|
||||
CONFIGURE_COMMAND ${CMAKE_COMMAND} ${GEODE_CODEGEN_CMAKE_ARGS} -DCMAKE_INSTALL_PREFIX:STRING=${GEODE_CODEGEN_BINARY_OUT} -S <SOURCE_DIR> -B <BINARY_DIR>
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -121,12 +121,15 @@ namespace geode {
|
|||
if (m_version.getMajor() != version.getMajor()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (m_compare) {
|
||||
case VersionCompare::Exact: return m_version == version; break;
|
||||
case VersionCompare::LessEq: return m_version <= version; break;
|
||||
case VersionCompare::MoreEq: return m_version >= version; break;
|
||||
case VersionCompare::LessEq:
|
||||
return m_version <= version;
|
||||
case VersionCompare::MoreEq:
|
||||
return m_version >= version;
|
||||
default:
|
||||
return m_version == version;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string toString() const;
|
||||
|
|
|
@ -131,15 +131,7 @@ namespace geode::addresser {
|
|||
// [[this + thunk] + offset] is the f we want
|
||||
auto address = *(intptr_t*)(*(intptr_t*)(reference_cast<intptr_t>(ins) + thunk) + index);
|
||||
|
||||
#ifdef GEODE_IS_WINDOWS
|
||||
// check if first instruction is a jmp, i.e. if the func is a thunk
|
||||
if (*reinterpret_cast<uint16_t*>(address) == 0x25ff) {
|
||||
// read where the jmp points to and jump there
|
||||
address = *reinterpret_cast<uint32_t*>(address + 2);
|
||||
// that then contains the actual address of the func
|
||||
address = *reinterpret_cast<uintptr_t*>(address);
|
||||
}
|
||||
#endif
|
||||
address = followThunkFunction(address);
|
||||
|
||||
return address;
|
||||
}
|
||||
|
@ -171,14 +163,27 @@ namespace geode::addresser {
|
|||
return addressOfNonVirtual(reinterpret_cast<R (T::*)(Ps...)>(func));
|
||||
}
|
||||
|
||||
static inline intptr_t followThunkFunction(intptr_t address) {
|
||||
#ifdef GEODE_IS_WINDOWS
|
||||
// check if first instruction is a jmp dword ptr [....], i.e. if the func is a thunk
|
||||
if (*reinterpret_cast<uint8_t*>(address) == 0xFF && *reinterpret_cast<uint8_t*>(address + 1) == 0x25) {
|
||||
// read where the jmp reads from
|
||||
address = *reinterpret_cast<uint32_t*>(address + 2);
|
||||
// that then contains the actual address of the func
|
||||
address = *reinterpret_cast<uintptr_t*>(address);
|
||||
}
|
||||
#endif
|
||||
return address;
|
||||
}
|
||||
|
||||
template <typename R, typename T, typename... Ps>
|
||||
static intptr_t addressOfNonVirtual(R (T::*func)(Ps...)) {
|
||||
return geode::cast::reference_cast<intptr_t>(func);
|
||||
return followThunkFunction(geode::cast::reference_cast<intptr_t>(func));
|
||||
}
|
||||
|
||||
template <typename R, typename... Ps>
|
||||
static intptr_t addressOfNonVirtual(R (*func)(Ps...)) {
|
||||
return geode::cast::reference_cast<intptr_t>(func);
|
||||
return followThunkFunction(geode::cast::reference_cast<intptr_t>(func));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
|
|
@ -115,15 +115,16 @@ Result<ComparableVersionInfo> ComparableVersionInfo::parse(std::string const& ra
|
|||
if (string.starts_with("<=")) {
|
||||
compare = VersionCompare::LessEq;
|
||||
string.erase(0, 2);
|
||||
}
|
||||
else if (string.starts_with(">=")) {
|
||||
} else if (string.starts_with(">=")) {
|
||||
compare = VersionCompare::MoreEq;
|
||||
string.erase(0, 2);
|
||||
}
|
||||
else if (string.starts_with("=")) {
|
||||
} else if (string.starts_with("=")) {
|
||||
compare = VersionCompare::Exact;
|
||||
string.erase(0, 1);
|
||||
} else {
|
||||
compare = VersionCompare::MoreEq;
|
||||
}
|
||||
|
||||
GEODE_UNWRAP_INTO(auto version, VersionInfo::parse(string));
|
||||
return Ok(ComparableVersionInfo(version, compare));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue