Версия для печати темы

Нажмите сюда для просмотра этой темы в обычном формате

UoKit.com Форумы _ UO Pilot _ Readmem Double

Автор: Drakono 8.12.2021, 14:01

Hi guys. Sorry it's in english. Was hard to register biggrin.gif

I have problem with newest release of UoPilot.
I'm trying to use readmem in one game based on tibia, but most of the values are stored as Double value.
CheatEngine is showing these values corectly.
Изображение
And my script is reading exact same pointer, but result is always 0. It looks like Pilot is reading double values like 4bytes values.
Изображение
Tried to use readmem as double on different address which I know is stored as 4bytes and result was that Pilot read it as 4 bytes.
Do you have any ways in Lua to read double values correctly?

Автор: cirus 8.12.2021, 14:38

Цитата
B:byte = 1b
W:word = 2b
D:dWord = 4b
C:char = 1b
S:String = 1-255b
DO:double = 8b
F:float = 4b
R:real = 6b


Автор: Drakono 8.12.2021, 19:28

If it reads double as just 8bytes then on this adress it should show value: 4645040803167600640.
This value is shown on this adress in CheatEngine when i change type from double to 8 bytes.
PlayerX value which is 4 byte when changed to 8 bytes in CheatEngine shows value: 3895535338477
So something is quite not right with how UoPilot reads double from memory.

Автор: Drakono 14.12.2021, 20:13

Does anyone on this forum has idea if it will be possible to use ffi and make double value pointer to adress with double value and use it in the script? Tried to do it for few days since there is no response, but couldn't make it work. :C

Автор: cirus 14.12.2021, 20:57

https://forum.uokit.com/index.php?s=&showtopic=70333&view=findpost&p=437715
Use double instead of float.

Автор: Drakono 15.12.2021, 2:56

It worked. Now I can make function that will update all information about my character. Thank you my friend. You are the beast of Lua.

Автор: Drakono 15.12.2021, 3:40

Here is the modified code for other people that want to read double




--lua
local PROCESS_VM_READ = 0x0010
local ffi = require("ffi")
local user, kernel = ffi.load('User32'), ffi.load('Kernel32')
ffi.cdef[[
int OpenProcess(int dwDesiredAccess, bool bInheritHandle, int dwProcessId);
int GetWindowThreadProcessId(int hWnd, int *lpdwProcessId);
bool CloseHandle(int hObject);
bool ReadProcessMemory(int hProcess, int lpBaseAddress, void *lpBuffer, int nSize, int *lpNumberOfBytesRead);
]]
function readmemory(address)
if workwindow() == 0 then log('No Workwindow') return -1 end
local PID, pointer_double = ffi.new('unsigned long[1]'), ffi.new('double[1]')
user.GetWindowThreadProcessId(workwindow(), PID)
local process = kernel.OpenProcess(PROCESS_VM_READ, true, PID[0])
if process > 0 then
kernel.ReadProcessMemory(process, address, pointer_double, 8, nil)
kernel.CloseHandle(process);
return tonumber(pointer_double[0])
end
log('Proccess not open.') return -2
end
playerptr = readmem (0xAB0F78, "D")
local hp = readmemory(playerptr + 0x4b0) --this is Double
playerX = readmem (0xAB14C8, "double") --this is 4byte
log ('clear')
log ("HP= ",hp," ", "PlayerX = ",playerX)

Русская версия Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)