Hmm gut, dann brauch ich ne Liste von allen Befehlen und den dazugehörigen Opcodes^^
Code:
Func InjectDLL($hWnd,$DllPath)
If IsHWnd($hWnd) = 0 Then
SetError(-1)
Return False
ElseIf StringLen($DllPath)<= 4 OR Stringright($DllPath, 4) <> ".dll" Then
SetError(-2)
Return False
EndIf
Local $PID,$PHandle,$PLibRemote,$ModHandle,$LoadLibRarya,$HthRead
Local $Kernel32 = DllOpen("kernel32.dll")
If $Kernel32 = -1 Then
Exit
EndIf
$PID = DLLCall("user32.dll","int","GetWindowThreadProcessId","hwnd",$hWnd,"int*",0)
If IsArray($PID) Then
$PID=$PID[2]
Else
SetError(-3)
Return False
EndIf
$PHandle = DLLCall($Kernel32,"int","OpenProcess","int",2035711,"int",0,"int",$PID)
If IsArray($PHandle) And $PHandle[0] > 0 Then
$PHandle = $PHandle[0]
ELSE
SetError(-4)
Return False
EndIf
$PLibRemote = DLLCall($Kernel32,"int","VirtualAllocEx","int",$PHandle,"short",0,"int",4096,"int",4096,"int",4)
If IsArray($PLibRemote) Then
If $PLibRemote[0] > 0 Then
$PLibRemote = $PLibRemote[0]
Else
SetError(-5)
Return False
EndIf
Else
SetError(-6)
Return False
EndIf
For $i = 0 To StringLen($DllPath)
$Ret = DLLCall("kernel32.dll","int","WriteProcessMemory","int",$PHandle,"int",$PLibRemote+$i,"int*",Asc(StringMid($DllPath,$i+1,1)),"int",1,"int",0)
If IsArray($Ret) Then
If $Ret[0] = 0 Then
SetError(-7)
Return False
EndIf
Else
SetError(-8)
Return False
EndIf
Next
$ModHandle = DLLCall($Kernel32,"long","GetModuleHandle","str","kernel32.dll")
If IsArray($ModHandle) Then
If $ModHandle[0] > 0 Then
$ModHandle = $ModHandle[0]
Else
SetError(-9)
Return False
EndIf
Else
SetError(-10)
Return False
EndIf
$LoadLibRarya = DLLCall($Kernel32,"long","GetProcAddress","long",$ModHandle,"str","LoadLibraryA")
If IsArray($LoadLibRarya) Then
If $LoadLibRarya[0] > 0 Then
$LoadLibRarya = $LoadLibRarya[0]
Else
SetError(-11)
Return False
EndIf
Else
SetError(-12)
Return False
EndIf
$HthRead = DLLCall($Kernel32,"int","CreateRemoteThread","int",$PHandle,"int",0,"int",0,"long",$LoadLibRarya,"long",$PLibRemote,"int",0,"int",0)
If IsArray($HthRead) Then
If $HthRead[0] > 0 Then
$HthRead = $HthRead[0]
Else
SetError(-13)
Return
EndIf
Else
SetError(-14)
Return False
EndIf
DLLCall($Kernel32,"int","VirtualFreeEx","int",$PHandle,"int",$PLibRemote,"int",4096,"int",32768)
DLLCall($Kernel32,"int","CloseHandle","int",$HthRead)
DLLCall($Kernel32,"int","CloseHandle","int",$PHandle)
DllClose($Kernel32)
Return True
EndFunc
Die ist halt für DLLs, aber wie kann ich einen Opcode injecten? Das ist doch ein einfacher String und nicht an einer Datei gebunden o.O