From a7605fac2bb6b17260f2dadba587363769624f5b Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 4 Feb 2021 21:47:47 +1100 Subject: [PATCH] feature: detect write failure and panic. --- internal/gohack/bhop.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/internal/gohack/bhop.go b/internal/gohack/bhop.go index be3d279..e9ac99b 100644 --- a/internal/gohack/bhop.go +++ b/internal/gohack/bhop.go @@ -8,7 +8,7 @@ import ( func RunBHOP(client *Client) { var ( - readValue byte + readValue = byte(0x0) readValuePtr = (uintptr)(unsafe.Pointer(&readValue)) writeValue = byte(0x6) writeValuePtr = (uintptr)(unsafe.Pointer(&writeValue)) @@ -21,8 +21,15 @@ func RunBHOP(client *Client) { if (readValue & (1 << 0)) > 0 { // FL_ONGROUND (1<<0) // https://github.com/ValveSoftware/source-sdk-2013/blob/master/mp/src/public/const.h client.Process.Write(client.OffsetForceJump(), writeValuePtr, unsafe.Sizeof(writeValue)) } + + readValue = 0x0 + client.Process.Read(client.OffsetForceJump(), readValuePtr, unsafe.Sizeof(readValuePtr)) + + if readValue == 0x0 { + panic("Write Error" + string(readValue) + " != " + string(writeValue)) + } } - time.Sleep(90) // 15ms tick + time.Sleep(90) } }