Lua Alien Module - Trouble using WriteProcessMemory function, unsure on types (unit32)

Posted by jefferysanders on Stack Overflow See other posts from Stack Overflow or by jefferysanders
Published on 2010-04-03T16:24:54Z Indexed on 2010/04/03 16:33 UTC
Read the original article Hit count: 445

Filed under:
|
require "alien"

--the address im trying to edit in the Mahjong game on Win7
local SCOREREF = 0x0744D554 
--this should give me full access to the process
local ACCESS = 0x001F0FFF
--this is my process ID for my open window of Mahjong
local PID = 1136

--function to open proc
local op = alien.Kernel32.OpenProcess
op:types{ ret = "pointer", abi = "stdcall"; "int", "int", "int"}

--function to write to proc mem
local wm = alien.Kernel32.WriteProcessMemory
wm:types{ ret = "long", abi = "stdcall"; "pointer", "pointer", "pointer", "long", "pointer" }


local pRef = op(ACCESS, true, PID)
local buf = alien.buffer("99")

--         ptr,uint32,byte arr (no idea what to make this),int, ptr
print( wm( pRef, SCOREREF, buf, 4, nil))
--prints 1 if success, 0 if failed

So that is my code. I am not even sure if I have the types set correctly.

I am completely lost and need some guidance. I really wish there was more online help/documentation for alien, it confuses my poor brain.

What utterly baffles me is that it WriteProcessMemory will sometimes complete successfully (though it does nothing at all, to my knowledge) and will also sometimes fail to complete successfully. As I've stated, my brain hurts.

Any help appreciated.

© Stack Overflow or respective owner

Related posts about lua

Related posts about alien