frida-go icon indicating copy to clipboard operation
frida-go copied to clipboard

After adding some HttpAPIs on Windows, execution errors will occur.

Open AnxiangLemon opened this issue 7 months ago • 1 comments

I am trying to call some interfaces of frida-go via HTTP, but there are operational issues.

download frida-core.a and .h from build action workflow(https://github.com/frida/frida-core/actions/runs/15490211352/artifacts/3275560636) for Windows-MinGW and put them in path that cgo can find

If the HTTP API is not added, it runs normally. I tried switching to frameworks like Gin but still encountered runtime errors.

Image

main.go:

package main

import (
	"fmt"
	"os"

	"github.com/frida/frida-go/frida"
	"github.com/gofiber/fiber/v2"
)

var script = `
        var modules = Process.enumerateModules();
                for (var i = 0; i < modules.length; i++) {
                    console.log(modules[i].name)
                }

`

func main() {
	mgr := frida.NewDeviceManager()

	devices, err := mgr.EnumerateDevices()
	if err != nil {
		panic(err)
	}

	for _, d := range devices {
		fmt.Println("[*] Found device with id:", d.ID())
	}

	localDev, err := mgr.LocalDevice()
	if err != nil {
		fmt.Println("Could not get local device: ", err)
		// Let's exit here because there is no point to do anything with nonexistent device
		os.Exit(1)
	}

	fmt.Println("[*] Chosen device: ", localDev.Name())

	fmt.Println("[*] Attaching to Telegram")
	session, err := localDev.Attach("Telegram.exe", nil)
	if err != nil {
		fmt.Println("Error occurred attaching:", err)
		os.Exit(1)
	}

	script, err := session.CreateScript(script)
	if err != nil {
		fmt.Println("Error occurred creating script:", err)
		os.Exit(1)
	}

	script.On("message", func(msg string) {
		fmt.Println("[*] Received", msg)
	})

	if err := script.Load(); err != nil {
		fmt.Println("Error loading script:", err)
		os.Exit(1)
	}

	// r := bufio.NewReader(os.Stdin)
	// r.ReadLine()

	//------I've just added some of the code below !!!   
	app := fiber.New()
	app.Get("/", func(c *fiber.Ctx) error {
		return c.SendString("Hello, Fiber!")
	})
	app.Listen(":3000")
}

I can run it on Linux, but the same code causes an error when I run it on Windows. Below are all the errors.

>go run main.go
runtime: nameOff 0x595 base 0x7ff6cee86380 not in ranges:
        types 0x7ff6cf0fb7c0 etypes 0x7ff6cf9db341
fatal error: runtime: name offset base pointer out of range

goroutine 1 gp=0xc0000021c0 m=0 mp=0x7ff6d04033c0 [running, locked to thread]:
runtime.throw({0x7ff6cf35a52a?, 0x198f27aa6e0?})
        /opt/hostedtoolcache/go/1.24.3/x64/src/runtime/panic.go:1101 +0x4d fp=0xc0001b3aa0 sp=0xc0001b3a70 pc=0x7ff6cd277cad
runtime.resolveNameOff(0xf000000cd26394e?, 0x595)
        /opt/hostedtoolcache/go/1.24.3/x64/src/runtime/type.go:315 +0x1bb fp=0xc0001b3af8 sp=0xc0001b3aa0 pc=0x7ff6cd27097b
runtime.rtype.nameOff(...)
        /opt/hostedtoolcache/go/1.24.3/x64/src/runtime/type.go:321
runtime.itabInit(0x1991ce0e298, 0x1)
        /opt/hostedtoolcache/go/1.24.3/x64/src/runtime/iface.go:232 +0x2c5 fp=0xc0001b3ba8 sp=0xc0001b3af8 pc=0x7ff6cd21aca5
runtime.getitab(0x7ff6cf1996e0, 0x7ff6cee86380, 0x1)
        /opt/hostedtoolcache/go/1.24.3/x64/src/runtime/iface.go:86 +0x12a fp=0xc0001b3bf0 sp=0xc0001b3ba8 pc=0x7ff6cd2754ca
runtime.typeAssert(0x7ff6cedd8c10, 0x7ff6cee86380)
        /opt/hostedtoolcache/go/1.24.3/x64/src/runtime/iface.go:474 +0x3f fp=0xc0001b3c30 sp=0xc0001b3bf0 pc=0x7ff6cd21b2ff
io.NopCloser(...)
        /opt/hostedtoolcache/go/1.24.3/x64/src/io/io.go:683
net/http.init()
        /opt/hostedtoolcache/go/1.24.3/x64/src/net/http/transfer.go:1094 +0xb5e fp=0xc0001b3e28 sp=0xc0001b3c30 pc=0x7ff6cd728e1e
runtime.doInit1(0x7ff6ced80580)
        /opt/hostedtoolcache/go/1.24.3/x64/src/runtime/proc.go:7353 +0xdd fp=0xc0001b3f50 sp=0xc0001b3e28 pc=0x7ff6cd25649d
runtime.doInit(...)
        /opt/hostedtoolcache/go/1.24.3/x64/src/runtime/proc.go:7320
runtime.main()
        /opt/hostedtoolcache/go/1.24.3/x64/src/runtime/proc.go:254 +0x325 fp=0xc0001b3fe0 sp=0xc0001b3f50 pc=0x7ff6cd247ee5
runtime.goexit({})
        /opt/hostedtoolcache/go/1.24.3/x64/src/runtime/asm_amd64.s:1700 +0x1 fp=0xc0001b3fe8 sp=0xc0001b3fe0 pc=0x7ff6cd27f001

goroutine 2 gp=0xc0000028c0 m=nil [force gc (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        /opt/hostedtoolcache/go/1.24.3/x64/src/runtime/proc.go:435 +0xce fp=0xc000067fa8 sp=0xc000067f88 pc=0x7ff6cd277d8e
runtime.goparkunlock(...)
        /opt/hostedtoolcache/go/1.24.3/x64/src/runtime/proc.go:441
runtime.forcegchelper()
        /opt/hostedtoolcache/go/1.24.3/x64/src/runtime/proc.go:348 +0xb8 fp=0xc000067fe0 sp=0xc000067fa8 pc=0x7ff6cd248158
runtime.goexit({})
        /opt/hostedtoolcache/go/1.24.3/x64/src/runtime/asm_amd64.s:1700 +0x1 fp=0xc000067fe8 sp=0xc000067fe0 pc=0x7ff6cd27f001
created by runtime.init.7 in goroutine 1
        /opt/hostedtoolcache/go/1.24.3/x64/src/runtime/proc.go:336 +0x1a

goroutine 3 gp=0xc000002c40 m=nil [GC sweep wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        /opt/hostedtoolcache/go/1.24.3/x64/src/runtime/proc.go:435 +0xce fp=0xc000069f80 sp=0xc000069f60 pc=0x7ff6cd277d8e
runtime.goparkunlock(...)
        /opt/hostedtoolcache/go/1.24.3/x64/src/runtime/proc.go:441
runtime.bgsweep(0xc000076000)
        /opt/hostedtoolcache/go/1.24.3/x64/src/runtime/mgcsweep.go:276 +0x94 fp=0xc000069fc8 sp=0xc000069f80 pc=0x7ff6cd231114
runtime.gcenable.gowrap1()
        /opt/hostedtoolcache/go/1.24.3/x64/src/runtime/mgc.go:204 +0x25 fp=0xc000069fe0 sp=0xc000069fc8 pc=0x7ff6cd225745
runtime.goexit({})
        /opt/hostedtoolcache/go/1.24.3/x64/src/runtime/asm_amd64.s:1700 +0x1 fp=0xc000069fe8 sp=0xc000069fe0 pc=0x7ff6cd27f001
created by runtime.gcenable in goroutine 1
        /opt/hostedtoolcache/go/1.24.3/x64/src/runtime/mgc.go:204 +0x66

goroutine 4 gp=0xc000002e00 m=nil [GC scavenge wait]:
runtime.gopark(0xc000076000?, 0x7ff6cf99a1f8?, 0x1?, 0x0?, 0xc000002e00?)
        /opt/hostedtoolcache/go/1.24.3/x64/src/runtime/proc.go:435 +0xce fp=0xc00007df78 sp=0xc00007df58 pc=0x7ff6cd277d8e
runtime.goparkunlock(...)
        /opt/hostedtoolcache/go/1.24.3/x64/src/runtime/proc.go:441
runtime.(*scavengerState).park(0x7ff6d0402500)
        /opt/hostedtoolcache/go/1.24.3/x64/src/runtime/mgcscavenge.go:425 +0x49 fp=0xc00007dfa8 sp=0xc00007df78 pc=0x7ff6cd22ebc9
runtime.bgscavenge(0xc000076000)
        /opt/hostedtoolcache/go/1.24.3/x64/src/runtime/mgcscavenge.go:653 +0x3c fp=0xc00007dfc8 sp=0xc00007dfa8 pc=0x7ff6cd22f13c
runtime.gcenable.gowrap2()
        /opt/hostedtoolcache/go/1.24.3/x64/src/runtime/mgc.go:205 +0x25 fp=0xc00007dfe0 sp=0xc00007dfc8 pc=0x7ff6cd2256e5
runtime.goexit({})
        /opt/hostedtoolcache/go/1.24.3/x64/src/runtime/asm_amd64.s:1700 +0x1 fp=0xc00007dfe8 sp=0xc00007dfe0 pc=0x7ff6cd27f001
created by runtime.gcenable in goroutine 1
        /opt/hostedtoolcache/go/1.24.3/x64/src/runtime/mgc.go:205 +0xa5

goroutine 5 gp=0xc000003340 m=nil [finalizer wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        /opt/hostedtoolcache/go/1.24.3/x64/src/runtime/proc.go:435 +0xce fp=0xc00007fe30 sp=0xc00007fe10 pc=0x7ff6cd277d8e
runtime.runfinq()
        /opt/hostedtoolcache/go/1.24.3/x64/src/runtime/mfinal.go:196 +0x107 fp=0xc00007ffe0 sp=0xc00007fe30 pc=0x7ff6cd224747
runtime.goexit({})
        /opt/hostedtoolcache/go/1.24.3/x64/src/runtime/asm_amd64.s:1700 +0x1 fp=0xc00007ffe8 sp=0xc00007ffe0 pc=0x7ff6cd27f001
created by runtime.createfing in goroutine 1
        /opt/hostedtoolcache/go/1.24.3/x64/src/runtime/mfinal.go:166 +0x3d

goroutine 6 gp=0xc000003500 m=nil [chan receive]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x7ff6ced7f598?)
        /opt/hostedtoolcache/go/1.24.3/x64/src/runtime/proc.go:435 +0xce fp=0xc00006bf18 sp=0xc00006bef8 pc=0x7ff6cd277d8e
runtime.chanrecv(0xc000024150, 0x0, 0x1)
        /opt/hostedtoolcache/go/1.24.3/x64/src/runtime/chan.go:664 +0x445 fp=0xc00006bf90 sp=0xc00006bf18 pc=0x7ff6cd216f45
runtime.chanrecv1(0x7ff6cd247fa0?, 0xc00006bf76?)
        /opt/hostedtoolcache/go/1.24.3/x64/src/runtime/chan.go:506 +0x12 fp=0xc00006bfb8 sp=0xc00006bf90 pc=0x7ff6cd216af2
runtime.unique_runtime_registerUniqueMapCleanup.func2(...)
        /opt/hostedtoolcache/go/1.24.3/x64/src/runtime/mgc.go:1796
runtime.unique_runtime_registerUniqueMapCleanup.gowrap1()
        /opt/hostedtoolcache/go/1.24.3/x64/src/runtime/mgc.go:1799 +0x2f fp=0xc00006bfe0 sp=0xc00006bfb8 pc=0x7ff6cd22876f
runtime.goexit({})
        /opt/hostedtoolcache/go/1.24.3/x64/src/runtime/asm_amd64.s:1700 +0x1 fp=0xc00006bfe8 sp=0xc00006bfe0 pc=0x7ff6cd27f001
created by unique.runtime_registerUniqueMapCleanup in goroutine 1
        /opt/hostedtoolcache/go/1.24.3/x64/src/runtime/mgc.go:1794 +0x85
exit status 2

English is not my native language; please excuse typing errors.

AnxiangLemon avatar Jun 17 '25 12:06 AnxiangLemon

Hey, unfortunately, there are still some issues using frida-go on windows, specifically the issue is related to two go runtimes being present (frida-go and frida-compiler-backend that now uses typescript-go). I am working on fixing it and will probably have it in the next couple of days.

NSEcho avatar Jun 17 '25 13:06 NSEcho