Sign in to follow this  
Followers 0
wolf9228

Work_With_Two_process Second version

1 post in this topic

New In this version
- Other method by which to read the memory of the child process without stopping the child process

loops As happens when send a message to a child process ,the child process is working non-stop

like thread
- General improvements to the functionality of the project

Two_Process_Library

Two_Process_Library_Second.zip

Two_Process_Library.au3

#include "Two_Process_Library_Constants.au3"

Func Work_With_Two_process($WaitChildProcess = True , $Timeout = 5000)
If $CmdLine[0] = 0 Then
$PrProcessID = _WinAPI_GetCurrentProcessID()
$PrhWnd = GUICreate("",0,0)
$UntCallMsg = RegisterWindowMessage("WM_CALLMSG",String($PrhWnd & $PrProcessID),$GlobalPassword)
$UntCoueMsg = RegisterWindowMessage("WM_CONTINUE",String($PrhWnd & $PrProcessID),$GlobalPassword)
GUIRegisterMsg($UntCallMsg,"CallMsgFunc")
GUIRegisterMsg($UntCoueMsg,"ContinueMsgFunc")
$Command = "RunChildProcess " & String($PrProcessID) & " " & String($PrhWnd)
if (@Compiled) Then
Run(FileGetShortName(@AutoItExe) & " " & $Command)
Else
Run(FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptFullPath) & " " & $Command)
EndIf
if ($WaitChildProcess) Then
$begin = TimerInit()
While Not ($ChProcessID) And TimerDiff($begin) < $Timeout
WEnd
EndIf
$GlobalParticularProcess = "ParentProcess"
Else
If ($CmdLine[0] = 3 And $CmdLine[1] == "RunChildProcess") Then
Opt("TrayIconHide", 1)
$PrProcessID = int($CmdLine[2])
$PrhWnd = HWnd($CmdLine[3])
$ChProcessID = _WinAPI_GetCurrentProcessID()
$ChhWnd = GUICreate("",0,0)
$UntCallMsg = RegisterWindowMessage("WM_CALLMSG",String($PrhWnd & $PrProcessID),$GlobalPassword)
$UntCoueMsg = RegisterWindowMessage("WM_CONTINUE",String($PrhWnd & $PrProcessID),$GlobalPassword)
GUIRegisterMsg($UntCallMsg,"CallMsgFunc")
GUIRegisterMsg($UntCoueMsg,"ContinueMsgFunc")
$RT = _SendMessage($PrhWnd,$UntCoueMsg,1,$ChProcessID)
if $RT <> $MsgOk Then Exit
$RT = _SendMessage($PrhWnd,$UntCoueMsg,2,$ChhWnd)
if $RT <> $MsgOk Then Exit
$GlobalParticularProcess = "ChildProcess"
Else
Exit
EndIf
EndIf
Return $GlobalParticularProcess
EndFunc

Func IsParentProcessWork($pTime = 5000)
if (TimerDiff($pbeginA) < $pTime) Then Return SetError(0,1,True)
if ($PrProcessID) And Not ProcessExists($PrProcessID) Then Return SetError(1,0,False)
$pbeginA = TimerInit()
Return True
EndFunc

Func IsChildProcessWork($pTime = 5000)
if (TimerDiff($pbeginB) < $pTime) Then Return SetError(0,1,True)
if ($ChProcessID) And Not ProcessExists($ChProcessID) Then Return SetError(1,0,False)
$pbeginB = TimerInit()
Return True
EndFunc

Func CloseParentProcess()
Return ProcessClose($PrProcessID)
EndFunc

Func CloseChildProcess()
Return ProcessClose($ChProcessID)
EndFunc

Func ContinueMsgFunc($hWnd,$Msg,$wParam,$lParam)
Select
Case $wParam = 1
$ChProcessID = int($lParam)
Return $MsgOk
Case $wParam = 2
$ChhWnd = HWnd($lParam)
Return $MsgOk
Case $wParam = 3
Return $MsgOk
EndSelect
Return 0
EndFunc

Func CallFunc($FuncName,$ReturnDirectly,$Param1 = 0,$Param2 = 0 ,$Param3 = 0 , _
$Param4 = 0 ,$Param5 = 0 ,$Param6 = 0 ,$Param7 = 0 ,$Param8 = 0 ,$Param9 = 0 , _
$Param10 = 0,$Param11 = 0,$Param12 = 0,$Param13 = 0,$Param14 = 0,$Param15 = 0, _
$Param16 = 0,$Param17 = 0,$Param18 = 0,$Param19 = 0,$Param20 = 0,$Param21 = 0, _
$Param22 = 0,$Param23 = 0,$Param24 = 0,$Param25 = 0,$Param26 = 0,$Param27 = 0, _
$Param28 = 0,$Param29 = 0,$Param30 = 0,$Param31 = 0,$Param32 = 0,$Param33 = 0)
;$FuncName Name Of function that will be invoked
;BOOL $ReturnDirectly if true will return immediately
;Other parameters are parameters which function will be invoked
;Parameter data types (DllStruct,Binary,Boolean,hWnd,Int,Float,String )
;return
;Success: results of an ReturnStruct function Or One
;Failure: zero

Local $ParamsArray[1] ,$ElementNu = 0 , $TagParamStruct = ""
For $i = 1 To @NumParams - 2
ReDim $ParamsArray[$i]
$Param = Eval(String("Param" & $i))
Select
Case IsString($Param)
$ParamsArray[$i - 1] = 1
$TagParamStruct &= "INT ParamType" & $i & ";CHAR ParamData" & $i & "[" & StringLen($Param) & "];"
Case IsBinary($Param)
$ParamsArray[$i - 1] = 2
$TagParamStruct &= "INT ParamType" & $i & ";BYTE ParamData" & $i & "[" & BinaryLen($Param) & "];"
Case IsInt($Param)
$ParamsArray[$i - 1] = 3
$TagParamStruct &= "INT ParamType" & $i & ";INT ParamData" & $i & ";"
Case IsFloat($Param)
$ParamsArray[$i - 1] = 4
$TagParamStruct &= "INT ParamType" & $i & ";DOUBLE ParamData" & $i & ";"
Case IsBool($Param)
$ParamsArray[$i - 1] = 5
$TagParamStruct &= "INT ParamType" & $i & ";BOOL ParamData" & $i & ";"
Case IsDllStruct($Param)
$ParamsArray[$i - 1] = 6
$TagParamStruct &= "INT ParamType" & $i & ";BYTE ParamData" & $i & "[" & DllStructGetSize($Param) & "];"
Case IsPtr($Param)
$ParamsArray[$i - 1] = 7
$TagParamStruct &= "INT ParamType" & $i & ";PTR ParamData" & $i & ";"
Case Else
Return SetError(1,0,0)
EndSelect
Next
$TagParamStruct = "INT Len;CHAR TagParamStruct[];INT NumParams;" & $TagParamStruct
$Len = StringLen($FuncName) + StringLen($TagParamStruct) + 1
$Len += StringLen($Len)
$TagParamStruct = StringReplace($TagParamStruct,"[]","[" & $Len & "]")
$GlobalParamStruct = DllStructCreate($TagParamStruct)
$ElementNu += 1
DllStructSetData($GlobalParamStruct,$ElementNu,$Len)
$ElementNu += 1
DllStructSetData($GlobalParamStruct,$ElementNu,$FuncName & "|" & $TagParamStruct)
$ElementNu += 1
DllStructSetData($GlobalParamStruct,$ElementNu,@NumParams - 2)
For $i = 1 To @NumParams - 2
$Param = Eval(String("Param" & $i))
$ElementNu += 1
DllStructSetData($GlobalParamStruct,$ElementNu,$ParamsArray[$i - 1])
$ElementNu += 1
Select
Case $ParamsArray[$i - 1] = 6
$OutPtr = DllStructGetPtr($GlobalParamStruct,$ElementNu)
_MemMoveMemory($Param,$OutPtr,DllStructGetSize($Param))
Case Else
DllStructSetData($GlobalParamStruct,$ElementNu,$Param)
EndSelect
Next
$ParamsPtr = DllStructGetPtr($GlobalParamStruct)
Sleep(300)
Local $WindowHandle = 0
Select
Case $GlobalParticularProcess == "ParentProcess"
$WindowHandle = $ChhWnd
Case $GlobalParticularProcess == "ChildProcess"
$WindowHandle = $PrhWnd
EndSelect
if ($ReturnDirectly) Then
$RT = _SendMessage($WindowHandle,$UntCallMsg,1,$ParamsPtr)
Return SetError($RT = 0,0,$RT)
Else
$pResultsStructPtr = _SendMessage($WindowHandle,$UntCallMsg,0,$ParamsPtr)
$LenStruct = Read_Ptr($ChProcessID,$pResultsStructPtr,"INT Len")
if Not IsDllStruct($LenStruct) Then Return SetError(1,0,0)
$jLen = DllStructGetData($LenStruct,1)
$pTagResultsStruct = "INT Len;CHAR TagResultsStruct[" & $jLen & "];PTR ResultsPtr"
$pResultsStruct = Read_Ptr($ChProcessID,$pResultsStructPtr,$pTagResultsStruct)
if Not IsDllStruct($pResultsStruct) Then Return SetError(1,0,0)
$TagResultsStruct = DllStructGetData($pResultsStruct,2)
$ResultsPtr = DllStructGetData($pResultsStruct,3)
$ResultsStruct = Read_Ptr($ChProcessID,$ResultsPtr,$TagResultsStruct)
if Not IsDllStruct($ResultsStruct) Then Return SetError(1,0,0)
$GlobalpResultsStruct = $pResultsStruct
$GlobalResultsStruct = $ResultsStruct
Return SetError(0,0,$ResultsStruct)
EndIf
EndFunc

Func ReturnStruct($TagResultsStruct,$ResultsStruct)
if Not IsDllStruct($ResultsStruct) Then Return 0
$jLen = StringLen($TagResultsStruct)
$ResultsPtr = DllStructGetPtr($ResultsStruct)
$pTagResultsStruct = "INT Len;CHAR TagResultsStruct[" & $jLen & "];PTR ResultsPtr"
$pResultsStruct = DllStructCreate($pTagResultsStruct)
if Not IsDllStruct($pResultsStruct) Then Return 0
DllStructSetData($pResultsStruct,1,$jLen)
DllStructSetData($pResultsStruct,2,$TagResultsStruct)
DllStructSetData($pResultsStruct,3,$ResultsPtr)
$GlobalResultsStruct = $ResultsStruct
$GlobalpResultsStruct = $pResultsStruct
Return DllStructGetPtr($pResultsStruct)
EndFunc

Func CallMsgFunc($hWnd,$Msg,$wParam,$lParam)
Local $NumParams = 0, $ElementNu = 0 , $TagParamStruct = "" , $Len = 0
Local $ProcessID = -1
Select
Case $GlobalParticularProcess == "ParentProcess"
$ProcessID = $ChProcessID
Case $GlobalParticularProcess == "ChildProcess"
$ProcessID = $PrProcessID
EndSelect
$LenStruct = Read_Ptr($ProcessID,$lParam,"INT Len")
$ElementNu += 1
$Len = DllStructGetData($LenStruct,$ElementNu)
$GlobalParamStruct = Read_Ptr($ProcessID,$lParam,"INT Len;CHAR TagParamStruct[" & $Len & "];")
$ElementNu += 1
$TagParamStruct = DllStructGetData($GlobalParamStruct,2)
$Split = StringSplit($TagParamStruct,"|")
$FuncName = $Split[1]
$TagParamStruct = $Split[2]
$GlobalParamStruct = Read_Ptr($ProcessID,$lParam,$TagParamStruct)
$ElementNu += 1
$NumParams = DllStructGetData($GlobalParamStruct,$ElementNu)
ReDim $ArgsArray[$NumParams + 1]
$ArgsArray[0] = "CallArgArray"
For $i = 1 To $NumParams
$ElementNu += 1
$ParamType = DllStructGetData($GlobalParamStruct,$ElementNu)
$ElementNu += 1
Select
Case $ParamType = 6
$ParamData = DllStructGetPtr($GlobalParamStruct,$ElementNu)
Case Else
$ParamData = DllStructGetData($GlobalParamStruct,$ElementNu)
EndSelect
if $ParamType = 5 Then $ParamData = $ParamData = 1
$ArgsArray[$i] = $ParamData
Next
Select
Case $wParam = 0
Switch $NumParams
Case 0
Return Call($FuncName)
Case Else
Return Call($FuncName,$ArgsArray)
EndSwitch
Case $wParam = 1 ; Return Directly)
AdlibRegister("AdlibCallFunc")
Return 1
EndSelect
Return 0
EndFunc

Func AdlibCallFunc()
AdlibUnRegister("AdlibCallFunc")
$GlobalResults = 0
$GlobalError = 0
$GlobalExtended = 0
Switch UBound($ArgsArray)
Case 1
$GlobalResults = Call($FuncName)
Case Else
$GlobalResults = Call($FuncName,$ArgsArray)
EndSwitch
$GlobalError = @error
$GlobalExtended = @extended
EndFunc

Func Read_Ptr($ProcessID,$Pointer,$TagStruct)
Local $Struct , $iRead
$Struct = DllStructCreate($TagStruct)
if @error Then Return SetError(1,0,0)
Switch $ProcessID
Case $PrProcessID
if Not $PrhProcess Then $PrhProcess = _WinAPI_OpenProcess($iPROCESS_ALL_ACCESS,False,$ProcessID)
if @error Then Return SetError(2,0,0)
$Return = _WinAPI_ReadProcessMemory($PrhProcess,$Pointer,DllStructGetPtr($Struct),DllStructGetSize($Struct),$iRead)
if Not $Return Then Return SetError(3,0,0)
Case $ChProcessID
if Not $ChhProcess Then $ChhProcess = _WinAPI_OpenProcess($iPROCESS_ALL_ACCESS,False,$ProcessID)
if @error Then Return SetError(2,0,0)
$Return = _WinAPI_ReadProcessMemory($ChhProcess,$Pointer,DllStructGetPtr($Struct),DllStructGetSize($Struct),$iRead)
if Not $Return Then Return SetError(3,0,0)
Case Else
Return SetError(4,0,0)
EndSwitch
Return SetError(0,0,$Struct)
EndFunc

Func RegisterWindowMessage($lpString,$Distinction,$Password)
$MsgStr = $lpString & $Distinction & $Password
$UINTMSG = DllCall("User32.dll","UINT","RegisterWindowMessageW","wstr",$MsgStr)
$Err = _WinAPI_GetLastError()
if Not $Err And Not @error Then Return SetError(0,0,$UINTMSG[0])
Return SetError(1,0,0)
EndFunc
 

 

ParentProcess.au3

#include "ChildProcess.au3"
;Work with two process

Global $Progress = 0 , $Labe2 = 0 , $DownloadInfoPtr = 0

StartAndParticular()
Func StartAndParticular()
$iParticularProcess = Work_With_Two_process() ;In The Two_Process_Library.au3 File
Select
Case $iParticularProcess == "ParentProcess"
ParentWinMain()
Case $iParticularProcess == "ChildProcess"
ChildWinMain() ;In the ChildProcess.au3 File
EndSelect
EndFunc

Func ParentWinMain()
Opt("GUIOnEventMode", 1)
$GuiC = GUICreate("WinMain",400,400,100,10)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
$Button_1 = GUICtrlCreateButton("Download kaspersky",10,10,380,40)
GUICtrlSetOnEvent(-1,"Clicked_Button_1")
$progressbar = GUICtrlCreateProgress(10,60,380,20)
$Label = GUICtrlCreateLabel("", 10,100,380,20)
$Labe2 = GUICtrlCreateLabel("", 10,130,380,20)
GUISetState(@SW_SHOW,$GuiC)
GUISwitch($GuiC)
While 1
if Not IsChildProcessWork() Then
MsgBox(0,"Error Msg","Child Process Not Working")
Exit
EndIf
if ($Progress) Then
$BOOL = Progress($progressbar,$Label,$Labe2)
if @error Then
$Progress = False
MsgBox(0,"Error Msg","Download Error")
Else
if @extended Then
$Progress = False
MsgBox(0,"Msg","Download complete")
GUICtrlSetData($progressbar,0)
EndIf
EndIf
EndIf
WEnd
EndFunc

Func _Exit()
Exit
EndFunc

Func Clicked_Button_1()
$DownloadInfoPtr = CallFunc("GetDownloadInfoPtr",False) ; Call function from child process
$DownloadInfoPtr = DllStructGetData($DownloadInfoPtr,1)
$Progress = True
$Url = "http://downloads.kaspersky-labs.com/trial/registered/zgf6dcjb0j6x41q42u2x/kis15.0.0.463en_6462.exe"
GUICtrlSetData($Labe2,"Connect to the server")
CallFunc("Inet_Read",True,$Url,30000,@ScriptDir) ;Call function from child process (Return Directly)
EndFunc

Func Progress($progressbar,$Label,$Labe2,$ProgressTime = 200)

$InfoStruct = Read_Ptr($ChProcessID,$DownloadInfoPtr,$TagInfoStruct)
; Read $DownloadInfoPtr From child process Fast red And Loop Of child process Not Stop
$FileSize = DllStructGetData($InfoStruct,1)
$MovePos = DllStructGetData($InfoStruct,2)
$IsComplete = DllStructGetData($InfoStruct,3)
$iError = DllStructGetData($InfoStruct,4)

if ($FileSize) Then
GUICtrlSetData($progressbar, (($MovePos / $FileSize) * 100))
GUICtrlSetData($Label,"FileSize = " & $FileSize & "     Number Of Bytes Read = " & $MovePos)
GUICtrlSetData($Labe2,"Download = " &  int((($MovePos / $FileSize) * 100)) & " %     Download = " & StringLeft(($MovePos / 1048576),6) & " MB")
Else
GUICtrlSetData($Labe2,"Waiting for the first time download")
EndIf

Sleep($ProgressTime)

if ($IsComplete) And ($MovePos = $FileSize) Then Return SetError($iError,1,$iError == 0)
Return SetError($iError,0,$iError == 0)

EndFunc
 

 

ChildProcess.au3

#include "Two_Process_Library.au3"

Func ChildWinMain()
While IsParentProcessWork()
WEnd
EndFunc

;-------------------------------------------------------------------------;
;They are called from the parent process

Func Inet_Read($lpszUrl,$ByteAtaTime,$FileDir)

$IsComplete = False

if ($ByteAtaTime <= 0) Then
if IsDllStruct($GlobalStructA) Then DllStructSetData($GlobalStructA,4,1) ; Error
Return SetError(1,0,False)
EndIf

$HIntOpen = InternetOpen("OPEN")
if Not ($HIntOpen) Then
if IsDllStruct($GlobalStructA) Then DllStructSetData($GlobalStructA,4,2) ; Error
Return SetError(2,0,False)
EndIf

$HIntOpenUrl = InternetOpenUrl($HIntOpen,$lpszUrl,"",0,0,0)
if Not ($HIntOpenUrl) Then
InternetCloseHandle($HIntOpen)
if IsDllStruct($GlobalStructA) Then DllStructSetData($GlobalStructA,4,3) ; Error
Return SetError(3,0,False)
EndIf

$FileSize = HttpQueryInfo($HIntOpenUrl,5) ; HTTP_QUERY_CONTENT_LENGTH = 5
if @error Then
InternetCloseHandle($HIntOpen)
InternetCloseHandle($HIntOpenUrl)
if IsDllStruct($GlobalStructA) Then DllStructSetData($GlobalStructA,4,4) ; Error
Return SetError(4,0,False)
EndIf
$FileSize = Number($FileSize)

$OriginalUrl = InternetQueryOption($HIntOpenUrl,34) ;INTERNET_OPTION_URL = 34
if @error Then
InternetCloseHandle($HIntOpen)
InternetCloseHandle($HIntOpenUrl)
if IsDllStruct($GlobalStructA) Then DllStructSetData($GlobalStructA,5,8) ; Error
Return SetError(5,0,False)
EndIf

$OriginalUrl = StringSplit($OriginalUrl,"/")
$OriginalUrl = $OriginalUrl[$OriginalUrl[0]]
if StringRight($FileDir,1) == "\" Then $FileDir = StringTrimRight($FileDir,1)
Local $FileName = $FileDir & "\" & $OriginalUrl

$hFile = _WinAPI_CreateFile($FileName,1)
if Not $hFile Then
InternetCloseHandle($HIntOpen)
InternetCloseHandle($HIntOpenUrl)
if IsDllStruct($GlobalStructA) Then DllStructSetData($GlobalStructA,4,6) ; Error
Return SetError(6,0,False)
EndIf

$Buffer = DllStructCreate("BYTE Buffer[" & $ByteAtaTime & "]")
if @error Then
InternetCloseHandle($HIntOpen)
InternetCloseHandle($HIntOpenUrl)
_WinAPI_CloseHandle($hFile)
if IsDllStruct($GlobalStructA) Then DllStructSetData($GlobalStructA,4,7) ; Error
Return SetError(7,0,False)
EndIf

Local $nBytes = 0 , $Error = False
$MovePos = 0
$lpBuffer = DllStructGetPtr($Buffer)

While IsParentProcessWork()
$lpdwNumberOfBytesRead = InternetReadFile($HIntOpenUrl,$lpBuffer,$ByteAtaTime)
$Error = @error
$MovePos += $lpdwNumberOfBytesRead
if $Error Or $lpdwNumberOfBytesRead <= 0 Then ExitLoop
if IsDllStruct($GlobalStructA) Then
DllStructSetData($GlobalStructA,1,$FileSize)
DllStructSetData($GlobalStructA,2,$MovePos)
EndIf
$BOOL = _WinAPI_WriteFile($hFile,$lpBuffer,$lpdwNumberOfBytesRead,$nBytes)
if Not($BOOL) Then
$Error = 1
ExitLoop
EndIf
WEnd

if IsDllStruct($GlobalStructA) And($Error) Then DllStructSetData($GlobalStructA,4,8) ; Error

if ($Error) Then
_WinAPI_CloseHandle($hFile)
InternetCloseHandle($HIntOpen)
InternetCloseHandle($HIntOpenUrl)
Return SetError(8,0,False)
EndIf

_WinAPI_CloseHandle($hFile)
InternetCloseHandle($HIntOpen)
InternetCloseHandle($HIntOpenUrl)

$IsComplete = True
if IsDllStruct($GlobalStructA) Then DllStructSetData($GlobalStructA,3,$IsComplete)

Return SetError(0,0,True)

EndFunc

Func GetDownloadInfoPtr()
$GlobalStructA = DllStructCreate($TagInfoStruct)
$DownloadInfoPtrSt = DllStructCreate("PTR")
DllStructSetData($DownloadInfoPtrSt,1,DllStructGetPtr($GlobalStructA))
Return ReturnStruct("PTR",$DownloadInfoPtrSt)
EndFunc

Func GetDownloadInfo()
$InfoStruct = DllStructCreate($TagInfoStruct)
DllStructSetData($InfoStruct,1,$FileSize)
DllStructSetData($InfoStruct,2,$MovePos)
DllStructSetData($InfoStruct,3,$IsComplete)
DllStructSetData($InfoStruct,4,$GlobalError)
Return ReturnStruct($TagInfoStruct,$InfoStruct)
EndFunc

;They are called from the parent process
;-------------------------------------------------------------------------;

Func InternetReadFile($hFile,$lpBuffer,$dwNumberOfBytesToRead)
$DLLSDWORD = DllStructCreate("DWORD")
$lpdwNumberOfBytesRead = DllStructGetPtr($DLLSDWORD)
$BOOL = DllCall($jDll,"BOOL","InternetReadFile","HANDLE",$hFile,"ptr",$lpBuffer, _
"DWORD",$dwNumberOfBytesToRead,"ptr",$lpdwNumberOfBytesRead)
if @error Or $BOOL[0] = 0 Then Return SetError(1,0,0)
Return SetError(0,0,DllStructGetData($DLLSDWORD,1))
EndFunc

Func HttpQueryInfo($hRequest,$dwInfoLevel,$lpdwIndex = 0)
Local $lpdwBufferLength = 1000
$DLLSDWORD = DllStructCreate("DWORD")
DllStructSetData($DLLSDWORD,1,$lpdwBufferLength)
$LPDWORDLENGTH = DllStructGetPtr($DLLSDWORD)
$DLLSlpvBuffer = DllStructCreate("WCHAR[" & $lpdwBufferLength & "]")
$lpvBuffer = DllStructGetPtr($DLLSlpvBuffer)
$BOOL = DllCall($jDll,"BOOL","HttpQueryInfoW","HANDLE",$hRequest,"DWORD",$dwInfoLevel, _
"ptr",$lpvBuffer,"ptr",$LPDWORDLENGTH,"DWORD",$lpdwIndex)
if @error Or $BOOL[0] = 0 Then Return SetError(1,0,0)
Return SetError(0,0,DllStructGetData($DLLSlpvBuffer,1))
EndFunc

Func InternetQueryOption($hInternet,$dwOption)
Local $lpdwBufferLength = 1000
$DLLSDWORD = DllStructCreate("DWORD")
DllStructSetData($DLLSDWORD,1,$lpdwBufferLength)
$LPDWORDLENGTH = DllStructGetPtr($DLLSDWORD)
$DLLSlpvBuffer = DllStructCreate("WCHAR[" & $lpdwBufferLength & "]")
$lpvBuffer = DllStructGetPtr($DLLSlpvBuffer)
$BOOL = DllCall($jDll,"BOOL","InternetQueryOptionW","HANDLE",$hInternet _
,"DWORD",$dwOption,"ptr",$lpvBuffer,"ptr",$LPDWORDLENGTH)
if @error Or $BOOL[0] = 0 Then Return SetError(1,0,0)
Return SetError(0,0,DllStructGetData($DLLSlpvBuffer,1))
EndFunc

Func InternetOpenUrl($hInternet,$lpszUrl,$lpszHeaders,$dwHeadersLength,$dwFlags,$dwContext)
$HINTERNET = DllCall($jDll,"HANDLE","InternetOpenUrlW","HANDLE",$hInternet,"wstr",$lpszUrl, _
"wstr",$lpszHeaders,"DWORD",$dwHeadersLength,"DWORD",$dwFlags,"ptr",$dwContext)
if @error Or Not ($HINTERNET[0]) Then Return SetError(1,0,0)
Return SetError(0,0,$HINTERNET[0])
EndFunc

Func InternetOpen($lpszAgent,$dwAccessType = 0,$lpszProxyName = "",$lpszProxyBypass = "",$dwFlags = 0)
$HINTERNET = DllCall($jDll,"HANDLE","InternetOpenW","wstr",$lpszAgent,"DWORD",$dwAccessType, _
"wstr",$lpszProxyName,"wstr",$lpszProxyBypass,"DWORD",$dwFlags)
if @error Or Not ($HINTERNET[0]) Then Return SetError(1,0,0)
Return SetError(0,0,$HINTERNET[0])
EndFunc

Func InternetCloseHandle($hInternet)
$BOOL = DllCall($jDll,"BOOL","InternetCloseHandle","HANDLE",$hInternet)
if @error Or $BOOL[0] = 0 Then Return SetError(1,0,0)
Return SetError(0,0,$BOOL[0])
EndFunc

 

Two_Process_Library_Constants.au3

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <Memory.au3>
#include <Math.au3>

Global $MovePos , $FileSize , $jDll = DllOpen("Wininet.dll") , $Buffer , $IsComplete
Global $UntCallMsg,$UntCoueMsg,$ArgsArray[1],$FuncName = "" ,$PrProcessID = 0,$ChProcessID = 0, _
$ChhWnd = 0,$PrhWnd = 0,$MsgOk = 123456789,$GlobalResultsStruct,$GlobalpResultsStruct,  _
$GlobalParamStruct , $GlobalParticularProcess = "" , $GlobalResults = 0 , $GlobalError = 0 , _
$GlobalExtended = 0 , $GlobalPassword = "GlobalPassword" , $PrhProcess = 0 ,$ChhProcess = 0
Global $iSYNCHRONIZE = ( 0x00100000 ) , $iSTANDARD_RIGHTS_REQUIRED = (0x000F0000) , $pbeginA = TimerInit()
Global $iPROCESS_ALL_ACCESS  = ($iSTANDARD_RIGHTS_REQUIRED + $iSYNCHRONIZE + 0xFFF),$pbeginB = TimerInit()
Global $TagInfoStruct = "INT FileSize;INT MovePos;BOOL IsComplete;INT iError"
Global $GlobalStructA , $GlobalStructB , $GlobalStructC ;$GlobalStructD , ....
1 person likes this

صرح السماء كان هنا

 

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0