Skip to content

Jire/kna

Repository files navigation

KNA (Kotlin Native Access)

High-performance easy native access from Kotlin

Build Status License

Currently still under development -- documentation and unit tests are missing.


Using from Gradle

Gradle Kotlin:

implementation("org.jire", "kna", "0.4.2")

Gradle Groovy:

implementation group: 'org.jire', name: 'kna', version: '0.4.2'

Attaching to a process

You can attach to a process using a name (executable file name):

val process = Attach.byName("process.exe")!!

Or you can attach using a process ID (PID):

val process = Attach.byID(123)!!

Attaching to modules of a process

You can use .modules() off a process to acquire attached modules.

val modules = process.modules()

Consider that each call to .modules() will reload all modules unless you specify attach as false like so:

val modules = process.modules(attach = false)

From the attached modules you can use .byName(moduleName) to select a certain module:

val module = modules.byName("module.dll")

Reading from processes & modules

You can use the implicit data type to read from an address:

val someByte: Byte = process[0x100]
val someInt: Int = process[0x101]
val someFloat: Float = process[0x105]
val someBoolean: Boolean = process[0x109]

The implicit type also works when passing arguments or using if expressions:

if (process[0x321]) // Boolean type inferred
	sin(process[0x555]) // Double type inferred

Sometimes it's easier or necessary to use explicit types:

val someByte = process.byte(0x100)
val someInt = process.int(0x101)
val someFloat = process.float(0x105)
val someBoolean = process.boolean(0x109)

Writing to processes & modules

You can use "implicit" writing with the set operator.

something[0x100] = 1.toByte()
something[0x101] = 1
something[0x105] = 1F
something[0x109] = true

There are no "explicit" writes, as the "implicit" writes are simply method overloads.

About

High-performance easy native access from Kotlin

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages