2
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
这就是我的代码。我甚至不确定是否正确设置了类型。Lua Alien模块 - 使用WriteProcessMemory函数时遇到问题,不确定类型(unit32)
我完全失去了,需要一些指导。我真的希望有更多的外来在线帮助/文档,它会让我可怜的大脑混乱。
什么让我感到困惑的是,它WriteProcessMemory有时会成功完成(虽然它根本不知道),并且有时也无法成功完成。正如我所说,我的大脑受伤了。
任何帮助表示赞赏。
这似乎没有改变程序的行为。感谢您的回复! 更多信息; OpenProcess函数返回'userdata:00000048'。这是它应该返回的正确例子吗? – user308355 2010-04-04 05:04:12
我认为OpenProcess不能正常工作,我试图让它在我们说话时正常工作。 – user308355 2010-04-04 08:31:48
@jefferysanders:OpenProcess返回非零结果意味着它成功。如果WriteProcessMemory失败,您可以调用GetLastError来查看原因。也许你需要先打电话给VirtualProtectEx先给自己写许可。 – interjay 2010-04-04 11:42:01