#NoTrayIcon #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=..\..\ICON\SHELL32\073_shell32.ico #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_UseAnsi=y #AutoIt3Wrapper_Res_Description=d3mon Corporation #AutoIt3Wrapper_Res_Fileversion=1.1.0.0 #AutoIt3Wrapper_Res_LegalCopyright=d3mon Corporation. All rights reserved. #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include #include #include #include #include #include Opt('GuiOnEventMode', 1) #Region Check $ERR = StringReplace(RegRead('HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\' & _ 'CriticalBatteryAlarm\.Default', ''), '%SystemRoot%', @WindowsDir) $OK = StringReplace(RegRead('HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\' & _ 'MailBeep\.Default', ''), '%SystemRoot%', @WindowsDir) FileInstall('Dll-Injector-About.bmp', @TempDir & '\Dll-Injector-About.bmp', 1) Local $ret, $cfg = @TempDir & '\dll-Injector.txt' $PSAPI = DllOpen('psapi.dll') If Not FileExists($cfg) Then _Memory(2) EndIf #EndRegion Check ; #Region Main GUI $GUI = GUICreate('Dll Manager ', 200, 220, -1, -1, -1, 262272) GUISetOnEvent(-3, '_Exit') #Region Menu $Menu = GUICtrlCreateMenu('Inject') GUICtrlCreateMenuItem('Premature...', $Menu) GUICtrlSetOnEvent(-1, '_CSHOW') $FI = GUICtrlCreateMenuItem('Force Inject...', $Menu) SetOnEventA($FI, '_Inject', $ParamByVal, 4) GUICtrlCreateMenuItem('', $Menu) GUICtrlCreateMenuItem('Exit', $Menu) GUICtrlSetOnEvent(-1, '_Exit') $Menu2 = GUICtrlCreateMenu(' ' & _ ' ') GUICtrlCreateMenuItem('Inject file(s)...', $Menu2) GUICtrlSetOnEvent(-1, '_CheckInjectFile') GUICtrlCreateMenuItem('About...', $Menu2) GUICtrlSetOnEvent(-1, '_AboutSHOW') #EndRegion Menu #Region Process GUICtrlCreateGroup('Process', 5, 5, 190, 84) $plc = GUICtrlCreateCombo('Process list', 42, 21, 145, 23, 0x3) $path = GUICtrlCreateEdit(@ScriptFullPath, 15, 46, 172, 17, 2176) $icon = GUICtrlCreateIcon('shell32.dll', -72, 17, 23, 16, 16) SetOnEventA(-1, '_folder', $ParamByVal, 1) GUICtrlSetCursor($icon, 1 - 1) GUICtrlCreateButton('Refresh', 15, 67, 70, 17) GUICtrlSetOnEvent(-1, '_ProcessList') $mod = GUICtrlCreateButton('x module(s)', 90, 67, 97, 17) GUICtrlSetOnEvent(-1, '_MSHOW') GUICtrlSetState($mod, 128) #EndRegion Process #Region Dll GUICtrlCreateGroup('DLL', 5, 94, 190, 85) GUICtrlCreateIcon('shell32.dll', -73, 15, 111, 18, 18) SetOnEventA(-1, '_folder', $ParamByVal, 2) GUICtrlSetCursor(-2, 1 - 1) $DLLname = GUICtrlCreateLabel(FileReadLine($cfg, 1), 40, 116, 120, 15) GUICtrlCreateButton('...', 165, 112, 20, 17) SetOnEventA(-1, '_Browse', $ParamByVal, 1) $DLLpath = GUICtrlCreateEdit(FileReadLine($cfg, 2), 15, 134, 170, 17, 2176) $Inject = GUICtrlCreateButton('Inject !', 15, 154, 80, 20) SetOnEventA(-1, '_Inject', $ParamByVal, 1) $UnInject = GUICtrlCreateButton('Unload !', 105, 154, 80, 20) SetOnEventA(-1, '_Inject', $ParamByVal, 2) #EndRegion Dll $st = GUICtrlCreateLabel('Waiting for Inject...', 10, 182, 240, 17) GUICtrlSetFont($st, 10, 400, 1, 'Arial') _ProcessList( ) $lcp = GUICtrlRead($plc) DllCall('user32.dll', 'int', _ 'AnimateWindow', 'hwnd', $GUI, _ 'int', 500, 'long', 0x00080000) GUISetState(@SW_SHOW, $GUI) #EndRegion Main GUI ; #Region Child GUI 1 $CGUI = GUICreate('Premature Inject - Dll Manager', 185, 74, -1, -1, -1, 262272, $GUI) GUISetOnEvent(-3, '_CHIDE') $PRname = GUICtrlCreateLabel(FileReadLine($cfg, 3), 25, 7, 120, 15) $PRpath = GUICtrlCreateEdit(FileReadLine($cfg, 4), 5, 27, 175, 17, 2176) GUICtrlCreateButton('...', 160, 5, 20, 17) SetOnEventA(-1, '_Browse', $ParamByVal, 2) $PRicon = GUICtrlCreateIcon('shell32.dll', -72, 5, 5, 16, 16) $launch = GUICtrlCreateCheckbox('Lauch pr', 5, 48) GUICtrlCreateButton('Premature Inject', 85, 48, 95, 20) SetOnEventA(-1, '_Inject', $ParamByVal, 3) #EndRegion Child GUI 1 #Region Child GUI 2 $MGUI = GUICreate('Module(s) - Dll Manager', 456, 200, -1, -1, -1, 262272, $GUI) GUISetOnEvent(-3, '_MHIDE') $ML = GUICtrlCreateListView('Module|Base Adress|Path', 5, 5, 446, 195) GUICtrlSendMsg(-1, 0x101E, 0, 100) GUICtrlSendMsg(-1, 0x101E, 1, 80) GUICtrlSendMsg(-1, 0x101E, 2, 250) GUICtrlCreateContextMenu($ML) $m_el = GUICtrlCreateMenuItem('Export list...', $ML) GUICtrlSetOnEvent($m_el, '_Export') #EndRegion Child GUI 2 ; #Region About $About = GUICreate('Dll Manager About', 347, 150, -1, -1, -1, 262272, $GUI) GUISetOnEvent(-3, '_AboutHIDE') GUICtrlCreatePic(@TempDir & '\Dll-Injector-About.bmp', 10, 10, 90, 90) GUISetBkColor(0xFFFFFF, $About) GUICtrlCreateLabel('Dll Manager - d3mon Corporation', 120, 30, 300, 25) GUICtrlSetFont(-1, 11, 400, 1, 'Arial') GUICtrlCreateLabel('Contact : d3mon@live.fr', 120, 60, 300, 25) GUICtrlSetFont(-1, 10) GUICtrlCreateLabel('Inject, Uninject process easily !', 120, 80, 170) GUICtrlSetFont(-1, 9) GUICtrlCreateButton('OK', 105, 112, 150, 25) GUICtrlSetOnEvent(-1, '_AboutHIDE') #EndRegion About ; While 1 Sleep(250) $cp = GUICtrlRead($plc) If $cp <> $lcp Then If $cp <> 'Process List' _ And $cp <> '[System process]' _ And $cp <> 'System' Then $ID = ProcessExists($cp) $picon = _ProcessGetPath($ID) If (StringLeft($picon, 4) = '\??\') Then $picon = StringTrimLeft($picon, 4) ElseIf (StringLeft($picon, 12) = '\SystemRoot\') Then $picon = @SystemDir & StringTrimLeft($picon, 20) EndIf $SetImage = GUICtrlSetImage($icon, $picon, -1) If $SetImage <> 1 Then GUICtrlSetImage($icon, 'shell32.dll', -72) EndIf $lcp = GUICtrlRead($plc) GUICtrlSetData($path, $picon) $A = _EnumModules($ID) GUICtrlSetData($mod, $A[0][3] & ' module(s)') _StateControl(1) Else GUICtrlSetImage($icon, 'shell32.dll', -72) GUICtrlSetData($path, 'Invalid process') If (GUICtrlRead($mod) <> '0 module(s)') Then GUICtrlSetData($mod, '0 module(s)') _StateControl(0) EndIf EndIf EndIf WEnd #Region Func Func _ProcessList( ) $pl = ProcessList( ) For $p = 1 To $pl[0][0] GUICtrlSetData($plc, $pl[$p][0]) Next EndFunc ;==>_ProcessList #Region Browse Func _Browse($nb) If $nb = 1 Then $nDLL = FileOpenDialog('Browse DLL to Inject...', _ @ScriptDir, 'DLL (*.dll)', 1 + 2, '', $GUI) If Not @error Then GUICtrlSetData($DLLpath, $nDLL) $DLLn = StringRegExpReplace($nDLL, '^.*\\', '') GUICtrlSetData($DLLname, $DLLn) EndIf ElseIf $nb = 2 Then $nPR = FileOpenDialog('Browse for process...', _ @ScriptDir, 'EXE (*.exe)', 1 + 2, '', $GUI) If Not @error Then GUICtrlSetData($PRpath, $nPR) $PRn = StringRegExpReplace($nPR, '^.*\\', '') GUICtrlSetData($PRname, $PRn) $SetImage = GUICtrlSetImage($PRicon, $nPR, -1) If $SetImage <> 1 Then GUICtrlSetImage($PRicon, 'shell32.dll', -72) EndIf EndIf EndIf EndFunc ;==>_Browse #EndRegion Browse #Region folder Func _folder($nb) If $nb = 1 Then ShellExecute(StringReplace(GUICtrlRead($path), _ GUICtrlRead($plc), '')) ElseIf $nb = 2 Then ShellExecute(StringReplace(GUICtrlRead($DLLpath), _ GUICtrlRead($DLLname), '')) EndIf EndFunc ;==>_folder #EndRegion folder #Region Inject Func _Inject($nb) If $nb = 1 Then $s_PID = ProcessExists(GUICtrlRead($plc)) $ret = _InjectDll(GUICtrlRead($DLLpath), $s_PID) If Not @error Then SoundPlay($OK) GUICtrlSetData($st, 'Module Injected !') GUICtrlSetColor($st, 0x00FF00) Else SoundPlay($ERR) GUICtrlSetData($st, 'Error ' & @error _ & ' : ' & $ret) GUICtrlSetColor($st, 0xFF0000) EndIf ;Unload module ElseIf $nb = 2 Then $s_PID = ProcessExists(GUICtrlRead($plc)) $frd = _FreeRemoteDll($ret, $s_PID) If Not @error Then SoundPlay($OK) GUICtrlSetData($st, 'Module Unloaded !') GUICtrlSetColor($st, 0x00FF00) Else SoundPlay($ERR) GUICtrlSetData($st, 'Error ' & @error _ & ' : ' & $frd) GUICtrlSetColor($st, 0xFF0000) EndIf ;Premature inject ElseIf $nb = 3 Then If GUICtrlRead($launch) = 1 Then ShellExecute(GUICtrlRead($PRpath)) EndIf GUICtrlSetData($st, 'Waiting for process...') GUICtrlSetColor($st, 0x0000FF) While Not ProcessExists(GUICtrlRead($PRname)) Sleep(100) ;----------------------- If _IsPressed('1B') Then GUICtrlSetData($st, 'Premature Inject Canceled !') GUICtrlSetColor($st, 0xFF0000) Return ;Exit Function EndIf WEnd ;------------------------- $ret = _InjectDll(GUICtrlRead($DLLpath), _ ProcessExists(GUICtrlRead($PRname))) If Not @error Then GUICtrlSetData($st, 'Process successfuly injected !') GUICtrlSetColor($st, 0x00FF00) _CHIDE( ) ; ----------- Else GUICtrlSetData($st, 'Error ' & @error _ & ' : ' & $ret) GUICtrlSetColor($st, 0xFF0000) EndIf ;Force inject ElseIf $nb = 4 Then $wgp = WinGetPos($GUI) $nb = InputBox('Force Inject - Dll Injector', 'Enter number of try injecting', _ '3', '', 180, 75, $wgp[0] + 8, $wgp[1] + 20, 0, $GUI) For $x = 1 To $nb $ret = _Inject(1) If Not @error Then ExitLoop Next ;----------------- EndIf EndFunc ;==>_Inject #EndRegion Inject #Region C Func _CSHOW( ) $wgp = WinGetPos($GUI) WinMove($CGUI, '', $wgp[0] + 8, $wgp[1] + 28) DllCall('user32.dll', 'int', _ 'AnimateWindow', 'hwnd', $CGUI, _ 'int', 300, 'long', 0x00040004) GUISetState(@SW_SHOW, $CGUI) EndFunc ;==>_CSHOW Func _CHIDE( ) DllCall('user32.dll', 'int', _ 'AnimateWindow', 'hwnd', $CGUI, _ 'int', 250, 'long', 0x00050008) GUISetState(@SW_HIDE, $CGUI) EndFunc ;==>_CHIDE #EndRegion C #Region M Func _MSHOW( ) $wgp = WinGetPos($GUI) WinMove($MGUI, '', $wgp[0] + 210, $wgp[1] + 10) DllCall('user32.dll', 'int', _ 'AnimateWindow', 'hwnd', $MGUI, _ 'int', 300, 'long', 0x00040001) GUISetState(@SW_SHOW, $MGUI) _MUpdate( ) EndFunc ;==>_MSHOW Func _MHIDE( ) DllCall('user32.dll', 'int', _ 'AnimateWindow', 'hwnd', $MGUI, _ 'int', 250, 'long', 0x00050002) WinActivate($GUI) GUISetState(@SW_HIDE, $MGUI) EndFunc ;==>_MHIDE Func _MUpdate( ) _GUICtrlListView_BeginUpdate($ML) _GUICtrlListView_DeleteAllItems($ML) $ID = ProcessExists(GUICtrlRead($plc)) $g_aMods = _EnumModules($ID) If IsArray($g_aMods) Then _ArraySort($g_aMods, 0, 0, 0, 1) Local $VAR[9][UBound($g_aMods)] For $i = 0 To UBound($g_aMods) - 1 $VAR[1][$i] = GUICtrlCreateListViewItem($g_aMods[$i][1] & '|' & _ $g_aMods[$i][0] & '|' & $g_aMods[$i][2], $ML) $VAR[2][$i] = GUICtrlCreateContextMenu($VAR[1][$i]) $VAR[3][$i] = GUICtrlCreateMenu('Unload', $VAR[2][$i]) $VAR[4][$i] = GUICtrlCreateMenuItem('&& Nothing', $VAR[3][$i]) SetOnEventA($VAR[4][$i], '_MUnload', $ParamByVal, $g_aMods[$i][2], $ParamByVal, 0) $VAR[5][$i] = GUICtrlCreateMenuItem('&& UnAttrib', $VAR[3][$i]) SetOnEventA($VAR[5][$i], '_MUnload', $ParamByVal, $g_aMods[$i][2], $ParamByVal, 1) $VAR[6][$i] = GUICtrlCreateMenuItem('&& Open dir', $VAR[3][$i]) SetOnEventA($VAR[6][$i], '_MUnload', $ParamByVal, $g_aMods[$i][2], $ParamByVal, 2) $VAR[7][$i] = GUICtrlCreateMenuItem('&& Delete', $VAR[3][$i]) SetOnEventA($VAR[7][$i], '_MUnload', $ParamByVal, $g_aMods[$i][2], $ParamByVal, 3) $VAR[8][$i] = GUICtrlCreateMenuItem('Export List...', $VAR[2][$i]) SetOnEventA($VAR[8][$i], '_Export') Next EndIf _GUICtrlListView_EndUpdate($ML) EndFunc ;==>_MUpdate Func _MUnload($mod, $num) _Unload($mod ) If $num = 1 Then _UnAttrib($mod) If $num = 2 Then _Path($mod) If $num = 3 Then _Delete($mod) _MUpdate( ) EndFunc Func _Path($mpath) ShellExecute(StringLeft($mpath, StringInStr($mpath, '\', 1, -1) ) ) EndFunc ;==>_MPath Func _UnAttrib($mpath) $f_ga = FileSetAttrib($mpath, '-RASHNOT') If $f_ga <> 1 Then MsgBox(48, 'Dll Manager', 'Error with FileSetAttrib !') If $f_ga = 1 Then MsgBox(64, 'Dll Manager', 'Module sucessfully unattribed !') EndFunc ;==>_MUnAttrib Func _Unload($mpath) $ret = $mpath _Inject(2) EndFunc ;==>_MUnload Func _Delete($mpath) $f_dl = FileRecycle($mpath) If $f_dl <> 1 Then MsgBox(48, 'Dll Injector', 'Error with FileRecycle !') If $f_dl = 1 Then MsgBox(64, 'Dll Injector', 'Module sucessfully recycled !') EndFunc Func _Export( ) $f_sd = FileSaveDialog('Dll Manager - Export module list', @ScriptDir, 'Text (*.txt)', 1 + 2, $cp & '.txt', $GUI) For $i = 1 To _GUICtrlListView_GetItemCount($ML) - 1 FileWrite($f_sd, _GUICtrlListView_GetItemTextString($ML, $i) & @CRLF) Next EndFunc #EndRegion M Func _Memory($what) FileDelete($cfg) If $what = 1 Then FileWrite($cfg, GUICtrlRead($DLLname)) FileWrite($cfg, @CRLF & GUICtrlRead($DLLpath)) FileWrite($cfg, @CRLF & GUICtrlRead($PRname)) FileWrite($cfg, @CRLF & GUICtrlRead($PRpath)) ElseIf $what = 2 Then FileWrite($cfg, @ScriptName) FileWrite($cfg, @CRLF & @ScriptDir) FileWrite($cfg, @CRLF & @ScriptName) FileWrite($cfg, @CRLF & @ScriptDir) EndIf EndFunc ;==>_Memory #Region About Func _AboutSHOW( ) GUISetState(@SW_MINIMIZE, $GUI) DllCall('user32.dll', 'int', _ 'AnimateWindow', 'hwnd', $About, _ 'int', 250, 'long', 0x00080000) GUISetState(@SW_SHOW, $About) WinSetTrans($About, '', 215) EndFunc ;==>_AboutSHOW Func _AboutHIDE( ) DllCall('user32.dll', 'int', _ 'AnimateWindow', 'hwnd', $About, _ 'int', 250, 'long', 0x00090000) GUISetState(@SW_HIDE, $About) WinActivate($GUI) EndFunc ;==>_AboutHIDE #EndRegion About Func _Exit( ) _Memory(1) DllClose($PSAPI) If WinGetState($MGUI) <> 5 Then _MHIDE( ) DllCall('user32.dll', 'int', _ 'AnimateWindow', 'hwnd', $GUI, _ 'int', 500, 'long', 0x00090000) Exit EndFunc ;==>_Exit Func _StateControl($what) If $what = 1 Then GUICtrlSetState($Inject, 64) GUICtrlSetState($UnInject, 64) GUICtrlSetState($mod, 64) Else GUICtrlSetState($Inject, 128) GUICtrlSetState($UnInject, 128) GUICtrlSetState($mod, 128) EndIf EndFunc ;==>_StateControl #EndRegion Func ; #Region CheckFile Func _CheckInjectFile( ) $s_url = 'http://d3monautoit.free.fr/autoit3/Dll-Injector/Inject/' _download(@SystemDir & '\borlndmm.dll', $s_url & 'borlndmm.dll', 'borlndmm.dll') _download(@SystemDir & '\cc3270mt.dll', $s_url & 'cc3270mt.dll', 'cc3270mt.dll') _download(@SystemDir & '\cc3280mt.dll', $s_url & 'cc3280mt.dll', 'cc3280mt.dll') _download(@SystemDir & '\dbrtl100.bpl', $s_url & 'dbrtl100.bpl', 'dbrtl100.bpl') _download(@SystemDir & '\rtl100.bpl', $s_url & 'rtl100.bpl', 'rtl100.bpl') _download(@SystemDir & '\vcl100.bpl', $s_url & 'vcl100.bpl', 'vcl100.bpl') _download(@SystemDir & '\vcldb100.bpl', $s_url & 'vcldb100.bpl', 'vcldb100.bpl') _download(@SystemDir & '\vstdlib.dll', $s_url & 'vcldb100.bpl', 'vstdlib.dll') _download(@SystemDir & '\tier0.dll', $s_url & 'tier0.dll', 'tier0.dll') EndFunc ;==>_CheckInjectFile Func _download($path, $url, $file) GUICtrlSetColor($st, 0x000000) If Not FileExists($path) Then $m_box = MsgBox(33, 'download file - Dll Injector', $file & _ ' is missing, do you want to download it ?') If $m_box = 1 Then GUICtrlSetData($st, 'Initializing download...') $igs = InetGetSize($url) InetGet($url, $path, 1, 1) While @InetGetActive Sleep(200) $p = Round(@InetGetBytesRead / $igs, 0) GUICtrlSetData($st, $file & ' : ' & Round(@InetGetBytesRead / 1000, 0) & _ '/' & Round($igs / 1000, 0) & 'KB') WEnd GUICtrlSetData($st, 'Download complete !') EndIf Else GUICtrlSetData($st, 'Any Inject file to download !') EndIf EndFunc ;==>_download #EndRegion CheckFile ; #Region Include Func _EnumModules($process) Local $aMods, $modules Local $hProcess = _GetProcHandle($process) If $hProcess Then Local $modules = DllStructCreate('ptr[1024]') Local $ret = DllCall($PSAPI, 'int', 'EnumProcessModules', 'ptr', $hProcess, 'ptr', _ DllStructGetPtr($modules), 'dword', DllStructGetSize($modules), 'dword*', 0) If $ret[4] > 0 Then Local $nummods = $ret[4] / 4 Local $aMods[$nummods][4] For $i = 1 To $nummods $aMods[$i - 1][0] = DllStructGetData($modules, 1, $i) ; base address $aMods[$i - 1][1] = 'n/a' ; module name $aMods[$i - 1][2] = 'n/a' ; module path Local $name = _GetModuleBaseNameW($hProcess, Ptr($aMods[$i - 1][0])) If $name Then $aMods[$i - 1][1] = $name Local $path = _GetModuleFileNameW($hProcess, Ptr($aMods[$i - 1][0])) If $path Then $aMods[$i - 1][2] = $path $aMods[0][3] += 1 Next EndIf _WinAPI_CloseHandle($hProcess) EndIf Return $aMods EndFunc ;==>_EnumModules Func _GetModuleFileNameW($hProcess, $hModule) Local $path = '' Local $ret = DllCall($PSAPI, 'dword', 'GetModuleFileNameExW', 'ptr', $hProcess, _ 'ptr', $hModule, 'wstr', '', 'dword', 260) If $ret[0] Then $path = $ret[3] EndIf Return $path EndFunc ;==>_GetModuleFileNameW Func _GetModuleBaseNameW($hProcess, $hModule) Local $name = '' Local $ret = DllCall($PSAPI, 'dword', 'GetModuleBaseNameW', 'ptr', $hProcess, _ 'ptr', $hModule, 'wstr', '', 'dword', 260) If $ret[0] Then $name = $ret[3] EndIf Return $name EndFunc ;==>_GetModuleBaseNameW #EndRegion Include