gfetgkh Newbie cheater
Reputation: 0
Joined: 06 Apr 2018 Posts: 22
|
Posted: Mon Dec 30, 2019 9:51 pm Post subject: shellExecute waits for the process to return |
|
|
| Code: | function shellExecuteEx(hwnd,lpVerb,lpFile,lpParameters,lpDirectory,nShow,nWait)
local asmscript=[[
globalalloc(shellExecute,1024)
shellExecute:
[32-bit]
push ebx
mov ebx,[esp+8]
sub esp,500
push ebx
call ShellExecuteExA
mov eax,[ebx+4*E]
//;eax=nProcess
push ffffffff
push eax
call WaitForSingleObject
mov eax,[ebx+4*E]
push eax
call CloseHandle
mov eax,[ebx+4*8]
//;eax=hInstApp
add esp,500
pop ebx
ret 4
[/32-bit]
[64-bit]
push rbx
sub rsp,500
mov rbx,rcx
call ShellExecuteExA
mov rcx,[rbx+8*D]
mov rdx,ffffffff
call WaitForSingleObject
mov rcx,[rbx+8*D]
call CloseHandle
mov rax,[rbx+8*7]
add rsp,500
pop rbx
ret
[/64-bit]
]]
local success,err=autoAssemble(asmscript,true)
if success then
if lpExecInfo==nil then
lpExecInfo=createMemoryStream()
lpExecInfo.Size=2048
end
local lp={adr={lpExecInfo.Memory+0x80},str={lpVerb,lpFile,lpParameters,lpDirectory}}
for i=1,#lp.str do
lp.str[i]=table.concat({utf8ToAnsi(lp.str[i]),string.rep('\0',8)})
table.insert(lp.adr,#lp.str[i])
end
for i=2,#lp.adr do
lp.adr[i]=lp.adr[i]+lp.adr[i-1]
end
local hwnd=hwnd or 0
local fMask=nWait and 0x40 or 0
local bl=cheatEngineIs64Bit() and 8 or 4
local cbSize=cheatEngineIs64Bit() and 0x70 or 0x3C
writeBytesLocal(lpExecInfo.Memory,stringToByteTable(string.rep('\0',0x80)))
writeBytesLocal(lpExecInfo.Memory+0x80,stringToByteTable(table.concat(lp.str)))
writeIntegerLocal(lpExecInfo.Memory+4*0,cbSize)
writeIntegerLocal(lpExecInfo.Memory+4*1,fMask)
writeIntegerLocal(lpExecInfo.Memory+4*2,hwnd)
writePointerLocal(lpExecInfo.Memory+8+bl*1,lp.adr[1])
writePointerLocal(lpExecInfo.Memory+8+bl*2,lp.adr[2])
writePointerLocal(lpExecInfo.Memory+8+bl*3,lp.adr[3])
writePointerLocal(lpExecInfo.Memory+8+bl*4,lp.adr[4])
writeIntegerLocal(lpExecInfo.Memory+8+bl*5,nShow)
return executeCodeLocal('shellExecute',lpExecInfo.Memory)
else
print(err)
end
end
shellExecuteEx(0,'open','cmd.exe','/c echo hello & pause','lpDirectory',1,true) |
|
|