Skip to content

Commit

Permalink
Update ImGui & apply compile options to dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Sumandora committed Sep 5, 2023
1 parent 02e841d commit f35ae89
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 8 deletions.
36 changes: 33 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,22 @@ else ()
list(REMOVE_ITEM SOURCE_FILES "${CMAKE_SOURCE_DIR}/Source/MenuPreview.cpp") # No need for this file if we aren't previewing the menu
add_library(${CMAKE_PROJECT_NAME} SHARED ${SOURCE_FILES})
endif ()
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE dl SDL2 GL)

target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE "-fno-rtti" "-ffunction-sections" "-march=native")
function(apply_obfuscation_parameters TARGET)
target_compile_options(${TARGET} PRIVATE "-fno-rtti") # Force a compile time error in case the target is using any RTTI features
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_options(${TARGET} PRIVATE "-fvisibility=hidden" "-fvisibility-inlines-hidden")
endif ()
endfunction()

apply_obfuscation_parameters(${CMAKE_PROJECT_NAME})

target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE "-march=native")

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE "-Wall" "-ggdb" "-DDEBUG")
else()
target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE "-Os" "-fvisibility=hidden" "-fvisibility-inlines-hidden")
target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE "-Os")
set(CMAKE_CXX_FLAGS "-D'IM_ASSERT(_EXPR)=((void)(_EXPR))' ${CMAKE_CXX_FLAGS}") # TODO Can you do this without set?
endif()

Expand Down Expand Up @@ -97,6 +105,8 @@ FetchContent_Declare(ReturnAddressSpoofer
FetchContent_MakeAvailable(ReturnAddressSpoofer)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE ReturnAddressSpoofer)

target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE "-ffunction-sections")

add_subdirectory("${ReturnAddressSpoofer_SOURCE_DIR}/ObjectFileRewriter")
add_custom_command(
TARGET ${CMAKE_PROJECT_NAME} PRE_LINK
Expand All @@ -112,3 +122,23 @@ FetchContent_Declare(HideSharedObject
FetchContent_MakeAvailable(HideSharedObject)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE HideSharedObject)


function(apply_obfuscation_recursively TARGET)
get_target_property(DEPENDENCIES ${TARGET} LINK_LIBRARIES)
if(NOT DEPENDENCIES)
return()
endif()

foreach(DEPENDENCY ${DEPENDENCIES})
get_target_property(LIB_TYPE ${DEPENDENCY} TYPE)
if(NOT LIB_TYPE STREQUAL "INTERFACE_LIBRARY")
apply_obfuscation_parameters(${DEPENDENCY})
endif ()
apply_obfuscation_recursively(${DEPENDENCY})
endforeach()

endfunction()

apply_obfuscation_recursively(${CMAKE_PROJECT_NAME})

target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE dl SDL2 GL)
2 changes: 1 addition & 1 deletion Dependencies/imgui
3 changes: 1 addition & 2 deletions Source/GUI/GUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void Gui::swapWindow(SDL_Window* window)

static std::once_flag init;
std::call_once(init, [&io, window]() {
ImGui_ImplSDL2_InitForOpenGL(window, nullptr);
ImGui_ImplSDL2_InitForOpenGL(window, SDL_GL_GetCurrentContext());
ImGui_ImplOpenGL3_Init();

// We are running straight into the multi monitor dpi issue here, but to my knowledge there is no appropriate solution to this when using ImGui
Expand Down Expand Up @@ -159,6 +159,5 @@ bool Gui::pollEvent(SDL_Event* event)

bool Gui::warpMouseInWindow()
{
// lol no
return visible;
}
4 changes: 2 additions & 2 deletions Source/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ void initializer()
eventLog.createReport("Initialized!");
}

int __attribute((constructor)) Startup()
int __attribute((constructor)) startup()
{
std::thread t(initializer);
t.detach();

return 0;
}

void __attribute((destructor)) Shutdown()
void __attribute((destructor)) shutdown()
{
Hooks::uninstallHooks();
Gui::destroy();
Expand Down

0 comments on commit f35ae89

Please sign in to comment.