24 lines
722 B
Kotlin
24 lines
722 B
Kotlin
package ru.dbotthepony.kstarbound
|
|
|
|
import jnr.ffi.LibraryLoader
|
|
import org.apache.logging.log4j.LogManager
|
|
import java.nio.LongBuffer
|
|
|
|
interface WindowsBindings {
|
|
fun NtQueryTimerResolution(minimumResolution: LongBuffer, maximumResolution: LongBuffer, currentResolution: LongBuffer)
|
|
fun NtSetTimerResolution(desiredResolution: Long, setResolution: Boolean, currentResolution: LongBuffer)
|
|
|
|
companion object {
|
|
private val LOGGER = LogManager.getLogger()
|
|
|
|
val INSTANCE by lazy {
|
|
try {
|
|
LibraryLoader.create(WindowsBindings::class.java).load("ntdll")
|
|
} catch (err: Throwable) {
|
|
LOGGER.error("Failed to link against ntdll.dll, if we are not on Windows then ignore this message", err)
|
|
null
|
|
}
|
|
}
|
|
}
|
|
}
|