Class GoApiSnapshot
Useful to apply function parameter information to functions found in a go binary.
Snapshot json files contain function / type information about functions and types extracted from the golang toolchain itself, for each arch and OSes that the golang toolchain supports, via cross-compiling against each GOARCH and GOOS.
Function and type info that is incompatible or not present in other arch / os targets will be split into different arch lookup keys that can be specified when deserializing the json.
The arch names will be one of "all", cpu-arch-name (eg. amd64), operating-system-name (eg. linux), operating-system-cpu-arch-name (eg. linux-amd64), or "unix" (artificial arch name that indicates the sub-elements are common to all unix-like arches).
Non-exhaustive list of current values:
- all - everything that is generically compatible with all platforms
- 386
- amd64
- arm
- arm64
- cgo
- darwin
- darwin-amd64
- darwin-amd64-cgo
- darwin-arm64
- darwin-arm64-cgo
- linux
- linux-386
- linux-386-cgo
- linux-amd64
- linux-amd64-cgo
- linux-arm
- linux-arm-cgo
- linux-arm64
- linux-arm64-cgo
- linux-cgo
- unix - an artificial goos that groups linux/bsd/darwin/aix/etc together
- windows
- windows-386
- windows-386-cgo
- windows-amd64
- windows-amd64-cgo
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic class -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionGoApiSnapshot(GoVer ver, Map<String, ghidra.app.util.bin.format.golang.rtti.GoApiSnapshot.GoArch> arches) -
Method Summary
Modifier and TypeMethodDescriptionstatic GoApiSnapshotget(GoVer goVer, String goArch, String goOS, TaskMonitor monitor) Returns a matchingGoApiSnapshotfor the specified golang version.static FilegetApiFile(File baseDir, GoVer ver) static ByteProvidergetApiSnapshotJsonFile(GoVer goVer, TaskMonitor monitor) getFuncdef(String funcName) Returns aGoApiSnapshot.GoFuncDeffor the specified function name.getTypeDef(String typeName) getVer()
-
Field Details
-
EMPTY
-
-
Constructor Details
-
GoApiSnapshot
-
-
Method Details
-
get
public static GoApiSnapshot get(GoVer goVer, String goArch, String goOS, TaskMonitor monitor) throws IOException, CancelledException Returns a matchingGoApiSnapshotfor the specified golang version. If an exact match isn't found, earlier patch revs will be tried until all patch levels are exhausted.- Parameters:
goVer- go version (controls which .json file is opened)goArch- GOARCH stringgoOS- GOOS stringmonitor-TaskMonitor- Returns:
GoApiSnapshotinstance, possibly anEMPTYinstance if no matching snapshot file is found- Throws:
IOException- if error parsing json or opening the snapshot container fileCancelledException- if user cancels
-
getApiSnapshotJsonFile
public static ByteProvider getApiSnapshotJsonFile(GoVer goVer, TaskMonitor monitor) throws IOException, CancelledException - Throws:
IOExceptionCancelledException
-
getApiFile
-
getVer
-
getFuncdef
Returns aGoApiSnapshot.GoFuncDeffor the specified function name. The function name should not contain generics (eg. "cmp.Compare" and not "cmp.Compare[sometypename]").- Parameters:
funcName- fully qualified name of function, without any generics- Returns:
GoApiSnapshot.GoFuncDefinstance, or null
-
getTypeDef
-