diff --git a/pkg/data/data.go b/pkg/data/data.go index 203fc7c..dc6f832 100644 --- a/pkg/data/data.go +++ b/pkg/data/data.go @@ -66,6 +66,7 @@ type OnlineGame struct { LastGameName string LastGamePassword string FPS int + Ping int } type Panel struct { diff --git a/pkg/memory/game_reader.go b/pkg/memory/game_reader.go index aa2ee5b..0ce0901 100644 --- a/pkg/memory/game_reader.go +++ b/pkg/memory/game_reader.go @@ -111,6 +111,7 @@ func (gd *GameReader) GetData() data.Data { LastGameName: gd.LastGameName(), LastGamePassword: gd.LastGamePass(), FPS: gd.FPS(), + Ping: gd.Ping(), }, Monsters: monsters, Corpses: gd.Corpses(pu.Position, hover), @@ -441,6 +442,12 @@ func (gd *GameReader) FPS() int { return int(gd.ReadUInt(gd.moduleBaseAddressPtr+gd.offset.FPS, Uint32)) } +func (gd *GameReader) Ping() int { + ptrToStructPtr := gd.moduleBaseAddressPtr + gd.offset.Ping + structPtrAddr := gd.ReadUInt(ptrToStructPtr, Uint64) + return int(gd.ReadUInt(uintptr(structPtrAddr+36), Uint32)) +} + func (gd *GameReader) HasMerc() bool { return gd.ReadUInt(gd.Process.moduleBaseAddressPtr+gd.offset.UI+0x8, Uint8) != 0 } diff --git a/pkg/memory/offset.go b/pkg/memory/offset.go index 56820ba..4091998 100644 --- a/pkg/memory/offset.go +++ b/pkg/memory/offset.go @@ -19,6 +19,7 @@ type Offset struct { KeyBindingsSkillsOffset uintptr TZ uintptr Quests uintptr + Ping uintptr LegacyGraphics uintptr } @@ -100,6 +101,12 @@ func calculateOffsets(process *Process) Offset { questOffset := uintptr(binary.LittleEndian.Uint32(bytes)) questDataOffset := questOffset + 1 + // Ping + pattern = process.FindPattern(memory, "\x48\x8B\x0D\xCC\xCC\xCC\xCC\x49\x2B\xC7", "xxx????xxx") + bytes = process.ReadBytesFromMemory(pattern+3, 4) + relativeOffset = int32(binary.LittleEndian.Uint32(bytes)) + pingOffset := pattern - process.moduleBaseAddressPtr + 7 + uintptr(relativeOffset) + // LegacyGraphics pattern = process.FindPattern(memory, "\x80\x3D\x00\x00\x00\x00\x00\x48\x8D\x54\x24\x30", "xx?????xxxxx") legacyGfxPtr := uintptr(process.ReadUInt(pattern+2, Uint32)) @@ -120,6 +127,7 @@ func calculateOffsets(process *Process) Offset { KeyBindingsSkillsOffset: keyBindingsSkillsOffset, TZ: tzOffset, Quests: questDataOffset, + Ping: pingOffset, LegacyGraphics: legacyGfxOffset, } }