High-performance easy native access from Kotlin
Currently still under development -- documentation and unit tests are missing.
Gradle Kotlin:
implementation("org.jire", "kna", "0.4.2")
Gradle Groovy:
implementation group: 'org.jire', name: 'kna', version: '0.4.2'
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)!!
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")
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)
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.