Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions TsudaKageyu/minhook/minhook_cmp.gox
Original file line number Diff line number Diff line change
@@ -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")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P3] normalize does not guard against invalid semver tags

normalize unconditionally does "v" + trimPrefix(version, "v"). For the upstream GNU-style tags the comment cites (e.g. 1.2.1A), this yields v1.2.1A, which is not valid Go semver — semver.Compare treats invalid versions as lowest, so such tags sort below everything. Not a problem for selecting the current v1.3.4 default, but worth a note if those older tags ever need to order correctly.

}

compareVer (a, b) => {
return semver.Compare(normalize(a.Version), normalize(b.Version))
}
103 changes: 103 additions & 0 deletions TsudaKageyu/minhook/v1.3.4/minhook_llar.gox
Original file line number Diff line number Diff line change
@@ -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 => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] filter accepts all OS targets for a Windows-only library

The filter only validates the shared option and accepts every OS target. For a strictly Windows library, consider rejecting non-Windows targets by inspecting target.require["os"] (see the os-aware patterns in rxi/microtar and tidwall/neco). As written the formula advertises support on platforms where it cannot build/run, which is the root cause of the lib-name mismatch above.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P3] Comment mentions Debug 'd' postfix but only Release is built

The comment says "Debug adds a trailing d", but c.buildType "Release" (line 53) is hardcoded and no d-suffixed name is ever produced. This is accurate about upstream but can mislead a reader into thinking a Debug code path exists here. Consider trimming the Debug mention or noting that only Release is built.

// package is a Windows x86/x86_64 API hooking library.
lib := "minhook.x64"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Lib name hardcoded to Windows .x64/.x32 for all targets

The comment on the lines above states "Non-Windows CMake uses libminhook", yet lib is unconditionally set to minhook.x64/minhook.x32 with no OS check (the branch on line 45 only inspects arch). Upstream's CMakeLists.txt applies the empty-prefix .x64/.x32 postfix only inside its if(WIN32) block; on non-Windows it produces libminhook.a/.so.

This name flows into the generated pkgconfig Libs: -lminhook.x64 (line 74). On a Linux/macOS build the linker will look for libminhook.x64.*, which does not exist, so the onTest link on line 96 fails. Since onTest uses cc/exec/LD_LIBRARY_PATH (Unix constructs), a non-Windows target seems expected. Please gate the lib name on target.require["os"] (default -lminhook off Windows), or restrict the formula to Windows in filter and validate on a Windows runner.

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"))!
}
Comment on lines +98 to +101

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Shared build sets only LD_LIBRARY_PATH/DYLD, not Windows PATH

For a shared Windows build the runtime DLL is located via the loader PATH (and is typically installed under bin), not LD_LIBRARY_PATH/DYLD_LIBRARY_PATH. The sibling rxi/microtar formula prepends installDir/bin to PATH when target.require["os"] contains windows. If a shared Windows test is intended, mirror that pattern so the DLL is found at runtime.

exec! binary
}
4 changes: 4 additions & 0 deletions TsudaKageyu/minhook/versions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"path": "TsudaKageyu/minhook",
"deps": {}
}
Loading