I have this code in C++ works without problem. but when i transpiled to nim-lang i crashed all times.
DWORD* floatingEnumInstance = *reinterpret_cast<DWORD**>(base_address + 0x24FB358);
typedef int(__thiscall* FloatingTextGetTextType)(DWORD* floatingEnumInstance,int textType);
FloatingTextGetTextType getFloatingTextType = *reinterpret_cast<FloatingTextGetTextType>(base_address + 0x5FBDD0);
int* textType = (int*)getFloatingTextType(floatingEnumInstance, 1);
DWORD* floatingTextInstance = *reinterpret_cast<DWORD**>(base_address + 0x24FB354);
typedef void(__thiscall* FloatingTextAddInternalLine)(
DWORD* floatingTextInstance,
core::game_object* object,
int* textType,
const char* msg, float, int, int animType, DWORD);
FloatingTextAddInternalLine showFloatingText = *reinterpret_cast<FloatingTextAddInternalLine>(base_address + 0x5F1E50);
showFloatingText(
floatingTextInstance,
game->local_player,
textType,
"hello",
0.0f,
0,
0,
0
);
My actual nim code
type
cstringConstImpl {.importcpp:"const char*".} = cstring
constChar* = distinct cstringConstImpl
let floatingEnumInstance = cast[ptr ByteAddress](address + 0x24FB358)[]
type FloatingTextGetType = proc(floatingEnumInstance: ByteAddress, textType: int): int {.gcsafe, thiscall.}
let getFloatingTextType = cast[FloatingTextGetType](address + 0x5FBDD0)
let textType = cast[uint](getFloatingTextType(floatingEnumInstance, 1))
let floatingTextManagerInstance = cast[ptr ByteAddress](address + 0x24FB354)[]
type FloatingTextAddInternalLine = proc(
floatingTextInstance: ByteAddress,
target: ByteAddress,
textType: uint,
text: constChar,
idk1: float,
idk2: int,
animationType: int,
instance2: DWORD
): void {.gcsafe, thiscall.}
let showFloatingTextFunction = cast[FloatingTextAddInternalLine](address + 0x5F1E50)
showFloatingTextFunction(floatingTextManagerInstance, cast[ptr ByteAddress](self.localPlayer)[], textType, constChar("hello"), 0.0,0,0,0)
When i execute C++ code works without problem but nim code is crashing :/