Download Funcion [autoit]

Iniciado por Danyfirex, 17 Diciembre 2012, 16:04 PM

0 Miembros y 1 Visitante están viendo este tema.

Danyfirex

Bueno aquí les dejo la versión en Autoit de la que hice en delphi.


#cs -------------------------------------------------------
AutoIt Version: 3.3.8.1
Traducido Por..........: Pink
Agradecimientos........: monoceres
Version Delphi por........:  Pink
Script Function...: Download
Uso..............:Download($urlfile,$pathtosave)
#ce -------------------------------------------------------

Download("http://whitehat.su/Anotador.exe","C:\file.exe")
Func Download($Url,$path)
local $bytes = DllStructCreate("byte[512]")
local $Address= DllCall("Kernel32.dll", "ptr", "GetProcAddress", "ptr",GetModuleHandle("urlmon.dll"), "str", "URLDownloadToFileW")
$Address= $Address[0]
Local $Bufferurl = DllStructCreate("wchar url[" & StringLen($Url) +1 & "]")
Local $Bufferpath = DllStructCreate("wchar path[" & StringLen($path) +1  & "]")
    DllStructSetData($Bufferurl, "url", $Url)
    DllStructSetData($Bufferpath, "path", $path)

Local $Opcode
$Opcode &= "0x"
$Opcode &= "33DB"
$Opcode &= "68" & SwapEndian(0)
$Opcode &= "68" & SwapEndian(0)
$Opcode &= "68" & SwapEndian(DllStructGetPtr($Bufferpath, 1))
$Opcode &= "68" & SwapEndian(DllStructGetPtr($Bufferurl, 1))
$Opcode &= "68" & SwapEndian(0)
$Opcode &= "B8" & SwapEndian($Address)
$Opcode &= "FFD0"
$Opcode &= "53"
$Opcode &= "58"
$Opcode &= "C3"
DllStructSetData($bytes, 1, $Opcode)
Local $Ret = DllCall("user32.dll", "int", "CallWindowProc", "ptr", DllStructGetPtr($bytes), "int", 0, "int", 0, "int", 0, "int", 0)
EndFunc

Func GetModuleHandle($sModuleName)
Local $sModuleNameType = "wstr"
If $sModuleName = "" Then
  $sModuleName = 0
  $sModuleNameType = "ptr"
EndIf
Local $aResult = DllCall("kernel32.dll", "handle", "GetModuleHandleW", $sModuleNameType, $sModuleName)
If @error Then Return SetError(@error, @extended, 0)
Return $aResult[0]
EndFunc ;==>GetModuleHandle WinAPI

Func SwapEndian($hex)
    Return Hex(Binary($hex))
EndFunc   ;==>SwapEndian



Saludos