Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rinlovesyou/kiergo

DirectX11 hook for imgui, made in go. Inspired by Kiero
https://github.com/rinlovesyou/kiergo

Last synced: 11 days ago
JSON representation

DirectX11 hook for imgui, made in go. Inspired by Kiero

Awesome Lists containing this project

README

        

# Kiero-Golang-DirectX11-Hook

This is a very dirty Golang implementation of [Kiero Hook for Directx11](https://github.com/Rebzzel/kiero).

For a QuickStart, you can check out the example folder.

## Information
This works due to a little modification of the [imgui-go wrapper by inkyblackness](https://github.com/inkyblackness/imgui-go).

you can get it with `go get github.com/RinLovesYou/imgui-go`

!! THIS MAKES A LOT OF ASSUMPTIONS ABOUT YOUR ENVIRONMENT. IT EXPECTS DEPENDENCIES LIKE MINHOOK/DX11/ETC TO BE INJECTED/PRESENT !!

![image](https://user-images.githubusercontent.com/29461788/178161976-84d73af1-1407-48c3-90e7-26b723a6cbf1.png)

## QuickStart

```go
package main

import (
"fmt"
"unsafe"

"github.com/RinLovesYou/imgui-go"
"github.com/RinLovesYou/kiergo"
)

func init() {
err := kiergo.Hook(OnPresent, WndProc)
if err != nil {
fmt.Println(err)
}
}

var gInitialized bool
var device unsafe.Pointer
var context unsafe.Pointer
var window unsafe.Pointer

var showDemo bool
var showGuide bool

func OnPresent(pSwapChain unsafe.Pointer, SyncInterval, FlagsT uint32) error {
if !gInitialized {
var err error

device, err = kiergo.SetupValuesGetDevice(pSwapChain)
if err != nil {
return err
}

context, err = kiergo.GetContext()
if err != nil {
return err
}

window, err = kiergo.GetGameWindow()
if err != nil {
return err
}

imgui.CreateContext(nil)
io := imgui.CurrentIO()
io.SetConfigFlags(imgui.ConfigFlagsNavEnableKeyboard)

imgui.Win32Init(window)
imgui.Dx11Init(device, context)

gInitialized = true
}

imgui.Dx11NewFrame()
imgui.Win32NewFrame()
imgui.NewFrame()

imgui.Begin("hello, golang")

imgui.Text("\"it just works\" - RinLovesYou 2022")
if imgui.Button("Show Demo") {
showDemo = !showDemo
}

if imgui.Button("Show Guide") {
showGuide = !showGuide
}

imgui.End()

if showDemo {
imgui.ShowDemoWindow(&showDemo)
}

if showGuide {
imgui.ShowUserGuide()
}

imgui.Render()
kiergo.SetRenderTargets()
imgui.Dx11RenderDrawData(imgui.RenderedDrawData())

return nil
}

func WndProc(hwnd unsafe.Pointer, msg uint32, wparam, lparam unsafe.Pointer) error {
imgui.Win32WndProcHandler(hwnd, msg, wparam, lparam)
return nil
}

func main() {

}

```

compile with `go build --buildmode=c-shared -o YourDll.dll main.go`