- moved "tests" to its own folder

- remove the src/theo folder contents just into src
- added some cmkr shit so that tests only build on windows
- added compile options for mcmodel=large in the demolibs
- changed how we get a ptr to the element from an interator
master
IDontCode 3 years ago
parent 1adcbab0b9
commit f1f808081b

@ -39,14 +39,14 @@ endif()
add_subdirectory(dependencies) add_subdirectory(dependencies)
set(CMAKE_FOLDER ${CMKR_CMAKE_FOLDER}) set(CMAKE_FOLDER ${CMKR_CMAKE_FOLDER})
# src # tests
set(CMKR_CMAKE_FOLDER ${CMAKE_FOLDER}) set(CMKR_CMAKE_FOLDER ${CMAKE_FOLDER})
if(CMAKE_FOLDER) if(CMAKE_FOLDER)
set(CMAKE_FOLDER "${CMAKE_FOLDER}/src") set(CMAKE_FOLDER "${CMAKE_FOLDER}/tests")
else() else()
set(CMAKE_FOLDER src) set(CMAKE_FOLDER tests)
endif() endif()
add_subdirectory(src) add_subdirectory(tests)
set(CMAKE_FOLDER ${CMKR_CMAKE_FOLDER}) set(CMAKE_FOLDER ${CMKR_CMAKE_FOLDER})
# Target Theodosius # Target Theodosius
@ -74,16 +74,16 @@ list(APPEND Theodosius_SOURCES
"include/recomp/reloc.hpp" "include/recomp/reloc.hpp"
"include/recomp/symbol_table.hpp" "include/recomp/symbol_table.hpp"
"include/theo.hpp" "include/theo.hpp"
"src/theo/decomp/decomp.cpp" "src/decomp/decomp.cpp"
"src/theo/decomp/routine.cpp" "src/decomp/routine.cpp"
"src/theo/decomp/symbol.cpp" "src/decomp/symbol.cpp"
"src/theo/obf/engine.cpp" "src/obf/engine.cpp"
"src/theo/obf/passes/jcc_rewrite_pass.cpp" "src/obf/passes/jcc_rewrite_pass.cpp"
"src/theo/obf/passes/next_inst_pass.cpp" "src/obf/passes/next_inst_pass.cpp"
"src/theo/obf/passes/reloc_transform_pass.cpp" "src/obf/passes/reloc_transform_pass.cpp"
"src/theo/recomp/recomp.cpp" "src/recomp/recomp.cpp"
"src/theo/recomp/symbol_table.cpp" "src/recomp/symbol_table.cpp"
"src/theo/theo.cpp" "src/theo.cpp"
) )
list(APPEND Theodosius_SOURCES list(APPEND Theodosius_SOURCES

@ -2,11 +2,11 @@
name = "Theodosius" name = "Theodosius"
[subdir.dependencies] [subdir.dependencies]
[subdir.src] [subdir.tests]
[target.Theodosius] [target.Theodosius]
type = "static" type = "static"
sources = ["include/**.hpp", "src/theo/**.cpp"] sources = ["include/**.hpp", "src/**.cpp"]
include-directories = ["include"] include-directories = ["include"]
compile-features = ["cxx_std_20"] compile-features = ["cxx_std_20"]

@ -3,6 +3,8 @@
#include <functional> #include <functional>
#include <map> #include <map>
#include <random> #include <random>
#include <bit>
#include <bitset>
#define XED_ENCODER #define XED_ENCODER
extern "C" { extern "C" {

@ -6,7 +6,7 @@ class rol_op_t : public operation_t {
explicit rol_op_t() explicit rol_op_t()
: operation_t( : operation_t(
[&](std::size_t val, std::uint32_t imm) -> std::size_t { [&](std::size_t val, std::uint32_t imm) -> std::size_t {
return _rotl64(val, (std::uint8_t)imm); return std::rotl(val, (std::uint8_t)imm);
}, },
XED_ICLASS_ROL) {} XED_ICLASS_ROL) {}

@ -6,7 +6,7 @@ class ror_op_t : public operation_t {
explicit ror_op_t() explicit ror_op_t()
: operation_t( : operation_t(
[&](std::size_t val, std::uint32_t imm) -> std::size_t { [&](std::size_t val, std::uint32_t imm) -> std::size_t {
return _rotr64(val, (std::uint8_t)imm); return std::rotr(val, (std::uint8_t)imm);
}, },
XED_ICLASS_ROR) {} XED_ICLASS_ROR) {}

@ -1,18 +0,0 @@
# This file is automatically generated from cmake.toml - DO NOT EDIT
# See https://github.com/build-cpp/cmkr for more information
# Create a configure-time dependency on cmake.toml to improve IDE support
if(CMKR_ROOT_PROJECT)
configure_file(cmake.toml cmake.toml COPYONLY)
endif()
# tests
set(CMKR_CMAKE_FOLDER ${CMAKE_FOLDER})
if(CMAKE_FOLDER)
set(CMAKE_FOLDER "${CMAKE_FOLDER}/tests")
else()
set(CMAKE_FOLDER tests)
endif()
add_subdirectory(tests)
set(CMAKE_FOLDER ${CMKR_CMAKE_FOLDER})

@ -1 +0,0 @@
[subdir.tests]

@ -67,7 +67,7 @@ std::optional<recomp::reloc_t*> next_inst_pass_t::has_next_inst_reloc(
sym->relocs().begin(), sym->relocs().end(), sym->relocs().begin(), sym->relocs().end(),
[&](recomp::reloc_t& reloc) -> bool { return !reloc.offset(); }); [&](recomp::reloc_t& reloc) -> bool { return !reloc.offset(); });
return res != sym->relocs().end() ? res._Ptr return res != sym->relocs().end() ? &(*res)
: std::optional<recomp::reloc_t*>(); : std::optional<recomp::reloc_t*>();
} }
} // namespace theo::obf } // namespace theo::obf

@ -41,7 +41,7 @@ std::optional<recomp::reloc_t*> reloc_transform_pass_t::has_legit_reloc(
sym->relocs().begin(), sym->relocs().end(), sym->relocs().begin(), sym->relocs().end(),
[&](recomp::reloc_t& reloc) -> bool { return reloc.offset(); }); [&](recomp::reloc_t& reloc) -> bool { return reloc.offset(); });
return res != sym->relocs().end() ? res._Ptr return res != sym->relocs().end() ? &(*res)
: std::optional<recomp::reloc_t*>(); : std::optional<recomp::reloc_t*>();
} }
} // namespace theo::obf } // namespace theo::obf

@ -1,7 +0,0 @@
[project]
name = "demolib"
[target.demolib]
type = "static"
sources = ["*.cpp"]

@ -1,7 +0,0 @@
[project]
name = "demolib2"
[target.demolib2]
type = "static"
sources = ["*.cpp"]

@ -30,6 +30,7 @@ endif()
project(demo) project(demo)
# Target demo # Target demo
if(WIN32) # windows
set(CMKR_TARGET demo) set(CMKR_TARGET demo)
set(demo_SOURCES "") set(demo_SOURCES "")
@ -62,4 +63,5 @@ target_link_libraries(demo PRIVATE
unset(CMKR_TARGET) unset(CMKR_TARGET)
unset(CMKR_SOURCES) unset(CMKR_SOURCES)
endif()

@ -2,7 +2,7 @@
name = "demo" name = "demo"
[target.demo] [target.demo]
condition = "windows"
type = "executable" type = "executable"
sources = ["*.cpp"] sources = ["*.cpp"]
link-libraries = ["Theodosius", "spdlog"] link-libraries = ["Theodosius", "spdlog"]

@ -30,6 +30,7 @@ endif()
project(demolib) project(demolib)
# Target demolib # Target demolib
if(WIN32) # windows
set(CMKR_TARGET demolib) set(CMKR_TARGET demolib)
set(demolib_SOURCES "") set(demolib_SOURCES "")
@ -50,6 +51,11 @@ endif()
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${demolib_SOURCES}) source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${demolib_SOURCES})
target_compile_options(demolib PUBLIC
"-Xclang -mcmodel=large"
)
unset(CMKR_TARGET) unset(CMKR_TARGET)
unset(CMKR_SOURCES) unset(CMKR_SOURCES)
endif()

@ -0,0 +1,8 @@
[project]
name = "demolib"
[target.demolib]
condition = "windows"
type = "static"
sources = ["*.cpp"]
compile-options = ["-Xclang -mcmodel=large"]

@ -30,6 +30,7 @@ endif()
project(demolib2) project(demolib2)
# Target demolib2 # Target demolib2
if(WIN32) # windows
set(CMKR_TARGET demolib2) set(CMKR_TARGET demolib2)
set(demolib2_SOURCES "") set(demolib2_SOURCES "")
@ -51,6 +52,11 @@ endif()
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${demolib2_SOURCES}) source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${demolib2_SOURCES})
target_compile_options(demolib2 PUBLIC
"-Xclang -mcmodel=large"
)
unset(CMKR_TARGET) unset(CMKR_TARGET)
unset(CMKR_SOURCES) unset(CMKR_SOURCES)
endif()

@ -0,0 +1,8 @@
[project]
name = "demolib2"
[target.demolib2]
condition = "windows"
type = "static"
sources = ["*.cpp"]
compile-options = ["-Xclang -mcmodel=large"]
Loading…
Cancel
Save