public final class DirectMappingKeystoneNative extends Object
The original function prototypes are declared in the header file keystone.h.
| 限定符和类型 | 方法和说明 |
|---|---|
static boolean |
ks_arch_supported(KeystoneArchitecture architecture)
Determine if the given architecture is supported by this library.
|
static int |
ks_asm(com.sun.jna.Pointer engine,
String assembly,
long address,
com.sun.jna.ptr.PointerByReference machineCodeBuffer,
com.sun.jna.ptr.IntByReference machineCodeSize,
com.sun.jna.ptr.IntByReference numberOfStatements)
Assemble a string given its the buffer, size, start address and number
of instructions to be decoded.
|
static KeystoneError |
ks_close(com.sun.jna.Pointer engine)
Close KS instance: MUST do to release the handle when it is not used anymore.
|
static KeystoneError |
ks_errno(com.sun.jna.Pointer engine)
Report the last error number when some API function fail.
|
static void |
ks_free(com.sun.jna.Pointer machineCodeBuffer)
Free memory allocated by ks_asm().
|
static KeystoneError |
ks_open(KeystoneArchitecture architecture,
KeystoneMode mode,
com.sun.jna.ptr.PointerByReference engine)
Create new instance of Keystone engine.
|
static KeystoneError |
ks_option(com.sun.jna.Pointer engine,
KeystoneOptionType type,
int value)
Set option for Keystone engine at runtime.
|
static KeystoneError |
ks_option(com.sun.jna.Pointer engine,
KeystoneOptionType type,
SymbolResolverCallback callback)
Set option for Keystone engine at runtime
Native function prototype: err ks_option(ks_engine *ks, ks_opt_type type, size_t value);
|
static String |
ks_strerror(KeystoneError errorCode)
Return a string describing given error code.
|
static int |
ks_version(com.sun.jna.ptr.IntByReference major,
com.sun.jna.ptr.IntByReference minor)
Returns combined API version & major and minor version numbers.
|
public static boolean ks_arch_supported(KeystoneArchitecture architecture)
Native function prototype: bool ks_arch_supported(ks_arch arch);
architecture - architecture typetrue if this library supports the given arch.public static int ks_asm(com.sun.jna.Pointer engine,
String assembly,
long address,
com.sun.jna.ptr.PointerByReference machineCodeBuffer,
com.sun.jna.ptr.IntByReference machineCodeSize,
com.sun.jna.ptr.IntByReference numberOfStatements)
On failure, call ks_errno(com.sun.jna.Pointer) for error code.
NOTE 1: this API will automatically determine memory needed to contain output bytes in *encoding.
NOTE 2: caller must free the allocated memory itself to avoid memory leaking.
Native function prototype: int ks_asm(ks_engine *ks, const char *string, uint64_t address, unsigned char **encoding, size_t *encoding_size, size_t *stat_count);
engine - handle returned by ks_open()assembly - NULL-terminated assembly string. Use ; or \n to separate statements.address - address of the first assembly instruction, or 0 to ignore.machineCodeBuffer - array of bytes containing encoding of input assembly string.
NOTE: *encoding will be allocated by this function, and should be freed
with ks_free() function.machineCodeSize - size of machineCodenumberOfStatements - number of statements successfully processedpublic static KeystoneError ks_close(com.sun.jna.Pointer engine)
Native function prototype: ks_err ks_close(ks_engine *ks);
engine - pointer to a handle returned by ks_open().public static KeystoneError ks_errno(com.sun.jna.Pointer engine)
Native function prototype: ks_err ks_errno(ks_engine *ks)
engine - handle returned by ks_open()KeystoneErrorpublic static void ks_free(com.sun.jna.Pointer machineCodeBuffer)
Native function prototype: void ks_free(unsigned char *p)
machineCodeBuffer - memory allocated in @encoding argument of ks_asm()public static KeystoneError ks_open(KeystoneArchitecture architecture, KeystoneMode mode, com.sun.jna.ptr.PointerByReference engine)
Native function prototype: ks_err ks_open(ks_arch arch, int mode, ks_engine **ks);
architecture - architecture type (KS_ARCH_*).mode - hardware mode. This is combined of KS_MODE_*.engine - pointer to ks_engine, which will be updated at return time.public static KeystoneError ks_option(com.sun.jna.Pointer engine, KeystoneOptionType type, int value)
Native function prototype: err ks_option(ks_engine *ks, ks_opt_type type, size_t value);
engine - handle returned by ks_open()type - type of option to be set. See KeystoneOptionTypevalue - option value corresponding with @typeKeystoneError.Ok on success, or other value on failure.
Refer to KeystoneError enum for detailed error.public static KeystoneError ks_option(com.sun.jna.Pointer engine, KeystoneOptionType type, SymbolResolverCallback callback)
Native function prototype: err ks_option(ks_engine *ks, ks_opt_type type, size_t value);
engine - handle returned by ks_open()type - ype of option to be set. See KeystoneOptionTypecallback - callback to resolve a unrecognized symbol.KeystoneError.Ok on success, or other value on failure.
Refer to KeystoneError enum for detailed error.public static String ks_strerror(KeystoneError errorCode)
Native function prototype: const char *ks_strerror(ks_err code);
errorCode - error code.public static int ks_version(com.sun.jna.ptr.IntByReference major,
com.sun.jna.ptr.IntByReference minor)
Native function prototype: unsigned int ks_version(unsigned int *major, unsigned int *minor);
major - The major number of API version.minor - The minor number of API version.Copyright © 2022. All rights reserved.