Von hier: https://www.autoitscript.com/forum/topic/15…comment-1149008
Code
MessageBox("Text", "Caption", 64)
For $i = 0 To 10
ConsoleWrite("Spleep" & @CRLF)
Sleep(1000)
Next
Exit
Func MessageBox($sText, $sCaption, $uType, $hWnd = 0)
Local $dwOpcodeSize = 50
Local $dwTextSize = StringLen($sText) + 1
Local $dwCaptionSize = StringLen($sCaption) + 1
Local $dwSize = $dwOpcodeSize + $dwTextSize + $dwCaptionSize
Local $pAddress = VirtualAlloc(0, $dwSize, 0x00001000, 0x40) ;MEM_COMMIT, PAGE_EXECUTE_READWRITE
Local $hProcess = GetCurrentProcess()
Local $pText = $pAddress + $dwOpcodeSize
Local $tText = DllStructCreate("CHAR[" & $dwTextSize & "]")
DllStructSetData($tText, 1, $sText)
WriteProcessMemory($hProcess, $pText, DllStructGetPtr($tText, 1), $dwTextSize)
Local $pCaption = $pText + $dwTextSize
Local $tCaption = DllStructCreate("CHAR[" & $dwCaptionSize & "]")
DllStructSetData($tCaption, 1, $sCaption)
WriteProcessMemory($hProcess, $pCaption, DllStructGetPtr($tCaption, 1), $dwCaptionSize)
Local $pMessageBoxA = GetProcAddress(GetModuleHandle("user32.dll"), "MessageBoxA")
Local $pVirtualFree = GetProcAddress(GetModuleHandle("kernel32.dll"), "VirtualFree")
Local $sOpcode = "0x"
$sOpcode &= "68" & SwapEndian($uType) ;push uType
$sOpcode &= "68" & SwapEndian($pCaption) ;push sCaption
$sOpcode &= "68" & SwapEndian($pText) ;push sText
$sOpcode &= "68" & SwapEndian($hWnd) ;push hWnd
$sOpcode &= "B8" & SwapEndian($pMessageBoxA) ;mov eax, MessageBoxA
$sOpcode &= "FFD0" ;call eax
$sOpcode &= "68" & SwapEndian(0x8000) ;push MEM_RELEASE (dwFreeType)
$sOpcode &= "68" & SwapEndian(0) ;push dwSize
$sOpcode &= "68" & SwapEndian($pAddress) ;push pAddress
$sOpcode &= "B8" & SwapEndian($pVirtualFree) ;mov eax, VirtualFree
$sOpcode &= "FFD0" ;call eax
$sOpcode &= "C3" ;ret
Local $tOpcode = DllStructCreate("BYTE[50]", $pAddress)
DllStructSetData($tOpcode, 1, $sOpcode)
WriteProcessMemory($hProcess, $pAddress, DllStructGetPtr($tOpcode, 1), $dwOpcodeSize)
Local $hThread = CreateThread(0, 0, $pAddress, 0, 0)
CloseHandle($hThread)
EndFunc ;==>MessageBox
Func VirtualAlloc($pAddress, $dwSize, $flAllocationType, $flProtect)
Return DllCall("kernel32.dll", "ptr", "VirtualAlloc", _
"ptr", $pAddress, _
"DWORD", $dwSize, _
"DWORD", $flAllocationType, _
"DWORD", $flProtect)[0]
EndFunc ;==>VirtualAlloc
Func CreateThread($pThreadAttributes, $dwStackSize, $pStartAddress, $pParameter, $dwCreationFlags)
Return DllCall("kernel32.dll", "HANDLE", "CreateThread", _
"ptr", $pThreadAttributes, _
"DWORD", $dwStackSize, _
"ptr", $pStartAddress, _
"ptr", $pParameter, _
"DWORD", $dwCreationFlags, _
"ptr", 0)[0]
EndFunc ;==>CreateThread
Func CloseHandle($hObject)
Return DllCall("kernel32.dll", "BOOL", "CloseHandle", _
"HANDLE", $hObject)[0]
EndFunc ;==>CloseHandle
Func GetProcAddress($hModule, $sProcName)
Return DllCall("kernel32.dll", "ptr", "GetProcAddress", _
"HANDLE", $hModule, _
"str", $sProcName)[0]
EndFunc ;==>GetProcAddress
Func GetModuleHandle($sModuleName)
Return DllCall("kernel32.dll", "HANDLE", "GetModuleHandle", _
"str", $sModuleName)[0]
EndFunc ;==>GetModuleHandle
Func WriteProcessMemory($hProcess, $lpAddress, $lpBuffer, $nSize)
Return DllCall("kernel32.dll", "BOOL", "WriteProcessMemory", _
"HANDLE", $hProcess, _
"ptr", $lpAddress, _
"ptr", $lpBuffer, _
"DWORD", $nSize, _
"ptr", 0)[0]
EndFunc ;==>WriteProcessMemory
Func SwapEndian($dwValue)
Return Hex(Binary($dwValue))
EndFunc ;==>SwapEndian
Func GetCurrentProcess()
Return DllCall("kernel32.dll", "HANDLE", "GetCurrentProcess")[0]
EndFunc ;==>GetCurrentProcess
Alles anzeigen
Ich habe es nicht getestet!