add libmem (#5430)
* Added libmem. * Update xmake.lua Minor changes * Update xmake.lua Removed unused flags. * Update xmake.lua * Update xmake.lua Shortened description. * Update xmake.lua * Create xmake.lua * Update xmake.lua * Update xmake.lua * Update xmake.lua * Update xmake.lua * Update xmake.lua * Update xmake.lua Optimized + fixed linux support in case missing ptrace and llvm::demangle. * Update xmake.lua * Update xmake.lua * Update xmake.lua * Update xmake.lua * Update xmake.lua * Fixed BSD and removed set_policy("compatibility.version", "3.0") as well as add_includedirs("include", { public = true }) * Fixed freebsd to bsd * Enforce LM_EXPORT to be used for DLL/LIB * Added missing syslinks for Ole32 (Win/MinGW) and uuid (MinGW) Added missing syslinks for Ole32 (Win/MinGW) and uuid (MinGW) * Added missing syslinks for Ole32 (Win/MinGW) and uuid (MinGW) Added missing syslinks for Ole32 (Win/MinGW) and uuid (MinGW) * Update xmake.lua * Update xmake.lua * Ole32 -> ole32 Ole32 -> ole32 * Ole32 -> ole32 Ole32 -> ole32 * Update xmake.lua * Update xmake.lua * Fixed install through add_headerfiles + Overwrote existing C test. * Removed renudant 2nd argument , {install = true} for func add_headerfiles * Fixed C test error. * fix c++ exports * Fix C++ DLL link * Update xmake.lua * Update xmake.lua * Delete packages/l/libmem/patches/cxxexport.patch * Update xmake.lua * Update xmake.lua * Update xmake.lua * Update xmake.lua * Update xmake.lua --------- Co-authored-by: ruki <waruqi@gmail.com> Co-authored-by: EnergoStalin <ens.stalin@gmail.com>pull/5497/head
parent
73945e34d5
commit
795ca3edcf
2 changed files with 116 additions and 0 deletions
@ -0,0 +1,63 @@ |
|||||||
|
add_rules("mode.debug", "mode.release") |
||||||
|
set_languages("c++17") |
||||||
|
|
||||||
|
add_requires("capstone", "keystone") |
||||||
|
|
||||||
|
target("libmem") |
||||||
|
set_kind("$(kind)") |
||||||
|
|
||||||
|
if is_plat("windows") and is_kind("shared") then |
||||||
|
add_rules("utils.symbols.export_all", {export_classes = true, export_filter = function (symbol) |
||||||
|
if symbol:find("libmem", 1, true) then |
||||||
|
return true |
||||||
|
end |
||||||
|
end}) |
||||||
|
end |
||||||
|
if is_plat("windows") or is_kind("shared") then |
||||||
|
add_defines("LM_EXPORT") |
||||||
|
end |
||||||
|
|
||||||
|
add_packages("capstone", "keystone") |
||||||
|
|
||||||
|
add_headerfiles("include/(libmem/*.h)") |
||||||
|
add_headerfiles("include/(libmem/*.hpp)") |
||||||
|
|
||||||
|
add_includedirs("include") |
||||||
|
add_includedirs( |
||||||
|
"external/llvm/include", |
||||||
|
"src/common", |
||||||
|
"internal", |
||||||
|
"src" |
||||||
|
) |
||||||
|
|
||||||
|
add_files( |
||||||
|
"src/common/*.c", |
||||||
|
"src/common/*.cpp", |
||||||
|
"src/common/arch/*.c", |
||||||
|
"internal/demangler/*.cpp", |
||||||
|
"external/llvm/lib/Demangle/*.cpp" |
||||||
|
) |
||||||
|
|
||||||
|
if is_plat("linux", "bsd") then |
||||||
|
add_syslinks("dl", "stdc++", "m") |
||||||
|
if is_plat("bsd") then |
||||||
|
add_syslinks("kvm", "procstat", "elf") |
||||||
|
end |
||||||
|
|
||||||
|
add_files("internal/posixutils/*.c") |
||||||
|
add_files("internal/elfutils/*.c") |
||||||
|
|
||||||
|
local arch = (is_arch("x86_64", "x64") and "x64" or "x86") |
||||||
|
local prefix = path.join("src", is_plat("linux") and "linux" or "freebsd") |
||||||
|
add_files(path.join(prefix, "ptrace", "*.c")) |
||||||
|
add_files(path.join(prefix, "*.c")) |
||||||
|
add_files(path.join(prefix, "ptrace", arch, "*.c")) |
||||||
|
|
||||||
|
elseif is_plat("windows", "mingw") then |
||||||
|
add_syslinks("user32", "psapi", "ntdll", "shell32", "ole32") |
||||||
|
if is_plat("mingw") then |
||||||
|
add_syslinks("uuid") |
||||||
|
end |
||||||
|
add_files("internal/winutils/*.c") |
||||||
|
add_files("src/win/*.c") |
||||||
|
end |
@ -0,0 +1,53 @@ |
|||||||
|
package("libmem") |
||||||
|
set_homepage("https://github.com/rdbo/libmem") |
||||||
|
set_description("Cross-platform game hacking library for C, C++, Rust, and Python, supporting process/memory hacking, hooking, detouring, and DLL/SO injection.") |
||||||
|
set_license("AGPL-3.0") |
||||||
|
|
||||||
|
add_urls("https://github.com/rdbo/libmem/archive/refs/tags/$(version).tar.gz", |
||||||
|
"https://github.com/rdbo/libmem.git") |
||||||
|
add_versions("5.0.2", "99adea3e86bd3b83985dce9076adda16968646ebd9d9316c9f57e6854aeeab9c") |
||||||
|
|
||||||
|
add_deps("capstone", "keystone") |
||||||
|
|
||||||
|
if is_plat("windows", "mingw") then |
||||||
|
add_syslinks("user32", "psapi", "ntdll", "shell32", "ole32") |
||||||
|
if is_plat("mingw") then |
||||||
|
add_syslinks("uuid") |
||||||
|
end |
||||||
|
elseif is_plat("linux") then |
||||||
|
add_syslinks("dl", "m") |
||||||
|
elseif is_plat("bsd") then |
||||||
|
add_syslinks("dl", "kvm", "procstat", "elf", "m") |
||||||
|
end |
||||||
|
|
||||||
|
on_load(function(package) |
||||||
|
if package:is_plat("windows") or package:config("shared") then |
||||||
|
package:add("defines", "LM_EXPORT") |
||||||
|
end |
||||||
|
end) |
||||||
|
|
||||||
|
on_install("windows", "linux", "bsd", function (package) |
||||||
|
os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua") |
||||||
|
import("package.tools.xmake").install(package) |
||||||
|
end) |
||||||
|
|
||||||
|
on_test(function (package) |
||||||
|
assert(package:check_csnippets({test = [[ |
||||||
|
#include <libmem/libmem.h> |
||||||
|
void test() { |
||||||
|
lm_thread_t resultThread; |
||||||
|
lm_bool_t result = LM_GetThread(&resultThread); |
||||||
|
} |
||||||
|
]]}, {configs = {languages = "c11"}})) |
||||||
|
|
||||||
|
assert(package:check_cxxsnippets({test = [[ |
||||||
|
#include <libmem/libmem.hpp> |
||||||
|
#include <vector> |
||||||
|
#include <optional> |
||||||
|
using namespace libmem; |
||||||
|
void test() { |
||||||
|
std::optional<Thread> currentThread = GetThread(); |
||||||
|
std::optional<std::vector<Thread>> threads = EnumThreads(); |
||||||
|
} |
||||||
|
]]}, {configs = {languages = "c++17"}})) |
||||||
|
end) |
Loading…
Reference in new issue