ysfc3m wrote: ↑Tue May 12, 2020 6:18 pm
I can^'t make it work. Can you go from my aob code please ? I am totally new and looking for starting point.
Use the 64-bit for 64-bit games
And 32 for 32-bit games
in 32-bit it's easy to save registers to stack using pushfd for flags and pushad for the rest of the registers then restore them by using popad and popfd. In 64-bit you have to save them manually, specially those that can affect the original code flow. This code is simply basic
but can be tedious to use. I still need to create some string manipulation codes like, strlen, strcat, strcmp so it won't need to
savefile each strings I need to save. Also I still don't have any idea howto convert floats to string.
Code: Select all
[ENABLE]
aobscanmodule(INJECT,Knight OnLine Client.bnbx,89 86 94 06 00 00 39)
alloc(newmem,$1000)
alloc(buf, 50)
alloc(buf2, $100)
label(code)
label(return)
label(hexcbuf)
label(isnum)
label(inttohex)
label(FileName)
label(crlf)
label(itoaloop)
label(itoaloop2)
label(itoaloop3)
label(inttostr)
label(savefile)
label(byteswritten)
label(hellostr)
buf: // allocated 50 bytes
db 0
buf2:
FileName:
db 'D:\games\myvaluesave.txt',0
byteswritten:
dd 0
tmp_register:
dd 0
crlf:
db 0d 0a 00
rbxstr1:
db 'esi = ',0
rbxstr2:
db ' [esi+00000694] = ',0
hellostr:
db 'HELLO',0
hexcbuf:
dd 0 0
db 0
newmem:
mov [esi+00000694],eax
// ^^^^^ ORIG code
// WRITE TO TXT FILE "HELLO"
mov dword ptr [tmp_register], esi
pushfd
pushad // I missed this at 64-bit :D
lea edx, [hellostr+0]
call savefile // Save Hello
mov eax, esi // convert to hex value of esi
call inttohex // save to hexcbuf
lea edx, [rbxstr1+0] // writes prefix first
call savefile
lea edx, [hexcbuf+0] // writes prefix first
call savefile
lea edx, [rbxstr2+0] // writes 2nd prefix first
call savefile
mov esi, dword ptr [tmp_register] // restore ebx
mov eax, dword ptr [esi+00000694] // the value of int32
call inttostr // convert to string save to buf
lea edx, [buf+0] // writes buf
call savefile
lea edx, [crlf+0] // write crlf
call savefile
popad
popfd
code:
jmp return
newmem+200:
savefile:
mov ebx, edx // buffer to write
push 0
push 80
push 4
push 0
push 0
push 4
push FileName
call CreateFileA
mov dword ptr [byteswritten], 0
mov esi, eax // move file handle to esi
mov edx, ebx
mov eax, ebx
mov ebx, FFFFFFFF
aloop: // get string length
inc ebx
cmp byte ptr [eax+ebx], 0
jnz short aloop
push 0
push [byteswritten]
push ebx // nNumberOfBytesToWrite
push eax //; lpBuffer
push esi //; hFile
call WriteFile
push esi
call CloseHandle
ret
newmem+300:
inttohex:
// put data to eax
lea edx, [hexcbuf+0]
mov ebx, 8
loophere:
mov cl, al
and cl, f
add cl, 30
cmp cl, 39
jle isnum
add cl, 7
isnum:
dec ebx
mov byte ptr [edx+ebx], cl
sar eax, 4
cmp ebx, 0
jne loophere
ret
newmem+400:
inttostr:
// put data to eax
lea ecx, [buf+0]
// initialize buf[50]
mov ebx, #50
itoaloop:
mov byte ptr [ecx], 0
inc ecx
dec ebx
cmp ebx, 0
jg itoaloop
// Convert rax to string
lea ecx, [buf+0]
xor esi, esi
mov ebx, #10
itoaloop2:
xor edx, edx
div ebx
add dl, 30
mov byte ptr [ecx], dl
inc ecx
inc esi
cmp eax, 0
jne itoaloop2
// String reverse
xor edx, edx
mov eax, esi
mov ebx, 2
div ebx
dec esi
xor ebx, ebx
lea ecx, [buf+0]
itoaloop3:
mov dl, byte ptr [ecx+ebx]
mov dh, byte ptr [ecx+esi]
mov byte ptr [ecx+ebx], dh
mov byte ptr [ecx+esi], dl
dec eax
dec esi
inc ebx
cmp eax, 0
jne itoaloop3
// Finally
ret
db 90 90 90 90
INJECT:
jmp newmem
nop
return:
registersymbol(INJECT)
[DISABLE]
INJECT:
db 89 86 94 06 00 00
unregistersymbol(INJECT)
dealloc(newmem)