├── .github ├── FUNDING.yml ├── CODEOWNERS └── workflows │ └── style.yml ├── libs ├── meson.build └── gum │ ├── meson.build │ ├── prof │ ├── gummalloccountsampler.h │ ├── gumsampler.c │ ├── gumwallclocksampler.h │ ├── gumcyclesampler.h │ ├── gumbusycyclesampler.h │ ├── gumsampler.h │ └── gumusertimesampler.h │ ├── gum-prof.h │ ├── gum-heap.h │ └── heap │ ├── gumallocationgroup.h │ ├── gumcobject.h │ ├── gumallocationgroup.c │ ├── gumallocationblock.h │ ├── gumallocatorprobe.h │ ├── gumcobjecttracker.h │ ├── gumcobject.c │ └── gumallocationblock.c ├── tests ├── dummy.cpp ├── dummy.mm ├── core │ ├── mapper.symbols │ ├── swiftapiresolver │ │ ├── runner.symbols │ │ ├── runner.version │ │ ├── runner.js │ │ └── meson.build │ ├── targetfunctions │ │ ├── specialfunctions.symbols │ │ ├── meson_options.txt │ │ ├── specialfunctions.version │ │ ├── targetfunctions.symbols │ │ ├── targetfunctions.version │ │ ├── specialfunctions.c │ │ ├── Makefile │ │ └── targetfunctions.c │ ├── mapper.xcent │ ├── arch-arm64 │ │ └── stalker-arm64-darwin.m │ └── interceptor-callbacklistener.h ├── gum-tests.symbols ├── data │ ├── targetfunctions-qnx-arm.so │ ├── specialfunctions-linux-arm.so │ ├── specialfunctions-linux-x86.so │ ├── specialfunctions-qnx-arm.so │ ├── targetfunctions-ios-arm.dylib │ ├── targetfunctions-ios-x86.dylib │ ├── targetfunctions-linux-arm.so │ ├── targetfunctions-linux-mips.so │ ├── targetfunctions-linux-x86.so │ ├── specialfunctions-android-arm.so │ ├── specialfunctions-android-x86.so │ ├── specialfunctions-ios-arm.dylib │ ├── specialfunctions-ios-x86.dylib │ ├── specialfunctions-linux-arm64.so │ ├── specialfunctions-linux-armhf.so │ ├── specialfunctions-linux-mips.so │ ├── targetfunctions-android-arm.so │ ├── targetfunctions-android-x86.so │ ├── targetfunctions-ios-arm64.dylib │ ├── targetfunctions-linux-arm64.so │ ├── targetfunctions-linux-armbe8.so │ ├── targetfunctions-linux-armhf.so │ ├── targetfunctions-linux-mips64.so │ ├── targetfunctions-linux-mipsel.so │ ├── targetfunctions-linux-x86_64.so │ ├── targetfunctions-macos-x86.dylib │ ├── specialfunctions-android-arm64.so │ ├── specialfunctions-android-x86_64.so │ ├── specialfunctions-freebsd-arm64.so │ ├── specialfunctions-freebsd-x86_64.so │ ├── specialfunctions-ios-arm64.dylib │ ├── specialfunctions-ios-arm64e.dylib │ ├── specialfunctions-ios-x86_64.dylib │ ├── specialfunctions-linux-arm64be.so │ ├── specialfunctions-linux-armbe8.so │ ├── specialfunctions-linux-mips64.so │ ├── specialfunctions-linux-mips64el.so │ ├── specialfunctions-linux-mipsel.so │ ├── specialfunctions-linux-x86_64.so │ ├── specialfunctions-macos-arm64.dylib │ ├── specialfunctions-macos-x86.dylib │ ├── specialfunctions-tvos-arm64.dylib │ ├── targetfunctions-android-arm64.so │ ├── targetfunctions-android-x86_64.so │ ├── targetfunctions-freebsd-arm64.so │ ├── targetfunctions-freebsd-x86_64.so │ ├── targetfunctions-ios-arm64e.dylib │ ├── targetfunctions-ios-x86_64.dylib │ ├── targetfunctions-linux-arm64be.so │ ├── targetfunctions-linux-mips64el.so │ ├── targetfunctions-macos-arm64.dylib │ ├── targetfunctions-macos-arm64e.dylib │ ├── targetfunctions-macos-x86_64.dylib │ ├── targetfunctions-tvos-arm64.dylib │ ├── specialfunctions-macos-arm64e.dylib │ ├── specialfunctions-macos-x86_64.dylib │ ├── specialfunctions-watchos-arm64.dylib │ ├── targetfunctions-watchos-arm64.dylib │ ├── specialfunctions-linux-arm64beilp32.so │ ├── targetfunctions-linux-arm64beilp32.so │ ├── prebuiltcmodule.c │ └── meson.build ├── gum-tests.version ├── run-android-x86.sh ├── run-android-x86_64.sh ├── run-android-arm.sh ├── run-android-arm64.sh ├── prof │ ├── meson.build │ ├── fakesampler.h │ └── sampler-fixture.c ├── gumjs │ └── meson.build ├── stubs │ ├── objc │ │ ├── dummyclass.h │ │ ├── meson.build │ │ └── dummyclass.m │ ├── dummyclasses.h │ ├── dummyclasses.c │ ├── fakebacktracer.h │ └── fakeeventsink.h ├── gum-tests-android.version ├── run-android.sh ├── run-qnx.sh ├── gumpp │ └── meson.build ├── heap │ ├── meson.build │ └── pagepool-fixture.c ├── gum-tests.xcent ├── vm.py ├── run.py ├── gum-tests.plist ├── run-linux-vm.sh ├── sign.sh ├── stalkerdummychannel.h └── run-ios.sh ├── ext ├── meson.build ├── symsrv │ ├── x86 │ │ └── symsrv.dll │ ├── arm64 │ │ └── symsrv.dll │ ├── x86_64 │ │ └── symsrv.dll │ └── meson.build └── dbghelp │ ├── x86 │ └── dbghelp.dll │ ├── arm64 │ └── dbghelp.dll │ ├── x86_64 │ └── dbghelp.dll │ └── meson.build ├── bindings ├── gumjs │ ├── runtime │ │ ├── cmodule-tcc │ │ │ ├── stdint.h │ │ │ ├── stdlib.h │ │ │ ├── inttypes.h │ │ │ ├── stdio.h │ │ │ └── string.h │ │ ├── cmodule │ │ │ └── gum │ │ │ │ ├── gummetalhash.h │ │ │ │ ├── gumprocess.h │ │ │ │ ├── gummetalarray.h │ │ │ │ ├── gummodule.h │ │ │ │ ├── gumtls.h │ │ │ │ ├── gumspinlock.h │ │ │ │ └── gummodulemap.h │ │ ├── entrypoint-v8.js │ │ └── entrypoint-quickjs.js │ ├── gumjs.h │ ├── gumansi.h │ ├── gumquickscriptbackend.h │ ├── gumv8script.h │ ├── gumquickscript.h │ ├── gumjs.c │ ├── gumv8cloak.h │ ├── gumv8kernel.h │ ├── gumv8file.h │ ├── gumquickcloak.h │ ├── gumquickkernel.h │ ├── devkit │ │ └── meson.build │ ├── gumquickfile.h │ ├── gumv8checksum.h │ ├── gumsourcemap.h │ ├── gumquicksymbol.h │ ├── gumv8cmodule.h │ ├── gumquickchecksum.h │ ├── gumquickcmodule.h │ ├── gumv8symbol.h │ ├── gumv8memory.h │ ├── gumv8codewriter.h │ ├── gumquickcodewriter.h │ ├── gumquickdatabase.h │ ├── gumquickapiresolver.h │ ├── gumquickmemory.h │ ├── gumv8apiresolver.h │ ├── gumv8database.h │ ├── gumquickprofiler.h │ ├── gumv8socket.h │ ├── gumquicksocket.h │ ├── guminspectorserver.h │ ├── gumv8codewriter.cpp │ ├── gumv8profiler.h │ ├── gumv8sampler.h │ ├── gumv8coderelocator.h │ ├── gumquickmodule.h │ ├── gumquickstream.h │ ├── gumv8scriptbackend.h │ ├── gumv8enumeratecontext.h │ ├── gumquickthread.h │ ├── gumquickcoderelocator.h │ ├── gumv8thread.h │ ├── gumv8stream.h │ ├── gumquickscript-priv.h │ ├── gumquicksampler.h │ ├── gumquickcodewriter.c │ └── gumv8coderelocator.cpp ├── meson.build └── gumpp │ ├── runtime.hpp │ ├── gumpp.symbols │ ├── gumpp.def │ ├── returnaddress.cpp │ ├── gumpp.version │ ├── string.hpp │ ├── invocationlistener.hpp │ ├── podwrapper.hpp │ ├── symbolutil.cpp │ ├── objectwrapper.hpp │ ├── runtime.cpp │ └── gumpp-static.filters ├── .gitignore ├── .gitmodules ├── BSDmakefile ├── vapi ├── capstone.vapi ├── libffi.vapi ├── libtcc.vapi ├── v8-10.0.vapi ├── frida-gum-windows-1.0.vapi ├── frida-gum-linux-1.0.vapi ├── frida-gum-freebsd-1.0.vapi ├── frida-gumjs-inspector-1.0.vapi ├── meson.build └── frida-gum-heap-1.0.vapi ├── subprojects ├── v8.wrap ├── xz.wrap ├── libffi.wrap ├── tinycc.wrap ├── quickjs.wrap ├── sqlite.wrap ├── capstone.wrap ├── libdwarf.wrap ├── libsoup.wrap ├── libunwind.wrap ├── minizip-ng.wrap ├── json-glib.wrap ├── openssl.wrap ├── glib-networking.wrap └── glib.wrap ├── tools └── meson.build ├── gum ├── backend-qnx │ ├── gumqnx-priv.h │ ├── gumthreadregistry-qnx.c │ ├── include │ │ └── gum │ │ │ └── gumqnx.h │ └── gummodule-qnx.c ├── arch-mips │ ├── gummipsreader.c │ ├── gummipsreader.h │ └── gummipsbacktracer.h ├── backend-barebone │ ├── gumthreadregistry-barebone.c │ ├── gummodule-barebone.c │ ├── include │ │ └── gum │ │ │ └── gumbarebone.h │ ├── gummoduleregistry-barebone.c │ ├── gumtls-barebone.c │ ├── gumsymbolutil-barebone.c │ └── gumexceptor-barebone.c ├── backend-freebsd │ ├── gumthreadregistry-freebsd.c │ ├── gummodule-freebsd.c │ └── include │ │ └── gum │ │ └── gumfreebsd.h ├── gumcloak-priv.h ├── backend-darwin │ ├── gumtvos.h │ ├── gumobjcapiresolver-priv.h │ ├── helpers │ │ ├── threadedbindprocessor.h │ │ └── Makefile │ ├── gumobjcapiresolver.h │ ├── include │ │ └── gum │ │ │ └── gumdarwinbacktracer.h │ ├── substrated.defs │ ├── gumobjcdisposeclasspairmonitor.h │ └── gummodule-darwin.h ├── gumtls-priv.h ├── gumfunction.h ├── arch-arm │ ├── gumarmreader.h │ ├── gumthumbreader.h │ └── gumarmbacktracer.h ├── gumstalker-priv.h ├── gumlibc.h ├── gum-init.h ├── gumsysinternals.h ├── gumleb.h ├── gumtls.h ├── arch-x86 │ ├── gumx86backtracer.h │ └── gumx86reader.h ├── gumprintf.h ├── arch-arm64 │ ├── gumarm64backtracer.h │ └── gumarm64reader.h ├── backend-libunwind │ └── include │ │ └── gum │ │ └── gumunwbacktracer.h ├── gumenumtypes.h.template ├── gummoduleapiresolver.h ├── backend-windows │ ├── gummodule-windows.h │ └── include │ │ └── gum │ │ └── gumwindows.h ├── devkit │ └── meson.build ├── gumswiftapiresolver.h ├── backend-dbghelp │ └── include │ │ └── gum │ │ └── gumdbghelpbacktracer.h ├── gummemorymap.h ├── gummodulefacade.h ├── gumspinlock.h ├── gumthreadregistry-priv.h ├── gumintrospect.c ├── gummoduleregistry.h ├── gumthreadregistry.h ├── backend-arm64 │ ├── gumstalker-arm64-glue.masm │ └── gumcpucontext-arm64.c ├── gumexceptorbackend.h ├── backend-posix │ └── gumtls-posix.c ├── gummoduleregistry-priv.h ├── gummodulemap.h ├── gumenumtypes.c.template ├── gumcodesegment.h ├── backend-elf │ └── gummoduleregistry-elf.h ├── gumdarwingrafter.h ├── gumreturnaddress.h ├── gummemory-priv.h ├── gumsymbolutil.h ├── backend-arm │ └── gumcpucontext-arm.c ├── gumspinlock.c ├── gumlibc.c ├── backend-x86 │ └── gumstalker-x86-glue.S ├── gummetalarray.h └── gumbacktracer.h ├── configure ├── Makefile ├── .cirrus.yml ├── docs └── config.toml ├── configure.bat └── make.bat /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: frida 2 | -------------------------------------------------------------------------------- /libs/meson.build: -------------------------------------------------------------------------------- 1 | subdir('gum') 2 | -------------------------------------------------------------------------------- /tests/dummy.cpp: -------------------------------------------------------------------------------- 1 | // Force C++ linking 2 | -------------------------------------------------------------------------------- /tests/dummy.mm: -------------------------------------------------------------------------------- 1 | // Force C++ linking 2 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | /.github/workflows/ @oleavr 2 | -------------------------------------------------------------------------------- /tests/core/mapper.symbols: -------------------------------------------------------------------------------- 1 | # No exported symbols. 2 | -------------------------------------------------------------------------------- /tests/gum-tests.symbols: -------------------------------------------------------------------------------- 1 | # No exported symbols. 2 | -------------------------------------------------------------------------------- /ext/meson.build: -------------------------------------------------------------------------------- 1 | subdir('dbghelp') 2 | subdir('symsrv') 3 | -------------------------------------------------------------------------------- /bindings/gumjs/runtime/cmodule-tcc/stdint.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /bindings/gumjs/runtime/cmodule-tcc/stdlib.h: -------------------------------------------------------------------------------- 1 | /* Empty for now. */ 2 | -------------------------------------------------------------------------------- /bindings/gumjs/runtime/cmodule-tcc/inttypes.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /tests/core/swiftapiresolver/runner.symbols: -------------------------------------------------------------------------------- 1 | _init 2 | _finalize 3 | _run 4 | -------------------------------------------------------------------------------- /tests/core/targetfunctions/specialfunctions.symbols: -------------------------------------------------------------------------------- 1 | _gum_test_special_function 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | /deps/ 3 | /gum/backend-darwin/helpers/build/ 4 | /subprojects/* 5 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "releng"] 2 | path = releng 3 | url = https://github.com/frida/releng.git 4 | -------------------------------------------------------------------------------- /ext/symsrv/x86/symsrv.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/ext/symsrv/x86/symsrv.dll -------------------------------------------------------------------------------- /tests/core/mapper.xcent: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/core/mapper.xcent -------------------------------------------------------------------------------- /BSDmakefile: -------------------------------------------------------------------------------- 1 | all: .DEFAULT 2 | 3 | .DEFAULT: 4 | @gmake ${.MAKEFLAGS} ${.TARGETS} 5 | 6 | .PHONY: all 7 | -------------------------------------------------------------------------------- /ext/dbghelp/x86/dbghelp.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/ext/dbghelp/x86/dbghelp.dll -------------------------------------------------------------------------------- /ext/symsrv/arm64/symsrv.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/ext/symsrv/arm64/symsrv.dll -------------------------------------------------------------------------------- /vapi/capstone.vapi: -------------------------------------------------------------------------------- 1 | // Placeholder to satisfy Meson's assumption that a vapi exists for each dependency. 2 | -------------------------------------------------------------------------------- /vapi/libffi.vapi: -------------------------------------------------------------------------------- 1 | // Placeholder to satisfy Meson's assumption that a vapi exists for each dependency. 2 | -------------------------------------------------------------------------------- /vapi/libtcc.vapi: -------------------------------------------------------------------------------- 1 | // Placeholder to satisfy Meson's assumption that a vapi exists for each dependency. 2 | -------------------------------------------------------------------------------- /vapi/v8-10.0.vapi: -------------------------------------------------------------------------------- 1 | // Placeholder to satisfy Meson's assumption that a vapi exists for each dependency. 2 | -------------------------------------------------------------------------------- /ext/dbghelp/arm64/dbghelp.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/ext/dbghelp/arm64/dbghelp.dll -------------------------------------------------------------------------------- /ext/dbghelp/x86_64/dbghelp.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/ext/dbghelp/x86_64/dbghelp.dll -------------------------------------------------------------------------------- /ext/symsrv/x86_64/symsrv.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/ext/symsrv/x86_64/symsrv.dll -------------------------------------------------------------------------------- /tests/data/targetfunctions-qnx-arm.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/targetfunctions-qnx-arm.so -------------------------------------------------------------------------------- /tests/core/targetfunctions/meson_options.txt: -------------------------------------------------------------------------------- 1 | option('stem_suffix', type: 'string', value: '', description: 'Stem suffix used') 2 | -------------------------------------------------------------------------------- /tests/data/specialfunctions-linux-arm.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/specialfunctions-linux-arm.so -------------------------------------------------------------------------------- /tests/data/specialfunctions-linux-x86.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/specialfunctions-linux-x86.so -------------------------------------------------------------------------------- /tests/data/specialfunctions-qnx-arm.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/specialfunctions-qnx-arm.so -------------------------------------------------------------------------------- /tests/data/targetfunctions-ios-arm.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/targetfunctions-ios-arm.dylib -------------------------------------------------------------------------------- /tests/data/targetfunctions-ios-x86.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/targetfunctions-ios-x86.dylib -------------------------------------------------------------------------------- /tests/data/targetfunctions-linux-arm.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/targetfunctions-linux-arm.so -------------------------------------------------------------------------------- /tests/data/targetfunctions-linux-mips.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/targetfunctions-linux-mips.so -------------------------------------------------------------------------------- /tests/data/targetfunctions-linux-x86.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/targetfunctions-linux-x86.so -------------------------------------------------------------------------------- /tests/data/specialfunctions-android-arm.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/specialfunctions-android-arm.so -------------------------------------------------------------------------------- /tests/data/specialfunctions-android-x86.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/specialfunctions-android-x86.so -------------------------------------------------------------------------------- /tests/data/specialfunctions-ios-arm.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/specialfunctions-ios-arm.dylib -------------------------------------------------------------------------------- /tests/data/specialfunctions-ios-x86.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/specialfunctions-ios-x86.dylib -------------------------------------------------------------------------------- /tests/data/specialfunctions-linux-arm64.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/specialfunctions-linux-arm64.so -------------------------------------------------------------------------------- /tests/data/specialfunctions-linux-armhf.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/specialfunctions-linux-armhf.so -------------------------------------------------------------------------------- /tests/data/specialfunctions-linux-mips.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/specialfunctions-linux-mips.so -------------------------------------------------------------------------------- /tests/data/targetfunctions-android-arm.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/targetfunctions-android-arm.so -------------------------------------------------------------------------------- /tests/data/targetfunctions-android-x86.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/targetfunctions-android-x86.so -------------------------------------------------------------------------------- /tests/data/targetfunctions-ios-arm64.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/targetfunctions-ios-arm64.dylib -------------------------------------------------------------------------------- /tests/data/targetfunctions-linux-arm64.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/targetfunctions-linux-arm64.so -------------------------------------------------------------------------------- /tests/data/targetfunctions-linux-armbe8.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/targetfunctions-linux-armbe8.so -------------------------------------------------------------------------------- /tests/data/targetfunctions-linux-armhf.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/targetfunctions-linux-armhf.so -------------------------------------------------------------------------------- /tests/data/targetfunctions-linux-mips64.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/targetfunctions-linux-mips64.so -------------------------------------------------------------------------------- /tests/data/targetfunctions-linux-mipsel.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/targetfunctions-linux-mipsel.so -------------------------------------------------------------------------------- /tests/data/targetfunctions-linux-x86_64.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/targetfunctions-linux-x86_64.so -------------------------------------------------------------------------------- /tests/data/targetfunctions-macos-x86.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/targetfunctions-macos-x86.dylib -------------------------------------------------------------------------------- /tests/core/targetfunctions/specialfunctions.version: -------------------------------------------------------------------------------- 1 | { 2 | global: 3 | gum_test_special_function; 4 | 5 | local: 6 | *; 7 | }; 8 | -------------------------------------------------------------------------------- /tests/data/specialfunctions-android-arm64.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/specialfunctions-android-arm64.so -------------------------------------------------------------------------------- /tests/data/specialfunctions-android-x86_64.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/specialfunctions-android-x86_64.so -------------------------------------------------------------------------------- /tests/data/specialfunctions-freebsd-arm64.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/specialfunctions-freebsd-arm64.so -------------------------------------------------------------------------------- /tests/data/specialfunctions-freebsd-x86_64.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/specialfunctions-freebsd-x86_64.so -------------------------------------------------------------------------------- /tests/data/specialfunctions-ios-arm64.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/specialfunctions-ios-arm64.dylib -------------------------------------------------------------------------------- /tests/data/specialfunctions-ios-arm64e.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/specialfunctions-ios-arm64e.dylib -------------------------------------------------------------------------------- /tests/data/specialfunctions-ios-x86_64.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/specialfunctions-ios-x86_64.dylib -------------------------------------------------------------------------------- /tests/data/specialfunctions-linux-arm64be.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/specialfunctions-linux-arm64be.so -------------------------------------------------------------------------------- /tests/data/specialfunctions-linux-armbe8.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/specialfunctions-linux-armbe8.so -------------------------------------------------------------------------------- /tests/data/specialfunctions-linux-mips64.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/specialfunctions-linux-mips64.so -------------------------------------------------------------------------------- /tests/data/specialfunctions-linux-mips64el.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/specialfunctions-linux-mips64el.so -------------------------------------------------------------------------------- /tests/data/specialfunctions-linux-mipsel.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/specialfunctions-linux-mipsel.so -------------------------------------------------------------------------------- /tests/data/specialfunctions-linux-x86_64.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/specialfunctions-linux-x86_64.so -------------------------------------------------------------------------------- /tests/data/specialfunctions-macos-arm64.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/specialfunctions-macos-arm64.dylib -------------------------------------------------------------------------------- /tests/data/specialfunctions-macos-x86.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/specialfunctions-macos-x86.dylib -------------------------------------------------------------------------------- /tests/data/specialfunctions-tvos-arm64.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/specialfunctions-tvos-arm64.dylib -------------------------------------------------------------------------------- /tests/data/targetfunctions-android-arm64.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/targetfunctions-android-arm64.so -------------------------------------------------------------------------------- /tests/data/targetfunctions-android-x86_64.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/targetfunctions-android-x86_64.so -------------------------------------------------------------------------------- /tests/data/targetfunctions-freebsd-arm64.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/targetfunctions-freebsd-arm64.so -------------------------------------------------------------------------------- /tests/data/targetfunctions-freebsd-x86_64.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/targetfunctions-freebsd-x86_64.so -------------------------------------------------------------------------------- /tests/data/targetfunctions-ios-arm64e.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/targetfunctions-ios-arm64e.dylib -------------------------------------------------------------------------------- /tests/data/targetfunctions-ios-x86_64.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/targetfunctions-ios-x86_64.dylib -------------------------------------------------------------------------------- /tests/data/targetfunctions-linux-arm64be.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/targetfunctions-linux-arm64be.so -------------------------------------------------------------------------------- /tests/data/targetfunctions-linux-mips64el.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/targetfunctions-linux-mips64el.so -------------------------------------------------------------------------------- /tests/data/targetfunctions-macos-arm64.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/targetfunctions-macos-arm64.dylib -------------------------------------------------------------------------------- /tests/data/targetfunctions-macos-arm64e.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/targetfunctions-macos-arm64e.dylib -------------------------------------------------------------------------------- /tests/data/targetfunctions-macos-x86_64.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/targetfunctions-macos-x86_64.dylib -------------------------------------------------------------------------------- /tests/data/targetfunctions-tvos-arm64.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/targetfunctions-tvos-arm64.dylib -------------------------------------------------------------------------------- /tests/data/specialfunctions-macos-arm64e.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/specialfunctions-macos-arm64e.dylib -------------------------------------------------------------------------------- /tests/data/specialfunctions-macos-x86_64.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/specialfunctions-macos-x86_64.dylib -------------------------------------------------------------------------------- /tests/data/specialfunctions-watchos-arm64.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/specialfunctions-watchos-arm64.dylib -------------------------------------------------------------------------------- /tests/data/targetfunctions-watchos-arm64.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/targetfunctions-watchos-arm64.dylib -------------------------------------------------------------------------------- /tests/core/swiftapiresolver/runner.version: -------------------------------------------------------------------------------- 1 | { 2 | global: 3 | init; 4 | finalize; 5 | run; 6 | 7 | local: 8 | *; 9 | }; 10 | -------------------------------------------------------------------------------- /tests/data/specialfunctions-linux-arm64beilp32.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/specialfunctions-linux-arm64beilp32.so -------------------------------------------------------------------------------- /tests/data/targetfunctions-linux-arm64beilp32.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7aGiven/frida-gum/main/tests/data/targetfunctions-linux-arm64beilp32.so -------------------------------------------------------------------------------- /tests/data/prebuiltcmodule.c: -------------------------------------------------------------------------------- 1 | extern void notify (int n); 2 | 3 | int 4 | answer (void) 5 | { 6 | notify (1337); 7 | 8 | return 42; 9 | } 10 | -------------------------------------------------------------------------------- /tests/gum-tests.version: -------------------------------------------------------------------------------- 1 | { 2 | global: 3 | # FreeBSD needs these two: 4 | __progname; 5 | environ; 6 | 7 | local: 8 | *; 9 | }; 10 | -------------------------------------------------------------------------------- /tests/run-android-x86.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | arch=x86 4 | apex_libdirs=/apex/com.android.runtime/lib 5 | 6 | exec $(dirname "$0")/run-android.sh $arch $apex_libdirs "$@" 7 | -------------------------------------------------------------------------------- /tests/run-android-x86_64.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | arch=x86_64 4 | apex_libdirs=/apex/com.android.runtime/lib64 5 | 6 | exec $(dirname "$0")/run-android.sh $arch $apex_libdirs "$@" 7 | -------------------------------------------------------------------------------- /bindings/meson.build: -------------------------------------------------------------------------------- 1 | bindings_inc = include_directories('.') 2 | 3 | if have_gumpp 4 | subdir('gumpp') 5 | endif 6 | 7 | if have_gumjs 8 | subdir('gumjs') 9 | endif 10 | -------------------------------------------------------------------------------- /tests/core/targetfunctions/targetfunctions.symbols: -------------------------------------------------------------------------------- 1 | _gum_test_target_function 2 | _gum_test_target_nop_function_a 3 | _gum_test_target_nop_function_b 4 | _gum_test_target_nop_function_c 5 | -------------------------------------------------------------------------------- /bindings/gumjs/runtime/cmodule/gum/gummetalhash.h: -------------------------------------------------------------------------------- 1 | #ifndef __GUM_METAL_HASH_H__ 2 | #define __GUM_METAL_HASH_H__ 3 | 4 | typedef struct _GumMetalHashTable GumMetalHashTable; 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /libs/gum/meson.build: -------------------------------------------------------------------------------- 1 | umbrella_headers = [ 2 | 'gum-heap.h', 3 | 'gum-prof.h', 4 | ] 5 | install_headers(umbrella_headers, subdir: install_header_subdir) 6 | 7 | subdir('heap') 8 | subdir('prof') 9 | -------------------------------------------------------------------------------- /subprojects/v8.wrap: -------------------------------------------------------------------------------- 1 | [wrap-git] 2 | url = https://github.com/frida/v8.git 3 | revision = 669119f601663b73fc01f8eee02cf2f093bbf25b 4 | depth = 1 5 | 6 | [provide] 7 | dependency_names = v8-10.0 8 | 9 | -------------------------------------------------------------------------------- /subprojects/xz.wrap: -------------------------------------------------------------------------------- 1 | [wrap-git] 2 | url = https://github.com/frida/xz.git 3 | revision = e70f5800ab5001c9509d374dbf3e7e6b866c43fe 4 | depth = 1 5 | 6 | [provide] 7 | dependency_names = liblzma 8 | 9 | -------------------------------------------------------------------------------- /tests/run-android-arm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | arch=arm 4 | apex_libdirs="/apex/com.android.art/lib:/apex/com.android.runtime/lib" 5 | 6 | exec $(dirname "$0")/run-android.sh $arch $apex_libdirs "$@" 7 | -------------------------------------------------------------------------------- /subprojects/libffi.wrap: -------------------------------------------------------------------------------- 1 | [wrap-git] 2 | url = https://github.com/frida/libffi.git 3 | revision = cca9fc2909f67d340f4a13ae274587eaf273371d 4 | depth = 1 5 | 6 | [provide] 7 | dependency_names = libffi 8 | 9 | -------------------------------------------------------------------------------- /subprojects/tinycc.wrap: -------------------------------------------------------------------------------- 1 | [wrap-git] 2 | url = https://github.com/frida/tinycc.git 3 | revision = 86c2ba69e97af8f311dff04fcf517b760b3e4491 4 | depth = 1 5 | 6 | [provide] 7 | dependency_names = libtcc 8 | 9 | -------------------------------------------------------------------------------- /subprojects/quickjs.wrap: -------------------------------------------------------------------------------- 1 | [wrap-git] 2 | url = https://github.com/frida/quickjs.git 3 | revision = f48e71e5240106dbca136e60f751e206d15cdb3f 4 | depth = 1 5 | 6 | [provide] 7 | dependency_names = quickjs 8 | 9 | -------------------------------------------------------------------------------- /subprojects/sqlite.wrap: -------------------------------------------------------------------------------- 1 | [wrap-git] 2 | url = https://github.com/frida/sqlite.git 3 | revision = 9337327a50008f2d2236112ccb6f44059b1bafbd 4 | depth = 1 5 | 6 | [provide] 7 | dependency_names = sqlite3 8 | 9 | -------------------------------------------------------------------------------- /tests/run-android-arm64.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | arch=arm64 4 | apex_libdirs="/apex/com.android.art/lib64:/apex/com.android.runtime/lib64" 5 | 6 | exec $(dirname "$0")/run-android.sh $arch $apex_libdirs "$@" 7 | -------------------------------------------------------------------------------- /subprojects/capstone.wrap: -------------------------------------------------------------------------------- 1 | [wrap-git] 2 | url = https://github.com/frida/capstone.git 3 | revision = 27fb5a53bc77baf3c3af7ccd466041418cecca35 4 | depth = 1 5 | 6 | [provide] 7 | dependency_names = capstone 8 | 9 | -------------------------------------------------------------------------------- /subprojects/libdwarf.wrap: -------------------------------------------------------------------------------- 1 | [wrap-git] 2 | url = https://github.com/frida/libdwarf.git 3 | revision = 50e3115b340c6a58d2f61af96f120a9d111ac024 4 | depth = 1 5 | 6 | [provide] 7 | dependency_names = libdwarf 8 | 9 | -------------------------------------------------------------------------------- /subprojects/libsoup.wrap: -------------------------------------------------------------------------------- 1 | [wrap-git] 2 | url = https://github.com/frida/libsoup.git 3 | revision = 80dc080951c9037aef51a40ffbe4508d3ce98d1b 4 | depth = 1 5 | 6 | [provide] 7 | dependency_names = libsoup-3.0 8 | 9 | -------------------------------------------------------------------------------- /subprojects/libunwind.wrap: -------------------------------------------------------------------------------- 1 | [wrap-git] 2 | url = https://github.com/frida/libunwind.git 3 | revision = 4d0abea0effd3c80916e70abe38c2a6156596f05 4 | depth = 1 5 | 6 | [provide] 7 | dependency_names = libunwind 8 | 9 | -------------------------------------------------------------------------------- /subprojects/minizip-ng.wrap: -------------------------------------------------------------------------------- 1 | [wrap-git] 2 | url = https://github.com/frida/minizip-ng.git 3 | revision = dfc1ccc070ff7bb50726c80215cac515253a8ba0 4 | depth = 1 5 | 6 | [provide] 7 | dependency_names = minizip 8 | 9 | -------------------------------------------------------------------------------- /bindings/gumjs/runtime/entrypoint-v8.js: -------------------------------------------------------------------------------- 1 | import './core.js'; 2 | import './error-handler-v8.js'; 3 | 4 | Script.load = async (name, source) => { 5 | Script._load(name, source); 6 | return await import(name); 7 | }; 8 | -------------------------------------------------------------------------------- /subprojects/json-glib.wrap: -------------------------------------------------------------------------------- 1 | [wrap-git] 2 | url = https://github.com/frida/json-glib.git 3 | revision = 1a39cbe151b02c4192987c8fcc98997a59db2154 4 | depth = 1 5 | 6 | [provide] 7 | dependency_names = json-glib-1.0 8 | 9 | -------------------------------------------------------------------------------- /subprojects/openssl.wrap: -------------------------------------------------------------------------------- 1 | [wrap-git] 2 | url = https://github.com/frida/openssl.git 3 | revision = 5029c4562d23547d8e29768e1b0de573c52bf3fc 4 | depth = 1 5 | 6 | [provide] 7 | dependency_names = openssl libcrypto libssl 8 | 9 | -------------------------------------------------------------------------------- /subprojects/glib-networking.wrap: -------------------------------------------------------------------------------- 1 | [wrap-git] 2 | url = https://github.com/frida/glib-networking.git 3 | revision = af4b017028e695528951c749a7096e96359521d8 4 | depth = 1 5 | 6 | [provide] 7 | dependency_names = gioopenssl 8 | 9 | -------------------------------------------------------------------------------- /tools/meson.build: -------------------------------------------------------------------------------- 1 | if get_option('graft_tool') \ 2 | .disable_auto_if(meson.is_subproject()) \ 3 | .allowed() 4 | executable('gum-graft', 'gumgraft.c', 5 | dependencies: [gum_dep], 6 | install: true, 7 | ) 8 | endif 9 | -------------------------------------------------------------------------------- /vapi/frida-gum-windows-1.0.vapi: -------------------------------------------------------------------------------- 1 | [CCode (cheader_filename = "gum/gumwindows.h")] 2 | namespace Gum.Windows { 3 | public Gum.CpuType query_native_cpu_type (); 4 | public Gum.CpuType cpu_type_from_pid (uint pid) throws Gum.Error; 5 | } 6 | -------------------------------------------------------------------------------- /bindings/gumjs/runtime/cmodule/gum/gumprocess.h: -------------------------------------------------------------------------------- 1 | #ifndef __GUM_PROCESS_H__ 2 | #define __GUM_PROCESS_H__ 3 | 4 | #include "gumdefs.h" 5 | 6 | gint gum_thread_get_system_error (void); 7 | void gum_thread_set_system_error (gint value); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /tests/core/targetfunctions/targetfunctions.version: -------------------------------------------------------------------------------- 1 | { 2 | global: 3 | gum_test_target_function; 4 | gum_test_target_nop_function_a; 5 | gum_test_target_nop_function_b; 6 | gum_test_target_nop_function_c; 7 | 8 | local: 9 | *; 10 | }; 11 | -------------------------------------------------------------------------------- /tests/prof/meson.build: -------------------------------------------------------------------------------- 1 | prof_sources = [ 2 | 'fakesampler.c', 3 | 'profiler.c', 4 | 'sampler.c', 5 | ] 6 | 7 | gum_tests_prof = static_library('gum-tests-prof', prof_sources, 8 | include_directories: test_incdirs, 9 | dependencies: [gum_dep], 10 | ) 11 | -------------------------------------------------------------------------------- /tests/gumjs/meson.build: -------------------------------------------------------------------------------- 1 | gumjs_sources = [ 2 | 'script.c', 3 | 'kscript.c', 4 | ] 5 | 6 | gum_tests_gumjs = static_library('gum-tests-gumjs', gumjs_sources, 7 | include_directories: test_incdirs, 8 | dependencies: [gumjs_dep, gumjs_inspector_dep], 9 | ) 10 | -------------------------------------------------------------------------------- /subprojects/glib.wrap: -------------------------------------------------------------------------------- 1 | [wrap-git] 2 | url = https://github.com/frida/glib.git 3 | revision = 9dc59b1b5503789ada22f7699e53256fa3287217 4 | depth = 1 5 | 6 | [provide] 7 | dependency_names = glib-2.0, gobject-2.0, gthread-2.0, gmodule-2.0, gio-2.0, gio-unix-2.0, gio-win32-2.0 8 | 9 | -------------------------------------------------------------------------------- /bindings/gumpp/runtime.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __RUNTIME_HPP__ 2 | #define __RUNTIME_HPP__ 3 | 4 | namespace Gum 5 | { 6 | class Runtime 7 | { 8 | public: 9 | static void ref (); 10 | static void unref (); 11 | 12 | private: 13 | static volatile int ref_count; 14 | }; 15 | } 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /tests/stubs/objc/dummyclass.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 Abdelrahman Eid 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __DUMMY_CLASS_H__ 8 | #define __DUMMY_CLASS_H__ 9 | 10 | void * dummy_class_get_dummy_method_impl (void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /tests/stubs/objc/meson.build: -------------------------------------------------------------------------------- 1 | objcdummyclass = custom_target('objcdummyclass', 2 | input: static_library('objcdummyclass-raw', 'dummyclass.m'), 3 | output: 'libobjcdummyclass.a', 4 | command: [ 5 | find_program('strip'), 6 | '-x', 7 | '@INPUT@', 8 | '-o', 9 | '@OUTPUT@', 10 | ], 11 | ) 12 | -------------------------------------------------------------------------------- /gum/backend-qnx/gumqnx-priv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licence: wxWindows Library Licence, Version 3.1 3 | */ 4 | 5 | #ifndef __GUM_QNX_PRIV_H__ 6 | #define __GUM_QNX_PRIV_H__ 7 | 8 | #include "gummemory.h" 9 | 10 | G_GNUC_INTERNAL GumPageProtection _gum_page_protection_from_posix ( 11 | const gint flags); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /ext/symsrv/meson.build: -------------------------------------------------------------------------------- 1 | symsrv_prefix = get_option('prefix') / get_option('libdir') / 'frida' 2 | uninstalled_symsrv_prefix = meson.current_source_dir() 3 | 4 | if host_os_family == 'windows' 5 | symsrv_dll = files(host_arch / 'symsrv.dll') 6 | install_data(symsrv_dll, install_dir: symsrv_prefix / host_arch) 7 | endif 8 | -------------------------------------------------------------------------------- /ext/dbghelp/meson.build: -------------------------------------------------------------------------------- 1 | dbghelp_prefix = get_option('prefix') / get_option('libdir') / 'frida' 2 | uninstalled_dbghelp_prefix = meson.current_source_dir() 3 | 4 | if host_os_family == 'windows' 5 | dbghelp_dll = files(host_arch / 'dbghelp.dll') 6 | install_data(dbghelp_dll, install_dir: dbghelp_prefix / host_arch) 7 | endif 8 | -------------------------------------------------------------------------------- /tests/gum-tests-android.version: -------------------------------------------------------------------------------- 1 | { 2 | global: 3 | ClaimSignalChain; 4 | UnclaimSignalChain; 5 | InvokeUserSignalHandler; 6 | InitializeSignalChain; 7 | EnsureFrontOfChain; 8 | SetSpecialSignalHandlerFn; 9 | AddSpecialSignalHandlerFn; 10 | RemoveSpecialSignalHandlerFn; 11 | 12 | local: 13 | *; 14 | }; 15 | -------------------------------------------------------------------------------- /tests/run-android.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | arch=$1 4 | apex_libdirs=$2 5 | 6 | remote_prefix=/data/local/tmp/frida-tests-$arch 7 | 8 | set -e 9 | make 10 | cd build/tests 11 | adb shell "mkdir $remote_prefix 2>/dev/null || true" 12 | adb push gum-tests data $remote_prefix 13 | adb shell "LD_LIBRARY_PATH='$apex_libdirs' $remote_prefix/gum-tests $@" 14 | -------------------------------------------------------------------------------- /tests/run-qnx.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | runner_tarball=$(mktemp "/tmp/gum-tests.XXXXXX") 4 | 5 | function dispose { 6 | rm -f "$runner_tarball" 7 | } 8 | trap dispose EXIT 9 | 10 | set -ex 11 | 12 | make 13 | 14 | cd build/tests 15 | tar -cf "$runner_tarball" gum-tests data/ 16 | /opt/sabrelite/run.sh "$runner_tarball" /opt/frida/gum-tests 17 | -------------------------------------------------------------------------------- /vapi/frida-gum-linux-1.0.vapi: -------------------------------------------------------------------------------- 1 | [CCode (cheader_filename = "gum/gumlinux.h")] 2 | namespace Gum.Linux { 3 | public Gum.CpuType cpu_type_from_file (string path) throws Gum.Error; 4 | public Gum.CpuType cpu_type_from_pid (Posix.pid_t pid) throws Gum.Error; 5 | public void enumerate_ranges (Posix.pid_t pid, Gum.PageProtection prot, Gum.FoundRangeFunc func); 6 | } 7 | -------------------------------------------------------------------------------- /bindings/gumjs/runtime/cmodule/gum/gummetalarray.h: -------------------------------------------------------------------------------- 1 | #ifndef __GUM_METAL_ARRAY_H__ 2 | #define __GUM_METAL_ARRAY_H__ 3 | 4 | #include 5 | 6 | typedef struct _GumMetalArray GumMetalArray; 7 | 8 | struct _GumMetalArray 9 | { 10 | gpointer data; 11 | guint length; 12 | guint capacity; 13 | 14 | guint element_size; 15 | }; 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /vapi/frida-gum-freebsd-1.0.vapi: -------------------------------------------------------------------------------- 1 | [CCode (cheader_filename = "gum/gumfreebsd.h")] 2 | namespace Gum.Freebsd { 3 | public string query_program_path_for_self () throws Gum.Error; 4 | public string query_program_path_for_pid (Posix.pid_t pid) throws Gum.Error; 5 | public void enumerate_ranges (Posix.pid_t pid, Gum.PageProtection prot, Gum.FoundRangeFunc func); 6 | } 7 | -------------------------------------------------------------------------------- /tests/gumpp/meson.build: -------------------------------------------------------------------------------- 1 | gumpp_sources = [ 2 | 'backtracer.cxx', 3 | ] 4 | 5 | gum_tests_gumpp = static_library('gum-tests-gumpp', gumpp_sources, 6 | override_options: [ 7 | 'cpp_std=c++14', 8 | 'cpp_eh=default', 9 | 'cpp_rtti=false', 10 | ], 11 | include_directories: test_incdirs, 12 | dependencies: [gumpp_dep, gum_dep], 13 | ) 14 | -------------------------------------------------------------------------------- /bindings/gumjs/runtime/cmodule/gum/gummodule.h: -------------------------------------------------------------------------------- 1 | #ifndef __GUM_MODULE_H__ 2 | #define __GUM_MODULE_H__ 3 | 4 | #include "gumdefs.h" 5 | 6 | typedef struct _GumModule GumModule; 7 | 8 | const gchar * gum_module_get_name (GumModule * self); 9 | const gchar * gum_module_get_path (GumModule * self); 10 | const GumMemoryRange * gum_module_get_range (GumModule * self); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /bindings/gumjs/runtime/cmodule/gum/gumtls.h: -------------------------------------------------------------------------------- 1 | #ifndef __GUM_TLS_H__ 2 | #define __GUM_TLS_H__ 3 | 4 | #include 5 | 6 | typedef gsize GumTlsKey; 7 | 8 | GumTlsKey gum_tls_key_new (void); 9 | void gum_tls_key_free (GumTlsKey key); 10 | 11 | gpointer gum_tls_key_get_value (GumTlsKey key); 12 | void gum_tls_key_set_value (GumTlsKey key, gpointer value); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /gum/arch-mips/gummipsreader.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #include "gummipsreader.h" 8 | 9 | #include 10 | 11 | gpointer 12 | gum_mips_reader_try_get_relative_jump_target (gconstpointer address) 13 | { 14 | g_assert_not_reached (); 15 | } 16 | -------------------------------------------------------------------------------- /tests/heap/meson.build: -------------------------------------------------------------------------------- 1 | heap_sources = [ 2 | 'allocationtracker.c', 3 | 'allocatorprobe.c', 4 | 'allocatorprobex.cxx', 5 | 'boundschecker.c', 6 | 'cobjecttracker.c', 7 | 'instancetracker.c', 8 | 'pagepool.c', 9 | 'sanitychecker.c', 10 | ] 11 | 12 | gum_tests_heap = static_library('gum-tests-heap', heap_sources, 13 | include_directories: test_incdirs, 14 | dependencies: [gum_dep], 15 | ) 16 | -------------------------------------------------------------------------------- /gum/backend-qnx/gumthreadregistry-qnx.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #include "gumthreadregistry-priv.h" 8 | 9 | void 10 | _gum_thread_registry_activate (GumThreadRegistry * self) 11 | { 12 | } 13 | 14 | void 15 | _gum_thread_registry_deactivate (GumThreadRegistry * self) 16 | { 17 | } 18 | -------------------------------------------------------------------------------- /gum/backend-barebone/gumthreadregistry-barebone.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #include "gumthreadregistry-priv.h" 8 | 9 | void 10 | _gum_thread_registry_activate (GumThreadRegistry * self) 11 | { 12 | } 13 | 14 | void 15 | _gum_thread_registry_deactivate (GumThreadRegistry * self) 16 | { 17 | } 18 | -------------------------------------------------------------------------------- /gum/backend-freebsd/gumthreadregistry-freebsd.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #include "gumthreadregistry-priv.h" 8 | 9 | void 10 | _gum_thread_registry_activate (GumThreadRegistry * self) 11 | { 12 | } 13 | 14 | void 15 | _gum_thread_registry_deactivate (GumThreadRegistry * self) 16 | { 17 | } 18 | -------------------------------------------------------------------------------- /gum/arch-mips/gummipsreader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_MIPS_READER_H__ 8 | #define __GUM_MIPS_READER_H__ 9 | 10 | #include "gumdefs.h" 11 | 12 | G_BEGIN_DECLS 13 | 14 | gpointer gum_mips_reader_try_get_relative_jump_target (gconstpointer address); 15 | 16 | G_END_DECLS 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /gum/gumcloak-priv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_CLOAK_PRIV_H__ 8 | #define __GUM_CLOAK_PRIV_H__ 9 | 10 | #include "gumcloak.h" 11 | 12 | G_BEGIN_DECLS 13 | 14 | G_GNUC_INTERNAL void _gum_cloak_init (void); 15 | G_GNUC_INTERNAL void _gum_cloak_deinit (void); 16 | 17 | G_END_DECLS 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /bindings/gumpp/gumpp.symbols: -------------------------------------------------------------------------------- 1 | _Interceptor_obtain 2 | _Backtracer_make_accurate 3 | _Backtracer_make_fuzzy 4 | _ReturnAddressDetails_from_address 5 | _SanityChecker_new 6 | _SanityChecker_new_with_heap_api 7 | _BusyCycleSampler_new 8 | _CycleSampler_new 9 | _MallocCountSampler_new 10 | _WallClockSampler_new 11 | _CallCountSampler_new 12 | _CallCountSampler_new_by_name 13 | _Profiler_new 14 | _find_function_ptr 15 | _find_matching_functions_array 16 | -------------------------------------------------------------------------------- /tests/core/targetfunctions/specialfunctions.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifdef _MSC_VER 4 | # define GUM_NOINLINE __declspec (noinline) 5 | #else 6 | # define GUM_NOINLINE __attribute__ ((noinline)) 7 | #endif 8 | 9 | gpointer GUM_NOINLINE 10 | gum_test_special_function (GString * str) 11 | { 12 | if (str != NULL) 13 | g_string_append_c (str, '|'); 14 | else 15 | g_usleep (G_USEC_PER_SEC / 100); 16 | 17 | return NULL; 18 | } 19 | -------------------------------------------------------------------------------- /bindings/gumpp/gumpp.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | Interceptor_obtain 3 | Backtracer_make_accurate 4 | Backtracer_make_fuzzy 5 | ReturnAddressDetails_from_address 6 | SanityChecker_new 7 | SanityChecker_new_with_heap_api 8 | BusyCycleSampler_new 9 | CycleSampler_new 10 | MallocCountSampler_new 11 | WallClockSampler_new 12 | CallCountSampler_new 13 | CallCountSampler_new_by_name 14 | Profiler_new 15 | find_function_ptr 16 | find_matching_functions_array 17 | -------------------------------------------------------------------------------- /gum/backend-darwin/gumtvos.h: -------------------------------------------------------------------------------- 1 | #ifndef __GUM_TVOS_H__ 2 | #define __GUM_TVOS_H__ 3 | 4 | #ifdef HAVE_TVOS 5 | # include 6 | # undef __TVOS_PROHIBITED 7 | # define __TVOS_PROHIBITED 8 | # undef __API_UNAVAILABLE 9 | # define __API_UNAVAILABLE(...) 10 | # include 11 | # include 12 | # include 13 | # undef __TVOS_PROHIBITED 14 | # define __TVOS_PROHIBITED __OS_AVAILABILITY(tvos,unavailable) 15 | #endif 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /configure: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | [ -z "$PYTHON" ] && PYTHON=$(which python3 >/dev/null && echo python3 || echo python) 4 | 5 | cd $(dirname $0) 6 | 7 | srcroot=$(pwd) 8 | 9 | if [ ! -f releng/meson/meson.py ]; then 10 | git submodule update --init --recursive --depth 1 || exit $? 11 | fi 12 | 13 | cd - >/dev/null 14 | 15 | exec "$PYTHON" \ 16 | -c "import sys; sys.path.insert(0, sys.argv[1]); from releng.meson_configure import main; main()" \ 17 | "$srcroot" \ 18 | "$@" 19 | -------------------------------------------------------------------------------- /gum/gumtls-priv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Eloi Vanderbeken 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_TLS_PRIV_H__ 8 | #define __GUM_TLS_PRIV_H__ 9 | 10 | #include 11 | 12 | G_BEGIN_DECLS 13 | 14 | G_GNUC_INTERNAL void _gum_tls_init (void); 15 | G_GNUC_INTERNAL void _gum_tls_realize (void); 16 | G_GNUC_INTERNAL void _gum_tls_deinit (void); 17 | 18 | G_END_DECLS 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /bindings/gumjs/gumjs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUMJS_H__ 8 | #define __GUMJS_H__ 9 | 10 | #include 11 | 12 | G_BEGIN_DECLS 13 | 14 | GUM_API void gumjs_prepare_to_fork (void); 15 | GUM_API void gumjs_recover_from_fork_in_parent (void); 16 | GUM_API void gumjs_recover_from_fork_in_child (void); 17 | 18 | G_END_DECLS 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /bindings/gumjs/runtime/cmodule/gum/gumspinlock.h: -------------------------------------------------------------------------------- 1 | #ifndef __GUM_SPINLOCK_H__ 2 | #define __GUM_SPINLOCK_H__ 3 | 4 | #include 5 | 6 | #define GUM_SPINLOCK_INIT { NULL } 7 | 8 | typedef struct _GumSpinlock GumSpinlock; 9 | 10 | struct _GumSpinlock 11 | { 12 | gpointer data; 13 | }; 14 | 15 | void gum_spinlock_init (GumSpinlock * spinlock); 16 | 17 | void gum_spinlock_acquire (GumSpinlock * spinlock); 18 | void gum_spinlock_release (GumSpinlock * spinlock); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /bindings/gumpp/returnaddress.cpp: -------------------------------------------------------------------------------- 1 | #include "gumpp.hpp" 2 | 3 | #include "runtime.hpp" 4 | 5 | #include 6 | 7 | namespace Gum 8 | { 9 | extern "C" bool ReturnAddressDetails_from_address (ReturnAddress address, ReturnAddressDetails & details) 10 | { 11 | Runtime::ref (); 12 | bool success = gum_return_address_details_from_address (address, reinterpret_cast (&details)) != FALSE; 13 | Runtime::unref (); 14 | return success; 15 | } 16 | } -------------------------------------------------------------------------------- /gum/gumfunction.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_FUNCTION_H__ 8 | #define __GUM_FUNCTION_H__ 9 | 10 | G_BEGIN_DECLS 11 | 12 | typedef struct _GumFunctionDetails GumFunctionDetails; 13 | 14 | struct _GumFunctionDetails 15 | { 16 | const gchar * name; 17 | gpointer address; 18 | gint num_arguments; 19 | }; 20 | 21 | G_END_DECLS 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | PYTHON ?= $(shell which python3 >/dev/null && echo python3 || echo python) 2 | 3 | all $(MAKECMDGOALS): 4 | @$(PYTHON) \ 5 | -c "import sys; sys.path.insert(0, sys.argv[1]); from releng.meson_make import main; main()" \ 6 | "$(shell pwd)" \ 7 | ./build \ 8 | $(MAKECMDGOALS) 9 | 10 | git-submodules: 11 | @if [ ! -f releng/meson/meson.py ]; then \ 12 | git submodule update --init --recursive --depth 1; \ 13 | fi 14 | -include git-submodules 15 | 16 | .PHONY: all $(MAKECMDGOALS) 17 | -------------------------------------------------------------------------------- /gum/backend-darwin/gumobjcapiresolver-priv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 Abdelrahman Eid 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_OBJC_API_RESOLVER_PRIV_H__ 8 | #define __GUM_OBJC_API_RESOLVER_PRIV_H__ 9 | 10 | #include 11 | 12 | G_BEGIN_DECLS 13 | 14 | GUM_API gchar * _gum_objc_api_resolver_find_method_by_address ( 15 | GumApiResolver * resolver, GumAddress address); 16 | 17 | G_END_DECLS 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /bindings/gumjs/gumansi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010-2025 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_ANSI_H__ 8 | #define __GUM_ANSI_H__ 9 | 10 | #include 11 | 12 | G_BEGIN_DECLS 13 | 14 | G_GNUC_INTERNAL gchar * _gum_ansi_string_to_utf8 (const gchar * str_ansi, 15 | gint length); 16 | G_GNUC_INTERNAL gchar * _gum_ansi_string_from_utf8 (const gchar * str_utf8); 17 | 18 | G_END_DECLS 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /.cirrus.yml: -------------------------------------------------------------------------------- 1 | task: 2 | name: freebsd-x86_64 3 | freebsd_instance: 4 | image_family: freebsd-14-2 5 | install_script: | 6 | pkg install -y git gmake 7 | compile_script: | 8 | ./configure \ 9 | --enable-gumpp \ 10 | --enable-gumjs \ 11 | --with-devkits=gum,gumjs \ 12 | --enable-tests 13 | make 14 | gum_devkit_artifacts: 15 | path: "build/gum/devkit/*" 16 | gumjs_devkit_artifacts: 17 | path: "build/bindings/gumjs/devkit/*" 18 | test_script: make test 19 | -------------------------------------------------------------------------------- /tests/gum-tests.xcent: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | application-identifier 6 | re.frida.GumTests 7 | com.apple.private.security.no-container 8 | 9 | platform-application 10 | 11 | get-task-allow 12 | 13 | task_for_pid-allow 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /vapi/frida-gumjs-inspector-1.0.vapi: -------------------------------------------------------------------------------- 1 | namespace Gum { 2 | [CCode (cheader_filename = "gumjs/guminspectorserver.h")] 3 | public class InspectorServer : GLib.Object { 4 | public signal void message (string message); 5 | 6 | public uint port { 7 | get; 8 | construct; 9 | } 10 | 11 | public InspectorServer (); 12 | public InspectorServer.with_port (uint port); 13 | 14 | public bool start () throws Gum.Error; 15 | public void stop (); 16 | 17 | public void post_message (string message); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /gum/backend-darwin/helpers/threadedbindprocessor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_THREADED_BIND_PROCESSOR_H__ 8 | #define __GUM_THREADED_BIND_PROCESSOR_H__ 9 | 10 | #include 11 | 12 | void gum_process_threaded_items (uint64_t preferred_base_address, 13 | uint64_t slide, uint16_t num_symbols, const uint64_t * symbols, 14 | uint16_t num_regions, uint64_t * regions); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /gum/arch-arm/gumarmreader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licence: wxWindows Library Licence, Version 3.1 3 | */ 4 | 5 | #ifndef __GUM_ARM_READER_H__ 6 | #define __GUM_ARM_READER_H__ 7 | 8 | #include "gumdefs.h" 9 | 10 | #include 11 | 12 | G_BEGIN_DECLS 13 | 14 | gpointer gum_arm_reader_try_get_relative_jump_target (gconstpointer address); 15 | gpointer gum_arm_reader_try_get_indirect_jump_target (gconstpointer address); 16 | cs_insn * gum_arm_reader_disassemble_instruction_at (gconstpointer address); 17 | 18 | G_END_DECLS 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /gum/gumstalker-priv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_STALKER_PRIV_H__ 8 | #define __GUM_STALKER_PRIV_H__ 9 | 10 | #include "gumstalker.h" 11 | 12 | G_BEGIN_DECLS 13 | 14 | G_GNUC_INTERNAL void _gum_stalker_modify_to_run_on_thread (GumStalker * self, 15 | GumThreadId thread_id, GumCpuContext * cpu_context, 16 | GumStalkerRunOnThreadFunc func, gpointer data); 17 | 18 | G_END_DECLS 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /docs/config.toml: -------------------------------------------------------------------------------- 1 | [library] 2 | version = "15.1.14" 3 | browse_url = "https://github.com/frida/frida-gum/" 4 | repository_url = "https://github.com/frida/frida-gum.git" 5 | website_url = "https://frida.re/" 6 | authors = "Frida Development Team" 7 | logo_url = "https://frida.re/img/logotype.svg" 8 | license = "wxWindows" 9 | description = "Cross-platform instrumentation and introspection library written in C." 10 | devhelp = true 11 | search_index = true 12 | 13 | [source-location] 14 | base_url = "https://github.com/frida/frida-gum/blob/master/" 15 | -------------------------------------------------------------------------------- /gum/arch-arm/gumthumbreader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_THUMB_READER_H__ 8 | #define __GUM_THUMB_READER_H__ 9 | 10 | #include "gumdefs.h" 11 | 12 | #include 13 | 14 | G_BEGIN_DECLS 15 | 16 | gpointer gum_thumb_reader_try_get_relative_jump_target (gconstpointer address); 17 | cs_insn * gum_thumb_reader_disassemble_instruction_at (gconstpointer address); 18 | 19 | G_END_DECLS 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /gum/gumlibc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015-2021 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_LIBC_H__ 8 | #define __GUM_LIBC_H__ 9 | 10 | #include 11 | 12 | G_BEGIN_DECLS 13 | 14 | GUM_API gpointer gum_memset (gpointer dst, gint c, gsize n); 15 | GUM_API gpointer gum_memcpy (gpointer dst, gconstpointer src, gsize n); 16 | GUM_API gpointer gum_memmove (gpointer dst, gconstpointer src, gsize n); 17 | 18 | G_END_DECLS 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /gum/gum-init.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014-2021 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_INIT_H__ 8 | #define __GUM_INIT_H__ 9 | 10 | #include 11 | #include 12 | 13 | typedef void (* GumDestructorFunc) (void); 14 | 15 | G_BEGIN_DECLS 16 | 17 | GUM_API void _gum_register_early_destructor (GumDestructorFunc destructor); 18 | GUM_API void _gum_register_destructor (GumDestructorFunc destructor); 19 | 20 | G_END_DECLS 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /tests/vm.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import pexpect 4 | import shlex 5 | import sys 6 | 7 | 8 | def run(arch: str, args: [str]): 9 | child = pexpect.spawn("arm_now", ["start", arch, "--sync"]) 10 | 11 | child.expect("buildroot login: ") 12 | child.sendline("root") 13 | child.expect("# ") 14 | 15 | child.sendline(shlex.join(["/root/gum-tests"] + args)) 16 | child.interact() 17 | 18 | 19 | if __name__ == "__main__": 20 | arch = sys.argv[1] 21 | args = sys.argv[2:] if len(sys.argv) >= 3 else [] 22 | run(arch, args) 23 | -------------------------------------------------------------------------------- /bindings/gumjs/runtime/cmodule-tcc/stdio.h: -------------------------------------------------------------------------------- 1 | #ifndef _STDIO_H 2 | #define _STDIO_H 3 | 4 | #include 5 | 6 | typedef struct _FILE FILE; 7 | 8 | extern FILE * stdout; 9 | extern FILE * stderr; 10 | 11 | int puts (const char * s); 12 | int fputs (const char * restrict s, FILE * restrict stream); 13 | int fflush (FILE * stream); 14 | int printf (const char * restrict format, ...); 15 | int fprintf (FILE * restrict stream, const char * restrict format, ...); 16 | int vfprintf (FILE * restrict stream, const char * restrict format, va_list ap); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /gum/gumsysinternals.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010-2014 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_SYS_INTERNALS_H__ 8 | #define __GUM_SYS_INTERNALS_H__ 9 | 10 | #include 11 | 12 | #ifdef G_OS_WIN32 13 | 14 | # if GLIB_SIZEOF_VOID_P == 4 15 | # define GUM_TEB_OFFSET_SELF 0x0018 16 | # define GUM_TEB_OFFSET_TID 0x0024 17 | # else 18 | # define GUM_TEB_OFFSET_SELF 0x0030 19 | # define GUM_TEB_OFFSET_TID 0x0048 20 | # endif 21 | 22 | #endif 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /bindings/gumpp/gumpp.version: -------------------------------------------------------------------------------- 1 | LIBGUMPP_1.0 { 2 | global: 3 | Interceptor_obtain; 4 | Backtracer_make_accurate; 5 | Backtracer_make_fuzzy; 6 | ReturnAddressDetails_from_address; 7 | SanityChecker_new; 8 | SanityChecker_new_with_heap_api; 9 | BusyCycleSampler_new; 10 | CycleSampler_new; 11 | MallocCountSampler_new; 12 | WallClockSampler_new; 13 | CallCountSampler_new; 14 | CallCountSampler_new_by_name; 15 | Profiler_new; 16 | find_function_ptr; 17 | find_matching_functions_array; 18 | 19 | local: 20 | *; 21 | }; 22 | -------------------------------------------------------------------------------- /bindings/gumjs/gumquickscriptbackend.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_QUICK_SCRIPT_BACKEND_H__ 8 | #define __GUM_QUICK_SCRIPT_BACKEND_H__ 9 | 10 | #include "gumscriptbackend.h" 11 | 12 | G_BEGIN_DECLS 13 | 14 | #define GUM_QUICK_TYPE_SCRIPT_BACKEND (gum_quick_script_backend_get_type ()) 15 | G_DECLARE_FINAL_TYPE (GumQuickScriptBackend, gum_quick_script_backend, 16 | GUM_QUICK, SCRIPT_BACKEND, GObject) 17 | 18 | G_END_DECLS 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /tests/stubs/dummyclasses.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2018 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __DUMMY_CLASSES_H__ 8 | #define __DUMMY_CLASSES_H__ 9 | 10 | #include 11 | 12 | G_BEGIN_DECLS 13 | 14 | #define MY_TYPE_PONY (my_pony_get_type ()) 15 | G_DECLARE_FINAL_TYPE (MyPony, my_pony, MY, PONY, GObject) 16 | 17 | #define ZOO_TYPE_ZEBRA (zoo_zebra_get_type ()) 18 | G_DECLARE_FINAL_TYPE (ZooZebra, zoo_zebra, ZOO, ZEBRA, GObject) 19 | 20 | G_END_DECLS 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /gum/gumleb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015-2021 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_LEB_H__ 8 | #define __GUM_LEB_H__ 9 | 10 | #include 11 | 12 | G_BEGIN_DECLS 13 | 14 | G_GNUC_INTERNAL gint64 gum_read_sleb128 (const guint8 ** data, 15 | const guint8 * end); 16 | G_GNUC_INTERNAL guint64 gum_read_uleb128 (const guint8 ** data, 17 | const guint8 * end); 18 | G_GNUC_INTERNAL void gum_skip_leb128 (const guint8 ** data, const guint8 * end); 19 | 20 | G_END_DECLS 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /gum/gumtls.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010-2017 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_TLS_H__ 8 | #define __GUM_TLS_H__ 9 | 10 | #include 11 | 12 | G_BEGIN_DECLS 13 | 14 | typedef gsize GumTlsKey; 15 | 16 | GUM_API GumTlsKey gum_tls_key_new (void); 17 | GUM_API void gum_tls_key_free (GumTlsKey key); 18 | 19 | GUM_API gpointer gum_tls_key_get_value (GumTlsKey key); 20 | GUM_API void gum_tls_key_set_value (GumTlsKey key, gpointer value); 21 | 22 | G_END_DECLS 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /bindings/gumjs/gumv8script.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015-2018 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_V8_SCRIPT_H__ 8 | #define __GUM_V8_SCRIPT_H__ 9 | 10 | #include "gumscript.h" 11 | 12 | G_BEGIN_DECLS 13 | 14 | #define GUM_V8_TYPE_SCRIPT (gum_v8_script_get_type ()) 15 | G_DECLARE_FINAL_TYPE (GumV8Script, gum_v8_script, GUM_V8, SCRIPT, GObject) 16 | 17 | G_GNUC_INTERNAL gboolean gum_v8_script_create_context (GumV8Script * self, 18 | GError ** error); 19 | 20 | G_END_DECLS 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /gum/backend-barebone/gummodule-barebone.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #include "gummodule.h" 8 | 9 | G_GNUC_WEAK GumModule * 10 | gum_module_load (const gchar * module_name, 11 | GError ** error) 12 | { 13 | g_set_error (error, GUM_ERROR, GUM_ERROR_NOT_SUPPORTED, 14 | "Not supported by the Barebone backend"); 15 | return NULL; 16 | } 17 | 18 | G_GNUC_WEAK GumAddress 19 | gum_module_find_global_export_by_name (const gchar * symbol_name) 20 | { 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /bindings/gumjs/runtime/cmodule-tcc/string.h: -------------------------------------------------------------------------------- 1 | #ifndef _STRING_H 2 | #define _STRING_H 3 | 4 | #include 5 | 6 | size_t strlen (const char * s); 7 | int strcmp (const char * s1, const char * s2); 8 | int strncmp (const char * s1, const char * s2, size_t n); 9 | char * strstr (const char * haystack, const char * needle); 10 | char * strchr (const char * s, int c); 11 | char * strrchr (const char * s, int c); 12 | void * memcpy (void * restrict dst, const void * restrict src, size_t n); 13 | void * memmove (void * dst, const void * src, size_t len); 14 | void * memset (void * b, int c, size_t len); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /gum/arch-arm/gumarmbacktracer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013-2022 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_ARM_BACKTRACER_H__ 8 | #define __GUM_ARM_BACKTRACER_H__ 9 | 10 | #include 11 | 12 | G_BEGIN_DECLS 13 | 14 | #define GUM_TYPE_ARM_BACKTRACER (gum_arm_backtracer_get_type ()) 15 | G_DECLARE_FINAL_TYPE (GumArmBacktracer, gum_arm_backtracer, GUM, ARM_BACKTRACER, 16 | GObject) 17 | 18 | GUM_API GumBacktracer * gum_arm_backtracer_new (void); 19 | 20 | G_END_DECLS 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /gum/arch-x86/gumx86backtracer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2022 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_X86_BACKTRACER_H__ 8 | #define __GUM_X86_BACKTRACER_H__ 9 | 10 | #include 11 | 12 | G_BEGIN_DECLS 13 | 14 | #define GUM_TYPE_X86_BACKTRACER (gum_x86_backtracer_get_type ()) 15 | G_DECLARE_FINAL_TYPE (GumX86Backtracer, gum_x86_backtracer, GUM, X86_BACKTRACER, 16 | GObject) 17 | 18 | GUM_API GumBacktracer * gum_x86_backtracer_new (void); 19 | 20 | G_END_DECLS 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /.github/workflows/style.yml: -------------------------------------------------------------------------------- 1 | name: Style 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - main 7 | 8 | jobs: 9 | check_style: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Check out repo 13 | uses: actions/checkout@v4 14 | - name: Find changed lines 15 | id: changed_lines 16 | uses: hestonhoffman/changed-lines@v1 17 | - name: Verify changed lines 18 | run: | 19 | cat << EOF > /tmp/changed-lines.json 20 | ${{ steps.changed_lines.outputs.changed_lines }} 21 | EOF 22 | ./tests/stylecheck.py /tmp/changed-lines.json 23 | -------------------------------------------------------------------------------- /bindings/gumjs/gumquickscript.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_QUICK_SCRIPT_H__ 8 | #define __GUM_QUICK_SCRIPT_H__ 9 | 10 | #include "gumscript.h" 11 | 12 | G_BEGIN_DECLS 13 | 14 | #define GUM_QUICK_TYPE_SCRIPT (gum_quick_script_get_type ()) 15 | G_DECLARE_FINAL_TYPE (GumQuickScript, gum_quick_script, GUM_QUICK, SCRIPT, 16 | GObject) 17 | 18 | G_GNUC_INTERNAL gboolean gum_quick_script_create_context (GumQuickScript * self, 19 | GError ** error); 20 | 21 | G_END_DECLS 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /gum/gumprintf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_PRINTF_H__ 8 | #define __GUM_PRINTF_H__ 9 | 10 | #include 11 | 12 | G_BEGIN_DECLS 13 | 14 | gint gum_vsnprintf (gchar * str, gsize size, const gchar * format, 15 | va_list args); 16 | gint gum_snprintf (gchar * str, gsize size, const gchar * format, ...); 17 | gint gum_vasprintf (gchar ** ret, const gchar * format, va_list ap); 18 | gint gum_asprintf (gchar ** ret, const gchar * format, ...); 19 | 20 | G_END_DECLS 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /gum/arch-mips/gummipsbacktracer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015-2022 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_MIPS_BACKTRACER_H__ 8 | #define __GUM_MIPS_BACKTRACER_H__ 9 | 10 | #include 11 | 12 | G_BEGIN_DECLS 13 | 14 | #define GUM_TYPE_MIPS_BACKTRACER (gum_mips_backtracer_get_type ()) 15 | G_DECLARE_FINAL_TYPE (GumMipsBacktracer, gum_mips_backtracer, GUM, 16 | MIPS_BACKTRACER, GObject) 17 | 18 | GUM_API GumBacktracer * gum_mips_backtracer_new (void); 19 | 20 | G_END_DECLS 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /tests/run.py: -------------------------------------------------------------------------------- 1 | import os 2 | from pathlib import Path 3 | import platform 4 | import subprocess 5 | import sys 6 | 7 | 8 | def main(): 9 | runner_env = { **os.environ } 10 | 11 | if platform.system() == 'Windows': 12 | runner_program = Path(sys.argv[1]) 13 | gumpp_dir = runner_program.parent.parent / "bindings" / "gumpp" 14 | if gumpp_dir.exists(): 15 | runner_env["PATH"] = str(gumpp_dir) + os.pathsep + runner_env["PATH"] 16 | 17 | process = subprocess.run(sys.argv[1:], env=runner_env) 18 | 19 | sys.exit(process.returncode) 20 | 21 | 22 | if __name__ == "__main__": 23 | main() 24 | -------------------------------------------------------------------------------- /gum/arch-arm64/gumarm64backtracer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015-2022 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_ARM64_BACKTRACER_H__ 8 | #define __GUM_ARM64_BACKTRACER_H__ 9 | 10 | #include 11 | 12 | G_BEGIN_DECLS 13 | 14 | #define GUM_TYPE_ARM64_BACKTRACER (gum_arm64_backtracer_get_type ()) 15 | G_DECLARE_FINAL_TYPE (GumArm64Backtracer, gum_arm64_backtracer, GUM, 16 | ARM64_BACKTRACER, GObject) 17 | 18 | GUM_API GumBacktracer * gum_arm64_backtracer_new (void); 19 | 20 | G_END_DECLS 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /gum/backend-libunwind/include/gum/gumunwbacktracer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015-2022 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_UNW_BACKTRACER_H__ 8 | #define __GUM_UNW_BACKTRACER_H__ 9 | 10 | #include 11 | 12 | G_BEGIN_DECLS 13 | 14 | #define GUM_TYPE_UNW_BACKTRACER (gum_unw_backtracer_get_type ()) 15 | G_DECLARE_FINAL_TYPE (GumUnwBacktracer, gum_unw_backtracer, GUM, UNW_BACKTRACER, 16 | GObject) 17 | 18 | GUM_API GumBacktracer * gum_unw_backtracer_new (void); 19 | 20 | G_END_DECLS 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /gum/gumenumtypes.h.template: -------------------------------------------------------------------------------- 1 | /*** BEGIN file-header ***/ 2 | #ifndef __GUM_ENUM_TYPES_H__ 3 | #define __GUM_ENUM_TYPES_H__ 4 | 5 | #include 6 | 7 | G_BEGIN_DECLS 8 | /*** END file-header ***/ 9 | 10 | /*** BEGIN file-production ***/ 11 | 12 | /* Enumerations from "@basename@" */ 13 | /*** END file-production ***/ 14 | 15 | /*** BEGIN value-header ***/ 16 | GType @enum_name@_get_type (void) G_GNUC_CONST; 17 | #define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type ()) 18 | /*** END value-header ***/ 19 | 20 | /*** BEGIN file-tail ***/ 21 | G_END_DECLS 22 | 23 | #endif /* __GUM_ENUM_TYPES_H__ */ 24 | /*** END file-tail ***/ 25 | -------------------------------------------------------------------------------- /tests/core/swiftapiresolver/runner.js: -------------------------------------------------------------------------------- 1 | class Runner { 2 | constructor() { 3 | this._cm = null; 4 | this._run = null; 5 | recv('start', this._onStart); 6 | } 7 | 8 | run(query) { 9 | return this._run(Memory.allocUtf8String(query)); 10 | } 11 | 12 | _onStart = (message, data) => { 13 | this._cm = new CModule(data); 14 | this._run = new NativeFunction(this._cm.run, 'uint', ['pointer'], { exceptions: 'propagate' }); 15 | send({ type: 'ready', symbols: this._cm }); 16 | }; 17 | } 18 | 19 | const runner = new Runner(); 20 | 21 | rpc.exports = { 22 | run(query) { 23 | return runner.run(query); 24 | } 25 | }; 26 | -------------------------------------------------------------------------------- /gum/backend-darwin/gumobjcapiresolver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016-2022 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_OBJC_API_RESOLVER_H__ 8 | #define __GUM_OBJC_API_RESOLVER_H__ 9 | 10 | #include 11 | 12 | G_BEGIN_DECLS 13 | 14 | #define GUM_TYPE_OBJC_API_RESOLVER (gum_objc_api_resolver_get_type ()) 15 | G_DECLARE_FINAL_TYPE (GumObjcApiResolver, gum_objc_api_resolver, GUM, 16 | OBJC_API_RESOLVER, GObject) 17 | 18 | GUM_API GumApiResolver * gum_objc_api_resolver_new (void); 19 | 20 | G_END_DECLS 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /gum/gummoduleapiresolver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016-2022 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_MODULE_API_RESOLVER_H__ 8 | #define __GUM_MODULE_API_RESOLVER_H__ 9 | 10 | #include 11 | 12 | G_BEGIN_DECLS 13 | 14 | #define GUM_TYPE_MODULE_API_RESOLVER (gum_module_api_resolver_get_type ()) 15 | G_DECLARE_FINAL_TYPE (GumModuleApiResolver, gum_module_api_resolver, GUM, 16 | MODULE_API_RESOLVER, GObject) 17 | 18 | GUM_API GumApiResolver * gum_module_api_resolver_new (void); 19 | 20 | G_END_DECLS 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /bindings/gumjs/gumjs.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018-2019 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #include "gumjs.h" 8 | 9 | #include "gumscriptbackend.h" 10 | 11 | void 12 | gumjs_prepare_to_fork (void) 13 | { 14 | gum_script_scheduler_stop (gum_script_backend_get_scheduler ()); 15 | } 16 | 17 | void 18 | gumjs_recover_from_fork_in_parent (void) 19 | { 20 | gum_script_scheduler_start (gum_script_backend_get_scheduler ()); 21 | } 22 | 23 | void 24 | gumjs_recover_from_fork_in_child (void) 25 | { 26 | gum_script_scheduler_start (gum_script_backend_get_scheduler ()); 27 | } 28 | -------------------------------------------------------------------------------- /libs/gum/prof/gummalloccountsampler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2019 Ole André Vadla Ravnås 3 | * Copyright (C) 2008 Christian Berentsen 4 | * 5 | * Licence: wxWindows Library Licence, Version 3.1 6 | */ 7 | 8 | #ifndef __GUM_MALLOC_COUNT_SAMPLER_H__ 9 | #define __GUM_MALLOC_COUNT_SAMPLER_H__ 10 | 11 | #include "gumsampler.h" 12 | 13 | #include 14 | 15 | G_BEGIN_DECLS 16 | 17 | GUM_API GumSampler * gum_malloc_count_sampler_new (void); 18 | GUM_API GumSampler * gum_malloc_count_sampler_new_with_heap_apis ( 19 | const GumHeapApiList * heap_apis); 20 | 21 | G_END_DECLS 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /tests/gum-tests.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | re.frida.GumTests 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundleName 12 | Frida 13 | CFBundleVersion 14 | 1.0 15 | SecTaskAccess 16 | 17 | allowed 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /gum/backend-darwin/include/gum/gumdarwinbacktracer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015-2022 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_DARWIN_BACKTRACER_H__ 8 | #define __GUM_DARWIN_BACKTRACER_H__ 9 | 10 | #include 11 | 12 | G_BEGIN_DECLS 13 | 14 | #define GUM_TYPE_DARWIN_BACKTRACER (gum_darwin_backtracer_get_type ()) 15 | G_DECLARE_FINAL_TYPE (GumDarwinBacktracer, gum_darwin_backtracer, GUM, 16 | DARWIN_BACKTRACER, GObject) 17 | 18 | GUM_API GumBacktracer * gum_darwin_backtracer_new (void); 19 | 20 | G_END_DECLS 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /libs/gum/gum-prof.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_PROF_H__ 8 | #define __GUM_PROF_H__ 9 | 10 | #include 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /gum/arch-arm64/gumarm64reader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015-2025 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_ARM64_READER_H__ 8 | #define __GUM_ARM64_READER_H__ 9 | 10 | #include "gumdefs.h" 11 | 12 | #include 13 | 14 | G_BEGIN_DECLS 15 | 16 | GUM_API gpointer gum_arm64_reader_find_next_bl_target (gconstpointer address); 17 | GUM_API gpointer gum_arm64_reader_try_get_relative_jump_target ( 18 | gconstpointer address); 19 | GUM_API cs_insn * gum_arm64_reader_disassemble_instruction_at ( 20 | gconstpointer address); 21 | 22 | G_END_DECLS 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /libs/gum/prof/gumsampler.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2018 Ole André Vadla Ravnås 3 | * Copyright (C) 2008 Christian Berentsen 4 | * 5 | * Licence: wxWindows Library Licence, Version 3.1 6 | */ 7 | 8 | #include "gumsampler.h" 9 | 10 | G_DEFINE_INTERFACE (GumSampler, gum_sampler, G_TYPE_OBJECT) 11 | 12 | static void 13 | gum_sampler_default_init (GumSamplerInterface * iface) 14 | { 15 | } 16 | 17 | GumSample 18 | gum_sampler_sample (GumSampler * self) 19 | { 20 | GumSamplerInterface * iface = GUM_SAMPLER_GET_IFACE (self); 21 | 22 | g_assert (iface->sample != NULL); 23 | 24 | return iface->sample (self); 25 | } 26 | -------------------------------------------------------------------------------- /tests/core/swiftapiresolver/meson.build: -------------------------------------------------------------------------------- 1 | extra_link_args = [] 2 | extra_link_depends = [] 3 | 4 | if host_os_family == 'darwin' 5 | symlist = 'runner.symbols' 6 | extra_link_args += '-Wl,-exported_symbols_list,' + meson.current_source_dir() / symlist 7 | extra_link_depends += symlist 8 | elif host_os_family != 'windows' 9 | symscript = 'runner.version' 10 | extra_link_args += '-Wl,--version-script,' + meson.current_source_dir() / symscript 11 | extra_link_depends += [symscript] 12 | endif 13 | 14 | shared_module('testswiftapiresolver', 'runner.c', 15 | dependencies: [gum_dep], 16 | link_args: extra_link_args, 17 | link_depends: extra_link_depends, 18 | ) 19 | -------------------------------------------------------------------------------- /libs/gum/gum-heap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2019 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_HEAP_H__ 8 | #define __GUM_HEAP_H__ 9 | 10 | #include 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /bindings/gumjs/gumv8cloak.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 Francesco Tamagni 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_V8_CLOAK_H__ 8 | #define __GUM_V8_CLOAK_H__ 9 | 10 | #include "gumv8core.h" 11 | 12 | struct GumV8Cloak 13 | { 14 | GumV8Core * core; 15 | }; 16 | 17 | G_GNUC_INTERNAL void _gum_v8_cloak_init (GumV8Cloak * self, 18 | GumV8Core * core, v8::Local scope); 19 | G_GNUC_INTERNAL void _gum_v8_cloak_realize (GumV8Cloak * self); 20 | G_GNUC_INTERNAL void _gum_v8_cloak_dispose (GumV8Cloak * self); 21 | G_GNUC_INTERNAL void _gum_v8_cloak_finalize (GumV8Cloak * self); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /configure.bat: -------------------------------------------------------------------------------- 1 | @setlocal 2 | @echo off 3 | rem:: Based on: https://github.com/microsoft/terminal/issues/217#issuecomment-737594785 4 | goto :_start_ 5 | 6 | :set_real_dp0 7 | set dp0=%~dp0 8 | set "dp0=%dp0:~0,-1%" 9 | goto :eof 10 | 11 | :_start_ 12 | call :set_real_dp0 13 | 14 | if not exist "%dp0%\releng\meson\meson.py" ( 15 | pushd "%dp0%" & git submodule update --init --recursive --depth 1 & popd 16 | if %errorlevel% neq 0 exit /b %errorlevel% 17 | ) 18 | 19 | endlocal & goto #_undefined_# 2>nul || title %COMSPEC% & python ^ 20 | -c "import sys; sys.path.insert(0, sys.argv[1]); from releng.meson_configure import main; main()" ^ 21 | "%dp0%" ^ 22 | %* 23 | -------------------------------------------------------------------------------- /gum/backend-darwin/substrated.defs: -------------------------------------------------------------------------------- 1 | /* 2 | * Regenerate with: 3 | * 4 | * $(xcrun --sdk macosx -f mig) \ 5 | * -isysroot $(xcrun --sdk macosx --show-sdk-path) \ 6 | * -sheader substratedserver.h \ 7 | * -server substratedserver.c \ 8 | * -header substratedclient.h \ 9 | * -user substratedclient.c \ 10 | * substrated.defs 11 | */ 12 | 13 | subsystem substrated 9000; 14 | 15 | #include 16 | #include 17 | 18 | routine substrated_mark( 19 | server : mach_port_t; 20 | task : vm_task_entry_t; 21 | source_address : mach_vm_address_t; 22 | source_size : mach_vm_size_t; 23 | inout target_address : mach_vm_address_t); 24 | -------------------------------------------------------------------------------- /bindings/gumpp/string.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __GUMPP_STRING_HPP__ 2 | #define __GUMPP_STRING_HPP__ 3 | 4 | #include "gumpp.hpp" 5 | 6 | #include "podwrapper.hpp" 7 | 8 | #include 9 | 10 | namespace Gum 11 | { 12 | class StringImpl : public PodWrapper 13 | { 14 | public: 15 | StringImpl (gchar * str) 16 | { 17 | assign_handle (str); 18 | } 19 | 20 | virtual ~StringImpl () 21 | { 22 | g_free (handle); 23 | } 24 | 25 | virtual const char * c_str () 26 | { 27 | return handle; 28 | } 29 | 30 | virtual size_t length () const 31 | { 32 | return strlen (handle); 33 | } 34 | }; 35 | } 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /gum/backend-windows/gummodule-windows.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_MODULE_WINDOWS_H__ 8 | #define __GUM_MODULE_WINDOWS_H__ 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | G_BEGIN_DECLS 15 | 16 | #define GUM_TYPE_NATIVE_MODULE (gum_native_module_get_type ()) 17 | G_DECLARE_FINAL_TYPE (GumNativeModule, gum_native_module, GUM, NATIVE_MODULE, 18 | GObject) 19 | 20 | G_GNUC_INTERNAL GumNativeModule * _gum_native_module_make (HMODULE handle); 21 | 22 | G_END_DECLS 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /gum/devkit/meson.build: -------------------------------------------------------------------------------- 1 | devkit_outputs = [ 2 | 'frida-gum.h', 3 | static_lib_prefix + 'frida-gum' + static_lib_suffix, 4 | 'frida-gum-example.c', 5 | ] 6 | 7 | if cc.get_argument_syntax() == 'msvc' 8 | devkit_outputs += [ 9 | 'frida-gum-example.sln', 10 | 'frida-gum-example.vcxproj', 11 | 'frida-gum-example.vcxproj.filters', 12 | ] 13 | endif 14 | 15 | custom_target('gum-devkit', 16 | input: gum, 17 | output: devkit_outputs, 18 | command: [ 19 | mkdevkit, 20 | 'frida-gum', 21 | f'@host_os@-@host_arch@', 22 | meson.current_build_dir(), 23 | ] + devkit_options, 24 | install: true, 25 | install_dir: get_option('libdir') / 'frida' / 'devkits' / 'gum' 26 | ) 27 | -------------------------------------------------------------------------------- /gum/gumswiftapiresolver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2023 Ole André Vadla Ravnås 3 | * Copyright (C) 2023 Håvard Sørbø 4 | * 5 | * Licence: wxWindows Library Licence, Version 3.1 6 | */ 7 | 8 | #ifndef __GUM_SWIFT_API_RESOLVER_H__ 9 | #define __GUM_SWIFT_API_RESOLVER_H__ 10 | 11 | #include 12 | 13 | G_BEGIN_DECLS 14 | 15 | #define GUM_TYPE_SWIFT_API_RESOLVER (gum_swift_api_resolver_get_type ()) 16 | G_DECLARE_FINAL_TYPE (GumSwiftApiResolver, gum_swift_api_resolver, GUM, 17 | SWIFT_API_RESOLVER, GObject) 18 | 19 | GUM_API GumApiResolver * gum_swift_api_resolver_new (void); 20 | 21 | G_END_DECLS 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /libs/gum/prof/gumwallclocksampler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2025 Ole André Vadla Ravnås 3 | * Copyright (C) 2009 Christian Berentsen 4 | * 5 | * Licence: wxWindows Library Licence, Version 3.1 6 | */ 7 | 8 | #ifndef __GUM_WALL_CLOCK_SAMPLER_H__ 9 | #define __GUM_WALL_CLOCK_SAMPLER_H__ 10 | 11 | #include "gumsampler.h" 12 | 13 | G_BEGIN_DECLS 14 | 15 | #define GUM_TYPE_WALL_CLOCK_SAMPLER (gum_wall_clock_sampler_get_type ()) 16 | G_DECLARE_FINAL_TYPE (GumWallClockSampler, gum_wall_clock_sampler, GUM, 17 | WALL_CLOCK_SAMPLER, GObject) 18 | 19 | GUM_API GumSampler * gum_wall_clock_sampler_new (void); 20 | 21 | G_END_DECLS 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /make.bat: -------------------------------------------------------------------------------- 1 | @setlocal 2 | @echo off 3 | rem:: Based on: https://github.com/microsoft/terminal/issues/217#issuecomment-737594785 4 | goto :_start_ 5 | 6 | :set_real_dp0 7 | set dp0=%~dp0 8 | set "dp0=%dp0:~0,-1%" 9 | goto :eof 10 | 11 | :_start_ 12 | call :set_real_dp0 13 | 14 | if not exist "%dp0%\releng\meson\meson.py" ( 15 | pushd "%dp0%" & git submodule update --init --recursive --depth 1 & popd 16 | if %errorlevel% neq 0 exit /b %errorlevel% 17 | ) 18 | 19 | endlocal & goto #_undefined_# 2>nul || title %COMSPEC% & python ^ 20 | -c "import sys; sys.path.insert(0, sys.argv[1]); from releng.meson_make import main; main()" ^ 21 | "%dp0%" ^ 22 | .\build ^ 23 | %* 24 | -------------------------------------------------------------------------------- /bindings/gumjs/gumv8kernel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015-2020 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_V8_KERNEL_H__ 8 | #define __GUM_V8_KERNEL_H__ 9 | 10 | #include "gumv8core.h" 11 | 12 | struct GumV8Kernel 13 | { 14 | GumV8Core * core; 15 | }; 16 | 17 | G_GNUC_INTERNAL void _gum_v8_kernel_init (GumV8Kernel * self, 18 | GumV8Core * core, v8::Local scope); 19 | G_GNUC_INTERNAL void _gum_v8_kernel_realize (GumV8Kernel * self); 20 | G_GNUC_INTERNAL void _gum_v8_kernel_dispose (GumV8Kernel * self); 21 | G_GNUC_INTERNAL void _gum_v8_kernel_finalize (GumV8Kernel * self); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /bindings/gumjs/runtime/cmodule/gum/gummodulemap.h: -------------------------------------------------------------------------------- 1 | #ifndef __GUM_MODULE_MAP_H__ 2 | #define __GUM_MODULE_MAP_H__ 3 | 4 | #include "gummodule.h" 5 | 6 | typedef struct _GumModuleMap GumModuleMap; 7 | 8 | typedef gboolean (* GumModuleMapFilterFunc) (GumModule * module, 9 | gpointer user_data); 10 | 11 | GumModuleMap * gum_module_map_new (void); 12 | GumModuleMap * gum_module_map_new_filtered (GumModuleMapFilterFunc func, 13 | gpointer data, GDestroyNotify data_destroy); 14 | 15 | GumModule * gum_module_map_find (GumModuleMap * self, GumAddress address); 16 | 17 | void gum_module_map_update (GumModuleMap * self); 18 | 19 | GPtrArray * gum_module_map_get_values (GumModuleMap * self); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /bindings/gumjs/gumv8file.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013-2020 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_V8_FILE_H__ 8 | #define __GUM_V8_FILE_H__ 9 | 10 | #include "gumv8core.h" 11 | 12 | struct GumV8File 13 | { 14 | GumV8Core * core; 15 | 16 | GHashTable * files; 17 | }; 18 | 19 | G_GNUC_INTERNAL void _gum_v8_file_init (GumV8File * self, 20 | GumV8Core * core, v8::Local scope); 21 | G_GNUC_INTERNAL void _gum_v8_file_realize (GumV8File * self); 22 | G_GNUC_INTERNAL void _gum_v8_file_dispose (GumV8File * self); 23 | G_GNUC_INTERNAL void _gum_v8_file_finalize (GumV8File * self); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /gum/backend-dbghelp/include/gum/gumdbghelpbacktracer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2022 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_DBGHELP_BACKTRACER_H__ 8 | #define __GUM_DBGHELP_BACKTRACER_H__ 9 | 10 | #include "gumdbghelp.h" 11 | 12 | #include 13 | 14 | G_BEGIN_DECLS 15 | 16 | #define GUM_TYPE_DBGHELP_BACKTRACER (gum_dbghelp_backtracer_get_type ()) 17 | G_DECLARE_FINAL_TYPE (GumDbghelpBacktracer, gum_dbghelp_backtracer, GUM, 18 | DBGHELP_BACKTRACER, GObject) 19 | 20 | GUM_API GumBacktracer * gum_dbghelp_backtracer_new (GumDbghelpImpl * dbghelp); 21 | 22 | G_END_DECLS 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /bindings/gumjs/gumquickcloak.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 Francesco Tamagni 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_QUICK_CLOAK_H__ 8 | #define __GUM_QUICK_CLOAK_H__ 9 | 10 | #include "gumquickcore.h" 11 | 12 | G_BEGIN_DECLS 13 | 14 | typedef struct _GumQuickCloak GumQuickCloak; 15 | 16 | struct _GumQuickCloak 17 | { 18 | GumQuickCore * core; 19 | }; 20 | 21 | G_GNUC_INTERNAL void _gum_quick_cloak_init (GumQuickCloak * self, 22 | JSValue ns, GumQuickCore * core); 23 | G_GNUC_INTERNAL void _gum_quick_cloak_dispose (GumQuickCloak * self); 24 | G_GNUC_INTERNAL void _gum_quick_cloak_finalize (GumQuickCloak * self); 25 | 26 | G_END_DECLS 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /libs/gum/prof/gumcyclesampler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2018 Ole André Vadla Ravnås 3 | * Copyright (C) 2008 Christian Berentsen 4 | * 5 | * Licence: wxWindows Library Licence, Version 3.1 6 | */ 7 | 8 | #ifndef __GUM_CYCLE_SAMPLER_H__ 9 | #define __GUM_CYCLE_SAMPLER_H__ 10 | 11 | #include "gumsampler.h" 12 | 13 | G_BEGIN_DECLS 14 | 15 | #define GUM_TYPE_CYCLE_SAMPLER (gum_cycle_sampler_get_type ()) 16 | G_DECLARE_FINAL_TYPE (GumCycleSampler, gum_cycle_sampler, GUM, CYCLE_SAMPLER, 17 | GObject) 18 | 19 | GUM_API GumSampler * gum_cycle_sampler_new (void); 20 | 21 | GUM_API gboolean gum_cycle_sampler_is_available (GumCycleSampler * self); 22 | 23 | G_END_DECLS 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /gum/gummemorymap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013-2022 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_MEMORY_MAP_H__ 8 | #define __GUM_MEMORY_MAP_H__ 9 | 10 | #include 11 | 12 | G_BEGIN_DECLS 13 | 14 | #define GUM_TYPE_MEMORY_MAP (gum_memory_map_get_type ()) 15 | G_DECLARE_FINAL_TYPE (GumMemoryMap, gum_memory_map, GUM, MEMORY_MAP, GObject) 16 | 17 | GUM_API GumMemoryMap * gum_memory_map_new (GumPageProtection prot); 18 | 19 | GUM_API gboolean gum_memory_map_contains (GumMemoryMap * self, 20 | const GumMemoryRange * range); 21 | 22 | GUM_API void gum_memory_map_update (GumMemoryMap * self); 23 | 24 | G_END_DECLS 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /tests/prof/fakesampler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2018 Ole André Vadla Ravnås 3 | * Copyright (C) 2008 Christian Berentsen 4 | * 5 | * Licence: wxWindows Library Licence, Version 3.1 6 | */ 7 | 8 | #ifndef __FAKE_SAMPLER_H__ 9 | #define __FAKE_SAMPLER_H__ 10 | 11 | #include 12 | #include 13 | 14 | G_BEGIN_DECLS 15 | 16 | #define GUM_TYPE_FAKE_SAMPLER (gum_fake_sampler_get_type ()) 17 | G_DECLARE_FINAL_TYPE (GumFakeSampler, gum_fake_sampler, GUM, FAKE_SAMPLER, 18 | GObject) 19 | 20 | GumSampler * gum_fake_sampler_new (void); 21 | 22 | void gum_fake_sampler_advance (GumFakeSampler * self, GumSample delta); 23 | 24 | G_END_DECLS 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /gum/gummodulefacade.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_MODULE_FACADE_H__ 8 | #define __GUM_MODULE_FACADE_H__ 9 | 10 | #include 11 | 12 | G_BEGIN_DECLS 13 | 14 | #define GUM_TYPE_MODULE_FACADE (gum_module_facade_get_type ()) 15 | G_DECLARE_FINAL_TYPE (GumModuleFacade, gum_module_facade, GUM, MODULE_FACADE, 16 | GObject) 17 | 18 | G_GNUC_INTERNAL GumModuleFacade * _gum_module_facade_new (GumModule * module, 19 | GObject * resolver); 20 | 21 | G_GNUC_INTERNAL GumModule * _gum_module_facade_get_module ( 22 | GumModuleFacade * self); 23 | 24 | G_END_DECLS 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /bindings/gumjs/gumquickkernel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_QUICK_KERNEL_H__ 8 | #define __GUM_QUICK_KERNEL_H__ 9 | 10 | #include "gumquickcore.h" 11 | 12 | G_BEGIN_DECLS 13 | 14 | typedef struct _GumQuickKernel GumQuickKernel; 15 | 16 | struct _GumQuickKernel 17 | { 18 | GumQuickCore * core; 19 | }; 20 | 21 | G_GNUC_INTERNAL void _gum_quick_kernel_init (GumQuickKernel * self, 22 | JSValue ns, GumQuickCore * core); 23 | G_GNUC_INTERNAL void _gum_quick_kernel_dispose (GumQuickKernel * self); 24 | G_GNUC_INTERNAL void _gum_quick_kernel_finalize (GumQuickKernel * self); 25 | 26 | G_END_DECLS 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /tests/stubs/dummyclasses.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2018 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #include "dummyclasses.h" 8 | 9 | struct _MyPony 10 | { 11 | GObject parent; 12 | }; 13 | 14 | struct _ZooZebra 15 | { 16 | GObject parent; 17 | }; 18 | 19 | G_DEFINE_TYPE (MyPony, my_pony, G_TYPE_OBJECT) 20 | G_DEFINE_TYPE (ZooZebra, zoo_zebra, G_TYPE_OBJECT) 21 | 22 | static void 23 | my_pony_class_init (MyPonyClass * klass) 24 | { 25 | } 26 | 27 | static void 28 | my_pony_init (MyPony * self) 29 | { 30 | } 31 | 32 | static void 33 | zoo_zebra_class_init (ZooZebraClass * klass) 34 | { 35 | } 36 | 37 | static void 38 | zoo_zebra_init (ZooZebra * self) 39 | { 40 | } 41 | -------------------------------------------------------------------------------- /bindings/gumjs/devkit/meson.build: -------------------------------------------------------------------------------- 1 | devkit_outputs = [ 2 | 'frida-gumjs.h', 3 | static_lib_prefix + 'frida-gumjs' + static_lib_suffix, 4 | 'frida-gumjs-example.c', 5 | ] 6 | 7 | if cc.get_argument_syntax() == 'msvc' 8 | devkit_outputs += [ 9 | 'frida-gumjs-example.sln', 10 | 'frida-gumjs-example.vcxproj', 11 | 'frida-gumjs-example.vcxproj.filters', 12 | ] 13 | endif 14 | 15 | custom_target('gumjs-devkit', 16 | input: [gum, gum_heap, gum_prof, gumjs], 17 | output: devkit_outputs, 18 | command: [ 19 | mkdevkit, 20 | 'frida-gumjs', 21 | f'@host_os@-@host_arch@', 22 | meson.current_build_dir(), 23 | ] + devkit_options, 24 | install: true, 25 | install_dir: get_option('libdir') / 'frida' / 'devkits' / 'gumjs' 26 | ) 27 | -------------------------------------------------------------------------------- /gum/backend-barebone/include/gum/gumbarebone.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_BAREBONE_H__ 8 | #define __GUM_BAREBONE_H__ 9 | 10 | #include 11 | #include 12 | 13 | G_BEGIN_DECLS 14 | 15 | GUM_API guint gum_barebone_query_page_size (void); 16 | GUM_API gpointer gum_barebone_try_remap_writable_pages (gconstpointer * addrs, 17 | guint n_addrs); 18 | 19 | GUM_API void gum_barebone_on_registry_activating (GumModuleRegistry * registry); 20 | GUM_API void gum_barebone_register_module (GumModuleRegistry * registry, 21 | GumModule * module); 22 | 23 | G_END_DECLS 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /bindings/gumjs/gumquickfile.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_QUICK_FILE_H__ 8 | #define __GUM_QUICK_FILE_H__ 9 | 10 | #include "gumquickcore.h" 11 | 12 | G_BEGIN_DECLS 13 | 14 | typedef struct _GumQuickFile GumQuickFile; 15 | 16 | struct _GumQuickFile 17 | { 18 | GumQuickCore * core; 19 | 20 | JSClassID file_class; 21 | }; 22 | 23 | G_GNUC_INTERNAL void _gum_quick_file_init (GumQuickFile * self, 24 | JSValue ns, GumQuickCore * core); 25 | G_GNUC_INTERNAL void _gum_quick_file_dispose (GumQuickFile * self); 26 | G_GNUC_INTERNAL void _gum_quick_file_finalize (GumQuickFile * self); 27 | 28 | G_END_DECLS 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /bindings/gumjs/gumv8checksum.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_V8_CHECKSUM_H__ 8 | #define __GUM_V8_CHECKSUM_H__ 9 | 10 | #include "gumv8core.h" 11 | 12 | struct GumV8Checksum 13 | { 14 | GumV8Core * core; 15 | 16 | GHashTable * checksums; 17 | }; 18 | 19 | G_GNUC_INTERNAL void _gum_v8_checksum_init (GumV8Checksum * self, 20 | GumV8Core * core, v8::Local scope); 21 | G_GNUC_INTERNAL void _gum_v8_checksum_realize (GumV8Checksum * self); 22 | G_GNUC_INTERNAL void _gum_v8_checksum_dispose (GumV8Checksum * self); 23 | G_GNUC_INTERNAL void _gum_v8_checksum_finalize (GumV8Checksum * self); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /tests/run-linux-vm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -z "$1" ]; then 4 | echo "Usage: $0 " > /dev/stderr 5 | exit 1 6 | fi 7 | arch=$1 8 | shift 1 9 | 10 | case $arch in 11 | mips) 12 | vm=mips32 13 | ;; 14 | mipsel) 15 | vm=mips32el 16 | ;; 17 | *) 18 | echo "Unsupported architecture: $arch" > /dev/stderr 19 | exit 1 20 | esac 21 | 22 | srcdir=$(cd $(dirname "$0") && pwd) 23 | builddir=$(cd build/$arch && pwd) 24 | intdir=$(mktemp -d) 25 | 26 | cleanup() { 27 | rm -rf "$intdir" 28 | } 29 | trap cleanup EXIT 30 | 31 | echo "Using: $intdir" 32 | set -e 33 | 34 | make -C "$builddir" 35 | cd $builddir/tests 36 | cp -a gum-tests "$intdir/" 37 | cd "$intdir" 38 | arm_now install $vm 39 | arm_now resize 500M 40 | "$srcdir/vm.py" $vm "$@" 41 | -------------------------------------------------------------------------------- /bindings/gumjs/gumsourcemap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016-2025 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_SOURCE_MAP_H__ 8 | #define __GUM_SOURCE_MAP_H__ 9 | 10 | #include 11 | 12 | G_BEGIN_DECLS 13 | 14 | #define GUM_TYPE_SOURCE_MAP (gum_source_map_get_type ()) 15 | G_DECLARE_FINAL_TYPE (GumSourceMap, gum_source_map, GUM, SOURCE_MAP, GObject) 16 | 17 | GumSourceMap * gum_source_map_new (const gchar * json); 18 | 19 | gboolean gum_source_map_resolve (GumSourceMap * self, guint * line, 20 | guint * column, const gchar ** source, const gchar ** name); 21 | 22 | gchar * gum_source_map_try_extract_inline (const gchar * source); 23 | 24 | G_END_DECLS 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /bindings/gumjs/gumquicksymbol.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_QUICK_SYMBOL_H__ 8 | #define __GUM_QUICK_SYMBOL_H__ 9 | 10 | #include "gumquickcore.h" 11 | 12 | G_BEGIN_DECLS 13 | 14 | typedef struct _GumQuickSymbol GumQuickSymbol; 15 | 16 | struct _GumQuickSymbol 17 | { 18 | GumQuickCore * core; 19 | 20 | JSClassID symbol_class; 21 | }; 22 | 23 | G_GNUC_INTERNAL void _gum_quick_symbol_init (GumQuickSymbol * self, 24 | JSValue ns, GumQuickCore * core); 25 | G_GNUC_INTERNAL void _gum_quick_symbol_dispose (GumQuickSymbol * self); 26 | G_GNUC_INTERNAL void _gum_quick_symbol_finalize (GumQuickSymbol * self); 27 | 28 | G_END_DECLS 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /gum/backend-darwin/helpers/Makefile: -------------------------------------------------------------------------------- 1 | helpers := \ 2 | build/threadedbindprocessor.dylib \ 3 | build/fixupchainprocessor.dylib \ 4 | $(NULL) 5 | 6 | sources := \ 7 | threadedbindprocessor.c \ 8 | fixupchainprocessor.c \ 9 | $(NULL) 10 | 11 | ios_cc := $(shell xcrun --sdk iphoneos -f clang) 12 | cflags := -Wall -Werror -pipe -Oz -g 13 | ldflags := -Wl,-dead_strip 14 | 15 | build: $(helpers) 16 | 17 | build/%.dylib: %.c $(sources) 18 | @mkdir -p $(@D) 19 | $(ios_cc) \ 20 | -isysroot $(shell xcrun --sdk iphoneos --show-sdk-path) \ 21 | -target arm64e-apple-ios14.0 \ 22 | $(cflags) \ 23 | -fno-ptrauth-calls \ 24 | -fno-ptrauth-returns \ 25 | -fno-stack-check \ 26 | -fno-stack-protector \ 27 | $< \ 28 | -o $@ \ 29 | -dynamiclib \ 30 | $(ldflags) 31 | 32 | .PHONY: build 33 | -------------------------------------------------------------------------------- /libs/gum/prof/gumbusycyclesampler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2018 Ole André Vadla Ravnås 3 | * Copyright (C) 2008 Christian Berentsen 4 | * 5 | * Licence: wxWindows Library Licence, Version 3.1 6 | */ 7 | 8 | #ifndef __GUM_BUSY_CYCLE_SAMPLER_H__ 9 | #define __GUM_BUSY_CYCLE_SAMPLER_H__ 10 | 11 | #include "gumsampler.h" 12 | 13 | G_BEGIN_DECLS 14 | 15 | #define GUM_TYPE_BUSY_CYCLE_SAMPLER (gum_busy_cycle_sampler_get_type ()) 16 | G_DECLARE_FINAL_TYPE (GumBusyCycleSampler, gum_busy_cycle_sampler, GUM, 17 | BUSY_CYCLE_SAMPLER, GObject) 18 | 19 | GUM_API GumSampler * gum_busy_cycle_sampler_new (void); 20 | 21 | GUM_API gboolean gum_busy_cycle_sampler_is_available ( 22 | GumBusyCycleSampler * self); 23 | 24 | G_END_DECLS 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /bindings/gumjs/gumv8cmodule.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2022 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_V8_CMODULE_H__ 8 | #define __GUM_V8_CMODULE_H__ 9 | 10 | #include "gumv8core.h" 11 | 12 | struct GumV8CModule 13 | { 14 | GumV8Core * core; 15 | 16 | GHashTable * cmodules; 17 | 18 | v8::Global * toolchain_key; 19 | }; 20 | 21 | G_GNUC_INTERNAL void _gum_v8_cmodule_init (GumV8CModule * self, 22 | GumV8Core * core, v8::Local scope); 23 | G_GNUC_INTERNAL void _gum_v8_cmodule_realize (GumV8CModule * self); 24 | G_GNUC_INTERNAL void _gum_v8_cmodule_dispose (GumV8CModule * self); 25 | G_GNUC_INTERNAL void _gum_v8_cmodule_finalize (GumV8CModule * self); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /bindings/gumjs/gumquickchecksum.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_QUICK_CHECKSUM_H__ 8 | #define __GUM_QUICK_CHECKSUM_H__ 9 | 10 | #include "gumquickcore.h" 11 | 12 | G_BEGIN_DECLS 13 | 14 | typedef struct _GumQuickChecksum GumQuickChecksum; 15 | 16 | struct _GumQuickChecksum 17 | { 18 | GumQuickCore * core; 19 | 20 | JSClassID checksum_class; 21 | }; 22 | 23 | G_GNUC_INTERNAL void _gum_quick_checksum_init (GumQuickChecksum * self, 24 | JSValue ns, GumQuickCore * core); 25 | G_GNUC_INTERNAL void _gum_quick_checksum_dispose (GumQuickChecksum * self); 26 | G_GNUC_INTERNAL void _gum_quick_checksum_finalize (GumQuickChecksum * self); 27 | 28 | G_END_DECLS 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /libs/gum/prof/gumsampler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2018 Ole André Vadla Ravnås 3 | * Copyright (C) 2008 Christian Berentsen 4 | * 5 | * Licence: wxWindows Library Licence, Version 3.1 6 | */ 7 | 8 | #ifndef __GUM_SAMPLER_H__ 9 | #define __GUM_SAMPLER_H__ 10 | 11 | #include 12 | #include 13 | 14 | G_BEGIN_DECLS 15 | 16 | #define GUM_TYPE_SAMPLER (gum_sampler_get_type ()) 17 | G_DECLARE_INTERFACE (GumSampler, gum_sampler, GUM, SAMPLER, GObject) 18 | 19 | typedef guint64 GumSample; 20 | 21 | struct _GumSamplerInterface 22 | { 23 | GTypeInterface parent; 24 | 25 | GumSample (* sample) (GumSampler * self); 26 | }; 27 | 28 | GUM_API GumSample gum_sampler_sample (GumSampler * self); 29 | 30 | G_END_DECLS 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /tests/stubs/fakebacktracer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2018 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __FAKE_BACKTRACER_H__ 8 | #define __FAKE_BACKTRACER_H__ 9 | 10 | #include 11 | #include 12 | 13 | G_BEGIN_DECLS 14 | 15 | #define GUM_TYPE_FAKE_BACKTRACER (gum_fake_backtracer_get_type ()) 16 | G_DECLARE_FINAL_TYPE (GumFakeBacktracer, gum_fake_backtracer, GUM, 17 | FAKE_BACKTRACER, GObject) 18 | 19 | struct _GumFakeBacktracer 20 | { 21 | GObject parent; 22 | 23 | const GumReturnAddress * ret_addrs; 24 | guint num_ret_addrs; 25 | }; 26 | 27 | GumBacktracer * gum_fake_backtracer_new (const GumReturnAddress * ret_addrs, 28 | guint num_ret_addrs); 29 | 30 | G_END_DECLS 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /gum/backend-barebone/gummoduleregistry-barebone.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #include "gummoduleregistry-priv.h" 8 | 9 | #include "gum/gumbarebone.h" 10 | 11 | void 12 | _gum_module_registry_activate (GumModuleRegistry * self) 13 | { 14 | gum_barebone_on_registry_activating (self); 15 | } 16 | 17 | void 18 | _gum_module_registry_deactivate (GumModuleRegistry * self) 19 | { 20 | } 21 | 22 | G_GNUC_WEAK void 23 | gum_barebone_on_registry_activating (GumModuleRegistry * registry) 24 | { 25 | } 26 | 27 | void 28 | gum_barebone_register_module (GumModuleRegistry * registry, 29 | GumModule * module) 30 | { 31 | _gum_module_registry_register (registry, module); 32 | } 33 | -------------------------------------------------------------------------------- /bindings/gumpp/invocationlistener.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __GUMPP_INVOCATION_LISTENER_HPP__ 2 | #define __GUMPP_INVOCATION_LISTENER_HPP__ 3 | 4 | #include "gumpp.hpp" 5 | 6 | namespace Gum 7 | { 8 | typedef struct _GumInvocationListenerProxy GumInvocationListenerProxy; 9 | 10 | class InvocationListenerProxy : public Object 11 | { 12 | public: 13 | InvocationListenerProxy (InvocationListener * listener); 14 | virtual ~InvocationListenerProxy (); 15 | 16 | virtual void ref (); 17 | virtual void unref (); 18 | virtual void * get_handle () const; 19 | 20 | virtual void on_enter (InvocationContext * context); 21 | virtual void on_leave (InvocationContext * context); 22 | 23 | protected: 24 | GumInvocationListenerProxy * cproxy; 25 | InvocationListener * listener; 26 | }; 27 | } 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /gum/gumspinlock.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010-2024 Ole André Vadla Ravnås 3 | * Copyright (C) 2024 Francesco Tamagni 4 | * 5 | * Licence: wxWindows Library Licence, Version 3.1 6 | */ 7 | 8 | #ifndef __GUM_SPINLOCK_H__ 9 | #define __GUM_SPINLOCK_H__ 10 | 11 | #include 12 | 13 | #define GUM_SPINLOCK_INIT { NULL } 14 | 15 | G_BEGIN_DECLS 16 | 17 | typedef struct _GumSpinlock GumSpinlock; 18 | 19 | struct _GumSpinlock 20 | { 21 | gpointer data; 22 | }; 23 | 24 | GUM_API void gum_spinlock_init (GumSpinlock * spinlock); 25 | 26 | GUM_API void gum_spinlock_acquire (GumSpinlock * spinlock); 27 | GUM_API gboolean gum_spinlock_try_acquire (GumSpinlock * spinlock); 28 | GUM_API void gum_spinlock_release (GumSpinlock * spinlock); 29 | 30 | G_END_DECLS 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /tests/stubs/objc/dummyclass.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 Abdelrahman Eid 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #import "dummyclass.h" 8 | 9 | #import 10 | 11 | @interface DummyClass : NSObject 12 | - (int) dummyMethod:(int)dummyArg; 13 | @end 14 | 15 | @implementation DummyClass 16 | - (int) dummyMethod:(int)dummyArg 17 | { 18 | int dummy = 0; 19 | 20 | for (int i = 0; i != dummyArg; i++) 21 | { 22 | for (int j = i; j != dummyArg; j++) 23 | dummy++; 24 | } 25 | 26 | return dummy; 27 | } 28 | @end 29 | 30 | void * 31 | dummy_class_get_dummy_method_impl (void) 32 | { 33 | DummyClass * obj = [[DummyClass alloc] init]; 34 | IMP method = [obj methodForSelector:@selector(dummyMethod:)]; 35 | return (void *) method; 36 | } 37 | -------------------------------------------------------------------------------- /bindings/gumjs/gumquickcmodule.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_QUICK_CMODULE_H__ 8 | #define __GUM_QUICK_CMODULE_H__ 9 | 10 | #include "gumquickcore.h" 11 | 12 | G_BEGIN_DECLS 13 | 14 | typedef struct _GumQuickCModule GumQuickCModule; 15 | 16 | struct _GumQuickCModule 17 | { 18 | GumQuickCore * core; 19 | 20 | GHashTable * cmodules; 21 | 22 | JSClassID cmodule_class; 23 | }; 24 | 25 | G_GNUC_INTERNAL void _gum_quick_cmodule_init (GumQuickCModule * self, 26 | JSValue ns, GumQuickCore * core); 27 | G_GNUC_INTERNAL void _gum_quick_cmodule_dispose (GumQuickCModule * self); 28 | G_GNUC_INTERNAL void _gum_quick_cmodule_finalize (GumQuickCModule * self); 29 | 30 | G_END_DECLS 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /bindings/gumjs/gumv8symbol.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015-2022 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_V8_SYMBOL_H__ 8 | #define __GUM_V8_SYMBOL_H__ 9 | 10 | #include "gumv8core.h" 11 | 12 | struct GumV8Symbol 13 | { 14 | GumV8Core * core; 15 | 16 | GHashTable * symbols; 17 | 18 | v8::Global * klass; 19 | v8::Global * template_object; 20 | }; 21 | 22 | G_GNUC_INTERNAL void _gum_v8_symbol_init (GumV8Symbol * self, 23 | GumV8Core * core, v8::Local scope); 24 | G_GNUC_INTERNAL void _gum_v8_symbol_realize (GumV8Symbol * self); 25 | G_GNUC_INTERNAL void _gum_v8_symbol_dispose (GumV8Symbol * self); 26 | G_GNUC_INTERNAL void _gum_v8_symbol_finalize (GumV8Symbol * self); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /bindings/gumjs/runtime/entrypoint-quickjs.js: -------------------------------------------------------------------------------- 1 | import './core.js'; 2 | import './error-handler-quickjs.js'; 3 | 4 | Script.load = (name, source) => { 5 | return new Promise((resolve, reject) => { 6 | Script._load(name, source, async evalResult => { 7 | try { 8 | await evalResult; 9 | const namespace = await import(name); 10 | resolve(namespace); 11 | } catch (e) { 12 | reject(e); 13 | } 14 | }); 15 | }); 16 | }; 17 | 18 | class WeakRef { 19 | constructor(target) { 20 | this._id = Script.bindWeak(target, this._onTargetDead); 21 | } 22 | 23 | deref() { 24 | if (this._id === null) 25 | return; 26 | return Script._derefWeak(this._id); 27 | } 28 | 29 | _onTargetDead = () => { 30 | this._id = null; 31 | }; 32 | } 33 | 34 | globalThis.WeakRef = WeakRef; 35 | -------------------------------------------------------------------------------- /bindings/gumjs/gumv8memory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010-2022 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_V8_MEMORY_H__ 8 | #define __GUM_V8_MEMORY_H__ 9 | 10 | #include "gumv8core.h" 11 | 12 | #include 13 | 14 | struct GumV8Memory 15 | { 16 | GumV8Core * core; 17 | 18 | GumMemoryAccessMonitor * monitor; 19 | v8::Global * on_access; 20 | }; 21 | 22 | G_GNUC_INTERNAL void _gum_v8_memory_init (GumV8Memory * self, 23 | GumV8Core * core, v8::Local scope); 24 | G_GNUC_INTERNAL void _gum_v8_memory_realize (GumV8Memory * self); 25 | G_GNUC_INTERNAL void _gum_v8_memory_dispose (GumV8Memory * self); 26 | G_GNUC_INTERNAL void _gum_v8_memory_finalize (GumV8Memory * self); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /bindings/gumjs/gumv8codewriter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017-2020 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_V8_CODE_WRITER_H__ 8 | #define __GUM_V8_CODE_WRITER_H__ 9 | 10 | #include "gumv8core.h" 11 | 12 | struct GumV8CodeWriter 13 | { 14 | GumV8Core * core; 15 | 16 | #include "gumv8codewriter-fields.inc" 17 | }; 18 | 19 | G_GNUC_INTERNAL void _gum_v8_code_writer_init (GumV8CodeWriter * self, 20 | GumV8Core * core, v8::Local scope); 21 | G_GNUC_INTERNAL void _gum_v8_code_writer_realize (GumV8CodeWriter * self); 22 | G_GNUC_INTERNAL void _gum_v8_code_writer_dispose (GumV8CodeWriter * self); 23 | G_GNUC_INTERNAL void _gum_v8_code_writer_finalize (GumV8CodeWriter * self); 24 | 25 | #include "gumv8codewriter-methods.inc" 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /tests/sign.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | host_os="$1" 4 | runner_binary="$2" 5 | runner_entitlements="$3" 6 | signed_runner_binary="$4" 7 | 8 | if [ -z "$CODESIGN" ]; then 9 | CODESIGN=codesign 10 | fi 11 | 12 | if [ -z "$MACOS_CERTID" ]; then 13 | MACOS_CERTID="-" 14 | fi 15 | 16 | if [ -z "$IOS_CERTID" ]; then 17 | IOS_CERTID="-" 18 | fi 19 | 20 | rm -f "$signed_runner_binary" 21 | cp "$runner_binary" "$signed_runner_binary" 22 | 23 | case $host_os in 24 | macos) 25 | "$CODESIGN" -f -s "$MACOS_CERTID" -i "re.frida.GumTests" "$signed_runner_binary" || exit 1 26 | ;; 27 | ios) 28 | "$CODESIGN" -f -s "$IOS_CERTID" --entitlements "$runner_entitlements" "$signed_runner_binary" || exit 1 29 | ;; 30 | tvos) 31 | "$CODESIGN" -f -s "$TVOS_CERTID" --entitlements "$runner_entitlements" "$signed_runner_binary" || exit 1 32 | ;; 33 | esac 34 | -------------------------------------------------------------------------------- /libs/gum/prof/gumusertimesampler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_USER_TIME_SAMPLER_H__ 8 | #define __GUM_USER_TIME_SAMPLER_H__ 9 | 10 | #include "gumsampler.h" 11 | 12 | #include 13 | 14 | G_BEGIN_DECLS 15 | 16 | #define GUM_TYPE_USER_TIME_SAMPLER (gum_user_time_sampler_get_type ()) 17 | G_DECLARE_FINAL_TYPE (GumUserTimeSampler, gum_user_time_sampler, GUM, 18 | USER_TIME_SAMPLER, GObject) 19 | 20 | GUM_API GumSampler * gum_user_time_sampler_new (void); 21 | GUM_API GumSampler * gum_user_time_sampler_new_with_thread_id ( 22 | GumThreadId thread_id); 23 | 24 | GUM_API gboolean gum_user_time_sampler_is_available (GumUserTimeSampler * self); 25 | 26 | G_END_DECLS 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /vapi/meson.build: -------------------------------------------------------------------------------- 1 | vapis = [ 2 | 'frida-gum-@0@.vapi'.format(api_version), 3 | 'frida-gum-heap-@0@.vapi'.format(api_version), 4 | ] 5 | 6 | if host_os_family == 'windows' 7 | vapis += ['frida-gum-windows-@0@.vapi'.format(api_version)] 8 | endif 9 | 10 | if host_os_family == 'darwin' 11 | vapis += ['frida-gum-darwin-@0@.vapi'.format(api_version)] 12 | endif 13 | 14 | if host_os_family == 'linux' 15 | vapis += ['frida-gum-linux-@0@.vapi'.format(api_version)] 16 | endif 17 | 18 | if host_os_family == 'freebsd' 19 | vapis += ['frida-gum-freebsd-@0@.vapi'.format(api_version)] 20 | endif 21 | 22 | if have_gumjs 23 | vapis += [ 24 | 'frida-gumjs-@0@.vapi'.format(api_version), 25 | 'frida-gumjs-inspector-@0@.vapi'.format(api_version), 26 | ] 27 | endif 28 | 29 | install_data(vapis, install_dir: get_option('prefix') / get_option('datadir') / 'vala' / 'vapi') 30 | -------------------------------------------------------------------------------- /libs/gum/heap/gumallocationgroup.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_ALLOCATION_GROUP_H__ 8 | #define __GUM_ALLOCATION_GROUP_H__ 9 | 10 | #include 11 | 12 | typedef struct _GumAllocationGroup GumAllocationGroup; 13 | 14 | struct _GumAllocationGroup 15 | { 16 | guint size; 17 | guint alive_now; 18 | guint alive_peak; 19 | guint total_peak; 20 | }; 21 | 22 | G_BEGIN_DECLS 23 | 24 | GUM_API GumAllocationGroup * gum_allocation_group_new (guint size); 25 | GUM_API GumAllocationGroup * gum_allocation_group_copy ( 26 | const GumAllocationGroup * group); 27 | GUM_API void gum_allocation_group_free (GumAllocationGroup * group); 28 | 29 | GUM_API void gum_allocation_group_list_free (GList * groups); 30 | 31 | G_END_DECLS 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /tests/core/arch-arm64/stalker-arm64-darwin.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017-2020 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #include "stalker-arm64-fixture.c" 8 | 9 | #import 10 | 11 | TESTLIST_BEGIN (stalker_darwin) 12 | TESTENTRY (foundation) 13 | TESTLIST_END () 14 | 15 | TESTCASE (foundation) 16 | { 17 | if (!g_test_slow ()) 18 | { 19 | g_print (" "); 20 | return; 21 | } 22 | 23 | fixture->sink->mask = GUM_CALL; 24 | 25 | gum_stalker_follow_me (fixture->stalker, fixture->transformer, 26 | GUM_EVENT_SINK (fixture->sink)); 27 | 28 | @autoreleasepool 29 | { 30 | [NSDictionary dictionary]; 31 | } 32 | 33 | gum_stalker_unfollow_me (fixture->stalker); 34 | 35 | g_assert_cmpuint (fixture->sink->events->len, >, 0); 36 | } 37 | -------------------------------------------------------------------------------- /gum/gumthreadregistry-priv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_THREAD_REGISTRY_PRIV_H__ 8 | #define __GUM_THREAD_REGISTRY_PRIV_H__ 9 | 10 | #include "gumthreadregistry.h" 11 | 12 | G_BEGIN_DECLS 13 | 14 | G_GNUC_INTERNAL void _gum_thread_registry_activate (GumThreadRegistry * self); 15 | G_GNUC_INTERNAL void _gum_thread_registry_deactivate (GumThreadRegistry * self); 16 | 17 | G_GNUC_INTERNAL void _gum_thread_registry_register (GumThreadRegistry * self, 18 | const GumThreadDetails * thread); 19 | G_GNUC_INTERNAL void _gum_thread_registry_unregister (GumThreadRegistry * self, 20 | GumThreadId id); 21 | G_GNUC_INTERNAL void _gum_thread_registry_rename (GumThreadRegistry * self, 22 | GumThreadId id, const gchar * name); 23 | 24 | G_END_DECLS 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /gum/gumintrospect.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #include "gum.h" 8 | 9 | #include 10 | #include 11 | 12 | gint 13 | main (gint argc, 14 | gchar * argv[]) 15 | { 16 | const gchar * expected_prefix = "--introspect-dump="; 17 | GError * error = NULL; 18 | 19 | if (argc != 2 || !g_str_has_prefix (argv[1], expected_prefix)) 20 | goto bad_usage; 21 | 22 | gum_init (); 23 | 24 | if (!g_irepository_dump (argv[1] + strlen (expected_prefix), &error)) 25 | goto dump_failed; 26 | 27 | return 0; 28 | 29 | bad_usage: 30 | { 31 | g_printerr ("usage: %s --introspect-dump=types.txt,out.xml\\n", argv[0]); 32 | return 1; 33 | } 34 | dump_failed: 35 | { 36 | g_printerr ("%s\n", error->message); 37 | return 1; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /gum/gummoduleregistry.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_MODULE_REGISTRY_H__ 8 | #define __GUM_MODULE_REGISTRY_H__ 9 | 10 | #include 11 | 12 | G_BEGIN_DECLS 13 | 14 | #define GUM_TYPE_MODULE_REGISTRY (gum_module_registry_get_type ()) 15 | G_DECLARE_FINAL_TYPE (GumModuleRegistry, gum_module_registry, GUM, 16 | MODULE_REGISTRY, GObject) 17 | 18 | GUM_API GumModuleRegistry * gum_module_registry_obtain (void); 19 | 20 | GUM_API void gum_module_registry_enumerate_modules (GumModuleRegistry * self, 21 | GumFoundModuleFunc func, gpointer user_data); 22 | 23 | GUM_API void gum_module_registry_lock (GumModuleRegistry * self); 24 | GUM_API void gum_module_registry_unlock (GumModuleRegistry * self); 25 | 26 | G_END_DECLS 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /gum/gumthreadregistry.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_THREAD_REGISTRY_H__ 8 | #define __GUM_THREAD_REGISTRY_H__ 9 | 10 | #include 11 | 12 | G_BEGIN_DECLS 13 | 14 | #define GUM_TYPE_THREAD_REGISTRY (gum_thread_registry_get_type ()) 15 | G_DECLARE_FINAL_TYPE (GumThreadRegistry, gum_thread_registry, GUM, 16 | THREAD_REGISTRY, GObject) 17 | 18 | GUM_API GumThreadRegistry * gum_thread_registry_obtain (void); 19 | 20 | GUM_API void gum_thread_registry_enumerate_threads (GumThreadRegistry * self, 21 | GumFoundThreadFunc func, gpointer user_data); 22 | 23 | GUM_API void gum_thread_registry_lock (GumThreadRegistry * self); 24 | GUM_API void gum_thread_registry_unlock (GumThreadRegistry * self); 25 | 26 | G_END_DECLS 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /gum/backend-arm64/gumstalker-arm64-glue.masm: -------------------------------------------------------------------------------- 1 | EXPORT gum_stalker_follow_me 2 | EXPORT gum_stalker_activate 3 | EXPORT gum_stalker_deactivate 4 | 5 | IMPORT _gum_stalker_do_follow_me 6 | IMPORT _gum_stalker_do_activate 7 | IMPORT _gum_stalker_do_deactivate 8 | 9 | AREA |.text|, CODE, ALIGN=8 10 | 11 | |gum_stalker_follow_me| PROC 12 | stp x29, x30, [sp, -16]! 13 | mov x29, sp 14 | mov x3, x30 15 | bl _gum_stalker_do_follow_me 16 | ldp x29, x30, [sp], 16 17 | br x0 18 | ENDP 19 | 20 | |gum_stalker_activate| PROC 21 | stp x29, x30, [sp, -16]! 22 | mov x29, sp 23 | mov x2, x30 24 | bl _gum_stalker_do_activate 25 | ldp x29, x30, [sp], 16 26 | br x0 27 | ENDP 28 | 29 | |gum_stalker_deactivate| PROC 30 | stp x29, x30, [sp, -16]! 31 | mov x29, sp 32 | mov x1, x30 33 | bl _gum_stalker_do_deactivate 34 | ldp x29, x30, [sp], 16 35 | br x0 36 | ENDP 37 | 38 | END 39 | -------------------------------------------------------------------------------- /bindings/gumjs/gumquickcodewriter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_QUICK_CODE_WRITER_H__ 8 | #define __GUM_QUICK_CODE_WRITER_H__ 9 | 10 | #include "gumquickcore.h" 11 | 12 | G_BEGIN_DECLS 13 | 14 | typedef struct _GumQuickCodeWriter GumQuickCodeWriter; 15 | 16 | struct _GumQuickCodeWriter 17 | { 18 | GumQuickCore * core; 19 | 20 | #include "gumquickcodewriter-fields.inc" 21 | }; 22 | 23 | G_GNUC_INTERNAL void _gum_quick_code_writer_init (GumQuickCodeWriter * self, 24 | JSValue ns, GumQuickCore * core); 25 | G_GNUC_INTERNAL void _gum_quick_code_writer_dispose (GumQuickCodeWriter * self); 26 | G_GNUC_INTERNAL void _gum_quick_code_writer_finalize ( 27 | GumQuickCodeWriter * self); 28 | 29 | #include "gumquickcodewriter-methods.inc" 30 | 31 | G_END_DECLS 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /bindings/gumjs/gumquickdatabase.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_QUICK_DATABASE_H__ 8 | #define __GUM_QUICK_DATABASE_H__ 9 | 10 | #include "gumquickcore.h" 11 | #include "gummemoryvfs.h" 12 | 13 | G_BEGIN_DECLS 14 | 15 | typedef struct _GumQuickDatabase GumQuickDatabase; 16 | 17 | struct _GumQuickDatabase 18 | { 19 | GumQuickCore * core; 20 | 21 | JSClassID database_class; 22 | JSClassID statement_class; 23 | 24 | GumMemoryVfs * memory_vfs; 25 | }; 26 | 27 | G_GNUC_INTERNAL void _gum_quick_database_init (GumQuickDatabase * self, 28 | JSValue ns, GumQuickCore * core); 29 | G_GNUC_INTERNAL void _gum_quick_database_dispose (GumQuickDatabase * self); 30 | G_GNUC_INTERNAL void _gum_quick_database_finalize (GumQuickDatabase * self); 31 | 32 | G_END_DECLS 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /bindings/gumjs/gumquickapiresolver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_QUICK_API_RESOLVER_H__ 8 | #define __GUM_QUICK_API_RESOLVER_H__ 9 | 10 | #include "gumquickobject.h" 11 | 12 | G_BEGIN_DECLS 13 | 14 | typedef struct _GumQuickApiResolver GumQuickApiResolver; 15 | 16 | struct _GumQuickApiResolver 17 | { 18 | GumQuickCore * core; 19 | 20 | GumQuickObjectManager objects; 21 | 22 | JSClassID api_resolver_class; 23 | }; 24 | 25 | G_GNUC_INTERNAL void _gum_quick_api_resolver_init (GumQuickApiResolver * self, 26 | JSValue ns, GumQuickCore * core); 27 | G_GNUC_INTERNAL void _gum_quick_api_resolver_dispose ( 28 | GumQuickApiResolver * self); 29 | G_GNUC_INTERNAL void _gum_quick_api_resolver_finalize ( 30 | GumQuickApiResolver * self); 31 | 32 | G_END_DECLS 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /tests/core/targetfunctions/Makefile: -------------------------------------------------------------------------------- 1 | top_srcdir := $(shell cd ../../.. && pwd) 2 | releng := $(top_srcdir)/releng 3 | data_dir := $(top_srcdir)/tests/data 4 | 5 | BUILDDIR ?= $(top_srcdir)/build 6 | MESON ?= $(releng)/meson/meson.py 7 | 8 | ifdef FRIDA_HOST 9 | host_machine := $(FRIDA_HOST) 10 | else 11 | host_machine := $(shell basename $$(ls -1 $(BUILDDIR)/frida-linux-*.txt | tail -1) | cut -d"." -f1 | cut -d"-" -f2-) 12 | endif 13 | host_arch := $(shell echo $(host_machine) | cut -d"-" -f2) 14 | 15 | crossfile := $(BUILDDIR)/frida-$(host_machine).txt 16 | pkg_config_path := $(top_srcdir)/deps/sdk-$(host_machine)/lib/pkgconfig 17 | 18 | build: 19 | $(MESON) setup \ 20 | --cross-file $(crossfile) \ 21 | --libdir "$(data_dir)" \ 22 | --strip \ 23 | -Dstem_suffix="-$(host_machine)" \ 24 | -Dpkg_config_path="$(pkg_config_path)" \ 25 | --wipe \ 26 | build 27 | $(MESON) install -C build 28 | 29 | .PHONY: build 30 | -------------------------------------------------------------------------------- /bindings/gumjs/gumquickmemory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_QUICK_MEMORY_H__ 8 | #define __GUM_QUICK_MEMORY_H__ 9 | 10 | #include "gumquickcore.h" 11 | 12 | #include 13 | 14 | G_BEGIN_DECLS 15 | 16 | typedef struct _GumQuickMemory GumQuickMemory; 17 | 18 | struct _GumQuickMemory 19 | { 20 | GumQuickCore * core; 21 | 22 | GumMemoryAccessMonitor * monitor; 23 | JSValue on_access; 24 | 25 | JSClassID memory_access_details_class; 26 | }; 27 | 28 | G_GNUC_INTERNAL void _gum_quick_memory_init (GumQuickMemory * self, JSValue ns, 29 | GumQuickCore * core); 30 | G_GNUC_INTERNAL void _gum_quick_memory_dispose (GumQuickMemory * self); 31 | G_GNUC_INTERNAL void _gum_quick_memory_finalize (GumQuickMemory * self); 32 | 33 | G_END_DECLS 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /gum/gumexceptorbackend.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016-2022 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_EXCEPTOR_BACKEND_H__ 8 | #define __GUM_EXCEPTOR_BACKEND_H__ 9 | 10 | #include "gumexceptor.h" 11 | 12 | G_BEGIN_DECLS 13 | 14 | G_GNUC_INTERNAL void _gum_exceptor_backend_prepare_to_fork (void); 15 | G_GNUC_INTERNAL void _gum_exceptor_backend_recover_from_fork_in_parent (void); 16 | G_GNUC_INTERNAL void _gum_exceptor_backend_recover_from_fork_in_child (void); 17 | 18 | #define GUM_TYPE_EXCEPTOR_BACKEND (gum_exceptor_backend_get_type ()) 19 | G_DECLARE_FINAL_TYPE (GumExceptorBackend, gum_exceptor_backend, GUM, 20 | EXCEPTOR_BACKEND, GObject) 21 | 22 | G_GNUC_INTERNAL GumExceptorBackend * gum_exceptor_backend_new ( 23 | GumExceptionHandler handler, gpointer user_data); 24 | 25 | G_END_DECLS 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /gum/backend-posix/gumtls-posix.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015-2019 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #include "gumtls.h" 8 | 9 | #include 10 | 11 | void 12 | _gum_tls_init (void) 13 | { 14 | } 15 | 16 | void 17 | _gum_tls_realize (void) 18 | { 19 | } 20 | 21 | void 22 | _gum_tls_deinit (void) 23 | { 24 | } 25 | 26 | GumTlsKey 27 | gum_tls_key_new (void) 28 | { 29 | pthread_key_t key; 30 | 31 | pthread_key_create (&key, NULL); 32 | 33 | return key; 34 | } 35 | 36 | void 37 | gum_tls_key_free (GumTlsKey key) 38 | { 39 | pthread_key_delete (key); 40 | } 41 | 42 | gpointer 43 | gum_tls_key_get_value (GumTlsKey key) 44 | { 45 | return pthread_getspecific (key); 46 | } 47 | 48 | void 49 | gum_tls_key_set_value (GumTlsKey key, 50 | gpointer value) 51 | { 52 | pthread_setspecific (key, value); 53 | } 54 | -------------------------------------------------------------------------------- /gum/backend-barebone/gumtls-barebone.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #include "gumtls.h" 8 | 9 | G_GNUC_WEAK GumTlsKey 10 | gum_tls_key_new (void) 11 | { 12 | G_PANIC_MISSING_IMPLEMENTATION (); 13 | return 0; 14 | } 15 | 16 | G_GNUC_WEAK void 17 | gum_tls_key_free (GumTlsKey key) 18 | { 19 | G_PANIC_MISSING_IMPLEMENTATION (); 20 | } 21 | 22 | void 23 | _gum_tls_init (void) 24 | { 25 | } 26 | 27 | void 28 | _gum_tls_realize (void) 29 | { 30 | } 31 | 32 | void 33 | _gum_tls_deinit (void) 34 | { 35 | } 36 | 37 | G_GNUC_WEAK gpointer 38 | gum_tls_key_get_value (GumTlsKey key) 39 | { 40 | G_PANIC_MISSING_IMPLEMENTATION (); 41 | return NULL; 42 | } 43 | 44 | G_GNUC_WEAK void 45 | gum_tls_key_set_value (GumTlsKey key, 46 | gpointer value) 47 | { 48 | G_PANIC_MISSING_IMPLEMENTATION (); 49 | } 50 | -------------------------------------------------------------------------------- /bindings/gumjs/gumv8apiresolver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016-2020 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_V8_API_RESOLVER_H__ 8 | #define __GUM_V8_API_RESOLVER_H__ 9 | 10 | #include "gumv8object.h" 11 | 12 | #include 13 | 14 | struct GumV8ApiResolver 15 | { 16 | GumV8Core * core; 17 | 18 | GumV8ObjectManager objects; 19 | }; 20 | 21 | typedef GumV8Object GumV8ApiResolverObject; 22 | 23 | G_GNUC_INTERNAL void _gum_v8_api_resolver_init (GumV8ApiResolver * self, 24 | GumV8Core * core, v8::Local scope); 25 | G_GNUC_INTERNAL void _gum_v8_api_resolver_realize (GumV8ApiResolver * self); 26 | G_GNUC_INTERNAL void _gum_v8_api_resolver_dispose (GumV8ApiResolver * self); 27 | G_GNUC_INTERNAL void _gum_v8_api_resolver_finalize (GumV8ApiResolver * self); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /gum/backend-qnx/include/gum/gumqnx.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_QNX_H__ 8 | #define __GUM_QNX_H__ 9 | 10 | #include "gumprocess.h" 11 | 12 | #include 13 | 14 | G_BEGIN_DECLS 15 | 16 | GUM_API GumCpuType gum_qnx_cpu_type_from_file (const gchar * path, 17 | GError ** error); 18 | GUM_API GumCpuType gum_qnx_cpu_type_from_pid (pid_t pid, GError ** error); 19 | GUM_API gchar * gum_qnx_query_program_path_for_self (GError ** error); 20 | GUM_API void gum_qnx_enumerate_ranges (pid_t pid, GumPageProtection prot, 21 | GumFoundRangeFunc func, gpointer user_data); 22 | 23 | GUM_API void gum_qnx_parse_ucontext (const ucontext_t * uc, 24 | GumCpuContext * ctx); 25 | GUM_API void gum_qnx_unparse_ucontext (const GumCpuContext * ctx, 26 | ucontext_t * uc); 27 | 28 | G_END_DECLS 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /bindings/gumpp/podwrapper.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __GUMPP_POD_WRAPPER_HPP__ 2 | #define __GUMPP_POD_WRAPPER_HPP__ 3 | 4 | #include 5 | 6 | namespace Gum 7 | { 8 | template 9 | class PodWrapper : public B 10 | { 11 | public: 12 | PodWrapper () 13 | : refcount (1), 14 | handle (NULL) 15 | { 16 | } 17 | 18 | virtual ~PodWrapper () 19 | { 20 | } 21 | 22 | virtual void ref () 23 | { 24 | g_atomic_int_add (&refcount, 1); 25 | } 26 | 27 | virtual void unref () 28 | { 29 | if (g_atomic_int_dec_and_test (&refcount)) 30 | delete static_cast (this); 31 | } 32 | 33 | virtual void * get_handle () const 34 | { 35 | return handle; 36 | } 37 | 38 | protected: 39 | void assign_handle (T * h) 40 | { 41 | handle = h; 42 | } 43 | 44 | volatile gint refcount; 45 | T * handle; 46 | }; 47 | } 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /gum/gummoduleregistry-priv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_MODULE_REGISTRY_PRIV_H__ 8 | #define __GUM_MODULE_REGISTRY_PRIV_H__ 9 | 10 | #include "gummoduleregistry.h" 11 | 12 | G_BEGIN_DECLS 13 | 14 | G_GNUC_INTERNAL GUM_API GPtrArray * _gum_module_registry_get_modules ( 15 | GumModuleRegistry * self); 16 | 17 | G_GNUC_INTERNAL void _gum_module_registry_activate (GumModuleRegistry * self); 18 | G_GNUC_INTERNAL void _gum_module_registry_deactivate (GumModuleRegistry * self); 19 | 20 | G_GNUC_INTERNAL void _gum_module_registry_reset (GumModuleRegistry * self); 21 | G_GNUC_INTERNAL void _gum_module_registry_register (GumModuleRegistry * self, 22 | GumModule * mod); 23 | G_GNUC_INTERNAL void _gum_module_registry_unregister (GumModuleRegistry * self, 24 | GumAddress base_address); 25 | 26 | G_END_DECLS 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /bindings/gumjs/gumv8database.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017-2022 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_V8_DATABASE_H__ 8 | #define __GUM_V8_DATABASE_H__ 9 | 10 | #include "gumv8core.h" 11 | #include "gummemoryvfs.h" 12 | 13 | struct GumV8Database 14 | { 15 | GumV8Core * core; 16 | 17 | GHashTable * databases; 18 | GHashTable * statements; 19 | v8::Global * database; 20 | v8::Global * statement; 21 | 22 | GumMemoryVfs * memory_vfs; 23 | }; 24 | 25 | G_GNUC_INTERNAL void _gum_v8_database_init (GumV8Database * self, 26 | GumV8Core * core, v8::Local scope); 27 | G_GNUC_INTERNAL void _gum_v8_database_realize (GumV8Database * self); 28 | G_GNUC_INTERNAL void _gum_v8_database_dispose (GumV8Database * self); 29 | G_GNUC_INTERNAL void _gum_v8_database_finalize (GumV8Database * self); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /gum/arch-x86/gumx86reader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_X86_READER_H__ 8 | #define __GUM_X86_READER_H__ 9 | 10 | #include "gumdefs.h" 11 | 12 | #include 13 | 14 | G_BEGIN_DECLS 15 | 16 | GUM_API guint gum_x86_reader_insn_length (guint8 * code); 17 | GUM_API gboolean gum_x86_reader_insn_is_jcc (const cs_insn * insn); 18 | 19 | GUM_API gpointer gum_x86_reader_find_next_call_target (gconstpointer address); 20 | GUM_API gpointer gum_x86_reader_try_get_relative_call_target ( 21 | gconstpointer address); 22 | GUM_API gpointer gum_x86_reader_try_get_relative_jump_target ( 23 | gconstpointer address); 24 | GUM_API gpointer gum_x86_reader_try_get_indirect_jump_target ( 25 | gconstpointer address); 26 | GUM_API cs_insn * gum_x86_reader_disassemble_instruction_at ( 27 | gconstpointer address); 28 | 29 | G_END_DECLS 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /libs/gum/heap/gumcobject.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_COBJECT_H__ 8 | #define __GUM_COBJECT_H__ 9 | 10 | #include 11 | #include 12 | 13 | typedef struct _GumCObject GumCObject; 14 | 15 | struct _GumCObject 16 | { 17 | gpointer address; 18 | gchar type_name[GUM_MAX_TYPE_NAME + 1]; 19 | GumReturnAddressArray return_addresses; 20 | 21 | /*< private */ 22 | gpointer data; 23 | }; 24 | 25 | #define GUM_COBJECT(b) ((GumCObject *) (b)) 26 | 27 | G_BEGIN_DECLS 28 | 29 | GUM_API GumCObject * gum_cobject_new (gpointer address, 30 | const gchar * type_name); 31 | GUM_API GumCObject * gum_cobject_copy ( 32 | const GumCObject * cobject); 33 | GUM_API void gum_cobject_free (GumCObject * cobject); 34 | 35 | GUM_API void gum_cobject_list_free (GList * cobject_list); 36 | 37 | G_END_DECLS 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /bindings/gumjs/gumquickprofiler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_QUICK_PROFILER_H__ 8 | #define __GUM_QUICK_PROFILER_H__ 9 | 10 | #include "gumquickinterceptor.h" 11 | #include "gumquicksampler.h" 12 | 13 | G_BEGIN_DECLS 14 | 15 | typedef struct _GumQuickProfiler GumQuickProfiler; 16 | 17 | struct _GumQuickProfiler 18 | { 19 | GumQuickSampler * sampler; 20 | GumQuickInterceptor * interceptor; 21 | GumQuickCore * core; 22 | 23 | JSClassID profiler_class; 24 | }; 25 | 26 | G_GNUC_INTERNAL void _gum_quick_profiler_init (GumQuickProfiler * self, 27 | JSValue ns, GumQuickSampler * sampler, GumQuickInterceptor * interceptor, 28 | GumQuickCore * core); 29 | G_GNUC_INTERNAL void _gum_quick_profiler_dispose (GumQuickProfiler * self); 30 | G_GNUC_INTERNAL void _gum_quick_profiler_finalize (GumQuickProfiler * self); 31 | 32 | G_END_DECLS 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /tests/core/interceptor-callbacklistener.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010-2019 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __INTERCEPTOR_CALLBACKLISTENER_H__ 8 | #define __INTERCEPTOR_CALLBACKLISTENER_H__ 9 | 10 | #include 11 | #include 12 | 13 | G_BEGIN_DECLS 14 | 15 | #define TEST_TYPE_CALLBACK_LISTENER (test_callback_listener_get_type ()) 16 | G_DECLARE_FINAL_TYPE (TestCallbackListener, test_callback_listener, TEST, 17 | CALLBACK_LISTENER, GObject) 18 | 19 | typedef void (* TestCallbackListenerFunc) (gpointer user_data, 20 | GumInvocationContext * context); 21 | 22 | struct _TestCallbackListener 23 | { 24 | GObject parent; 25 | 26 | TestCallbackListenerFunc on_enter; 27 | TestCallbackListenerFunc on_leave; 28 | gpointer user_data; 29 | }; 30 | 31 | TestCallbackListener * test_callback_listener_new (void); 32 | 33 | G_END_DECLS 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /bindings/gumjs/gumv8socket.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010-2022 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_V8_SOCKET_H__ 8 | #define __GUM_V8_SOCKET_H__ 9 | 10 | #include "gumv8object.h" 11 | 12 | struct GumV8Socket 13 | { 14 | GumV8Core * core; 15 | 16 | GumV8ObjectManager objects; 17 | 18 | v8::Global * listener; 19 | v8::Global * connection; 20 | }; 21 | 22 | typedef GumV8Object GumV8SocketListener; 23 | 24 | G_GNUC_INTERNAL void _gum_v8_socket_init (GumV8Socket * self, 25 | GumV8Core * core, v8::Local scope); 26 | G_GNUC_INTERNAL void _gum_v8_socket_realize (GumV8Socket * self); 27 | G_GNUC_INTERNAL void _gum_v8_socket_flush (GumV8Socket * self); 28 | G_GNUC_INTERNAL void _gum_v8_socket_dispose (GumV8Socket * self); 29 | G_GNUC_INTERNAL void _gum_v8_socket_finalize (GumV8Socket * self); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /gum/backend-darwin/gumobjcdisposeclasspairmonitor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 Francesco Tamagni 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_OBJC_DISPOSE_CLASS_PAIR_MONITOR_H__ 8 | #define __GUM_OBJC_DISPOSE_CLASS_PAIR_MONITOR_H__ 9 | 10 | #include 11 | 12 | G_BEGIN_DECLS 13 | 14 | #define GUM_TYPE_OBJC_DISPOSE_CLASS_PAIR_MONITOR \ 15 | (gum_objc_dispose_class_pair_monitor_get_type ()) 16 | G_DECLARE_FINAL_TYPE (GumObjcDisposeClassPairMonitor, 17 | gum_objc_dispose_class_pair_monitor, 18 | GUM, OBJC_DISPOSE_CLASS_PAIR_MONITOR, 19 | GObject) 20 | 21 | struct _GumObjcDisposeClassPairMonitor 22 | { 23 | GObject parent; 24 | GRecMutex mutex; 25 | GumInterceptor * interceptor; 26 | }; 27 | 28 | G_GNUC_INTERNAL GumObjcDisposeClassPairMonitor * 29 | gum_objc_dispose_class_pair_monitor_obtain (void); 30 | 31 | G_END_DECLS 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /bindings/gumjs/gumquicksocket.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_QUICK_SOCKET_H__ 8 | #define __GUM_QUICK_SOCKET_H__ 9 | 10 | #include "gumquickstream.h" 11 | 12 | G_BEGIN_DECLS 13 | 14 | typedef struct _GumQuickSocket GumQuickSocket; 15 | 16 | struct _GumQuickSocket 17 | { 18 | GumQuickStream * stream; 19 | GumQuickCore * core; 20 | 21 | GumQuickObjectManager objects; 22 | 23 | JSClassID socket_listener_class; 24 | JSClassID socket_connection_class; 25 | }; 26 | 27 | G_GNUC_INTERNAL void _gum_quick_socket_init (GumQuickSocket * self, 28 | JSValue ns, GumQuickStream * stream, GumQuickCore * core); 29 | G_GNUC_INTERNAL void _gum_quick_socket_flush (GumQuickSocket * self); 30 | G_GNUC_INTERNAL void _gum_quick_socket_dispose (GumQuickSocket * self); 31 | G_GNUC_INTERNAL void _gum_quick_socket_finalize (GumQuickSocket * self); 32 | 33 | G_END_DECLS 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /libs/gum/heap/gumallocationgroup.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #include "gumallocationgroup.h" 8 | #include "gummemory.h" 9 | 10 | GumAllocationGroup * 11 | gum_allocation_group_new (guint size) 12 | { 13 | GumAllocationGroup * group; 14 | 15 | group = g_slice_new0 (GumAllocationGroup); 16 | group->size = size; 17 | 18 | return group; 19 | } 20 | 21 | GumAllocationGroup * 22 | gum_allocation_group_copy (const GumAllocationGroup * group) 23 | { 24 | return g_slice_dup (GumAllocationGroup, group); 25 | } 26 | 27 | void 28 | gum_allocation_group_free (GumAllocationGroup * group) 29 | { 30 | g_slice_free (GumAllocationGroup, group); 31 | } 32 | 33 | void 34 | gum_allocation_group_list_free (GList * groups) 35 | { 36 | GList * cur; 37 | 38 | for (cur = groups; cur != NULL; cur = cur->next) 39 | gum_allocation_group_free (cur->data); 40 | 41 | g_list_free (groups); 42 | } 43 | -------------------------------------------------------------------------------- /bindings/gumjs/guminspectorserver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018-2022 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_INSPECTOR_SERVER_H__ 8 | #define __GUM_INSPECTOR_SERVER_H__ 9 | 10 | #include 11 | #include 12 | 13 | G_BEGIN_DECLS 14 | 15 | #define GUM_TYPE_INSPECTOR_SERVER (gum_inspector_server_get_type ()) 16 | G_DECLARE_FINAL_TYPE (GumInspectorServer, gum_inspector_server, GUM, 17 | INSPECTOR_SERVER, GObject) 18 | 19 | GUM_API GumInspectorServer * gum_inspector_server_new (void); 20 | GUM_API GumInspectorServer * gum_inspector_server_new_with_port (guint port); 21 | 22 | GUM_API gboolean gum_inspector_server_start (GumInspectorServer * self, 23 | GError ** error); 24 | GUM_API void gum_inspector_server_stop (GumInspectorServer * self); 25 | 26 | GUM_API void gum_inspector_server_post_message (GumInspectorServer * self, 27 | const gchar * message); 28 | 29 | G_END_DECLS 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /libs/gum/heap/gumallocationblock.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_ALLOCATION_BLOCK_H__ 8 | #define __GUM_ALLOCATION_BLOCK_H__ 9 | 10 | #include 11 | #include 12 | 13 | typedef struct _GumAllocationBlock GumAllocationBlock; 14 | 15 | struct _GumAllocationBlock 16 | { 17 | gpointer address; 18 | guint size; 19 | GumReturnAddressArray return_addresses; 20 | }; 21 | 22 | #define GUM_ALLOCATION_BLOCK(b) ((GumAllocationBlock *) (b)) 23 | 24 | G_BEGIN_DECLS 25 | 26 | GUM_API GumAllocationBlock * gum_allocation_block_new (gpointer address, 27 | guint size); 28 | GUM_API GumAllocationBlock * gum_allocation_block_copy ( 29 | const GumAllocationBlock * block); 30 | GUM_API void gum_allocation_block_free (GumAllocationBlock * block); 31 | 32 | GUM_API void gum_allocation_block_list_free (GList * block_list); 33 | 34 | G_END_DECLS 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /bindings/gumjs/gumv8codewriter.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017-2020 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #include "gumv8codewriter.h" 8 | 9 | #include "gumv8macros.h" 10 | 11 | #define GUMJS_MODULE_NAME CodeWriter 12 | 13 | using namespace v8; 14 | 15 | #include "gumv8codewriter.inc" 16 | 17 | void 18 | _gum_v8_code_writer_init (GumV8CodeWriter * self, 19 | GumV8Core * core, 20 | Local scope) 21 | { 22 | auto isolate = core->isolate; 23 | 24 | self->core = core; 25 | 26 | auto module = External::New (isolate, self); 27 | 28 | #include "gumv8codewriter-init.inc" 29 | } 30 | 31 | void 32 | _gum_v8_code_writer_realize (GumV8CodeWriter * self) 33 | { 34 | } 35 | 36 | void 37 | _gum_v8_code_writer_dispose (GumV8CodeWriter * self) 38 | { 39 | #include "gumv8codewriter-dispose.inc" 40 | } 41 | 42 | void 43 | _gum_v8_code_writer_finalize (GumV8CodeWriter * self) 44 | { 45 | } 46 | -------------------------------------------------------------------------------- /gum/gummodulemap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015-2024 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_MODULE_MAP_H__ 8 | #define __GUM_MODULE_MAP_H__ 9 | 10 | #include 11 | 12 | G_BEGIN_DECLS 13 | 14 | #define GUM_TYPE_MODULE_MAP (gum_module_map_get_type ()) 15 | G_DECLARE_FINAL_TYPE (GumModuleMap, gum_module_map, GUM, MODULE_MAP, GObject) 16 | 17 | typedef gboolean (* GumModuleMapFilterFunc) (GumModule * module, 18 | gpointer user_data); 19 | 20 | GUM_API GumModuleMap * gum_module_map_new (void); 21 | GUM_API GumModuleMap * gum_module_map_new_filtered (GumModuleMapFilterFunc func, 22 | gpointer data, GDestroyNotify data_destroy); 23 | 24 | GUM_API GumModule * gum_module_map_find (GumModuleMap * self, 25 | GumAddress address); 26 | 27 | GUM_API void gum_module_map_update (GumModuleMap * self); 28 | 29 | GUM_API GPtrArray * gum_module_map_get_values (GumModuleMap * self); 30 | 31 | G_END_DECLS 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /bindings/gumjs/gumv8profiler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_V8_PROFILER_H__ 8 | #define __GUM_V8_PROFILER_H__ 9 | 10 | #include "gumv8interceptor.h" 11 | #include "gumv8object.h" 12 | #include "gumv8sampler.h" 13 | 14 | struct GumV8Profiler 15 | { 16 | GumV8Sampler * sampler; 17 | GumV8Interceptor * interceptor; 18 | GumV8Core * core; 19 | 20 | GumV8ObjectManager objects; 21 | }; 22 | 23 | G_GNUC_INTERNAL void _gum_v8_profiler_init (GumV8Profiler * self, 24 | GumV8Sampler * sampler, GumV8Interceptor * interceptor, GumV8Core * core, 25 | v8::Local scope); 26 | G_GNUC_INTERNAL void _gum_v8_profiler_realize (GumV8Profiler * self); 27 | G_GNUC_INTERNAL void _gum_v8_profiler_flush (GumV8Profiler * self); 28 | G_GNUC_INTERNAL void _gum_v8_profiler_dispose (GumV8Profiler * self); 29 | G_GNUC_INTERNAL void _gum_v8_profiler_finalize (GumV8Profiler * self); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /gum/backend-qnx/gummodule-qnx.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015-2025 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #include "gummodule-elf.h" 8 | 9 | #include 10 | 11 | GumModule * 12 | gum_module_load (const gchar * module_name, 13 | GError ** error) 14 | { 15 | GumModule * module; 16 | gpointer handle; 17 | 18 | handle = dlopen (module_name, RTLD_LAZY); 19 | if (handle == NULL) 20 | goto not_found; 21 | 22 | module = gum_process_find_module_by_name (module_name); 23 | g_assert (module != NULL); 24 | 25 | return module; 26 | 27 | not_found: 28 | { 29 | g_set_error (error, GUM_ERROR, GUM_ERROR_NOT_FOUND, "%s", dlerror ()); 30 | return NULL; 31 | } 32 | } 33 | 34 | gchar * 35 | _gum_native_module_find_path_by_address (GumAddress address) 36 | { 37 | Dl_info info; 38 | 39 | if (dladdr (GSIZE_TO_POINTER (address), &info) == 0) 40 | return NULL; 41 | 42 | return g_strdup (info.dli_fname); 43 | } 44 | -------------------------------------------------------------------------------- /gum/backend-freebsd/gummodule-freebsd.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022-2025 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #include "gummodule-elf.h" 8 | 9 | #include 10 | 11 | GumModule * 12 | gum_module_load (const gchar * module_name, 13 | GError ** error) 14 | { 15 | GumModule * module; 16 | gpointer handle; 17 | 18 | handle = dlopen (module_name, RTLD_LAZY); 19 | if (handle == NULL) 20 | goto not_found; 21 | 22 | module = gum_process_find_module_by_name (module_name); 23 | g_assert (module != NULL); 24 | 25 | return module; 26 | 27 | not_found: 28 | { 29 | g_set_error (error, GUM_ERROR, GUM_ERROR_NOT_FOUND, "%s", dlerror ()); 30 | return NULL; 31 | } 32 | } 33 | 34 | gchar * 35 | _gum_native_module_find_path_by_address (GumAddress address) 36 | { 37 | Dl_info info; 38 | 39 | if (dladdr (GSIZE_TO_POINTER (address), &info) == 0) 40 | return NULL; 41 | 42 | return g_strdup (info.dli_fname); 43 | } 44 | -------------------------------------------------------------------------------- /bindings/gumjs/gumv8sampler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_V8_SAMPLER_H__ 8 | #define __GUM_V8_SAMPLER_H__ 9 | 10 | #include "gumv8object.h" 11 | 12 | #include 13 | 14 | struct GumV8Sampler 15 | { 16 | GumV8Core * core; 17 | 18 | v8::Global * klass; 19 | 20 | GumV8ObjectManager objects; 21 | }; 22 | 23 | G_GNUC_INTERNAL void _gum_v8_sampler_init (GumV8Sampler * self, 24 | GumV8Core * core, v8::Local scope); 25 | G_GNUC_INTERNAL void _gum_v8_sampler_realize (GumV8Sampler * self); 26 | G_GNUC_INTERNAL void _gum_v8_sampler_flush (GumV8Sampler * self); 27 | G_GNUC_INTERNAL void _gum_v8_sampler_dispose (GumV8Sampler * self); 28 | G_GNUC_INTERNAL void _gum_v8_sampler_finalize (GumV8Sampler * self); 29 | 30 | G_GNUC_INTERNAL gboolean _gum_v8_sampler_get (v8::Local value, 31 | GumSampler ** sampler, GumV8Sampler * module); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /gum/backend-darwin/gummodule-darwin.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_MODULE_DARWIN_H__ 8 | #define __GUM_MODULE_DARWIN_H__ 9 | 10 | #include "gummodule.h" 11 | #include "gum/gumdarwinmoduleresolver.h" 12 | 13 | G_BEGIN_DECLS 14 | 15 | #define GUM_TYPE_NATIVE_MODULE (gum_native_module_get_type ()) 16 | G_DECLARE_FINAL_TYPE (GumNativeModule, gum_native_module, GUM, NATIVE_MODULE, 17 | GObject) 18 | 19 | G_GNUC_INTERNAL GumNativeModule * _gum_native_module_make (const gchar * path, 20 | const GumMemoryRange * range, GumDarwinModuleResolver * resolver); 21 | 22 | G_GNUC_INTERNAL void _gum_native_module_detach_resolver ( 23 | GumNativeModule * self); 24 | 25 | G_GNUC_INTERNAL gpointer _gum_native_module_get_handle (GumNativeModule * self); 26 | G_GNUC_INTERNAL GumDarwinModule * _gum_native_module_get_darwin_module ( 27 | GumNativeModule * self); 28 | 29 | G_END_DECLS 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /bindings/gumjs/gumv8coderelocator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017-2020 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_V8_CODE_RELOCATOR_H__ 8 | #define __GUM_V8_CODE_RELOCATOR_H__ 9 | 10 | #include "gumv8codewriter.h" 11 | #include "gumv8instruction.h" 12 | 13 | struct GumV8CodeRelocator 14 | { 15 | GumV8CodeWriter * writer; 16 | GumV8Instruction * instruction; 17 | GumV8Core * core; 18 | 19 | #include "gumv8coderelocator-fields.inc" 20 | }; 21 | 22 | G_GNUC_INTERNAL void _gum_v8_code_relocator_init (GumV8CodeRelocator * self, 23 | GumV8CodeWriter * writer, GumV8Instruction * instruction, GumV8Core * core, 24 | v8::Local scope); 25 | G_GNUC_INTERNAL void _gum_v8_code_relocator_realize (GumV8CodeRelocator * self); 26 | G_GNUC_INTERNAL void _gum_v8_code_relocator_dispose (GumV8CodeRelocator * self); 27 | G_GNUC_INTERNAL void _gum_v8_code_relocator_finalize ( 28 | GumV8CodeRelocator * self); 29 | 30 | #include "gumv8coderelocator-methods.inc" 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /bindings/gumjs/gumquickmodule.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020-2024 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_QUICK_MODULE_H__ 8 | #define __GUM_QUICK_MODULE_H__ 9 | 10 | #include "gumquickcore.h" 11 | 12 | G_BEGIN_DECLS 13 | 14 | typedef struct _GumQuickModule GumQuickModule; 15 | 16 | struct _GumQuickModule 17 | { 18 | GumQuickCore * core; 19 | 20 | JSClassID module_class; 21 | JSClassID module_map_class; 22 | }; 23 | 24 | G_GNUC_INTERNAL void _gum_quick_module_init (GumQuickModule * self, 25 | JSValue ns, GumQuickCore * core); 26 | G_GNUC_INTERNAL void _gum_quick_module_dispose (GumQuickModule * self); 27 | G_GNUC_INTERNAL void _gum_quick_module_finalize (GumQuickModule * self); 28 | 29 | G_GNUC_INTERNAL JSValue _gum_quick_module_new_from_handle (JSContext * ctx, 30 | GumModule * handle, GumQuickModule * parent); 31 | G_GNUC_INTERNAL JSValue _gum_quick_module_new_take_handle (JSContext * ctx, 32 | GumModule * handle, GumQuickModule * parent); 33 | 34 | G_END_DECLS 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /bindings/gumjs/gumquickstream.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_QUICK_STREAM_H__ 8 | #define __GUM_QUICK_STREAM_H__ 9 | 10 | #include "gumquickobject.h" 11 | 12 | G_BEGIN_DECLS 13 | 14 | typedef struct _GumQuickStream GumQuickStream; 15 | 16 | struct _GumQuickStream 17 | { 18 | GumQuickCore * core; 19 | 20 | GumQuickObjectManager objects; 21 | 22 | JSClassID io_stream_class; 23 | JSValue io_stream_proto; 24 | JSClassID input_stream_class; 25 | JSClassID output_stream_class; 26 | JSClassID native_input_stream_class; 27 | JSClassID native_output_stream_class; 28 | }; 29 | 30 | G_GNUC_INTERNAL void _gum_quick_stream_init (GumQuickStream * self, 31 | JSValue ns, GumQuickCore * core); 32 | G_GNUC_INTERNAL void _gum_quick_stream_flush (GumQuickStream * self); 33 | G_GNUC_INTERNAL void _gum_quick_stream_dispose (GumQuickStream * self); 34 | G_GNUC_INTERNAL void _gum_quick_stream_finalize (GumQuickStream * self); 35 | 36 | G_END_DECLS 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /tests/core/targetfunctions/targetfunctions.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifdef _MSC_VER 4 | # define GUM_NOINLINE __declspec (noinline) 5 | #else 6 | # define GUM_NOINLINE __attribute__ ((noinline)) 7 | #endif 8 | 9 | gpointer GUM_NOINLINE 10 | gum_test_target_function (GString * str) 11 | { 12 | if (str != NULL) 13 | g_string_append_c (str, '|'); 14 | else 15 | g_usleep (G_USEC_PER_SEC / 100); 16 | 17 | return NULL; 18 | } 19 | 20 | static guint gum_test_target_functions_counter = 0; 21 | 22 | gpointer GUM_NOINLINE 23 | gum_test_target_nop_function_a (gpointer data) 24 | { 25 | gum_test_target_functions_counter++; 26 | 27 | return GSIZE_TO_POINTER (0x1337); 28 | } 29 | 30 | gpointer GUM_NOINLINE 31 | gum_test_target_nop_function_b (gpointer data) 32 | { 33 | gum_test_target_functions_counter += 2; 34 | 35 | return GSIZE_TO_POINTER (2); 36 | } 37 | 38 | gpointer GUM_NOINLINE 39 | gum_test_target_nop_function_c (gpointer data) 40 | { 41 | gum_test_target_functions_counter += 3; 42 | 43 | gum_test_target_nop_function_a (data); 44 | 45 | return GSIZE_TO_POINTER (3); 46 | } 47 | -------------------------------------------------------------------------------- /libs/gum/heap/gumallocatorprobe.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2019 Ole André Vadla Ravnås 3 | * Copyright (C) 2008 Christian Berentsen 4 | * 5 | * Licence: wxWindows Library Licence, Version 3.1 6 | */ 7 | 8 | #ifndef __GUM_ALLOCATOR_PROBE_H__ 9 | #define __GUM_ALLOCATOR_PROBE_H__ 10 | 11 | #include "gumallocationtracker.h" 12 | 13 | #include 14 | 15 | G_BEGIN_DECLS 16 | 17 | #define GUM_TYPE_ALLOCATOR_PROBE (gum_allocator_probe_get_type ()) 18 | G_DECLARE_FINAL_TYPE (GumAllocatorProbe, gum_allocator_probe, GUM, 19 | ALLOCATOR_PROBE, GObject) 20 | 21 | GUM_API GumAllocatorProbe * gum_allocator_probe_new (void); 22 | 23 | GUM_API void gum_allocator_probe_attach (GumAllocatorProbe * self); 24 | GUM_API void gum_allocator_probe_attach_to_apis (GumAllocatorProbe * self, 25 | const GumHeapApiList * apis); 26 | GUM_API void gum_allocator_probe_detach (GumAllocatorProbe * self); 27 | 28 | GUM_API void gum_allocator_probe_suppress (GumAllocatorProbe * self, 29 | gpointer function_address); 30 | 31 | G_END_DECLS 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /bindings/gumjs/gumv8scriptbackend.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015-2022 Ole André Vadla Ravnås 3 | * Copyright (C) 2020 Francesco Tamagni 4 | * 5 | * Licence: wxWindows Library Licence, Version 3.1 6 | */ 7 | 8 | #ifndef __GUM_V8_SCRIPT_BACKEND_H__ 9 | #define __GUM_V8_SCRIPT_BACKEND_H__ 10 | 11 | #include "gumscriptbackend.h" 12 | #include "gumscriptscheduler.h" 13 | 14 | G_BEGIN_DECLS 15 | 16 | #define GUM_V8_TYPE_SCRIPT_BACKEND (gum_v8_script_backend_get_type ()) 17 | G_DECLARE_FINAL_TYPE (GumV8ScriptBackend, gum_v8_script_backend, GUM_V8, 18 | SCRIPT_BACKEND, GObject) 19 | 20 | G_GNUC_INTERNAL gpointer gum_v8_script_backend_get_platform ( 21 | GumV8ScriptBackend * self); 22 | G_GNUC_INTERNAL GumScriptScheduler * gum_v8_script_backend_get_scheduler ( 23 | GumV8ScriptBackend * self); 24 | G_GNUC_INTERNAL gboolean gum_v8_script_backend_is_scope_mutex_trapped ( 25 | GumV8ScriptBackend * self); 26 | G_GNUC_INTERNAL void gum_v8_script_backend_mark_scope_mutex_trapped ( 27 | GumV8ScriptBackend * self); 28 | 29 | G_END_DECLS 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /bindings/gumjs/gumv8enumeratecontext.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_V8_ENUMERATE_CONTEXT_H__ 8 | #define __GUM_V8_ENUMERATE_CONTEXT_H__ 9 | 10 | #include "gumv8script.h" 11 | 12 | #include 13 | 14 | template 15 | class GumV8EnumerateContext 16 | { 17 | public: 18 | GumV8EnumerateContext (v8::Isolate * isolate, T * parent) 19 | : isolate (isolate), 20 | context (isolate->GetCurrentContext ()), 21 | parent (parent), 22 | elements (v8::Array::New (isolate)), 23 | n (0) 24 | { 25 | } 26 | 27 | v8::Local 28 | End () 29 | { 30 | return elements; 31 | } 32 | 33 | gboolean 34 | Collect (v8::Local element) 35 | { 36 | elements->Set (context, n++, element).ToChecked (); 37 | return TRUE; 38 | } 39 | 40 | v8::Isolate * isolate; 41 | v8::Local context; 42 | T * parent; 43 | 44 | private: 45 | v8::Local elements; 46 | guint n; 47 | }; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /gum/gumenumtypes.c.template: -------------------------------------------------------------------------------- 1 | /*** BEGIN file-header ***/ 2 | #include "gumenumtypes.h" 3 | 4 | #include "gum.h" 5 | 6 | /*** END file-header ***/ 7 | 8 | /*** BEGIN file-tail ***/ 9 | /*** END file-tail ***/ 10 | 11 | /*** BEGIN file-production ***/ 12 | 13 | /* Enumerations from "@basename@" */ 14 | /*** END file-production ***/ 15 | 16 | /*** BEGIN value-header ***/ 17 | GType 18 | @enum_name@_get_type (void) 19 | { 20 | static gsize static_g_define_type_id = 0; 21 | 22 | if (g_once_init_enter (&static_g_define_type_id)) 23 | { 24 | static const G@Type@Value values[] = { 25 | /*** END value-header ***/ 26 | 27 | /*** BEGIN value-production ***/ 28 | { @VALUENAME@, "@VALUENAME@", "@valuenick@" }, 29 | /*** END value-production ***/ 30 | 31 | /*** BEGIN value-tail ***/ 32 | { 0, NULL, NULL } 33 | }; 34 | GType g_define_type_id = g_@type@_register_static ( 35 | g_intern_static_string ("@EnumName@"), values); 36 | g_once_init_leave (&static_g_define_type_id, g_define_type_id); 37 | } 38 | 39 | return static_g_define_type_id; 40 | } 41 | 42 | /*** END value-tail ***/ 43 | -------------------------------------------------------------------------------- /bindings/gumjs/gumquickthread.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020-2024 Ole André Vadla Ravnås 3 | * Copyright (C) 2024 Håvard Sørbø 4 | * 5 | * Licence: wxWindows Library Licence, Version 3.1 6 | */ 7 | 8 | #ifndef __GUM_QUICK_THREAD_H__ 9 | #define __GUM_QUICK_THREAD_H__ 10 | 11 | #include "gumquickcore.h" 12 | 13 | #include 14 | 15 | G_BEGIN_DECLS 16 | 17 | typedef struct _GumQuickThread GumQuickThread; 18 | 19 | struct _GumQuickThread 20 | { 21 | GumQuickCore * core; 22 | 23 | JSClassID thread_class; 24 | 25 | GumBacktracer * accurate_backtracer; 26 | GumBacktracer * fuzzy_backtracer; 27 | }; 28 | 29 | G_GNUC_INTERNAL void _gum_quick_thread_init (GumQuickThread * self, 30 | JSValue ns, GumQuickCore * core); 31 | G_GNUC_INTERNAL void _gum_quick_thread_dispose (GumQuickThread * self); 32 | G_GNUC_INTERNAL void _gum_quick_thread_finalize (GumQuickThread * self); 33 | 34 | G_GNUC_INTERNAL JSValue _gum_quick_thread_new (JSContext * ctx, 35 | const GumThreadDetails * details, GumQuickThread * parent); 36 | 37 | G_END_DECLS 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /bindings/gumpp/symbolutil.cpp: -------------------------------------------------------------------------------- 1 | #include "gumpp.hpp" 2 | 3 | #include "podwrapper.hpp" 4 | #include "runtime.hpp" 5 | 6 | #include 7 | 8 | namespace Gum 9 | { 10 | class SymbolPtrArray : public PodWrapper 11 | { 12 | public: 13 | SymbolPtrArray (GArray * arr) 14 | { 15 | assign_handle (arr); 16 | } 17 | 18 | virtual ~SymbolPtrArray () 19 | { 20 | g_array_free (handle, TRUE); 21 | 22 | Runtime::unref (); 23 | } 24 | 25 | virtual int length () 26 | { 27 | return handle->len; 28 | } 29 | 30 | virtual void * nth (int n) 31 | { 32 | return g_array_index (handle, gpointer, n); 33 | } 34 | }; 35 | 36 | extern "C" void * find_function_ptr (const char * name) 37 | { 38 | Runtime::ref (); 39 | void * result = gum_find_function (name); 40 | Runtime::unref (); 41 | return result; 42 | } 43 | 44 | extern "C" PtrArray * find_matching_functions_array (const char * str) 45 | { 46 | Runtime::ref (); 47 | return new SymbolPtrArray (gum_find_functions_matching (str)); 48 | } 49 | } -------------------------------------------------------------------------------- /gum/backend-freebsd/include/gum/gumfreebsd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_FREEBSD_H__ 8 | #define __GUM_FREEBSD_H__ 9 | 10 | #include "gumprocess.h" 11 | 12 | #include 13 | #include 14 | 15 | G_BEGIN_DECLS 16 | 17 | GUM_API gchar * gum_freebsd_query_program_path_for_self (GError ** error); 18 | GUM_API gchar * gum_freebsd_query_program_path_for_pid (pid_t pid, 19 | GError ** error); 20 | GUM_API void gum_freebsd_enumerate_ranges (pid_t pid, GumPageProtection prot, 21 | GumFoundRangeFunc func, gpointer user_data); 22 | 23 | GUM_API void gum_freebsd_parse_ucontext (const ucontext_t * uc, 24 | GumCpuContext * ctx); 25 | GUM_API void gum_freebsd_unparse_ucontext (const GumCpuContext * ctx, 26 | ucontext_t * uc); 27 | GUM_API void gum_freebsd_parse_regs (const struct reg * regs, 28 | GumCpuContext * ctx); 29 | GUM_API void gum_freebsd_unparse_regs (const GumCpuContext * ctx, 30 | struct reg * regs); 31 | 32 | G_END_DECLS 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /tests/prof/sampler-fixture.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2025 Ole André Vadla Ravnås 3 | * Copyright (C) 2008 Christian Berentsen 4 | * 5 | * Licence: wxWindows Library Licence, Version 3.1 6 | */ 7 | 8 | #include "gumsampler.h" 9 | 10 | #include "gumusertimesampler.h" 11 | #include "testutil.h" 12 | #include "valgrind.h" 13 | 14 | #include 15 | 16 | #define TESTCASE(NAME) \ 17 | void test_sampler_ ## NAME ( \ 18 | TestSamplerFixture * fixture, gconstpointer data) 19 | #define TESTENTRY(NAME) \ 20 | TESTENTRY_WITH_FIXTURE ("Prof/Sampler", test_sampler, NAME, \ 21 | TestSamplerFixture) 22 | 23 | typedef struct _TestSamplerFixture 24 | { 25 | GumSampler * sampler; 26 | } TestSamplerFixture; 27 | 28 | static void 29 | test_sampler_fixture_setup (TestSamplerFixture * fixture, 30 | gconstpointer data) 31 | { 32 | } 33 | 34 | static void 35 | test_sampler_fixture_teardown (TestSamplerFixture * fixture, 36 | gconstpointer data) 37 | { 38 | g_clear_object (&fixture->sampler); 39 | } 40 | -------------------------------------------------------------------------------- /bindings/gumjs/gumquickcoderelocator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_QUICK_CODE_RELOCATOR_H__ 8 | #define __GUM_QUICK_CODE_RELOCATOR_H__ 9 | 10 | #include "gumquickcodewriter.h" 11 | #include "gumquickinstruction.h" 12 | 13 | G_BEGIN_DECLS 14 | 15 | typedef struct _GumQuickCodeRelocator GumQuickCodeRelocator; 16 | 17 | struct _GumQuickCodeRelocator 18 | { 19 | GumQuickCodeWriter * writer; 20 | GumQuickInstruction * instruction; 21 | GumQuickCore * core; 22 | 23 | #include "gumquickcoderelocator-fields.inc" 24 | }; 25 | 26 | G_GNUC_INTERNAL void _gum_quick_code_relocator_init ( 27 | GumQuickCodeRelocator * self, JSValue ns, GumQuickCodeWriter * writer, 28 | GumQuickInstruction * instruction, GumQuickCore * core); 29 | G_GNUC_INTERNAL void _gum_quick_code_relocator_dispose ( 30 | GumQuickCodeRelocator * self); 31 | G_GNUC_INTERNAL void _gum_quick_code_relocator_finalize ( 32 | GumQuickCodeRelocator * self); 33 | 34 | #include "gumquickcoderelocator-methods.inc" 35 | 36 | G_END_DECLS 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /gum/gumcodesegment.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016-2019 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_CODE_SEGMENT_H__ 8 | #define __GUM_CODE_SEGMENT_H__ 9 | 10 | #include 11 | 12 | G_BEGIN_DECLS 13 | 14 | typedef struct _GumCodeSegment GumCodeSegment; 15 | 16 | GUM_API gboolean gum_code_segment_is_supported (void); 17 | 18 | GUM_API GumCodeSegment * gum_code_segment_new (gsize size, 19 | const GumAddressSpec * spec); 20 | GUM_API void gum_code_segment_free (GumCodeSegment * segment); 21 | 22 | GUM_API gpointer gum_code_segment_get_address (GumCodeSegment * self); 23 | GUM_API gsize gum_code_segment_get_size (GumCodeSegment * self); 24 | GUM_API gsize gum_code_segment_get_virtual_size (GumCodeSegment * self); 25 | 26 | GUM_API void gum_code_segment_realize (GumCodeSegment * self); 27 | GUM_API void gum_code_segment_map (GumCodeSegment * self, gsize source_offset, 28 | gsize source_size, gpointer target_address); 29 | 30 | GUM_API gboolean gum_code_segment_mark (gpointer code, gsize size, 31 | GError ** error); 32 | 33 | G_END_DECLS 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /bindings/gumpp/objectwrapper.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __GUMPP_OBJECT_WRAPPER_HPP__ 2 | #define __GUMPP_OBJECT_WRAPPER_HPP__ 3 | 4 | #include 5 | 6 | namespace Gum 7 | { 8 | template 9 | class ObjectWrapper : public B 10 | { 11 | public: 12 | ObjectWrapper () 13 | : handle (NULL) 14 | { 15 | } 16 | 17 | virtual ~ObjectWrapper () 18 | { 19 | } 20 | 21 | virtual void ref () 22 | { 23 | g_object_ref (handle); 24 | } 25 | 26 | virtual void unref () 27 | { 28 | g_object_unref (handle); 29 | } 30 | 31 | virtual void * get_handle () const 32 | { 33 | return handle; 34 | } 35 | 36 | protected: 37 | void assign_handle (T * h) 38 | { 39 | handle = h; 40 | g_object_weak_ref (G_OBJECT (handle), delete_wrapper, this); 41 | } 42 | 43 | static void delete_wrapper (gpointer data, GObject * where_the_object_was) 44 | { 45 | D * impl = static_cast (data); 46 | g_assert (impl->handle == (gpointer) where_the_object_was); 47 | delete impl; 48 | } 49 | 50 | T * handle; 51 | }; 52 | } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /gum/backend-elf/gummoduleregistry-elf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_MODULE_REGISTRY_ELF_H__ 8 | #define __GUM_MODULE_REGISTRY_ELF_H__ 9 | 10 | #include "guminvocationcontext.h" 11 | #include "gummoduleregistry-priv.h" 12 | 13 | G_BEGIN_DECLS 14 | 15 | typedef struct _GumRtldNotifierDetails GumRtldNotifierDetails; 16 | 17 | typedef void (* GumFoundRtldNotifierFunc) ( 18 | const GumRtldNotifierDetails * details, gpointer user_data); 19 | typedef void (* GumSynchronizeModulesFunc) (void); 20 | 21 | struct _GumRtldNotifierDetails 22 | { 23 | gpointer location; 24 | GumPointCut point_cut; 25 | }; 26 | 27 | G_GNUC_INTERNAL void _gum_module_registry_enumerate_loaded_modules ( 28 | GumFoundModuleFunc func, gpointer user_data); 29 | G_GNUC_INTERNAL void _gum_module_registry_enumerate_rtld_notifiers ( 30 | GumFoundRtldNotifierFunc func, gpointer user_data); 31 | G_GNUC_INTERNAL void _gum_module_registry_handle_rtld_notification ( 32 | GumSynchronizeModulesFunc sync, GumInvocationContext * ic); 33 | 34 | G_END_DECLS 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /gum/gumdarwingrafter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021-2022 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_DARWIN_GRAFTER_H__ 8 | #define __GUM_DARWIN_GRAFTER_H__ 9 | 10 | #include 11 | 12 | G_BEGIN_DECLS 13 | 14 | typedef enum { 15 | GUM_DARWIN_GRAFTER_FLAGS_NONE = 0, 16 | GUM_DARWIN_GRAFTER_FLAGS_INGEST_FUNCTION_STARTS = (1 << 0), 17 | GUM_DARWIN_GRAFTER_FLAGS_INGEST_IMPORTS = (1 << 1), 18 | GUM_DARWIN_GRAFTER_FLAGS_TRANSFORM_LAZY_BINDS = (1 << 2), 19 | } GumDarwinGrafterFlags; 20 | 21 | #define GUM_TYPE_DARWIN_GRAFTER (gum_darwin_grafter_get_type ()) 22 | G_DECLARE_FINAL_TYPE (GumDarwinGrafter, gum_darwin_grafter, GUM, DARWIN_GRAFTER, 23 | GObject) 24 | 25 | GUM_API GumDarwinGrafter * gum_darwin_grafter_new_from_file ( 26 | const gchar * path, GumDarwinGrafterFlags flags); 27 | 28 | GUM_API void gum_darwin_grafter_add (GumDarwinGrafter * self, 29 | guint32 code_offset); 30 | 31 | GUM_API gboolean gum_darwin_grafter_graft (GumDarwinGrafter * self, 32 | GError ** error); 33 | 34 | G_END_DECLS 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /bindings/gumjs/gumv8thread.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010-2024 Ole André Vadla Ravnås 3 | * Copyright (C) 2024 Håvard Sørbø 4 | * 5 | * Licence: wxWindows Library Licence, Version 3.1 6 | */ 7 | 8 | #ifndef __GUM_V8_THREAD_H__ 9 | #define __GUM_V8_THREAD_H__ 10 | 11 | #include "gumv8core.h" 12 | 13 | #include 14 | 15 | struct GumV8Thread 16 | { 17 | GumV8Core * core; 18 | 19 | v8::Global * klass; 20 | 21 | GumBacktracer * accurate_backtracer; 22 | GumBacktracer * fuzzy_backtracer; 23 | 24 | v8::Global * accurate_enum_value; 25 | v8::Global * fuzzy_enum_value; 26 | }; 27 | 28 | G_GNUC_INTERNAL void _gum_v8_thread_init (GumV8Thread * self, 29 | GumV8Core * core, v8::Local scope); 30 | G_GNUC_INTERNAL void _gum_v8_thread_realize (GumV8Thread * self); 31 | G_GNUC_INTERNAL void _gum_v8_thread_dispose (GumV8Thread * self); 32 | G_GNUC_INTERNAL void _gum_v8_thread_finalize (GumV8Thread * self); 33 | 34 | G_GNUC_INTERNAL v8::Local _gum_v8_thread_new ( 35 | const GumThreadDetails * details, GumV8Thread * module); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /tests/heap/pagepool-fixture.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2010 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #include "gumpagepool.h" 8 | 9 | #include "gummemory.h" 10 | #include "testutil.h" 11 | 12 | #include 13 | 14 | #define TESTCASE(NAME) \ 15 | void test_page_pool_ ## NAME ( \ 16 | TestPagePoolFixture * fixture, gconstpointer data) 17 | #define TESTENTRY(NAME) \ 18 | TESTENTRY_WITH_FIXTURE ("Heap/PagePool", test_page_pool, NAME, \ 19 | TestPagePoolFixture) 20 | 21 | typedef struct _TestPagePoolFixture 22 | { 23 | GumPagePool * pool; 24 | } TestPagePoolFixture; 25 | 26 | static void 27 | test_page_pool_fixture_setup (TestPagePoolFixture * fixture, 28 | gconstpointer data) 29 | { 30 | } 31 | 32 | static void 33 | test_page_pool_fixture_teardown (TestPagePoolFixture * fixture, 34 | gconstpointer data) 35 | { 36 | g_object_unref (fixture->pool); 37 | } 38 | 39 | #define SETUP_POOL(ptr, protect_mode, n_pages) \ 40 | fixture->pool = gum_page_pool_new (protect_mode, n_pages); \ 41 | *ptr = fixture->pool 42 | -------------------------------------------------------------------------------- /bindings/gumjs/gumv8stream.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016-2022 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_V8_STREAM_H__ 8 | #define __GUM_V8_STREAM_H__ 9 | 10 | #include "gumv8object.h" 11 | 12 | struct GumV8Stream 13 | { 14 | GumV8Core * core; 15 | 16 | GumV8ObjectManager objects; 17 | 18 | v8::Global * io_stream; 19 | v8::Global * input_stream; 20 | v8::Global * output_stream; 21 | }; 22 | 23 | typedef GumV8Object GumV8IOStream; 24 | typedef GumV8Object GumV8InputStream; 25 | typedef GumV8Object GumV8OutputStream; 26 | 27 | G_GNUC_INTERNAL void _gum_v8_stream_init (GumV8Stream * self, GumV8Core * core, 28 | v8::Local scope); 29 | G_GNUC_INTERNAL void _gum_v8_stream_realize (GumV8Stream * self); 30 | G_GNUC_INTERNAL void _gum_v8_stream_flush (GumV8Stream * self); 31 | G_GNUC_INTERNAL void _gum_v8_stream_dispose (GumV8Stream * self); 32 | G_GNUC_INTERNAL void _gum_v8_stream_finalize (GumV8Stream * self); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /tests/stubs/fakeeventsink.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2018 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __FAKE_EVENT_SINK_H__ 8 | #define __FAKE_EVENT_SINK_H__ 9 | 10 | #include 11 | #include 12 | 13 | G_BEGIN_DECLS 14 | 15 | #define GUM_TYPE_FAKE_EVENT_SINK (gum_fake_event_sink_get_type ()) 16 | G_DECLARE_FINAL_TYPE (GumFakeEventSink, gum_fake_event_sink, GUM, 17 | FAKE_EVENT_SINK, GObject) 18 | 19 | struct _GumFakeEventSink 20 | { 21 | GObject parent; 22 | 23 | GumEventType mask; 24 | GArray * events; 25 | }; 26 | 27 | GumEventSink * gum_fake_event_sink_new (void); 28 | 29 | void gum_fake_event_sink_reset (GumFakeEventSink * self); 30 | 31 | const GumCallEvent * gum_fake_event_sink_get_nth_event_as_call ( 32 | GumFakeEventSink * self, guint n); 33 | const GumRetEvent * gum_fake_event_sink_get_nth_event_as_ret ( 34 | GumFakeEventSink * self, guint n); 35 | const GumExecEvent * gum_fake_event_sink_get_nth_event_as_exec ( 36 | GumFakeEventSink * self, guint n); 37 | 38 | void gum_fake_event_sink_dump (GumFakeEventSink * self); 39 | 40 | G_END_DECLS 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /bindings/gumjs/gumquickscript-priv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020-2023 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_QUICK_SCRIPT_PRIV_H__ 8 | #define __GUM_QUICK_SCRIPT_PRIV_H__ 9 | 10 | #include "gumquickscript.h" 11 | 12 | #include 13 | 14 | G_BEGIN_DECLS 15 | 16 | typedef struct _GumQuickWorker GumQuickWorker; 17 | 18 | G_GNUC_INTERNAL GumQuickWorker * _gum_quick_script_make_worker ( 19 | GumQuickScript * self, const gchar * url, JSValue on_message); 20 | G_GNUC_INTERNAL GumQuickWorker * _gum_quick_worker_ref ( 21 | GumQuickWorker * worker); 22 | G_GNUC_INTERNAL void _gum_quick_worker_unref (GumQuickWorker * worker); 23 | G_GNUC_INTERNAL void _gum_quick_worker_terminate (GumQuickWorker * self); 24 | G_GNUC_INTERNAL void _gum_quick_worker_post (GumQuickWorker * self, 25 | const gchar * message, GBytes * data); 26 | 27 | G_GNUC_INTERNAL JSValue _gum_quick_script_rethrow_parse_error_with_decorations ( 28 | GumQuickScript * self, JSContext * ctx, const gchar * name); 29 | 30 | G_GNUC_INTERNAL void _gum_quick_panic (JSContext * ctx, const gchar * prefix); 31 | 32 | G_END_DECLS 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /gum/gumreturnaddress.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2010 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_RETURN_ADDRESS_H__ 8 | #define __GUM_RETURN_ADDRESS_H__ 9 | 10 | #include 11 | 12 | typedef struct _GumReturnAddressDetails GumReturnAddressDetails; 13 | typedef gpointer GumReturnAddress; 14 | typedef struct _GumReturnAddressArray GumReturnAddressArray; 15 | 16 | struct _GumReturnAddressDetails 17 | { 18 | GumReturnAddress address; 19 | gchar module_name[GUM_MAX_PATH + 1]; 20 | gchar function_name[GUM_MAX_SYMBOL_NAME + 1]; 21 | gchar file_name[GUM_MAX_PATH + 1]; 22 | guint line_number; 23 | guint column; 24 | }; 25 | 26 | struct _GumReturnAddressArray 27 | { 28 | guint len; 29 | GumReturnAddress items[GUM_MAX_BACKTRACE_DEPTH]; 30 | }; 31 | 32 | G_BEGIN_DECLS 33 | 34 | GUM_API gboolean gum_return_address_details_from_address ( 35 | GumReturnAddress address, GumReturnAddressDetails * details); 36 | 37 | GUM_API gboolean gum_return_address_array_is_equal ( 38 | const GumReturnAddressArray * array1, 39 | const GumReturnAddressArray * array2); 40 | 41 | G_END_DECLS 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /gum/backend-barebone/gumsymbolutil-barebone.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #include "gumsymbolutil.h" 8 | 9 | static GArray * gum_pointer_array_new_empty (void); 10 | 11 | G_GNUC_WEAK gboolean 12 | gum_symbol_details_from_address (gpointer address, 13 | GumDebugSymbolDetails * details) 14 | { 15 | return FALSE; 16 | } 17 | 18 | G_GNUC_WEAK gchar * 19 | gum_symbol_name_from_address (gpointer address) 20 | { 21 | return NULL; 22 | } 23 | 24 | G_GNUC_WEAK gpointer 25 | gum_find_function (const gchar * name) 26 | { 27 | return NULL; 28 | } 29 | 30 | G_GNUC_WEAK GArray * 31 | gum_find_functions_named (const gchar * name) 32 | { 33 | return gum_pointer_array_new_empty (); 34 | } 35 | 36 | G_GNUC_WEAK GArray * 37 | gum_find_functions_matching (const gchar * str) 38 | { 39 | return gum_pointer_array_new_empty (); 40 | } 41 | 42 | G_GNUC_WEAK gboolean 43 | gum_load_symbols (const gchar * path) 44 | { 45 | return FALSE; 46 | } 47 | 48 | static GArray * 49 | gum_pointer_array_new_empty (void) 50 | { 51 | return g_array_new (FALSE, FALSE, sizeof (gpointer)); 52 | } 53 | -------------------------------------------------------------------------------- /bindings/gumjs/gumquicksampler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_QUICK_SAMPLER_H__ 8 | #define __GUM_QUICK_SAMPLER_H__ 9 | 10 | #include "gumquickcore.h" 11 | 12 | #include 13 | 14 | G_BEGIN_DECLS 15 | 16 | typedef struct _GumQuickSampler GumQuickSampler; 17 | 18 | struct _GumQuickSampler 19 | { 20 | GumQuickCore * core; 21 | 22 | JSClassID sampler_class; 23 | JSClassID cycle_sampler_class; 24 | JSClassID busy_cycle_sampler_class; 25 | JSClassID wall_clock_sampler_class; 26 | JSClassID user_time_sampler_class; 27 | JSClassID malloc_count_sampler_class; 28 | JSClassID call_count_sampler_class; 29 | }; 30 | 31 | G_GNUC_INTERNAL void _gum_quick_sampler_init (GumQuickSampler * self, 32 | JSValue ns, GumQuickCore * core); 33 | G_GNUC_INTERNAL void _gum_quick_sampler_dispose (GumQuickSampler * self); 34 | G_GNUC_INTERNAL void _gum_quick_sampler_finalize (GumQuickSampler * self); 35 | 36 | G_GNUC_INTERNAL gboolean _gum_quick_sampler_get (JSContext * ctx, JSValue val, 37 | GumQuickSampler * parent, GumSampler ** sampler); 38 | 39 | G_END_DECLS 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /tests/data/meson.build: -------------------------------------------------------------------------------- 1 | if host_os_family != 'windows' 2 | test_function_filenames = [] 3 | 4 | test_function_libraries = [ 5 | 'targetfunctions', 6 | 'specialfunctions', 7 | ] 8 | 9 | if host_os_family == 'darwin' 10 | shlib_extension = 'dylib' 11 | else 12 | shlib_extension = 'so' 13 | endif 14 | 15 | if host_machine.endian() == 'big' 16 | if host_abi == 'arm' or host_abi == 'armhf' 17 | host_abi = 'armbe8' 18 | elif host_abi == 'arm64' 19 | host_abi = 'arm64be' 20 | endif 21 | endif 22 | 23 | foreach l : test_function_libraries 24 | name = '@0@-@1@-@2@.@3@'.format(l, host_os, host_abi, shlib_extension) 25 | test_function_filenames += [name] 26 | endforeach 27 | 28 | test_data = custom_target('gum-tests-data', 29 | input: test_function_filenames, 30 | output: test_function_filenames, 31 | command: ['cp', '@INPUT@', '@OUTDIR@'], 32 | ) 33 | test_data_stamp = custom_target('gum-tests-data-stamp', 34 | input: [test_data], 35 | output: '.stamp', 36 | command: ['touch', '@OUTPUT@'], 37 | ) 38 | 39 | shared_module('prebuiltcmodule', 'prebuiltcmodule.c', 40 | name_prefix: '', 41 | ) 42 | else 43 | test_data_stamp = [] 44 | endif 45 | -------------------------------------------------------------------------------- /bindings/gumjs/gumquickcodewriter.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #include "gumquickcodewriter.h" 8 | 9 | #include "gumquickmacros.h" 10 | 11 | static GumQuickCodeWriter * gumjs_get_parent_module (GumQuickCore * core); 12 | 13 | #include "gumquickcodewriter.inc" 14 | 15 | void 16 | _gum_quick_code_writer_init (GumQuickCodeWriter * self, 17 | JSValue ns, 18 | GumQuickCore * core) 19 | { 20 | JSContext * ctx = core->ctx; 21 | JSValue proto, ctor; 22 | 23 | self->core = core; 24 | 25 | _gum_quick_core_store_module_data (core, "code-writer", self); 26 | 27 | #include "gumquickcodewriter-init.inc" 28 | } 29 | 30 | void 31 | _gum_quick_code_writer_dispose (GumQuickCodeWriter * self) 32 | { 33 | JSContext * ctx = self->core->ctx; 34 | 35 | #include "gumquickcodewriter-dispose.inc" 36 | } 37 | 38 | void 39 | _gum_quick_code_writer_finalize (GumQuickCodeWriter * self) 40 | { 41 | } 42 | 43 | static GumQuickCodeWriter * 44 | gumjs_get_parent_module (GumQuickCore * core) 45 | { 46 | return _gum_quick_core_load_module_data (core, "code-writer"); 47 | } 48 | -------------------------------------------------------------------------------- /gum/backend-windows/include/gum/gumwindows.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010-2025 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_WINDOWS_H__ 8 | #define __GUM_WINDOWS_H__ 9 | 10 | #include 11 | 12 | #include 13 | #ifndef WIN32_LEAN_AND_MEAN 14 | # define WIN32_LEAN_AND_MEAN 15 | #endif 16 | #include 17 | 18 | G_BEGIN_DECLS 19 | 20 | GUM_API GumCpuType gum_windows_query_native_cpu_type (void); 21 | GUM_API GumCpuType gum_windows_cpu_type_from_pid (guint pid, GError ** error); 22 | 23 | GUM_API gchar * gum_windows_query_thread_name (HANDLE thread); 24 | GUM_API GumAddress gum_windows_query_thread_entrypoint_routine (HANDLE thread); 25 | GUM_API void gum_windows_parse_context (const CONTEXT * context, 26 | GumCpuContext * cpu_context); 27 | GUM_API void gum_windows_unparse_context (const GumCpuContext * cpu_context, 28 | CONTEXT * context); 29 | GUM_API CONTEXT * gum_windows_get_active_exceptor_context (void); 30 | 31 | GUM_API GumPageProtection gum_page_protection_from_windows (DWORD native_prot); 32 | GUM_API DWORD gum_page_protection_to_windows (GumPageProtection prot); 33 | 34 | G_END_DECLS 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /libs/gum/heap/gumcobjecttracker.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2018 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_COBJECT_TRACKER_H__ 8 | #define __GUM_COBJECT_TRACKER_H__ 9 | 10 | #include 11 | #include 12 | 13 | G_BEGIN_DECLS 14 | 15 | #define GUM_TYPE_COBJECT_TRACKER (gum_cobject_tracker_get_type ()) 16 | G_DECLARE_FINAL_TYPE (GumCObjectTracker, gum_cobject_tracker, GUM, 17 | COBJECT_TRACKER, GObject) 18 | 19 | GUM_API GumCObjectTracker * gum_cobject_tracker_new (void); 20 | GUM_API GumCObjectTracker * gum_cobject_tracker_new_with_backtracer ( 21 | GumBacktracer * backtracer); 22 | 23 | GUM_API void gum_cobject_tracker_track (GumCObjectTracker * self, 24 | const gchar * type_name, gpointer type_constructor); 25 | 26 | GUM_API void gum_cobject_tracker_begin (GumCObjectTracker * self); 27 | GUM_API void gum_cobject_tracker_end (GumCObjectTracker * self); 28 | 29 | GUM_API guint gum_cobject_tracker_peek_total_count (GumCObjectTracker * self, 30 | const gchar * type_name); 31 | GUM_API GList * gum_cobject_tracker_peek_object_list (GumCObjectTracker * self); 32 | 33 | G_END_DECLS 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /gum/gummemory-priv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010-2021 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_MEMORY_PRIV_H__ 8 | #define __GUM_MEMORY_PRIV_H__ 9 | 10 | #include "gummemory.h" 11 | 12 | typedef struct _GumMatchToken GumMatchToken; 13 | typedef enum _GumMatchType GumMatchType; 14 | 15 | enum _GumMatchType 16 | { 17 | GUM_MATCH_EXACT, 18 | GUM_MATCH_WILDCARD, 19 | GUM_MATCH_MASK 20 | }; 21 | 22 | struct _GumMatchToken 23 | { 24 | GumMatchType type; 25 | GArray * bytes; 26 | GArray * masks; 27 | guint offset; 28 | }; 29 | 30 | G_BEGIN_DECLS 31 | 32 | G_GNUC_INTERNAL void _gum_memory_backend_init (void); 33 | G_GNUC_INTERNAL void _gum_memory_backend_deinit (void); 34 | G_GNUC_INTERNAL guint _gum_memory_backend_query_page_size (void); 35 | G_GNUC_INTERNAL gint _gum_page_protection_to_posix (GumPageProtection prot); 36 | 37 | G_GNUC_INTERNAL gpointer gum_internal_malloc (size_t size); 38 | G_GNUC_INTERNAL gpointer gum_internal_calloc (size_t count, size_t size); 39 | G_GNUC_INTERNAL gpointer gum_internal_realloc (gpointer mem, size_t size); 40 | G_GNUC_INTERNAL void gum_internal_free (gpointer mem); 41 | 42 | G_END_DECLS 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /gum/gumsymbolutil.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2010 Ole André Vadla Ravnås 3 | * Copyright (C) 2008 Christian Berentsen 4 | * Copyright (C) 2020 Matt Oh 5 | * 6 | * Licence: wxWindows Library Licence, Version 3.1 7 | */ 8 | 9 | #ifndef __GUM_SYMBOL_UTIL_H__ 10 | #define __GUM_SYMBOL_UTIL_H__ 11 | 12 | #include 13 | 14 | typedef struct _GumDebugSymbolDetails GumDebugSymbolDetails; 15 | 16 | struct _GumDebugSymbolDetails 17 | { 18 | GumAddress address; 19 | gchar module_name[GUM_MAX_PATH + 1]; 20 | gchar symbol_name[GUM_MAX_SYMBOL_NAME + 1]; 21 | gchar file_name[GUM_MAX_PATH + 1]; 22 | guint line_number; 23 | guint column; 24 | }; 25 | 26 | G_BEGIN_DECLS 27 | 28 | GUM_API gboolean gum_symbol_details_from_address (gpointer address, 29 | GumDebugSymbolDetails * details); 30 | GUM_API gchar * gum_symbol_name_from_address (gpointer address); 31 | 32 | GUM_API gpointer gum_find_function (const gchar * name); 33 | GUM_API GArray * gum_find_functions_named (const gchar * name); 34 | GUM_API GArray * gum_find_functions_matching (const gchar * str); 35 | GUM_API gboolean gum_load_symbols (const gchar * path); 36 | 37 | G_END_DECLS 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /libs/gum/heap/gumcobject.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #include "gumcobject.h" 8 | #include "gummemory.h" 9 | #include "gumreturnaddress.h" 10 | 11 | #include 12 | 13 | GumCObject * 14 | gum_cobject_new (gpointer address, 15 | const gchar * type_name) 16 | { 17 | GumCObject * cobject; 18 | 19 | cobject = g_slice_new (GumCObject); 20 | cobject->address = address; 21 | g_strlcpy (cobject->type_name, type_name, sizeof (cobject->type_name)); 22 | cobject->return_addresses.len = 0; 23 | cobject->data = NULL; 24 | 25 | return cobject; 26 | } 27 | 28 | GumCObject * 29 | gum_cobject_copy (const GumCObject * cobject) 30 | { 31 | return g_slice_dup (GumCObject, cobject); 32 | } 33 | 34 | void 35 | gum_cobject_free (GumCObject * cobject) 36 | { 37 | g_slice_free (GumCObject, cobject); 38 | } 39 | 40 | void 41 | gum_cobject_list_free (GList * cobject_list) 42 | { 43 | GList * cur; 44 | 45 | for (cur = cobject_list; cur != NULL; cur = cur->next) 46 | { 47 | GumCObject * cobject = cur->data; 48 | gum_cobject_free (cobject); 49 | } 50 | 51 | g_list_free (cobject_list); 52 | } 53 | -------------------------------------------------------------------------------- /bindings/gumjs/gumv8coderelocator.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017-2020 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #include "gumv8coderelocator.h" 8 | 9 | #include "gumv8macros.h" 10 | 11 | #define GUMJS_MODULE_NAME CodeRelocator 12 | 13 | using namespace v8; 14 | 15 | #include "gumv8coderelocator.inc" 16 | 17 | void 18 | _gum_v8_code_relocator_init (GumV8CodeRelocator * self, 19 | GumV8CodeWriter * writer, 20 | GumV8Instruction * instruction, 21 | GumV8Core * core, 22 | Local scope) 23 | { 24 | auto isolate = core->isolate; 25 | 26 | self->writer = writer; 27 | self->instruction = instruction; 28 | self->core = core; 29 | 30 | auto module = External::New (isolate, self); 31 | 32 | #include "gumv8coderelocator-init.inc" 33 | } 34 | 35 | void 36 | _gum_v8_code_relocator_realize (GumV8CodeRelocator * self) 37 | { 38 | } 39 | 40 | void 41 | _gum_v8_code_relocator_dispose (GumV8CodeRelocator * self) 42 | { 43 | #include "gumv8coderelocator-dispose.inc" 44 | } 45 | 46 | void 47 | _gum_v8_code_relocator_finalize (GumV8CodeRelocator * self) 48 | { 49 | } 50 | -------------------------------------------------------------------------------- /gum/backend-barebone/gumexceptor-barebone.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #include "gumexceptorbackend.h" 8 | 9 | struct _GumExceptorBackend 10 | { 11 | GObject parent; 12 | 13 | GumExceptionHandler handler; 14 | gpointer handler_data; 15 | }; 16 | 17 | G_DEFINE_TYPE (GumExceptorBackend, gum_exceptor_backend, G_TYPE_OBJECT) 18 | 19 | void 20 | _gum_exceptor_backend_prepare_to_fork (void) 21 | { 22 | } 23 | 24 | void 25 | _gum_exceptor_backend_recover_from_fork_in_parent (void) 26 | { 27 | } 28 | 29 | void 30 | _gum_exceptor_backend_recover_from_fork_in_child (void) 31 | { 32 | } 33 | 34 | static void 35 | gum_exceptor_backend_class_init (GumExceptorBackendClass * klass) 36 | { 37 | } 38 | 39 | static void 40 | gum_exceptor_backend_init (GumExceptorBackend * self) 41 | { 42 | } 43 | 44 | GumExceptorBackend * 45 | gum_exceptor_backend_new (GumExceptionHandler handler, 46 | gpointer user_data) 47 | { 48 | GumExceptorBackend * backend; 49 | 50 | backend = g_object_new (GUM_TYPE_EXCEPTOR_BACKEND, NULL); 51 | backend->handler = handler; 52 | backend->handler_data = user_data; 53 | 54 | return backend; 55 | } 56 | -------------------------------------------------------------------------------- /gum/backend-arm/gumcpucontext-arm.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #include "gumdefs.h" 8 | 9 | gpointer 10 | gum_cpu_context_get_nth_argument (GumCpuContext * self, 11 | guint n) 12 | { 13 | if (n < 4) 14 | { 15 | return (gpointer) self->r[n]; 16 | } 17 | else 18 | { 19 | gpointer * stack_argument = (gpointer *) self->sp; 20 | 21 | return stack_argument[n - 4]; 22 | } 23 | } 24 | 25 | void 26 | gum_cpu_context_replace_nth_argument (GumCpuContext * self, 27 | guint n, 28 | gpointer value) 29 | { 30 | if (n < 4) 31 | { 32 | self->r[n] = (guint32) value; 33 | } 34 | else 35 | { 36 | gpointer * stack_argument = (gpointer *) self->sp; 37 | 38 | stack_argument[n - 4] = value; 39 | } 40 | } 41 | 42 | gpointer 43 | gum_cpu_context_get_return_value (GumCpuContext * self) 44 | { 45 | return (gpointer) self->r[0]; 46 | } 47 | 48 | void 49 | gum_cpu_context_replace_return_value (GumCpuContext * self, 50 | gpointer value) 51 | { 52 | self->r[0] = (guint32) value; 53 | } 54 | -------------------------------------------------------------------------------- /gum/gumspinlock.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010-2019 Ole André Vadla Ravnås 3 | * Copyright (C) 2024 Francesco Tamagni 4 | * 5 | * Licence: wxWindows Library Licence, Version 3.1 6 | */ 7 | 8 | #include "gumspinlock.h" 9 | 10 | typedef struct _GumSpinlockImpl GumSpinlockImpl; 11 | 12 | struct _GumSpinlockImpl 13 | { 14 | volatile gint is_held; 15 | }; 16 | 17 | void 18 | gum_spinlock_init (GumSpinlock * spinlock) 19 | { 20 | GumSpinlockImpl * self = (GumSpinlockImpl *) spinlock; 21 | 22 | self->is_held = FALSE; 23 | } 24 | 25 | void 26 | gum_spinlock_acquire (GumSpinlock * spinlock) 27 | { 28 | GumSpinlockImpl * self = (GumSpinlockImpl *) spinlock; 29 | 30 | while (!g_atomic_int_compare_and_exchange (&self->is_held, FALSE, TRUE)) 31 | ; 32 | } 33 | 34 | gboolean 35 | gum_spinlock_try_acquire (GumSpinlock * spinlock) 36 | { 37 | GumSpinlockImpl * self = (GumSpinlockImpl *) spinlock; 38 | 39 | if (self->is_held) 40 | return FALSE; 41 | 42 | gum_spinlock_acquire (spinlock); 43 | 44 | return TRUE; 45 | } 46 | 47 | void 48 | gum_spinlock_release (GumSpinlock * spinlock) 49 | { 50 | GumSpinlockImpl * self = (GumSpinlockImpl *) spinlock; 51 | 52 | g_atomic_int_set (&self->is_held, FALSE); 53 | } 54 | -------------------------------------------------------------------------------- /libs/gum/heap/gumallocationblock.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #include "gumallocationblock.h" 8 | 9 | #include "gummemory.h" 10 | #include "gumreturnaddress.h" 11 | 12 | #include 13 | 14 | GumAllocationBlock * 15 | gum_allocation_block_new (gpointer address, 16 | guint size) 17 | { 18 | GumAllocationBlock * block; 19 | 20 | block = g_slice_new (GumAllocationBlock); 21 | block->address = address; 22 | block->size = size; 23 | block->return_addresses.len = 0; 24 | 25 | return block; 26 | } 27 | 28 | GumAllocationBlock * 29 | gum_allocation_block_copy (const GumAllocationBlock * block) 30 | { 31 | return g_slice_dup (GumAllocationBlock, block); 32 | } 33 | 34 | void 35 | gum_allocation_block_free (GumAllocationBlock * block) 36 | { 37 | g_slice_free (GumAllocationBlock, block); 38 | } 39 | 40 | void 41 | gum_allocation_block_list_free (GList * block_list) 42 | { 43 | GList * cur; 44 | 45 | for (cur = block_list; cur != NULL; cur = cur->next) 46 | { 47 | GumAllocationBlock * block = cur->data; 48 | gum_allocation_block_free (block); 49 | } 50 | 51 | g_list_free (block_list); 52 | } 53 | -------------------------------------------------------------------------------- /bindings/gumpp/runtime.cpp: -------------------------------------------------------------------------------- 1 | #include "runtime.hpp" 2 | 3 | #include 4 | #ifdef HAVE_WINDOWS 5 | #include 6 | #endif 7 | 8 | namespace Gum 9 | { 10 | volatile int Runtime::ref_count = 0; 11 | 12 | #ifndef GUMPP_STATIC 13 | static void init () 14 | { 15 | gum_init_embedded (); 16 | } 17 | 18 | static void deinit () 19 | { 20 | gum_deinit_embedded (); 21 | } 22 | #endif 23 | 24 | #ifdef HAVE_WINDOWS 25 | 26 | #ifndef GUMPP_STATIC 27 | extern "C" BOOL WINAPI DllMain (HINSTANCE inst_dll, DWORD reason, LPVOID reserved) 28 | { 29 | switch (reason) 30 | { 31 | case DLL_PROCESS_ATTACH: 32 | init (); 33 | break; 34 | case DLL_PROCESS_DETACH: 35 | if (reserved == NULL) 36 | deinit (); 37 | break; 38 | } 39 | 40 | return TRUE; 41 | } 42 | #endif 43 | 44 | void Runtime::ref () 45 | { 46 | } 47 | 48 | void Runtime::unref () 49 | { 50 | } 51 | 52 | #else 53 | 54 | void Runtime::ref () 55 | { 56 | if (g_atomic_int_add (&ref_count, 1) == 0) 57 | g_atomic_int_inc (&ref_count); 58 | init (); 59 | } 60 | 61 | void Runtime::unref () 62 | { 63 | if (g_atomic_int_dec_and_test (&ref_count)) 64 | deinit (); 65 | } 66 | #endif 67 | } 68 | -------------------------------------------------------------------------------- /bindings/gumpp/gumpp-static.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | {03327442-c52b-47a0-87b6-77585055cb08} 24 | 25 | 26 | 27 | 28 | frida-gum32-lib 29 | 30 | 31 | -------------------------------------------------------------------------------- /gum/gumlibc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015-2024 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #include "gumlibc.h" 8 | 9 | gpointer 10 | gum_memset (gpointer dst, 11 | gint c, 12 | gsize n) 13 | { 14 | gsize offset; 15 | 16 | for (offset = 0; offset != n; offset++) 17 | ((guint8 *) dst)[offset] = c; 18 | 19 | return dst; 20 | } 21 | 22 | #if defined (_MSC_VER) || !(defined (HAVE_ARM64) && defined (__LP64__)) 23 | 24 | gpointer 25 | gum_memcpy (gpointer dst, 26 | gconstpointer src, 27 | gsize n) 28 | { 29 | gsize offset; 30 | 31 | for (offset = 0; offset != n; offset++) 32 | ((guint8 *) dst)[offset] = ((guint8 *) src)[offset]; 33 | 34 | return dst; 35 | } 36 | 37 | gpointer 38 | gum_memmove (gpointer dst, 39 | gconstpointer src, 40 | gsize n) 41 | { 42 | guint8 * dst_u8 = dst; 43 | const guint8 * src_u8 = src; 44 | gsize i; 45 | 46 | if (dst_u8 < src_u8) 47 | { 48 | for (i = 0; i != n; i++) 49 | dst_u8[i] = src_u8[i]; 50 | } 51 | else if (dst_u8 > src_u8) 52 | { 53 | for (i = n; i != 0; i--) 54 | dst_u8[i - 1] = src_u8[i - 1]; 55 | } 56 | 57 | return dst; 58 | } 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /tests/stalkerdummychannel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __STALKER_DUMMY_CHANNEL_H__ 8 | #define __STALKER_DUMMY_CHANNEL_H__ 9 | 10 | #include 11 | 12 | G_BEGIN_DECLS 13 | 14 | typedef struct _StalkerDummyChannel StalkerDummyChannel; 15 | typedef guint StalkerDummyState; 16 | 17 | struct _StalkerDummyChannel 18 | { 19 | volatile StalkerDummyState state; 20 | GumThreadId thread_id; 21 | GMutex mutex; 22 | GCond cond; 23 | }; 24 | 25 | void sdc_init (StalkerDummyChannel * self); 26 | void sdc_finalize (StalkerDummyChannel * self); 27 | 28 | GumThreadId sdc_await_thread_id (StalkerDummyChannel * self); 29 | void sdc_put_thread_id (StalkerDummyChannel * self, GumThreadId thread_id); 30 | 31 | #define SDC_DECLARE_LOCKSTEP(name) \ 32 | void sdc_await_ ##name## _confirmation (StalkerDummyChannel * self); \ 33 | void sdc_put_ ##name## _confirmation (StalkerDummyChannel * self); 34 | 35 | SDC_DECLARE_LOCKSTEP (follow) 36 | SDC_DECLARE_LOCKSTEP (run) 37 | SDC_DECLARE_LOCKSTEP (unfollow) 38 | SDC_DECLARE_LOCKSTEP (flush) 39 | SDC_DECLARE_LOCKSTEP (finish) 40 | 41 | G_END_DECLS 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /vapi/frida-gum-heap-1.0.vapi: -------------------------------------------------------------------------------- 1 | [CCode (cheader_filename = "gum/gum-heap.h", gir_namespace = "FridaGum", gir_version = "1.0")] 2 | namespace Gum { 3 | public class InstanceTracker : GLib.Object { 4 | public InstanceTracker (); 5 | 6 | public void begin (Gum.InstanceVTable? vtable = null); 7 | public void end (); 8 | 9 | public uint peek_total_count (string type_name); 10 | public GLib.List peek_instances (); 11 | public void walk_instances (Gum.WalkInstanceFunc func); 12 | } 13 | 14 | public delegate void WalkInstanceFunc (Gum.InstanceDetails id); 15 | 16 | public struct InstanceVTable { 17 | void * create_instance; 18 | void * free_instance; 19 | 20 | void * type_id_to_name; 21 | } 22 | 23 | public struct InstanceDetails { 24 | public void * address; 25 | public uint ref_count; 26 | public string type_name; 27 | } 28 | 29 | public class BoundsChecker : GLib.Object { 30 | public BoundsChecker (Gum.Backtracer? backtracer = null, Gum.BoundsOutputFunc? output = null); 31 | 32 | public uint pool_size { get; set; } 33 | public uint front_alignment { get; set; } 34 | 35 | public void attach (); 36 | public void attach_to_apis (Gum.HeapApiList apis); 37 | public void detach (); 38 | } 39 | 40 | public delegate void BoundsOutputFunc (string text); 41 | } 42 | -------------------------------------------------------------------------------- /gum/backend-x86/gumstalker-x86-glue.S: -------------------------------------------------------------------------------- 1 | .text 2 | 3 | #if (defined (HAVE_WINDOWS) && defined (__i386__)) || defined (__APPLE__) 4 | # define GUM_CSYM(x) _ ## x 5 | #else 6 | # define GUM_CSYM(x) x 7 | #endif 8 | 9 | .globl GUM_CSYM (gum_stalker_follow_me) 10 | GUM_CSYM (gum_stalker_follow_me): 11 | #ifdef i386 12 | movl %esp, %eax 13 | subl $12, %esp 14 | pushl %eax 15 | pushl (4 + 8)(%eax) 16 | pushl (4 + 4)(%eax) 17 | pushl (4 + 0)(%eax) 18 | call GUM_CSYM (_gum_stalker_do_follow_me) 19 | addl $28, %esp 20 | ret 21 | #else 22 | mov %rsp, %rcx 23 | jmp GUM_CSYM (_gum_stalker_do_follow_me) 24 | #endif 25 | 26 | .globl GUM_CSYM (gum_stalker_activate) 27 | GUM_CSYM (gum_stalker_activate): 28 | #ifdef i386 29 | movl %esp, %eax 30 | pushl %eax 31 | pushl (4 + 4)(%eax) 32 | pushl (4 + 0)(%eax) 33 | call GUM_CSYM (_gum_stalker_do_activate) 34 | addl $12, %esp 35 | ret 36 | #else 37 | mov %rsp, %rdx 38 | jmp GUM_CSYM (_gum_stalker_do_activate) 39 | #endif 40 | 41 | .globl GUM_CSYM (gum_stalker_deactivate) 42 | GUM_CSYM (gum_stalker_deactivate): 43 | #ifdef i386 44 | movl %esp, %eax 45 | subl $4, %esp 46 | pushl %eax 47 | pushl (4 + 0)(%eax) 48 | call GUM_CSYM (_gum_stalker_do_deactivate) 49 | addl $12, %esp 50 | ret 51 | #else 52 | mov %rsp, %rsi 53 | jmp GUM_CSYM (_gum_stalker_do_deactivate) 54 | #endif 55 | -------------------------------------------------------------------------------- /gum/gummetalarray.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017-2019 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #ifndef __GUM_METAL_ARRAY_H__ 8 | #define __GUM_METAL_ARRAY_H__ 9 | 10 | #include 11 | 12 | typedef struct _GumMetalArray GumMetalArray; 13 | 14 | struct _GumMetalArray 15 | { 16 | gpointer data; 17 | guint length; 18 | guint capacity; 19 | 20 | guint element_size; 21 | }; 22 | 23 | G_BEGIN_DECLS 24 | 25 | GUM_API void gum_metal_array_init (GumMetalArray * array, guint element_size); 26 | GUM_API void gum_metal_array_free (GumMetalArray * array); 27 | 28 | GUM_API gpointer gum_metal_array_element_at (GumMetalArray * self, 29 | guint index_); 30 | GUM_API gpointer gum_metal_array_insert_at (GumMetalArray * self, guint index_); 31 | GUM_API void gum_metal_array_remove_at (GumMetalArray * self, guint index_); 32 | GUM_API void gum_metal_array_remove_all (GumMetalArray * self); 33 | GUM_API gpointer gum_metal_array_append (GumMetalArray * self); 34 | 35 | GUM_API void gum_metal_array_get_extents (GumMetalArray * self, 36 | gpointer * start, gpointer * end); 37 | GUM_API void gum_metal_array_ensure_capacity (GumMetalArray * self, 38 | guint capacity); 39 | 40 | G_END_DECLS 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /gum/gumbacktracer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008-2022 Ole André Vadla Ravnås 3 | * Copyright (C) 2021 Francesco Tamagni 4 | * 5 | * Licence: wxWindows Library Licence, Version 3.1 6 | */ 7 | 8 | #ifndef __GUM_BACKTRACER_H__ 9 | #define __GUM_BACKTRACER_H__ 10 | 11 | #include 12 | #include 13 | 14 | G_BEGIN_DECLS 15 | 16 | #define GUM_TYPE_BACKTRACER (gum_backtracer_get_type ()) 17 | G_DECLARE_INTERFACE (GumBacktracer, gum_backtracer, GUM, BACKTRACER, GObject) 18 | 19 | struct _GumBacktracerInterface 20 | { 21 | GTypeInterface parent; 22 | 23 | void (* generate) (GumBacktracer * self, const GumCpuContext * cpu_context, 24 | GumReturnAddressArray * return_addresses, guint limit); 25 | }; 26 | 27 | GUM_API GumBacktracer * gum_backtracer_make_accurate (void); 28 | GUM_API GumBacktracer * gum_backtracer_make_fuzzy (void); 29 | 30 | GUM_API void gum_backtracer_generate (GumBacktracer * self, 31 | const GumCpuContext * cpu_context, 32 | GumReturnAddressArray * return_addresses); 33 | GUM_API void gum_backtracer_generate_with_limit (GumBacktracer * self, 34 | const GumCpuContext * cpu_context, 35 | GumReturnAddressArray * return_addresses, guint limit); 36 | 37 | G_END_DECLS 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /tests/run-ios.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | remote_host=iphone 4 | remote_prefix=/usr/local/opt/frida-tests 5 | 6 | set -e 7 | 8 | make 9 | 10 | cd build/tests 11 | 12 | ssh "$remote_host" "mkdir -p '$remote_prefix'" 13 | rsync -rLz gum-tests data "$remote_host:$remote_prefix/" || exit 1 14 | 15 | ssh "$remote_host" "rm -f /var/mobile/Library/Logs/CrashReporter/gum-tests-*" 16 | 17 | log_path=$(mktemp "$TMPDIR/gum-tests.XXXXXX") 18 | ssh "$remote_host" "$remote_prefix/gum-tests" "$@" | tee "$log_path" 19 | 20 | if [ ${PIPESTATUS[0]} -ne 0 ]; then 21 | while ! ssh "$remote_host" "ls /var/mobile/Library/Logs/CrashReporter/gum-tests-*" 2>/dev/null; do 22 | sleep 1 23 | done 24 | 25 | remote_report_path=$(ssh "$remote_host" "echo /var/mobile/Library/Logs/CrashReporter/gum-tests-*") 26 | local_report_path=$(mktemp "$TMPDIR/gum-tests.XXXXXX") 27 | scp "$remote_host:$remote_report_path" "$local_report_path" 28 | 29 | program_base=$(egrep "^(0x.+)\sgum-tests" "$local_report_path" | awk '{ print $1; }') 30 | 31 | cat "$local_report_path" 32 | 33 | echo "Crash:" 34 | egrep "^\d+\s+gum-tests" "$local_report_path" \ 35 | | awk '{ print $3; }' \ 36 | | xargs atos -o gum-tests -l $program_base 37 | 38 | rm "$local_report_path" 39 | ssh "$remote_host" "rm $remote_report_path" 40 | fi 41 | 42 | rm "$log_path" 43 | -------------------------------------------------------------------------------- /gum/backend-arm64/gumcpucontext-arm64.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014-2015 Ole André Vadla Ravnås 3 | * 4 | * Licence: wxWindows Library Licence, Version 3.1 5 | */ 6 | 7 | #include "gumdefs.h" 8 | 9 | gpointer 10 | gum_cpu_context_get_nth_argument (GumCpuContext * self, 11 | guint n) 12 | { 13 | if (n < 8) 14 | { 15 | return GSIZE_TO_POINTER (self->x[n]); 16 | } 17 | else 18 | { 19 | gpointer * stack_argument = GSIZE_TO_POINTER (self->sp); 20 | 21 | return stack_argument[n - 8]; 22 | } 23 | } 24 | 25 | void 26 | gum_cpu_context_replace_nth_argument (GumCpuContext * self, 27 | guint n, 28 | gpointer value) 29 | { 30 | if (n < 8) 31 | { 32 | self->x[n] = GPOINTER_TO_SIZE (value); 33 | } 34 | else 35 | { 36 | gpointer * stack_argument = GSIZE_TO_POINTER (self->sp); 37 | 38 | stack_argument[n - 8] = value; 39 | } 40 | } 41 | 42 | gpointer 43 | gum_cpu_context_get_return_value (GumCpuContext * self) 44 | { 45 | return GSIZE_TO_POINTER (self->x[0]); 46 | } 47 | 48 | void 49 | gum_cpu_context_replace_return_value (GumCpuContext * self, 50 | gpointer value) 51 | { 52 | self->x[0] = GPOINTER_TO_SIZE (value); 53 | } 54 | --------------------------------------------------------------------------------