use pattern for key bindings

This commit is contained in:
guiyomu-dev
2025-09-29 00:17:25 +02:00
parent 00cfbed068
commit ead8e9fbe3
2 changed files with 16 additions and 2 deletions

View File

@@ -8,8 +8,8 @@ import (
) )
func (gd *GameReader) GetKeyBindings() data.KeyBindings { func (gd *GameReader) GetKeyBindings() data.KeyBindings {
blob := gd.ReadBytesFromMemory(gd.moduleBaseAddressPtr+0x1DFFAF4, 0x500) blob := gd.ReadBytesFromMemory(gd.offset.KeyBindingsOffset, 0x500)
blobSkills := gd.ReadBytesFromMemory(gd.moduleBaseAddressPtr+0x2228030, 0x500) blobSkills := gd.ReadBytesFromMemory(gd.offset.KeyBindingsSkillsOffset, 0x500)
skillsKB := [16]data.SkillBinding{} skillsKB := [16]data.SkillBinding{}
for i := 0; i < 7; i++ { for i := 0; i < 7; i++ {

View File

@@ -15,6 +15,8 @@ type Offset struct {
WidgetStatesOffset uintptr WidgetStatesOffset uintptr
WaypointsOffset uintptr WaypointsOffset uintptr
FPS uintptr FPS uintptr
KeyBindingsOffset uintptr
KeyBindingsSkillsOffset uintptr
} }
func calculateOffsets(process Process) Offset { func calculateOffsets(process Process) Offset {
@@ -71,6 +73,16 @@ func calculateOffsets(process Process) Offset {
fpsOffsetPtr := uintptr(process.ReadUInt(pattern+2, Uint32)) fpsOffsetPtr := uintptr(process.ReadUInt(pattern+2, Uint32))
fpsOffset := pattern - process.moduleBaseAddressPtr + 6 + fpsOffsetPtr fpsOffset := pattern - process.moduleBaseAddressPtr + 6 + fpsOffsetPtr
// Keybindings
pattern = process.FindPattern(memory, "\x00\xA8\x00\x00\x00\x00\x7F\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x0F\x00\x00\x00\x00\x00\x00\x80\x4C\x6F\x00\x00\x79\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x52", "xx????x?xx????xxxxxxxxxxxxx??x?xxxxxxxxxxx")
keyBindingsOffset := pattern + 0x65
// KeyBindings Skills
pattern = process.FindPattern(memory, "\x0F\x10\x04\x24\x48\x6B\xC8\x1C\x48\x8D\x05", "xxxxxxxxxxx")
var keyBindingsSkillsOffset uintptr
bytes = process.ReadBytesFromMemory(pattern+11, 4)
relativeOffset := int32(binary.LittleEndian.Uint32(bytes))
keyBindingsSkillsOffset = uintptr(int64(pattern) + 15 + int64(relativeOffset))
return Offset{ return Offset{
GameData: gameDataOffset, GameData: gameDataOffset,
@@ -83,5 +95,7 @@ func calculateOffsets(process Process) Offset {
WidgetStatesOffset: WidgetStatesOffset, WidgetStatesOffset: WidgetStatesOffset,
WaypointsOffset: WaypointsOffset, WaypointsOffset: WaypointsOffset,
FPS: fpsOffset, FPS: fpsOffset,
KeyBindingsOffset: keyBindingsOffset,
KeyBindingsSkillsOffset: keyBindingsSkillsOffset,
} }
} }