diff --git a/TsudaKageyu/minhook/minhook_cmp.gox b/TsudaKageyu/minhook/minhook_cmp.gox new file mode 100644 index 0000000..47b7ef0 --- /dev/null +++ b/TsudaKageyu/minhook/minhook_cmp.gox @@ -0,0 +1,11 @@ +import "strings" + +// Upstream mixes unprefixed GNU-style tags (1.2.1.1, 1.2.1A) with v-prefixed +// releases (v1.3.4). Strip an optional v, then compare as Go semver. +func normalize(version string) string { + return "v" + strings.trimPrefix(version, "v") +} + +compareVer (a, b) => { + return semver.Compare(normalize(a.Version), normalize(b.Version)) +} diff --git a/TsudaKageyu/minhook/v1.3.4/minhook_llar.gox b/TsudaKageyu/minhook/v1.3.4/minhook_llar.gox new file mode 100644 index 0000000..d405553 --- /dev/null +++ b/TsudaKageyu/minhook/v1.3.4/minhook_llar.gox @@ -0,0 +1,103 @@ +import ( + "os" + "path/filepath" +) + +const consumerSource = `#include "MinHook.h" + +int main(void) { + MH_Initialize(); + MH_Uninitialize(); + return 0; +} +` + +id "TsudaKageyu/minhook" + +fromVer "v1.3.4" + +defaults { + "shared": "OFF", +} + +filter => { + for name, values in target.options { + if name != "shared" { + return false + } + for value in values { + if value != "ON" && value != "OFF" { + return false + } + } + } + return true +} + +onBuild ctx => { + installDir := ctx.outputDir + shared := target.options["shared"][0] == "ON" + + // WIN32 Release/RelWithDebInfo/MinSizeRel postfixes are .x64 / .x32; + // Debug adds a trailing d. Non-Windows CMake uses libminhook, but this + // package is a Windows x86/x86_64 API hooking library. + lib := "minhook.x64" + if values := target.require["arch"]; values.len > 0 { + arch := values[0] + if arch == "386" || arch == "x86" || arch == "i386" { + lib = "minhook.x32" + } + } + + c := cmake.new(ctx.SourceDir, filepath.join(ctx.SourceDir, "_build"), installDir) + c.buildType "Release" + c.define "CMAKE_POLICY_VERSION_MINIMUM", "3.5" + c.defineBool "BUILD_SHARED_LIBS", shared + c.configure + c.build + c.install + + licenseDir := filepath.join(installDir, "licenses") + os.mkdirAll(licenseDir, 0o755)! + os.writeFile(filepath.join(licenseDir, "LICENSE.txt"), os.readFile(filepath.join(ctx.SourceDir, "LICENSE.txt"))!, 0o644)! + + pcDir := filepath.join(installDir, "lib", "pkgconfig") + os.mkdirAll(pcDir, 0o755)! + pc := `prefix=$${pcfiledir}/../.. +exec_prefix=$${prefix} +libdir=$${prefix}/lib +includedir=$${prefix}/include + +Name: minhook +Description: The Minimalistic x86/x64 API Hooking Library for Windows +Version: 1.3.4 +Libs: -L$${libdir} -l` + lib + ` +Cflags: -I$${includedir} +` + os.writeFile(filepath.join(pcDir, "minhook.pc"), []byte(pc), 0o644)! + + pkgconfig.use installDir + ctx.setMetadata pkgconfig.lookup("minhook")! +} + +onTest ctx => { + installDir := ctx.outputDir + testDir := filepath.join(ctx.SourceDir, "_llar_consumer") + os.mkdirAll(testDir, 0o755)! + + sourcePath := filepath.join(testDir, "consumer.c") + os.writeFile(sourcePath, []byte(consumerSource), 0o644)! + + pkgconfig.use installDir + flagsFile := filepath.join(testDir, "minhook.flags") + os.writeFile(flagsFile, []byte(pkgconfig.lookup("minhook")!), 0o644)! + + binary := filepath.join(testDir, "consumer") + cc! sourcePath, "-o", binary, "@"+flagsFile + + if target.options["shared"][0] == "ON" { + os.setenv("LD_LIBRARY_PATH", filepath.join(installDir, "lib"))! + os.setenv("DYLD_LIBRARY_PATH", filepath.join(installDir, "lib"))! + } + exec! binary +} diff --git a/TsudaKageyu/minhook/versions.json b/TsudaKageyu/minhook/versions.json new file mode 100644 index 0000000..7d06c72 --- /dev/null +++ b/TsudaKageyu/minhook/versions.json @@ -0,0 +1,4 @@ +{ + "path": "TsudaKageyu/minhook", + "deps": {} +}