macos fixes and implemented the bootstrapper without testing

This commit is contained in:
altalk23 2022-10-08 12:41:36 +03:00
parent 76175c746d
commit 48ab98a115
21 changed files with 218 additions and 34 deletions

View file

@ -10,6 +10,7 @@ There's nothing worse than having to read thousands of words just to see what so
```cpp
#include <Geode.hpp>
#include <Modify.hpp>
USE_GEODE_NAMESPACE();

View file

@ -257,9 +257,37 @@ class cocos2d::CCKeypadHandler {
class cocos2d::CCLabelBMFont {
static cocos2d::CCLabelBMFont* create(char const*, char const*) = mac 0x347660;
auto limitLabelWidth(float, float, float) = mac 0x34a6e0, ios 0x21b740;
auto setScale(float) = mac 0x34a5d0;
auto setString(char const*, bool) = mac 0x3489e0;
auto setAnchorPoint(cocos2d::CCPoint const&) = mac 0x349440;
virtual ~CCLabelBMFont() = mac 0x347e80, ios 0x219afc;
virtual auto init() = mac 0x347b10, ios 0x2198e0;
virtual auto setScaleX(float) = mac 0x34a5b0, ios 0x21b6e8;
virtual auto setScaleY(float) = mac 0x34a5d0, ios 0x21b714;
virtual auto setScale(float) = mac 0x34a590, ios 0x21b6bc;
virtual auto setAnchorPoint(cocos2d::CCPoint const&) = mac 0x349440, ios 0x21aa7c;
virtual auto setString(char const*) = mac 0x348990, ios 0x21a408;
virtual auto setString(char const*, bool) = mac 0x3489e0, ios 0x21a42c;
virtual auto getString() = mac 0x348bf0, ios 0x21a60c;
virtual auto setCString(char const*) = mac 0x348c10, ios 0x21a63c;
virtual auto updateLabel() = mac 0x349480, ios 0x21aad0;
virtual auto setAlignment(cocos2d::CCTextAlignment) = mac 0x34a530, ios 0x21b68c;
virtual auto setWidth(float) = mac 0x34a550, ios 0x21b69c;
virtual auto setLineBreakWithoutSpace(bool) = mac 0x34a570, ios 0x21b6ac;
virtual auto isOpacityModifyRGB() = mac 0x3490e0, ios 0x21a8c4;
virtual auto setOpacityModifyRGB(bool) = mac 0x348f70, ios 0x21a80c;
virtual auto getOpacity() = mac 0x348df0, ios 0x21a748;
virtual auto getDisplayedOpacity() = mac 0x348e10, ios 0x21a758;
virtual auto setOpacity(unsigned char) = mac 0x348e30, ios 0x21a768;
virtual auto updateDisplayedOpacity(unsigned char) = mac 0x349100, ios 0x21a8d4;
virtual auto isCascadeOpacityEnabled() = mac 0x349400, ios 0x21aa5c;
virtual auto setCascadeOpacityEnabled(bool) = mac 0x349420, ios 0x21aa6c;
virtual auto getColor() = mac 0x348c30, ios 0x21a648;
virtual auto getDisplayedColor() = mac 0x348c50, ios 0x21a658;
virtual auto setColor(cocos2d::ccColor3B const&) = mac 0x348c70, ios 0x21a668;
virtual auto updateDisplayedColor(cocos2d::ccColor3B const&) = mac 0x349210, ios 0x21a968;
virtual auto isCascadeColorEnabled() = mac 0x3493c0, ios 0x21aa3c;
virtual auto setCascadeColorEnabled(bool) = mac 0x3493e0, ios 0x21aa4c;
virtual auto setString(unsigned short*, bool) = mac 0x348a60, ios 0x21a4b4;
}
class cocos2d::CCLabelTTF {
@ -747,6 +775,23 @@ class cocos2d::CCSpriteBatchNode {
static auto createWithTexture(cocos2d::CCTexture2D*, unsigned int) = mac 0xbb310;
auto getUsedAtlasCapacity() = mac 0xbc6b0;
auto increaseAtlasCapacity(unsigned int) = mac 0xbc670;
virtual ~CCSpriteBatchNode() = mac 0xbb790, ios 0x130d18;
virtual auto init() = mac 0xbb680, ios 0x130c20;
virtual auto addChild(cocos2d::CCNode*) = mac 0xbbb40, ios 0x131034;
virtual auto addChild(cocos2d::CCNode*, int) = mac 0xbbb50, ios 0x131038;
virtual auto addChild(cocos2d::CCNode*, int, int) = mac 0xbb930, ios 0x130e0c;
virtual auto removeChild(cocos2d::CCNode*, bool) = mac 0xbbbb0, ios 0x1310a4;
virtual auto removeAllChildrenWithCleanup(bool) = mac 0xbbe30, ios 0x1312d8;
virtual auto reorderChild(cocos2d::CCNode*, int) = mac 0xbbb60, ios 0x13103c;
virtual auto sortAllChildren() = mac 0xbbee0, ios 0x13137c;
virtual auto draw() = mac 0xbc540, ios 0x13191c;
virtual auto visit() = mac 0xbb880, ios 0x130d54;
virtual auto getTexture() = mac 0xbcd70, ios 0x131a70;
virtual auto setTexture(cocos2d::CCTexture2D*) = mac 0xbcda0, ios 0x131a90;
virtual auto setBlendFunc(cocos2d::ccBlendFunc) = mac 0xbcd30, ios 0x131a50;
virtual auto getBlendFunc() = mac 0xbcd50, ios 0x131a60;
}
class cocos2d::CCSpriteFrame {

View file

@ -117,12 +117,18 @@ target_link_libraries(${PROJECT_NAME} z lilac_hook geode-sdk)
set_source_files_properties(${OBJC_SOURCES} PROPERTIES SKIP_PRECOMPILE_HEADERS ON)
target_precompile_headers(${PROJECT_NAME} PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/DefaultInclude.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/Modify.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/Utils.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/Loader.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/UI.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/Bindings.hpp"
# "${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/Modify.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/Geode/cocos/cocos2dx/include/cocos2d.h"
)
# Create launcher
if (APPLE)
add_subdirectory(launcher/mac)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm" OR GEODE_TARGET_PLATFORM STREQUAL "iOS")
add_custom_command(TARGET geode-loader
POST_BUILD COMMAND

View file

@ -3,5 +3,5 @@
#include "Bindings.hpp"
#include "Utils.hpp"
#include "Loader.hpp"
#include "Modify.hpp"
// #include "Modify.hpp"
#include "UI.hpp"

View file

@ -198,6 +198,7 @@ public:
* @js ctor
*/
CCLabelBMFont();
GEODE_MONOSTATE_CONSTRUCTOR_COCOS(CCLabelBMFont, CCSpriteBatchNode)
/**
* @js NA
* @lua NA

View file

@ -68,6 +68,7 @@ public:
* @js ctor
*/
CCSpriteBatchNode();
GEODE_MONOSTATE_CONSTRUCTOR_COCOS(CCSpriteBatchNode, CCNode)
/**
* @js NA
* @lua NA

View file

@ -1,6 +1,6 @@
#pragma once
#include <Geode/Geode.hpp>
#include <Geode/Bindings.hpp>
#include "Traits.hpp"
#include <vector>

View file

@ -0,0 +1,41 @@
#include "../../../filesystem/fs/filesystem.hpp"
#include <mach-o/dyld.h>
#include <unistd.h>
#include <dlfcn.h>
#include <array>
__attribute__((constructor)) void _entry() {
std::array<char, PATH_MAX> gddir;
uint32_t out = PATH_MAX;
_NSGetExecutablePath(gddir.data(), &out);
ghc::filesystem::path gdpath = gddir.data();
auto workingDir = gdpath.parent_path().parent_path();
auto updatesDir = workingDir / "geode" / "update";
auto resourcesDir = workingDir / "geode" / "resources";
auto error = std::error_code();
if (ghc::filesystem::exists(updatesDir / "Geode.dylib", error) && !error) {
ghc::filesystem::rename(
updatesDir / "Geode.dylib",
workingDir / "Geode.dylib", error
);
if (error) return;
}
if (ghc::filesystem::exists(updatesDir / "resources", error) && !error) {
ghc::filesystem::rename(
updatesDir / "resources",
resourcesDir / "geode.loader", error
);
if (error) return;
}
auto dylib = dlopen("Geode.dylib", RTLD_NOW);
if (dylib) return;
return;
}

View file

@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 3.3.0)
add_library(Bootstrapper SHARED Bootstrapper.cpp)
set_target_properties(Bootstrapper PROPERTIES
PREFIX ""
OUTPUT_NAME "GeodeBootstrapper"
LIBRARY_OUTPUT_DIRECTORY "${GEODE_BIN_PATH}/nightly"
RUNTIME_OUTPUT_DIRECTORY "${GEODE_BIN_PATH}/nightly"
)

View file

@ -0,0 +1,40 @@
#include <Windows.h>
#include "../../../filesystem/fs/filesystem.hpp"
DWORD WINAPI load(PVOID _) {
auto workingDir = ghc::filesystem::current_path();
auto updatesDir = workingDir / "geode" / "update";
auto resourcesDir = workingDir / "geode" / "resources";
auto error = std::error_code();
if (ghc::filesystem::exists(updatesDir / "Geode.dll", error) && !error) {
ghc::filesystem::rename(
updatesDir / "Geode.dll",
workingDir / "Geode.dll", error
);
if (error) return error.value();
}
if (ghc::filesystem::exists(updatesDir / "resources", error) && !error) {
ghc::filesystem::rename(
updatesDir / "resources",
resourcesDir / "geode.loader", error
);
if (error) return error.value();
}
LoadLibraryA("Geode.dll");
return 0;
}
BOOL WINAPI DllMain(HINSTANCE module, DWORD reason, LPVOID _) {
if (reason == DLL_PROCESS_ATTACH) {
HANDLE handle = CreateThread(NULL, 0, load, module, 0, NULL);
if (handle)
CloseHandle(handle);
else
return FALSE;
}
return TRUE;
}

View file

@ -1,15 +1,17 @@
cmake_minimum_required(VERSION 3.3.0)
add_library(proxy_loader SHARED proxyLoader.c)
set_target_properties(proxy_loader PROPERTIES
add_library(ProxyLoader SHARED proxyLoader.c)
set_target_properties(ProxyLoader PROPERTIES
PREFIX ""
OUTPUT_NAME "XInput9_1_0"
RUNTIME_OUTPUT_DIRECTORY "${GEODE_BIN_PATH}"
RUNTIME_OUTPUT_DIRECTORY "${GEODE_BIN_PATH}/nightly"
LIBRARY_OUTPUT_DIRECTORY "${GEODE_BIN_PATH}/nightly"
)
add_custom_command(
COMMAND
${CMAKE_COMMAND} -E rename "$<TARGET_FILE:proxy_loader>" "${GEODE_BIN_PATH}/nightly/$<TARGET_FILE_NAME:proxy_loader>"
DEPENDS $<TARGET_FILE:proxy_loader>
VERBATIM
TARGET proxy_loader
add_library(Bootstrapper SHARED Bootstrapper.cpp)
set_target_properties(ProxyLoader PROPERTIES
PREFIX ""
OUTPUT_NAME "GeodeBootstrapper"
RUNTIME_OUTPUT_DIRECTORY "${GEODE_BIN_PATH}/nightly"
LIBRARY_OUTPUT_DIRECTORY "${GEODE_BIN_PATH}/nightly"
)

View file

@ -11,7 +11,7 @@ DWORD XInputGetDSoundAudioDeviceGuids(DWORD user, GUID* render, GUID* capture) {
#pragma comment(linker, "/export:XInputGetDSoundAudioDeviceGuids=_XInputGetDSoundAudioDeviceGuids")
DWORD WINAPI load(PVOID _) {
LoadLibraryA("Geode.dll");
LoadLibraryA("GeodeBootstrapper.dll");
return 0;
}

View file

@ -1,6 +1,6 @@
#include <Geode/Bindings.hpp>
#include <Geode/utils/Ref.hpp>
#include <Geode/modify/Field.hpp>
#include <Geode/Modify.hpp>
#include <Geode/utils/WackyGeodeMacros.hpp>
USE_GEODE_NAMESPACE();
@ -95,7 +95,7 @@ CCNode* CCNode::getChildByIDRecursive(std::string const& id) {
return child;
}
CCARRAY_FOREACH_B_TYPE(m_pChildren, child, CCNode) {
if (child = child->getChildByIDRecursive(id)) {
if ((child = child->getChildByIDRecursive(id))) {
return child;
}
}

View file

@ -1,4 +1,4 @@
#include <Geode/Geode.hpp>
#include <Geode/Modify.hpp>
#include <array>
USE_GEODE_NAMESPACE();

View file

@ -8,6 +8,7 @@
#include <InternalMod.hpp>
#include "../ui/internal/info/ModInfoLayer.hpp"
#include <InternalLoader.hpp>
#include <Geode/Modify.hpp>
USE_GEODE_NAMESPACE();

View file

@ -1,4 +1,3 @@
#include <Geode/Bindings.hpp>
#include <Geode/Modify.hpp>
USE_GEODE_NAMESPACE();

View file

@ -1,4 +1,4 @@
#include <Geode/Geode.hpp>
#include <Geode/Modify.hpp>
#include <Geode/ui/SceneManager.hpp>
USE_GEODE_NAMESPACE();

View file

@ -197,7 +197,7 @@ void Index::indexUpdateProgress(
uint8_t percentage
) {
Loader::get()->queueInGDThread([this, status, info, percentage]() -> void {
Log::get() << info;
log::debug(info);
m_callbacksMutex.lock();
for (auto& d : m_callbacks) {
d(status, info, percentage);

View file

@ -6,6 +6,7 @@
#include <Geode/loader/Log.hpp>
#include <Geode/loader/Interface.hpp>
#include "../core/Core.hpp"
#include <array>
int geodeEntry(void* platformData);
// platform-specific entry points
@ -16,20 +17,55 @@ int geodeEntry(void* platformData);
std::length_error::~length_error() _NOEXCEPT {} // do not ask...
__attribute__((constructor)) void _entry() {
char gddir[PATH_MAX];
uint32_t out = PATH_MAX;
_NSGetExecutablePath(gddir, &out);
// camila has an old ass macos and this function turned
// from dynamic to static thats why she needs to define it
// this is what old versions does to a silly girl
ghc::filesystem::path gdpath = gddir;
__attribute__((constructor)) void _entry() {
std::array<char, PATH_MAX> gddir;
uint32_t out = PATH_MAX;
_NSGetExecutablePath(gddir.data(), &out);
ghc::filesystem::path gdpath = gddir.data();
ghc::filesystem::current_path(gdpath.parent_path().parent_path());
auto workingDir = ghc::filesystem::current_path();
auto updatesDir = workingDir / "geode" / "update";
auto error = std::error_code();
if (ghc::filesystem::exists(updatesDir / "GeodeBootstrapper.dylib", error) && !error) {
ghc::filesystem::rename(
updatesDir / "GeodeBootstrapper.dylib",
workingDir / "GeodeBootstrapper.dylib", error
);
if (error) return;
}
geodeEntry(nullptr);
}
#elif defined(GEODE_IS_WINDOWS)
#include <Windows.h>
DWORD WINAPI loadThread(void* arg) {
auto module = GetModuleHandleA("GeodeBootstrapper.dll");
FreeLibrary(module);
auto workingDir = ghc::filesystem::current_path();
auto updatesDir = workingDir / "geode" / "update";
auto error = std::error_code();
if (ghc::filesystem::exists(updatesDir / "GeodeBootstrapper.dll", error) && !error) {
ghc::filesystem::rename(
updatesDir / "GeodeBootstrapper.dll",
workingDir / "GeodeBootstrapper.dll", error
);
if (error) return error.value();
}
return geodeEntry(arg);
}

View file

@ -1,4 +1,5 @@
#include <Geode/Geode.hpp>
#include <Geode/Modify.hpp>
USE_GEODE_NAMESPACE();

View file

@ -1,36 +1,36 @@
#include <Geode/Geode.hpp>
#include <Geode/Modify.hpp>
USE_GEODE_NAMESPACE();
// Exported functions
GEODE_API bool GEODE_CALL geode_enable() {
Log::get() << "Enabled";
log::info("Enabled");
return true;
}
GEODE_API bool GEODE_CALL geode_disable() {
Log::get() << "Disabled";
log::info("Disabled");
return true;
}
GEODE_API bool GEODE_CALL geode_load(Mod*) {
Log::get() << "Loaded";
log::info("Loaded");
return true;
}
GEODE_API bool GEODE_CALL geode_unload() {
Log::get() << "Unoaded";
log::info("Unloaded");
return true;
}
// Modify
class $modify(GJGarageLayerTest, GJGarageLayer) {
GJGarageLayerTest() :
myValue(1907),
myString("yeah have fun finding a better thing for this") {}
myValue(1907) {}
int myValue;
std::string myString;
std::string myString = "yeah have fun finding a better thing for this";
bool init() {
if (!GJGarageLayer::init()) return false;