Leaderboard
Popular Content
Showing content with the highest reputation on 05/06/2014 in Posts
-
You can find a lot of libraries (DLLs) to create OpenGL windows and contexts, to load images and data into textures, to load 3D models, and to call functions that are not in opengl32.dll. Are all these external libraries necessary? The zip files below contains UDFs to create contexts, load images and models, and call functions without any external libraries. They also contains a number of examples. Well, it's not quite true that I do not use any DLLs at all. In some examples I'm using The Embedded Flat Assembler (FASM) UDF by Ward (includes fasm.dll) to optimize loops. This is the ExLauncher, that can be used to run the examples: Press Play to run the first example, and Next to run the following examples. In the Samples menu you can select OpenGL 1.1, 2.1, and 3.3 examples. With Samples | Models you can open the 3D model Viewers, and run 3D model examples. With Samples | Templates you can see a number of templates, as you can use as a start for your own examples. The documentation is divided into five chapters: Chapter 1 is mostly about OpenGL 1.x. Topics like calling functions, creating a rendering context, and loading images into textures are also covered.Chapter 2 deals with OpenGL 2.x and the new concepts that appeared in these versions. Most important is the concept of shaders.Chapter 3 is mostly about OpenGL 3.x. There is also a section on OpenGL/GLSL versions and a section on error handling.Chapter 4 is about implementing a model loader for Wavefront (OBJ) 3D models.Chapter 5 is a summary.In bottom of the post you can download zip files. Use ExLauncher.au3 in top folder to run examples. To view Wavefront (OBJ) 3D models see section 4.0. Chapter 1 is mostly about OpenGL 1.x. Topics like calling functions, creating a rendering context, and loading images into textures are also covered. 1.1 Calling functions Functions defined in OpenGL 1.2 and higher and functions defined in extensions are part of the software that belongs to the video card. To access these functions you normally use a function loading library e.g. GLEW. You can also access the functions manually: 1.2 Rendering contexts (Update 2013-09-21) With OpenGL 3.0 and higher there are more ways to create a rendering context. In the OpenGL wiki the terms simple and proper are used to describe two different types of contexts. Update: New MSAA context. 1.3 Textures and images (Update 2013-09-21) A texture is an OpenGL object that contains an image. Without an image loading library or at least an image loading function it can be tricky to load an image into a texture. These functions loads BMP, GIF, ICO, JPG, PNG, RGB, RGBA, TGA, TGA(RLE), TIF and WMF files. Update: Anisotropic filter (bottom of spoiler). 1.4 OpenGL 1.1 examples (Update 2013-08-03) SamplesOpenGL 1.1 contains the OpenGL 1.1 examples. Here is a list: 1.5 Run examples (Update 2013-08-03) You can run examples in the Samples folder by double clicking, or you can run them from Scite. The easiest is to use ExLauncher.au3 in the top folder: 1.6 Threads example Imagine that when you move the mouse across the screen, it'll create a track on the screen that follows your mouse. Then imagine that there isn't just one track, but many tracks that are slightly offset relative to each other. This is threads: Chapter 2 deals with OpenGL 2.x and the new concepts that appeared in these versions. Most important is the concept of shaders. 2.1 New concepts In the last versions of OpenGL 1.x and especially in version 2.0 and 2.1 a new set of concepts showed up. It was concepts such as shaders, attributes, uniforms and vertex buffer objects (VBOs): 2.2 Shaders Shaders were introduced in OpenGL 2.0. A shader is a program running on the GPU. You write a shader in the OpenGL Shading Language (GLSL). It's a C-like language: 2.3 Math functions When you use shaders in OpenGL 2.0 and higher you don't use old functions like glMultMatrix, glRotate, glTranslate, gluLookAt or gluPerspective. You have to use a new set of functions that works with the functionality of the shaders: 2.4 OpenGL 2.1 examples (Update 2013-06-16) SamplesOpenGL 2.1 contains the OpenGL 2.1 examples. All these examples are based on shaders and the new concepts in OpenGL 2.1. Here is a list: Chapter 3 is mostly about OpenGL 3.x. There is also a section on OpenGL/GLSL versions and a section on error handling. 3.1 OpenGL versions OpenGL versions and corresponding GLSL version: 3.2 Error handling OpenGL error handling is done with glGetError and glGet-functions. Initialize error handling before a group of commands and check errors after the last command. Here error handling is illustrated with LoadGLSLshader in oglIncludesoglLoadShaders.au3: 3.3 OpenGL 3.3 examples (Update 2013-06-16) SamplesOpenGL 3.3 contains the OpenGL 3.3 examples. Most of these examples are added in an update on 2013-06-16. Chapter 4 is about implementing a model loader for Wavefront (OBJ) 3D models 4.0 View 3D models (New 2014-05-04) Added a few pictures that shows how the model Viewers works. 4.1 3D models (New 2013-08-03) When you need a 3D model in your OpenGL project you probably just want to find the model on the internet and load it into your project with some kind of model loading function. 4.2 Wavefront (OBJ) loader (Update 2013-09-21) A Wavefront 3D model (Wavefront .obj file) consists usually of two files: An OBJ-file (Object files) which contains vertices, texture coordinates, normal vectors and face triangles to describe the geometry of the model. And a MTL-file (Material files) with material definitions to describe the look of the model. Material definitions are parameters for the OpenGL glMaterial command to describe the light reflectivities of the surface of the model, and definitions of texture maps to put on the surface of the model. 4.3 Wavefront (OBJ) viewer (Update 2013-09-21) SamplesModelsModel Viewer contains two viewers for Wavefront (OBJ) 3D models. Model Viewer (OBJ) 1.1.au3 is an OpenGL 1.1 version (2.0 or lower) and Model Viewer (OBJ) 2.1.au3 is a 2.1 version (2.1 or higher). Model Viewer (OBJ).au3 calls the proper script depending on your OpenGL version. The latter can be opened through the Tools menu in ExLauncher.au3. 4.4 Example models (Update 2013-09-21) The Models folder at the top level contains the example models. The SamplesModels folder at the top level contains the viewers and the au3-scripts to run the examples. Example models are split into two groups: Samples and models. Models are further divided into three groups: Small, medium and large models: 4.5 Large models (Update 2013-09-21) The optimizations provided in this update and the 2013-08-24 update has largely eliminated the problems of large models. 4.6 Using the models (Update 2013-09-21) SamplesModelsOpenGL 1.1 and SamplesModelsOpenGL 2.1 contains some small examples which shows how to use the models. 4.7 Software (Update 2013-08-24) Blender is a program to edit 3D models. AssimpView is a model viewer. Both of these programs are able to export a model as a Wavefront (OBJ) triangle mesh. 4.8 Next version (Update 2013-09-21) Some issues should be handled in the next version: 4.9 Summary (Update 2013-09-21) This is a summary of the main features and limitations for the Wavefront (OBJ) 3D model loader: Chapter 5 is a summary 5.1 Sources for the UDFs (New 2013-06-16) The zipfile contains a number of OpenGL UDFs in the oglIncludes folder. This is a description of the sources for these UDFs: 5.2 Updates (New 2014-05-04) The example was released 2013-05-19. This is a summary of the updates. Zip files and downloads Included UDFs FASM.au3 and MemoryDll.au3 by Ward to optimize loops. The UDFs are included in the code zip. Contents of the code zip The zipfiles contains a number of files and folders: ExLauncher.au3 - to start the examples, run this fileImages - images used in the examples (not since 2014-05-04)Models - Wavefront (OBJ) 3D example modelsIncludes - utility functions and UDFsoglIncludes - OpenGL related constants and functionsSamples - a collection of examples and templatesTools - a few OpenGL toolszLinks - links to dokuUpdate 2014-05-04 for AutoIt 3.3.10 (code): OpenGL2-3.3.10.7z Downloads at Dropbox The images and 3D models can be downloaded from OpenGL Images and Models at Dropbox. The folder contains three 7z-files: Images.7z, 3.5 MB - the images from the first release 2013-05-19. You need these images, but if you have already installed the images, you do not need to download this package.ModelSamples.7z, 1.66 MB - sample 3D models. If you want to test the Wavefront (OBJ) 3D models and the model loading functions, you need this package.Models.7z, 39.15 MB (250 MB uncompressed) - larger models. The pictures in post 13, 14 and 16 are created from models in this package.If you don't want to test any 3D models there is no need to download and install the last two packages.Click the Download button in upper right corner to download all three packages in one big zip. Testet on XP 32 bit with a NVIDIA video card supporting OpenGL 3.3 and Win 7 64 bit with an Intel card supporting OpenGL 3.1. Use ExLauncher.au3 in top folder to run examples. To view Wavefront (OBJ) 3D models see section 4.0. AutoIt 3.3.8 You can get the 2013-09-21 version for 3.3.8 here. You need the images and possibly the 3D models. x64 issues (no x64 issues in 3.3.10)1 point
-
Through the project can downloaded files using the Thread function and assembly language also the project allows to download files on the memory or to a file directly project Files ASM_Download.zip New project Files New_ASM_Download.zip New2 project Files New2_ASM_Download.zip New3 project Files New3_ASM_Download.zip ASM_Download.au3 #include <Memory.au3> #include <WinAPI.au3> Global $tagInetHandle = "DWORD Complete;DWORD Pause;DWORD MemBool;DWORD Error;DWORD MovePos;DWORD BytesAtaTime;DWORD" & _ " FileSize;DWORD NuOfBytesRead;PTR hLockData;PTR hFile;DWORD lpNumberOfBytesWritten;DWORD Cancel;PTR HIntOpenUrl;" & _ "PTR MemAddress;PTR MemInetHandle;PTR StringUrl;PTR HIntOpen;PTR MemData;PTR MemString;DWORD FreeHandle" Global $tagInetHandlesPtr = "DWORD Update;DWORD CompleteAll;PTR InetHandlesPtr;PTR FreeInetHandles;DWORD LOOP" & _ ";DWORD MovePos;PTR ThModule",$Wininet = DllOpen( "Wininet.dll" ) ,$HIntOpen , $InetHandles , $Threadhandle = 0 Global $MsvcrtModule = _WinAPI_LoadLibrary( "Msvcrt.dll" ) Global $WininethModule = _WinAPI_LoadLibrary("Wininet.dll") Global $Kernel32Module = _WinAPI_LoadLibrary("Kernel32.dll") Global $_wtol = _WinAPI_GetProcAddress($MsvcrtModule,"_wtol") Global $memset = _WinAPI_GetProcAddress($MsvcrtModule,"memset") Global $WriteFile = _WinAPI_GetProcAddress($Kernel32Module,"WriteFile") Global $GlobalLock = _WinAPI_GetProcAddress($Kernel32Module,"GlobalLock") Global $GlobalFree = _WinAPI_GetProcAddress($Kernel32Module,"GlobalFree") Global $CloseHandle = _WinAPI_GetProcAddress($Kernel32Module,"CloseHandle") Global $GlobalReAlloc = _WinAPI_GetProcAddress($Kernel32Module,"GlobalReAlloc") Global $HttpQueryInfoW = _WinAPI_GetProcAddress($WininethModule,"HttpQueryInfoW") Global $InternetOpenUrlW = _WinAPI_GetProcAddress($WininethModule,"InternetOpenUrlW") Global $InternetReadFile = _WinAPI_GetProcAddress($WininethModule,"InternetReadFile") Global $InternetCloseHandle = _WinAPI_GetProcAddress($WininethModule,"InternetCloseHandle") Global $PtrSize = DllStructGetSize(DllStructCreate("PTR")) , $lpdwBufferStruct Global $DwordSize = DllStructGetSize(DllStructCreate("DWORD")) Global $ASMVER = DllStructCreate("DWORD VER1;PTR VER2;PTR VER3") Global $HandleSize = DllStructGetSize( DllStructCreate( $tagInetHandle ) ) Global $InetHandlesPtr = DllStructCreate( $tagInetHandlesPtr) Global $FreeInetHandle = LoadFreeInetHandle() Global $StartDownLoad = LoadStartDownLoad() Global $FileDownLoad = LoadFileDownLoad( ) Global $MemDownLoad = LoadMemDownLoad( ) Global $ThreadProc = LoadThreadProc( ) Func DownloadFile($lpszUrl,$BytesAtaTime,$Memory = True,$FileName = "") Local $hFile = 0 if ($BytesAtaTime < 1) Then Return SetError(1,0,0) if Not($HIntOpen) Then $HIntOpen = InternetOpen("OPEN") if Not ($HIntOpen) Then Return SetError(2,0,0) if Not($Memory) Then $hFile = _WinAPI_CreateFile($FileName,1) if Not($hFile) Then Return SetError(3,0,0) EndIf Local $nhMemory = _MemGlobalAlloc($HandleSize,$GHND) Local $hLockHandle = _MemGlobalLock($nhMemory) Local $InetHandle = DllStructCreate($tagInetHandle,$hLockHandle) DllStructSetData($InetHandle,"HIntOpen",$HIntOpen) DllStructSetData($InetHandle,"BytesAtaTime",$BytesAtaTime) DllStructSetData($InetHandle,"hFile",$hFile) DllStructSetData($InetHandle,"MemInetHandle",$nhMemory) Local $vhMemory = _MemGlobalAlloc($BytesAtaTime,$GHND) Local $hLockData = _MemGlobalLock($vhMemory) DllStructSetData($InetHandle,"hLockData",$hLockData) DllStructSetData($InetHandle,"MemData",$vhMemory) DllStructSetData($InetHandle,"MemBool",$Memory) Local $StaLen = (StringLen($lpszUrl) + 1) Local $nhMemory = _MemGlobalAlloc(($StaLen * 2),$GHND) Local $hLockString = _MemGlobalLock($nhMemory) DllStructSetData($InetHandle,"StringUrl",$hLockString) DllStructSetData($InetHandle, "MemString" , $nhMemory) DllStructSetData(DllStructCreate("WCHAR[" & $StaLen & "]",$hLockString),1,$lpszUrl) Local $Count = DllStructGetData($InetHandles,"Count") if @error Then $Count = 1 Local $NewSize = ($DwordSize + $PtrSize) Local $vhMemory = _MemGlobalAlloc($NewSize,$GHND) Local $NewhLockHandles = _MemGlobalLock($vhMemory) $InetHandles = DllStructCreate("DWORD Count;PTR InetHandle[1]",$NewhLockHandles) DllStructSetData($InetHandles,"InetHandle",$hLockHandle) DllStructSetData($InetHandles,"Count",1) DllStructSetData($InetHandlesPtr,"InetHandlesPtr",$NewhLockHandles) Else $Count += 1 Local $OldhLockHandles = DllStructGetData($InetHandlesPtr,"InetHandlesPtr") Local $NewSize = ($DwordSize + ($PtrSize * $Count)) Local $vhMemory = _MemGlobalAlloc($NewSize,$GHND) Local $NewhLockHandles = _MemGlobalLock($vhMemory) _MemMoveMemory($OldhLockHandles,$NewhLockHandles,$NewSize) $InetHandles = DllStructCreate("DWORD Count;PTR InetHandle[" & $Count & "]",$NewhLockHandles ) DllStructSetData($InetHandles,"InetHandle",$hLockHandle,$Count) DllStructSetData($InetHandles,"Count",$Count) DllStructSetData($InetHandlesPtr,"FreeInetHandles",GlobalHandle($OldhLockHandles)) DllStructSetData($InetHandlesPtr,"InetHandlesPtr" ,$NewhLockHandles) DllStructSetData($InetHandlesPtr,"Update",1) EndIf if Not($Threadhandle) Then $Threadhandle = CreateThread(DllStructGetPtr($ThreadProc)) DllStructSetData($InetHandlesPtr ,"ThModule",$Threadhandle) EndIf Return SetError(0,0,$hLockHandle) EndFunc Func CloseThreadLoop() if ( DllStructGetData($InetHandlesPtr ,"CompleteAll" ) <> 2 ) Then Return False _MemGlobalFree(GlobalHandle(DllStructGetData($InetHandlesPtr,"InetHandlesPtr"))) _WinAPI_CloseHandle($Threadhandle) InternetCloseHandle($HIntOpen) DllCallAddress("PTR:CDECL",$memset,"PTR",DllStructGetPtr($InetHandlesPtr),"INT",0,"UINT_PTR",DllStructGetSize($InetHandlesPtr)) $Threadhandle = 0 $InetHandles = 0 $HIntOpen = 0 Return True EndFunc Func LoadThreadProc() Local $OffSetUpdate = 0 , $OffSetCompleteAll = $DwordSize Local $OffSetInetHandlesPtr = ($OffSetCompleteAll + $DwordSize) Local $OffSetFreeHandle = (($DwordSize * 10) + ($PtrSize * 9)) Local $OffSetFreeInetHandles = ($OffSetInetHandlesPtr + $PtrSize) Local $OffSetLOOP = ($OffSetFreeInetHandles + $PtrSize) Local $OffSetMovePos = ($OffSetLOOP + $DwordSize) Local $OffSetPause = $DwordSize , $OffSetComplete = 0 Local $OffSetCount = 0 , $OffSetInetHandles = $DwordSize Local $OffSetMemBool = ($DwordSize * 2) Local $Start,$Free,$JZFree,$LOOP,$End,$JZEnd,$JMPStart1,$JMPStart2,$Out,$JZLOOP1,$JZMemDown,$JMPEndLoop Local $InetHandlesPtrPtr = DllStructGetPtr($InetHandlesPtr) ,$JMPLOOP,$JZOut,$MemDown,$EndLoop,$JZLOOP2 Local $FileDownLoadPtr = DllStructGetPtr( $FileDownLoad ) , $VER3PTR = DllStructGetPtr( $ASMVER,"VER3") Local $JZLOOP3 , $JZFreeNext , $FreeNext ,$JMPLOOP2 , $VER2PTR = DllStructGetPtr( $ASMVER , "VER2" ) Local $FreeInetHandlePtr=DllStructGetPtr($FreeInetHandle),$MemDownLoadPtr=DllStructGetPtr($MemDownLoad) For $i = 1 To 2 $_ASMCode = "0x" ; Start: // $Start = BinaryLen($_ASMCode) $_ASMCode &= "BB" & HexBinary($InetHandlesPtrPtr) ;mov ebx,$InetHandlesPtrPtr $_ASMCode &= "C643" & Hex($OffSetCompleteAll,2) & Hex(0,2) ;mov [ebx + $OffSetCompleteAll],0 $_ASMCode &= "807B" & Hex($OffSetUpdate,2) & Hex(1,2) ;CMP [ebx + $OffSetUpdate],1 $_ASMCode &= "74" & Hex($Free - $JZFree,2) ;JZ JZFree $JZFree = BinaryLen($_ASMCode) $_ASMCode &= "C643" & Hex($OffSetLOOP,2) & Hex(0,2) ;mov [ebx + $OffSetLOOP],0 ; $LOOP: // $LOOP = BinaryLen($_ASMCode) $_ASMCode &= "BB" & HexBinary($InetHandlesPtrPtr) ;mov ebx,$InetHandlesPtrPtr $_ASMCode &= "8B43" & Hex($OffSetLOOP,2) ;mov eax,[ebx + $OffSetLOOP] $_ASMCode &= "8B53" & Hex($OffSetInetHandlesPtr,2) ;mov edx,[ebx + $OffSetInetHandlesPtr] $_ASMCode &= "3B02" ;CMP eax,[edx] $_ASMCode &= "74" & Hex($End - $JZEnd,2) ;JZ $End $JZEnd = BinaryLen($_ASMCode) $_ASMCode &= "8043" & Hex($OffSetLOOP,2) & Hex(1,2) ;add [ebx + $OffSetLOOP],1 $_ASMCode &= "83C2" & Hex($OffSetInetHandles,2) ;add edx,$OffSetInetHandles $_ASMCode &= "8B43" & Hex($OffSetMovePos,2) ;mov eax,[ebx + $OffSetMovePos] $_ASMCode &= "03D0" ;add edx,eax $_ASMCode &= "8B12" ;mov edx,[edx] $_ASMCode &= "B8" & HexBinary($VER2PTR) ;mov eax,$VER2PTR $_ASMCode &= "8910" ;mov [eax],edx $_ASMCode &= "83FA" & Hex(0,2) ;CMP edx,0 $_ASMCode &= "74" & Hex(($EndLoop - $JZLOOP1),2) ;JZ $EndLoop $JZLOOP1 = BinaryLen($_ASMCode) $_ASMCode &= "C643" & Hex($OffSetCompleteAll,2) & Hex(1,2) ;mov [ebx + $OffSetCompleteAll],1 $_ASMCode &= "807A" & Hex($OffSetFreeHandle,2) & Hex(0,2) ;CMP [edx + $OffSetFreeHandle],0 $_ASMCode &= "74" & Hex(($FreeNext - $JZFreeNext),2) ;JZ $FreeNext $JZFreeNext = BinaryLen($_ASMCode) $_ASMCode &= "B8" & HexBinary($FreeInetHandlePtr) ;mov eax,$FreeInetHandle $_ASMCode &= "FFD0" ;call eax $_ASMCode &= "EB" & Hex(($EndLoop - $JMPLOOP2),2) ;JMP $EndLoop $JMPLOOP2 = BinaryLen($_ASMCode) ; $FreeNex: // $FreeNext = BinaryLen($_ASMCode) $_ASMCode &= "807A" & Hex($OffSetComplete,2) & Hex(1,2) ;CMP [edx + $OffSetComplete],1 // Complete $_ASMCode &= "74" & Hex(($EndLoop - $JZLOOP2),2) ;JZ $EndLoop $JZLOOP2 = BinaryLen($_ASMCode) $_ASMCode &= "807A" & Hex($OffSetPause,2) & Hex(1,2) ;CMP [edx + $OffSetPause],1 // Pause $_ASMCode &= "74" & Hex(($EndLoop - $JZLOOP3),2) ;JZ $EndLoop $JZLOOP3 = BinaryLen($_ASMCode) $_ASMCode &= "807A" & Hex($OffSetMemBool,2) & Hex(1,2) ;CMP [edx + $OffSetMemBool],1 $_ASMCode &= "74" & Hex($MemDown - $JZMemDown,2) ;JZ $MemDown $JZMemDown = BinaryLen($_ASMCode) $_ASMCode &= "52" ;push edx $_ASMCode &= "B8" & HexBinary($FileDownLoadPtr) ;mov eax,$FileDownLoadPtr $_ASMCode &= "FFD0" ;call eax $_ASMCode &= "EB" & Hex(($EndLoop - $JMPEndLoop),2) ;JMP $EndLoop $JMPEndLoop = BinaryLen($_ASMCode) ; $MemDown: // $MemDown = BinaryLen($_ASMCode) $_ASMCode &= "52" ;push edx $_ASMCode &= "B8" & HexBinary($MemDownLoadPtr) ;mov eax,$MemDownLoadPtr $_ASMCode &= "FFD0" ;call eax ; $EndLoop: // $EndLoop = BinaryLen($_ASMCode) $_ASMCode &= "BB" & HexBinary($InetHandlesPtrPtr) ;mov ebx,$InetHandlesPtrPtr $_ASMCode &= "8043" & Hex($OffSetMovePos,2) & Hex($PtrSize,2) ;add [ebx + $OffSetMovePos],$PtrSize $JMPLOOP = BinaryLen($_ASMCode) $_ASMCode &= "E9" & HexBinary(-(($JMPLOOP - $LOOP) + 5)) ;JMP $LOOP ; $Free: // $Free = BinaryLen($_ASMCode) $_ASMCode &= "BB" & HexBinary($InetHandlesPtrPtr) ;mov ebx,$InetHandlesPtrPtr $_ASMCode &= "C643" & Hex($OffSetUpdate,2) & Hex(0,2) ;mov [ebx + $OffSetUpdate],0 $_ASMCode &= "8B43" & Hex($OffSetFreeInetHandles,2) ;mov eax,[ebx + $OffSetFreeInetHandles] $_ASMCode &= "50" ;push eax $_ASMCode &= "B8" & HexBinary($GlobalFree) ;mov eax,$GlobalFree $_ASMCode &= "FFD0" ;call eax $JMPStart1 = BinaryLen($_ASMCode) $_ASMCode &= "E9" & HexBinary(-(($JMPStart1 - $Start) + 5)) ;JMP Start ; $End: // $End = BinaryLen($_ASMCode) $_ASMCode &= "BB" & HexBinary($InetHandlesPtrPtr) ;mov ebx,$InetHandlesPtrPtr $_ASMCode &= "807B" & Hex($OffSetCompleteAll,2) & Hex(0,2) ;CMP [ebx + $OffSetCompleteAll],0 $_ASMCode &= "74" & Hex($Out - $JZOut,2) ;JZ $Out $JZOut = BinaryLen($_ASMCode) $_ASMCode &= "C643" & Hex($OffSetLOOP,2) & Hex(0,2) ;mov [ebx + $OffSetLOOP],0 $_ASMCode &= "C643" & Hex($OffSetMovePos,2) & Hex(0,2) ;mov [ebx + $OffSetMovePos],0 $JMPStart2 = BinaryLen($_ASMCode) $_ASMCode &= "E9" & HexBinary(-(($JMPStart2 - $Start) + 5)) ;JMP Start ; $Out: // $Out = BinaryLen($_ASMCode) $_ASMCode &= "C643" & Hex($OffSetCompleteAll,2) & Hex(2,2) ;mov [edx + $OffSetCompleteAll],2 $_ASMCode &= "C3" Next $AddressSt = DllStructCreate("byte[" & BinaryLen($_ASMCode) & "]") DllStructSetData($AddressSt,1,$_ASMCode) Return $AddressSt EndFunc Func LoadMemDownLoad() Local $OffSetInetHandle = $PtrSize Local $VER1PTR = DllStructGetPtr( $ASMVER ,"VER1") Local $VER2PTR = DllStructGetPtr( $ASMVER ,"VER2") Local $OffSetComplete = 0 Local $OffSetByteAtaTime = ( $DwordSize * 5) Local $OffSetNuOfBytesRead = ($DwordSize * 7) Local $OffSethLockData = ($DwordSize * 8) Local $OffSethFile = (($DwordSize * 8) + $PtrSize) Local $OffSetNuOfBytesWn = (($DwordSize * 8) + ($PtrSize * 2)) Local $OffSetHIntOpenUrl = (($DwordSize * 10) + ($PtrSize * 2)) Local $OffSetCancel = (($DwordSize * 9) + ($PtrSize * 2)) Local $OffSetMemData = (($DwordSize * 10) + ($PtrSize * 7)) Local $OffSetMemString = (($DwordSize * 10) + ($PtrSize * 8)) Local $OffSetMovePos = ($DwordSize * 4) Local $Complete , $JZCancel , $JZComplete2 , $JZComplete , $MemFree Local $vStartDownLoad,$vJZStartDownLoad,$JMP__Next,$__Next,$JZCancel2 Local $StartDownLoadPtr = DllStructGetPtr($StartDownLoad) For $i = 1 To 2 $_ASMCode = "0x" $_ASMCode &= "8B5C24" & Hex($OffSetInetHandle,2) ;mov ebx,[esp + $OffSetInetHandle] $_ASMCode &= "B8" & HexBinary($VER2PTR) ;mov eax,$VER2PTR $_ASMCode &= "8918" ;mov [eax],ebx $_ASMCode &= "807B" & Hex($OffSetHIntOpenUrl,2) & Hex(0,2) ;CMP [ebx + $OffSetHIntOpenUrl],0 $_ASMCode &= "74" & Hex($vStartDownLoad - $vJZStartDownLoad,2) ;JZ $vStartDownLoad $vJZStartDownLoad = BinaryLen($_ASMCode) $_ASMCode &= "EB" & Hex(($__Next - $JMP__Next),2) ;JMP __Next $JMP__Next = BinaryLen($_ASMCode) ; StartDownLoad: // $vStartDownLoad = BinaryLen($_ASMCode) $_ASMCode &= "53" ;push ebx $_ASMCode &= "B8" & HexBinary($StartDownLoadPtr) ;mov eax,$StartDownLoadPtr $_ASMCode &= "FFD0" ;call eax $_ASMCode &= "B8" & HexBinary(0) ;mov eax,0 $_ASMCode &= "C2" & Hex($PtrSize,2) & Hex(0,2) ;ret ($PtrSize) & "00" // Args Size ; __Next: // $__Next = BinaryLen($_ASMCode) $_ASMCode &= "807A" & Hex($OffSetCancel,2) & Hex(1,2) ;CMP [edx + $OffSetCancel],1 // Cancel $_ASMCode &= "0F84" & HexBinary(($Complete - $JZCancel)) ;JZ Complete; $JZCancel = BinaryLen($_ASMCode) $_ASMCode &= "68" & HexBinary(0x0042) ;push $GHND = 0x0042 $_ASMCode &= "8B43" & Hex($OffSetMovePos,2) ;mov eax,[ebx + $OffSetMovePos] $_ASMCode &= "0343" & Hex($OffSetByteAtaTime,2) ;add eax,[ebx + $OffSetByteAtaTime] $_ASMCode &= "50" ;push eax $_ASMCode &= "FF73" & Hex($OffSetMemData,2) ;push [ebx + $OffSetMemData] $_ASMCode &= "B8" & HexBinary($GlobalReAlloc) ;mov eax,$GlobalReAlloc $_ASMCode &= "FFD0" ;call eax $_ASMCode &= "BB" & HexBinary($VER2PTR) ;mov ebx,$VER2PTR $_ASMCode &= "8B1B" ;mov ebx,[ebx] $_ASMCode &= "8943" & Hex($OffSetMemData,2) ;mov [ebx + $OffSetMemData],eax $_ASMCode &= "50" ;push eax $_ASMCode &= "B8" & HexBinary($GlobalLock) ;mov eax,$GlobalLock $_ASMCode &= "FFD0" ;call eax $_ASMCode &= "BB" & HexBinary($VER2PTR) ;mov ebx,$VER2PTR $_ASMCode &= "8B1B" ;mov ebx,[ebx] $_ASMCode &= "8943" & Hex($OffSethLockData,2) ;mov [ebx + $OffSethLockData],eax $_ASMCode &= "C643" & Hex($OffSetNuOfBytesRead,2) & Hex(0,2) ;mov [ebx + $OffSetNuOfBytesRead],0 $_ASMCode &= "83C3" & Hex($OffSetNuOfBytesRead,2) ;add ebx,$OffSetNuOfBytesRead $_ASMCode &= "53" ;push ebx $_ASMCode &= "BB" & HexBinary($VER2PTR) ;mov ebx,$VER2PTR $_ASMCode &= "8B1B" ;mov ebx,[ebx] $_ASMCode &= "FF73" & Hex($OffSetByteAtaTime,2) ;push [ebx + $OffSetByteAtaTime] $_ASMCode &= "8B53" & Hex($OffSetMovePos,2) ;mov edx,[ebx + $OffSetMovePos] $_ASMCode &= "8B43" & Hex($OffSethLockData,2) ;mov eax,[ebx + $OffSethLockData] $_ASMCode &= "03C2" ;add eax,edx $_ASMCode &= "50" ;push eax $_ASMCode &= "FF73" & Hex($OffSetHIntOpenUrl,2) ;push [ebx + $OffSetHIntOpenUrl] $_ASMCode &= "B8" & HexBinary($InternetReadFile) ;mov eax,$InternetReadFile $_ASMCode &= "FFD0" ;call eax $_ASMCode &= "BB" & HexBinary($VER1PTR) ;mov ebx,$VER1PTR $_ASMCode &= "8903" ;mov [ebx],eax $_ASMCode &= "BB" & HexBinary($VER2PTR) ;mov ebx,$VER2PTR $_ASMCode &= "8B1B" ;mov ebx,[ebx] $_ASMCode &= "8B43" & Hex($OffSetNuOfBytesRead,2) ;mov eax,[ebx + $OffSetNuOfBytesRead] $_ASMCode &= "0143" & Hex($OffSetMovePos,2) ;add [ebx + $OffSetMovePos],eax $_ASMCode &= "BB" & HexBinary($VER1PTR) ;mov ebx,$VER1PTR $_ASMCode &= "8B03" ;mov eax,[ebx] $_ASMCode &= "83F8" & Hex(0,2) ;CMP eax,0 $_ASMCode &= "74" & Hex(($Complete - $JZComplete),2) ;JZ Complete $JZComplete = BinaryLen($_ASMCode) $_ASMCode &= "BB" & HexBinary($VER2PTR) ;mov ebx,$VER2PTR $_ASMCode &= "8B1B" ;mov ebx,[ebx] $_ASMCode &= "807B" & Hex($OffSetNuOfBytesRead,2) & Hex(0,2) ;CMP [ebx + $OffSetNuOfBytesRead],0 $_ASMCode &= "74" & Hex(($Complete - $JZComplete2),2) ;JZ Complete $JZComplete2 = BinaryLen($_ASMCode) $_ASMCode &= "B8" & HexBinary(0) ;mov eax,0 $_ASMCode &= "C2" & Hex($PtrSize,2) & Hex(0,2) ;ret ($PtrSize) & "00" // Args Size ; Complete: // $Complete = BinaryLen($_ASMCode) $_ASMCode &= "BB" & HexBinary($VER2PTR) ;mov ebx,$VER2PTR $_ASMCode &= "8B1B" ;mov ebx,[ebx] $_ASMCode &= "C643" & Hex($OffSetComplete,2) & Hex(1,2) ;mov [ebx + $OffSetComplete],1 $_ASMCode &= "FF73" & Hex($OffSetHIntOpenUrl,2) ;push [ebx + $OffSetHIntOpenUrl] $_ASMCode &= "B8" & HexBinary($InternetCloseHandle) ;mov eax,$InternetCloseHandle $_ASMCode &= "FFD0" ;call eax $_ASMCode &= "BB" & HexBinary($VER2PTR) ;mov ebx,$VER2PTR $_ASMCode &= "8B1B" ;mov ebx,[ebx] $_ASMCode &= "FF73" & Hex($OffSetMemString,2) ;push [ebx + $OffSetMemString] $_ASMCode &= "B8" & HexBinary($GlobalFree) ;mov eax,$GlobalFree $_ASMCode &= "FFD0" ;call eax $_ASMCode &= "807A" & Hex($OffSetCancel,2) & Hex(1,2) ;CMP [edx + $OffSetCancel],1 // Cancel $_ASMCode &= "0F84" & HexBinary(($MemFree - $JZCancel2)) ;JZ $MemFree; $JZCancel2 = BinaryLen($_ASMCode) $_ASMCode &= "68" & HexBinary(0x0042) ;push $GHND = 0x0042 $_ASMCode &= "8B43" & Hex($OffSetMovePos,2) ;mov eax,[ebx + $OffSetMovePos] $_ASMCode &= "50" ;push eax $_ASMCode &= "FF73" & Hex($OffSetMemData,2) ;push [ebx + $OffSetMemData] $_ASMCode &= "B8" & HexBinary($GlobalReAlloc) ;mov eax,$GlobalReAlloc $_ASMCode &= "FFD0" ;call eax $_ASMCode &= "BB" & HexBinary($VER2PTR) ;mov ebx,$VER2PTR $_ASMCode &= "8B1B" ;mov ebx,[ebx] $_ASMCode &= "8943" & Hex($OffSetMemData,2) ;mov [ebx + $OffSetMemData],eax $_ASMCode &= "50" ;push eax $_ASMCode &= "B8" & HexBinary($GlobalLock) ;mov eax,$GlobalLock $_ASMCode &= "FFD0" ;call eax $_ASMCode &= "BB" & HexBinary($VER2PTR) ;mov ebx,$VER2PTR $_ASMCode &= "8B1B" ;mov ebx,[ebx] $_ASMCode &= "8943" & Hex($OffSethLockData,2) ;mov [ebx + $OffSethLockData],eax $_ASMCode &= "B8" & HexBinary(0) ;mov eax,0 $_ASMCode &= "C2" & Hex($PtrSize,2) & Hex(0,2) ;ret ($PtrSize) & "00" // Args Size ; MemFree: // $MemFree = BinaryLen($_ASMCode) $_ASMCode &= "BB" & HexBinary($VER2PTR) ;mov ebx,$VER2PTR $_ASMCode &= "8B1B" ;mov ebx,[ebx] $_ASMCode &= "FF73" & Hex($OffSetMemData,2) ;push [ebx + $OffSetMemData] $_ASMCode &= "B8" & HexBinary($GlobalFree) ;mov eax,$GlobalFree $_ASMCode &= "FFD0" ;call eax $_ASMCode &= "B8" & HexBinary(0) ;mov eax,0 $_ASMCode &= "C2" & Hex($PtrSize,2) & Hex(0,2) ;ret ($PtrSize) & "00" // Args Size Next $AddressSt = DllStructCreate("byte[" & BinaryLen($_ASMCode) & "]") DllStructSetData($AddressSt,1,$_ASMCode) Return $AddressSt EndFunc Func LoadFileDownLoad() Local $OffSetInetHandle = $PtrSize Local $VER1PTR = DllStructGetPtr( $ASMVER ,"VER1") Local $VER2PTR = DllStructGetPtr( $ASMVER ,"VER2") Local $OffSetComplete = 0 Local $OffSetByteAtaTime = ( $DwordSize * 5) Local $OffSetNuOfBytesRead = ($DwordSize * 7) Local $OffSethLockData = ($DwordSize * 8) Local $OffSethFile = (($DwordSize * 8) + $PtrSize) Local $OffSetNuOfBytesWn = (($DwordSize * 8) + ($PtrSize * 2)) Local $OffSetHIntOpenUrl = (($DwordSize * 10) + ($PtrSize * 2)) Local $OffSetCancel = (($DwordSize * 9) + ($PtrSize * 2)) Local $OffSetMemData = (($DwordSize * 10) + ($PtrSize * 7)) Local $OffSetMemString = (($DwordSize * 10) + ($PtrSize * 8)) Local $OffSetMovePos = ($DwordSize * 4) Local $Complete , $JZCancel , $JZComplete2 , $JZComplete Local $vStartDownLoad,$vJZStartDownLoad,$JMP__Next,$__Next Local $StartDownLoadPtr = DllStructGetPtr($StartDownLoad) For $i = 1 To 2 $_ASMCode = "0x" $_ASMCode &= "8B5C24" & Hex($OffSetInetHandle,2) ;mov ebx,[esp + $OffSetInetHandle] $_ASMCode &= "B8" & HexBinary($VER2PTR) ;mov eax,$VER2PTR $_ASMCode &= "8918" ;mov [eax],ebx $_ASMCode &= "807B" & Hex($OffSetHIntOpenUrl,2) & Hex(0,2) ;CMP [ebx + $OffSetHIntOpenUrl],0 $_ASMCode &= "74" & Hex($vStartDownLoad - $vJZStartDownLoad,2) ;JZ $vStartDownLoad $vJZStartDownLoad = BinaryLen($_ASMCode) $_ASMCode &= "EB" & Hex(($__Next - $JMP__Next),2) ;JMP __Next $JMP__Next = BinaryLen($_ASMCode) ; StartDownLoad: // $vStartDownLoad = BinaryLen($_ASMCode) $_ASMCode &= "53" ;push ebx $_ASMCode &= "B8" & HexBinary($StartDownLoadPtr) ;mov eax,$StartDownLoadPtr $_ASMCode &= "FFD0" ;call eax $_ASMCode &= "B8" & HexBinary(0) ;mov eax,0 $_ASMCode &= "C2" & Hex($PtrSize,2) & Hex(0,2) ;ret ($PtrSize) & "00" // Args Size ; __Next: // $__Next = BinaryLen($_ASMCode) $_ASMCode &= "807A" & Hex($OffSetCancel,2) & Hex(1,2) ;CMP [edx + $OffSetCancel],1 // Cancel $_ASMCode &= "0F84" & HexBinary(($Complete - $JZCancel)) ;JZ Complete; $JZCancel = BinaryLen($_ASMCode) $_ASMCode &= "C643" & Hex($OffSetNuOfBytesRead,2) & Hex(0,2) ;mov [ebx + $OffSetNuOfBytesRead],0 $_ASMCode &= "83C3" & Hex($OffSetNuOfBytesRead,2) ;add ebx,$OffSetNuOfBytesRead $_ASMCode &= "53" ;push ebx $_ASMCode &= "BB" & HexBinary($VER2PTR) ;mov ebx,$VER2PTR $_ASMCode &= "8B1B" ;mov ebx,[ebx] $_ASMCode &= "FF73" & Hex($OffSetByteAtaTime,2) ;push [ebx + $OffSetByteAtaTime] $_ASMCode &= "FF73" & Hex($OffSethLockData,2) ;push [ebx + $OffSethLockData] $_ASMCode &= "FF73" & Hex($OffSetHIntOpenUrl,2) ;push [ebx + $OffSetHIntOpenUrl] $_ASMCode &= "B8" & HexBinary($InternetReadFile) ;mov eax,$InternetReadFile $_ASMCode &= "FFD0" ;call eax $_ASMCode &= "BB" & HexBinary($VER1PTR) ;mov ebx,$VER1PTR $_ASMCode &= "8903" ;mov [ebx],eax $_ASMCode &= "BB" & HexBinary($VER2PTR) ;mov ebx,$VER2PTR $_ASMCode &= "8B1B" ;mov ebx,[ebx] $_ASMCode &= "68" & HexBinary(0) ;push lpOverlapped = 0 $_ASMCode &= "83C3" & Hex($OffSetNuOfBytesWn,2) ;add ebx,$OffSetNuOfBytesWn $_ASMCode &= "53" ;push ebx $_ASMCode &= "BB" & HexBinary($VER2PTR) ;mov ebx,$VER2PTR $_ASMCode &= "8B1B" ;mov ebx,[ebx] $_ASMCode &= "FF73" & Hex($OffSetNuOfBytesRead,2) ;push [ebx + $OffSetNuOfBytesRead] $_ASMCode &= "FF73" & Hex($OffSethLockData,2) ;push [ebx + $OffSethLockData] $_ASMCode &= "FF73" & Hex($OffSethFile,2) ;push [ebx + $OffSethFile] $_ASMCode &= "B8" & HexBinary($WriteFile) ;mov eax,$WriteFile $_ASMCode &= "FFD0" ;call eax $_ASMCode &= "BB" & HexBinary($VER2PTR) ;mov ebx,$VER2PTR $_ASMCode &= "8B1B" ;mov ebx,[ebx] $_ASMCode &= "8B43" & Hex($OffSetNuOfBytesRead,2) ;mov eax,[ebx + $OffSetNuOfBytesRead] $_ASMCode &= "0143" & Hex($OffSetMovePos,2) ;add [ebx + $OffSetMovePos],eax $_ASMCode &= "BB" & HexBinary($VER1PTR) ;mov ebx,$VER1PTR $_ASMCode &= "8B03" ;mov eax,[ebx] $_ASMCode &= "83F8" & Hex(0,2) ;CMP eax,0 $_ASMCode &= "74" & Hex(($Complete - $JZComplete),2) ;JZ Complete $JZComplete = BinaryLen($_ASMCode) $_ASMCode &= "BB" & HexBinary($VER2PTR) ;mov ebx,$VER2PTR $_ASMCode &= "8B1B" ;mov ebx,[ebx] $_ASMCode &= "807B" & Hex($OffSetNuOfBytesRead,2) & Hex(0,2) ;CMP [ebx + $OffSetNuOfBytesRead],0 $_ASMCode &= "74" & Hex(($Complete - $JZComplete2),2) ;JZ Complete $JZComplete2 = BinaryLen($_ASMCode) $_ASMCode &= "B8" & HexBinary(0) ;mov eax,0 $_ASMCode &= "C2" & Hex($PtrSize,2) & Hex(0,2) ;ret ($PtrSize) & "00" // Args Size ; Complete: // $Complete = BinaryLen($_ASMCode) $_ASMCode &= "BB" & HexBinary($VER2PTR) ;mov ebx,$VER2PTR $_ASMCode &= "8B1B" ;mov ebx,[ebx] $_ASMCode &= "C643" & Hex($OffSetComplete,2) & Hex(1,2) ;mov [ebx + $OffSetComplete],1 $_ASMCode &= "FF73" & Hex($OffSetHIntOpenUrl,2) ;push [ebx + $OffSetHIntOpenUrl] $_ASMCode &= "B8" & HexBinary($InternetCloseHandle) ;mov eax,$InternetCloseHandle $_ASMCode &= "FFD0" ;call eax $_ASMCode &= "BB" & HexBinary($VER2PTR) ;mov ebx,$VER2PTR $_ASMCode &= "8B1B" ;mov ebx,[ebx] $_ASMCode &= "FF73" & Hex($OffSethFile,2) ;push [ebx + $OffSethFile] $_ASMCode &= "B8" & HexBinary($CloseHandle) ;mov eax,$CloseHandle $_ASMCode &= "FFD0" ;call eax $_ASMCode &= "BB" & HexBinary($VER2PTR) ;mov ebx,$VER2PTR $_ASMCode &= "8B1B" ;mov ebx,[ebx] $_ASMCode &= "FF73" & Hex($OffSetMemData,2) ;push [ebx + $OffSetMemData] $_ASMCode &= "B8" & HexBinary($GlobalFree) ;mov eax,$GlobalFree $_ASMCode &= "FFD0" ;call eax $_ASMCode &= "BB" & HexBinary($VER2PTR) ;mov ebx,$VER2PTR $_ASMCode &= "8B1B" ;mov ebx,[ebx] $_ASMCode &= "FF73" & Hex($OffSetMemString,2) ;push [ebx + $OffSetMemString] $_ASMCode &= "B8" & HexBinary($GlobalFree) ;mov eax,$GlobalFree $_ASMCode &= "FFD0" ;call eax $_ASMCode &= "B8" & HexBinary(0) ;mov eax,0 $_ASMCode &= "C2" & Hex($PtrSize,2) & Hex(0,2) ;ret ($PtrSize) & "00" // Args Size Next $AddressSt = DllStructCreate("byte[" & BinaryLen($_ASMCode) & "]") DllStructSetData($AddressSt,1,$_ASMCode) Return $AddressSt EndFunc Func LoadStartDownLoad() Local $OffSetInetHandle = $PtrSize Local $OffSetFileSize = ($DwordSize * 6) Local $OffSetComplete = 0 , $OffSetError = ( $DwordSize * 3 ) Local $OffSetHIntOpenUrl = (($DwordSize * 10) + ($PtrSize * 2)) Local $OffSetStringUrl = (($DwordSize * 10) + ($PtrSize * 5)) Local $OffSetHIntOpen = (($DwordSize * 10) + ($PtrSize * 6)) Local $OffSetMemData = (($DwordSize * 10) + ($PtrSize * 7)) Local $OffSetMemString = (($DwordSize * 10) + ($PtrSize * 8)) Local $OffSetMemBool = ($DwordSize * 2) Local $OffSethFile = (($DwordSize * 8) + $PtrSize) Local $lpdwBufferLength = 100 , $dwInfoLevel = 5 $lpdwBufferStruct = DllStructCreate("WCHAR[100]") Local $BufPtr = DllStructGetPtr($lpdwBufferStruct) Local $VER1PTR = DllStructGetPtr( $ASMVER ,"VER1") Local $VER2PTR = DllStructGetPtr( $ASMVER ,"VER2") Local $Error,$JZError,$JZReturn,$Return For $i = 1 To 2 $_ASMCode = "0x" $_ASMCode &= "8B5C24" & Hex($OffSetInetHandle,2) ;mov ebx,[esp + $OffSetInetHandle] $_ASMCode &= "B8" & HexBinary($VER2PTR) ;mov eax,$VER2PTR $_ASMCode &= "8918" ;mov [eax],ebx $_ASMCode &= "B8" & HexBinary(0) ;mov eax,0 $_ASMCode &= "50" ;push eax $_ASMCode &= "50" ;push eax $_ASMCode &= "50" ;push eax $_ASMCode &= "50" ;push eax $_ASMCode &= "FF73" & Hex($OffSetStringUrl,2) ;push [ebx + $OffSetStringUrl] $_ASMCode &= "FF73" & Hex($OffSetHIntOpen,2) ;push [ebx + $OffSetHIntOpen] $_ASMCode &= "B8" & HexBinary($InternetOpenUrlW) ;mov eax,$InternetOpenUrlW $_ASMCode &= "FFD0" ;call eax $_ASMCode &= "83F8" & Hex(0,2) ;CMP eax,0 $_ASMCode &= "74" & Hex($Error - $JZError,2) ;JZ Error $JZError = BinaryLen($_ASMCode) $_ASMCode &= "BB" & HexBinary($VER2PTR) ;mov ebx,$VER2PTR $_ASMCode &= "8B1B" ;mov ebx,[ebx] $_ASMCode &= "8943" & Hex($OffSetHIntOpenUrl,2) ;mov [ebx + $OffSetHIntOpenUrl],eax $_ASMCode &= "B8" & HexBinary(0) ;mov eax,0 $_ASMCode &= "50" ;push eax $_ASMCode &= "B8" & HexBinary($VER1PTR) ;mov eax,$VER1PTR $_ASMCode &= "C600" & Hex($lpdwBufferLength,2) ;mov [eax],$lpdwBufferLength $_ASMCode &= "50" ;push eax $_ASMCode &= "B8" & HexBinary($BufPtr) ;mov eax,$BufPtr $_ASMCode &= "C600" & Hex(0,2) ;mov [eax],0 $_ASMCode &= "50" ;push eax $_ASMCode &= "B8" & HexBinary($dwInfoLevel) ;mov eax,$dwInfoLevel $_ASMCode &= "50" ;push eax $_ASMCode &= "FF73" & Hex($OffSetHIntOpenUrl,2) ;push [ebx + $OffSetHIntOpenUrl] $_ASMCode &= "B8" & HexBinary($HttpQueryInfoW) ;mov eax,$HttpQueryInfoW $_ASMCode &= "FFD0" ;call eax $_ASMCode &= "B8" & HexBinary($BufPtr) ;mov eax,$BufPtr $_ASMCode &= "50" ;push eax $_ASMCode &= "B8" & HexBinary($_wtol) ;mov eax,$_wtol $_ASMCode &= "FFD0" ;call eax $_ASMCode &= "83C4" & Hex($DwordSize,2) ;add esp,$DwordSize $_ASMCode &= "BB" & HexBinary($VER2PTR) ;mov ebx,$VER2PTR $_ASMCode &= "8B1B" ;mov ebx,[ebx] $_ASMCode &= "8943" & Hex($OffSetFileSize,2) ;mov [ebx + $OffSetFileSize],eax $_ASMCode &= "B8" & HexBinary(1) ;mov eax,1 $_ASMCode &= "C2" & Hex($PtrSize,2) & Hex(0,2) ;ret ($PtrSize) & "00" // Args Size ; $Error: // $Error = BinaryLen($_ASMCode) $_ASMCode &= "BB" & HexBinary($VER2PTR) ;mov ebx,$VER2PTR $_ASMCode &= "8B1B" ;mov ebx,[ebx] $_ASMCode &= "C643" & Hex($OffSetComplete,2) & Hex(1,2) ;mov [ebx + $OffSetComplete],1 $_ASMCode &= "C643" & Hex($OffSetError,2) & Hex(1,2) ;mov [ebx + $OffSetError],1 $_ASMCode &= "FF73" & Hex($OffSetMemData,2) ;push [ebx + $OffSetMemData] $_ASMCode &= "B8" & HexBinary($GlobalFree) ;mov eax,$GlobalFree $_ASMCode &= "FFD0" ;call eax $_ASMCode &= "BB" & HexBinary($VER2PTR) ;mov ebx,$VER2PTR $_ASMCode &= "8B1B" ;mov ebx,[ebx] $_ASMCode &= "FF73" & Hex($OffSetMemString,2) ;push [ebx + $OffSetMemString] $_ASMCode &= "B8" & HexBinary($GlobalFree) ;mov eax,$GlobalFree $_ASMCode &= "FFD0" ;call eax $_ASMCode &= "BB" & HexBinary($VER2PTR) ;mov ebx,$VER2PTR $_ASMCode &= "8B1B" ;mov ebx,[ebx] $_ASMCode &= "807A" & Hex($OffSetMemBool,2) & Hex(1,2) ;CMP [edx + $OffSetMemBool],1 $JZReturn = BinaryLen($_ASMCode) $_ASMCode &= "74" & Hex($Return - $JZReturn,2) ;JZ Return $_ASMCode &= "FF73" & Hex($OffSethFile,2) ;push [ebx + $OffSethFile] $_ASMCode &= "B8" & HexBinary($CloseHandle) ;mov eax,$CloseHandle $_ASMCode &= "FFD0" ;call eax ; $Return: // $Return = BinaryLen($_ASMCode) $_ASMCode &= "B8" & HexBinary(0) ;mov eax,0 $_ASMCode &= "C2" & Hex($PtrSize,2) & Hex(0,2) ;ret ($PtrSize) & "00" // Args Size Next $AddressSt = DllStructCreate("byte[" & BinaryLen($_ASMCode) & "]") DllStructSetData($AddressSt,1,$_ASMCode) Return $AddressSt EndFunc Func LoadFreeInetHandle() Local $VER2PTR = DllStructGetPtr( $ASMVER , "VER2" ) Local $InetHandlesPtrPtr = DllStructGetPtr($InetHandlesPtr) Local $OffSetMemData = (($DwordSize * 10) + ($PtrSize * 7)) Local $OffSetMemString = (($DwordSize * 10) + ($PtrSize * 8)) Local $OffSetHIntOpenUrl = (($DwordSize * 10) + ($PtrSize * 2)) Local $OffSethFile = (($DwordSize * 8) + $PtrSize) Local $OffSetMemInetHandle = (($DwordSize * 10) + ($PtrSize * 3)) Local $OffSetUpdate = 0 , $OffSetCompleteAll = $DwordSize Local $OffSetInetHandlesPtr = ($OffSetCompleteAll + $DwordSize) Local $OffSetFreeHandle = (($DwordSize * 10) + ($PtrSize * 9)) Local $OffSetFreeInetHandles = ($OffSetInetHandlesPtr + $PtrSize) Local $OffSetLOOP = ($OffSetFreeInetHandles + $PtrSize) Local $OffSetMovePos = ($OffSetLOOP + $DwordSize) Local $OffSetMemBool = ($DwordSize * 2) Local $OffSetPause = $DwordSize , $OffSetComplete = 0 Local $OffSetInetHandles = $DwordSize Local $__Next,$JZ__Next,$JZMemDown,$MemDown,$JMP__Next For $i = 1 To 2 $_ASMCode = "0x" $_ASMCode &= "BB" & HexBinary($InetHandlesPtrPtr) ;mov ebx,$InetHandlesPtrPtr $_ASMCode &= "8B43" & Hex($OffSetMovePos,2) ;mov eax,[ebx + $OffSetMovePos] $_ASMCode &= "8B53" & Hex($OffSetInetHandlesPtr,2) ;mov edx,[ebx + $OffSetInetHandlesPtr] $_ASMCode &= "83C2" & Hex($OffSetInetHandles,2) ;add edx,$OffSetInetHandles $_ASMCode &= "03D0" ;add edx,eax $_ASMCode &= "8B12" ;mov edx,[edx] $_ASMCode &= "B8" & HexBinary($VER2PTR) ;mov eax,$VER2PTR $_ASMCode &= "8910" ;mov [eax],edx $_ASMCode &= "807A" & Hex($OffSetComplete,2) & Hex(1,2) ;CMP [edx + $OffSetComplete],1 // Complete $_ASMCode &= "0F84" & HexBinary($__Next - $JZ__Next) ;JZ JZ__Next $JZ__Next = BinaryLen($_ASMCode) $_ASMCode &= "807A" & Hex($OffSetMemBool,2) & Hex(1,2) ;CMP [edx + $OffSetMemBool],1 $_ASMCode &= "74" & Hex($MemDown - $JZMemDown,2) ;JZ $MemDown $JZMemDown = BinaryLen($_ASMCode) $_ASMCode &= "FF73" & Hex($OffSetHIntOpenUrl,2) ;push [ebx + $OffSetHIntOpenUrl] $_ASMCode &= "B8" & HexBinary($InternetCloseHandle) ;mov eax,$InternetCloseHandle $_ASMCode &= "FFD0" ;call eax $_ASMCode &= "BB" & HexBinary($VER2PTR) ;mov ebx,$VER2PTR $_ASMCode &= "8B1B" ;mov ebx,[ebx] $_ASMCode &= "FF73" & Hex($OffSethFile,2) ;push [ebx + $OffSethFile] $_ASMCode &= "B8" & HexBinary($CloseHandle) ;mov eax,$CloseHandle $_ASMCode &= "FFD0" ;call eax $_ASMCode &= "BB" & HexBinary($VER2PTR) ;mov ebx,$VER2PTR $_ASMCode &= "8B1B" ;mov ebx,[ebx] $_ASMCode &= "FF73" & Hex($OffSetMemData,2) ;push [ebx + $OffSetMemData] $_ASMCode &= "B8" & HexBinary($GlobalFree) ;mov eax,$GlobalFree $_ASMCode &= "FFD0" ;call eax $_ASMCode &= "BB" & HexBinary($VER2PTR) ;mov ebx,$VER2PTR $_ASMCode &= "8B1B" ;mov ebx,[ebx] $_ASMCode &= "FF73" & Hex($OffSetMemString,2) ;push [ebx + $OffSetMemString] $_ASMCode &= "B8" & HexBinary($GlobalFree) ;mov eax,$GlobalFree $_ASMCode &= "FFD0" ;call eax $_ASMCode &= "BB" & HexBinary($VER2PTR) ;mov ebx,$VER2PTR $_ASMCode &= "8B1B" ;mov ebx,[ebx] $_ASMCode &= "FF73" & Hex($OffSetMemInetHandle,2) ;push [ebx + $OffSetMemInetHandle] $_ASMCode &= "B8" & HexBinary($GlobalFree) ;mov eax,$GlobalFree $_ASMCode &= "FFD0" ;call eax $_ASMCode &= "EB" & Hex(($__Next - $JMP__Next),2) ;JMP __Next $JMP__Next = BinaryLen($_ASMCode) ; $MemDown: // $MemDown = BinaryLen($_ASMCode) $_ASMCode &= "FF73" & Hex($OffSetHIntOpenUrl,2) ;push [ebx + $OffSetHIntOpenUrl] $_ASMCode &= "B8" & HexBinary($InternetCloseHandle) ;mov eax,$InternetCloseHandle $_ASMCode &= "FFD0" ;call eax $_ASMCode &= "BB" & HexBinary($VER2PTR) ;mov ebx,$VER2PTR $_ASMCode &= "8B1B" ;mov ebx,[ebx] $_ASMCode &= "FF73" & Hex($OffSetMemData,2) ;push [ebx + $OffSetMemData] $_ASMCode &= "B8" & HexBinary($GlobalFree) ;mov eax,$GlobalFree $_ASMCode &= "FFD0" ;call eax $_ASMCode &= "BB" & HexBinary($VER2PTR) ;mov ebx,$VER2PTR $_ASMCode &= "8B1B" ;mov ebx,[ebx] $_ASMCode &= "FF73" & Hex($OffSetMemString,2) ;push [ebx + $OffSetMemString] $_ASMCode &= "B8" & HexBinary($GlobalFree) ;mov eax,$GlobalFree $_ASMCode &= "FFD0" ;call eax $_ASMCode &= "BB" & HexBinary($VER2PTR) ;mov ebx,$VER2PTR $_ASMCode &= "8B1B" ;mov ebx,[ebx] $_ASMCode &= "FF73" & Hex($OffSetMemInetHandle,2) ;push [ebx + $OffSetMemInetHandle] $_ASMCode &= "B8" & HexBinary($GlobalFree) ;mov eax,$GlobalFree $_ASMCode &= "FFD0" ;call eax ; $__Next: // $__Next = BinaryLen($_ASMCode) $_ASMCode &= "BB" & HexBinary($InetHandlesPtrPtr) ;mov ebx,$InetHandlesPtrPtr $_ASMCode &= "8B43" & Hex($OffSetMovePos,2) ;mov eax,[ebx + $OffSetMovePos] $_ASMCode &= "8B53" & Hex($OffSetInetHandlesPtr,2) ;mov edx,[ebx + $OffSetInetHandlesPtr] $_ASMCode &= "03D0" ;add edx,eax $_ASMCode &= "83C2" & Hex($OffSetInetHandles,2) ;add edx,$OffSetInetHandles $_ASMCode &= "68" & HexBinary($PtrSize) ; push $PtrSize $_ASMCode &= "68" & HexBinary(0) ; push 0 $_ASMCode &= "52" ;push edx $_ASMCode &= "B8" & HexBinary($memset) ;mov eax,$memset $_ASMCode &= "FFD0" ;call eax $_ASMCode &= "83C4" & Hex(($DwordSize + ($PtrSize * 2)),2) ;add esp,(($DwordSize * 2) + $PtrSize) $_ASMCode &= "C2" & Hex(0,2) & Hex(0,2) ;ret (0) & "00" // Args Size Next $AddressSt = DllStructCreate("byte[" & BinaryLen($_ASMCode) & "]") DllStructSetData($AddressSt,1,$_ASMCode) Return $AddressSt EndFunc Func DownloadReSetPause($HLockHandle) Local $InetHandle = DllStructCreate($tagInetHandle,$HLockHandle) if @error Then Return SetError(1,0,False) $Pause = DllStructGetData($InetHandle,"Pause") if @error Then Return SetError(2,0,False) $Complete = DllStructGetData($InetHandle,"Complete") if @error Or ($Complete) Then Return SetError(3,0,False) DllStructSetData($InetHandle,"Pause",Not($Pause)) if @error Then Return SetError(4,0,False) Return SetError(0,0,True) EndFunc Func DownloadCancel($HLockHandle) Local $InetHandle = DllStructCreate($tagInetHandle,$HLockHandle) if @error Then Return SetError(1,0,False) $Cancel = DllStructGetData($InetHandle,"Cancel") if @error Or ($Cancel) Then Return SetError(2,0,False) $Complete = DllStructGetData($InetHandle,"Complete") if @error Or ($Complete) Then Return SetError(3,0,False) $Pause = DllStructGetData($InetHandle,"Pause") if @error Then Return SetError(4,0,False) if ($Pause) Then DownloadReSetPause($InetHandle) if @error Then Return SetError(5,0,False) DllStructSetData($InetHandle,"Cancel",1) if @error Then Return SetError(6,0,False) Return SetError(0,0,True) EndFunc Func DownloadGetInfo($HLockHandle) Local $InetHandle = DllStructCreate($tagInetHandle,$HLockHandle) if @error Then Return SetError(1,0,0) $MemBool = DllStructGetData($InetHandle,"MemBool") if @error Then Return SetError(2,0,0) Local $InfoArray[11] if ($MemBool) Then $InfoArray[0] = $MemBool $InfoArray[1] = DllStructGetData($InetHandle,"Complete") $InfoArray[2] = DllStructGetData($InetHandle,"Pause") $InfoArray[3] = DllStructGetData($InetHandle,"Cancel") $InfoArray[4] = DllStructGetData($InetHandle,"Error") $InfoArray[5] = DllStructGetData($InetHandle,"MovePos") $InfoArray[6] = DllStructGetData($InetHandle,"FileSize") $InfoArray[7] = DllStructGetData($InetHandle,"BytesAtaTime") $InfoArray[8] = DllStructGetData($InetHandle,"NuOfBytesRead") $InfoArray[9] = DllStructGetData($InetHandle,"hLockData") $InfoArray[10] = DllStructGetData($InetHandle,"MemData") Else $InfoArray[0] = $MemBool $InfoArray[1] = DllStructGetData($InetHandle,"Complete") $InfoArray[2] = DllStructGetData($InetHandle,"Pause") $InfoArray[3] = DllStructGetData($InetHandle,"Cancel") $InfoArray[4] = DllStructGetData($InetHandle,"Error") $InfoArray[5] = DllStructGetData($InetHandle,"MovePos") $InfoArray[6] = DllStructGetData($InetHandle,"FileSize") $InfoArray[7] = DllStructGetData($InetHandle,"BytesAtaTime") $InfoArray[8] = DllStructGetData($InetHandle,"NuOfBytesRead") $InfoArray[9] = 0 $InfoArray[10] = 0 EndIf Return SetError(0,0,$InfoArray) EndFunc Func DownloadFreeHLockHandle($HLockHandle) Local $InetHandle = DllStructCreate($tagInetHandle,$HLockHandle) if @error Then Return SetError(1,0,0) DllStructSetData($InetHandle,"FreeHandle",1) if @error Then Return SetError(2,0,False) Return SetError(0,0,True) EndFunc Func HexBinary($Value) Return Hex(Binary($Value)) EndFunc Func CreateThread($lpStartAddress,$lpParameter = 0) $Return = DllCall("Kernel32.dll","ptr","CreateThread","ptr",0,"DWORD",0 _ ,"ptr",$lpStartAddress,"ptr",$lpParameter,"DWORD",0,"DWORD*",0) if @error Or $Return[0] = 0 Then Return SetError(1,0,0) $lpThreadId = $Return[6] Return SetError(0,$lpThreadId,$Return[0]) EndFunc Func GlobalHandle($pMem) $HGLOBAL = DllCall("Kernel32.dll","ptr","GlobalHandle","ptr",$pMem) if @error Or $HGLOBAL[0] = 0 Then Return SetError(1,0,0) Return SetError(0,0,$HGLOBAL[0]) EndFunc Func InternetReadFile($hFile,$lpBuffer,$dwNumberOfBytesToRead) $DLLSDWORD = DllStructCreate("DWORD") $lpdwNumberOfBytesRead = DllStructGetPtr($DLLSDWORD) $BOOL = DllCall($Wininet,"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($Wininet,"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 InternetOpenUrl($hInternet,$lpszUrl,$lpszHeaders,$dwHeadersLength,$dwFlags,$dwContext) $HINTERNET = DllCall($Wininet,"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($Wininet,"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($Wininet,"BOOL","InternetCloseHandle","HANDLE",$hInternet) if @error Or $BOOL[0] = 0 Then Return SetError(1,0,0) Return SetError(0,0,$BOOL[0]) EndFunc DownloadExample.au3 #include <WinAPI.au3> #include <Memory.au3> #include <ProgressConstants.au3> #Include <GuiButton.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Include "ASM_Download.au3" #Include "GUICtrlSetOnEventEx.au3" Global $Array $controlID1 = DownloaderMultiFiles($Array,"http://www.swfmax.com/get/SWF.max.exe",@ScriptDir & "\Dir1\SWF.max.exe") GUICtrlSetOnEventEx($controlID1,$BN_CLICKED,"Clicked_Pause_Buttons") GUICtrlSetOnEventEx($controlID1 + 1,$BN_CLICKED,"Clicked_Cancel_Buttons") $controlID2 = DownloaderMultiFiles($Array,"http://download.winzip.com/winzip150.exe",@ScriptDir & "\Dir1\winzip150.exe") GUICtrlSetOnEventEx($controlID2,$BN_CLICKED,"Clicked_Pause_Buttons") GUICtrlSetOnEventEx($controlID2 + 1,$BN_CLICKED,"Clicked_Cancel_Buttons") ;---------------------------Memory---------------------------------------------------------------------------------------------- $controlID3 = DownloaderMultiFiles($Array,"http://www.flash-swf-converter.com/downloads/swfconverter.exe","",True) ;True Memory GUICtrlSetOnEventEx($controlID3,$BN_CLICKED,"Clicked_Pause_Buttons") GUICtrlSetOnEventEx($controlID3 + 1,$BN_CLICKED,"Clicked_Cancel_Buttons") ;---------------------------Memory---------------------------------------------------------------------------------------------- $controlID4 = DownloaderMultiFiles($Array,"http://www.win-rar.com/fileadmin/winrar-versions/wrar420.exe",@ScriptDir & "\Dir2\wrar420.exe") GUICtrlSetOnEventEx($controlID4,$BN_CLICKED,"Clicked_Pause_Buttons") GUICtrlSetOnEventEx($controlID4 + 1,$BN_CLICKED,"Clicked_Cancel_Buttons") $controlID5 = DownloaderMultiFiles($Array,"http://bookstore.ashrae.biz/journal/download.php?file=ASHRAE-D-AJ10Jan05-20091230.pdf",@ScriptDir & "\Dir2\20091230.pdf") GUICtrlSetOnEventEx($controlID5,$BN_CLICKED,"Clicked_Pause_Buttons") GUICtrlSetOnEventEx($controlID5 + 1,$BN_CLICKED,"Clicked_Cancel_Buttons") While 1 ProgressLoop() ;---------------------------Memory---------------------------------------------- $DownlHandle = EnvGet(($controlID3 + 1)) $InfoArray = DownloadGetInfo($DownlHandle) if Not @error Then $Complete = $InfoArray[1] if $Complete Then Local $nBytes $hLockData = $InfoArray[9] $FileSize = $InfoArray[6] ;-----------------For Unknown Size -------------------------- $MemData = $InfoArray[10] $FileSize = _MemGlobalSize($MemData) ;-----------------For Unknown Size -------------------------- $hFile = _WinAPI_CreateFile(@ScriptDir & "\Dir2\" & "Memory_swfconverter.exe",1) _WinAPI_WriteFile($hFile,$hLockData,$FileSize,$nBytes) _WinAPI_CloseHandle($hFile) DownloadFreeHLockHandle($DownlHandle) EndIf EndIf ;---------------------------Memory---------------------------------------------- if CloseThreadLoop() Then MsgBox(0,"Msg","ThreadClose") ExitLoop EndIf WEnd GUIDelete($Array[0][0]) $Array = 0 $controlID1 = DownloaderMultiFiles($Array,"http://www.swfmax.com/get/SWF.max.exe",@ScriptDir & "\Dir1\SWF.max.exe") GUICtrlSetOnEventEx($controlID1,$BN_CLICKED,"Clicked_Pause_Buttons") GUICtrlSetOnEventEx($controlID1 + 1,$BN_CLICKED,"Clicked_Cancel_Buttons") $controlID2 = DownloaderMultiFiles($Array,"http://download.winzip.com/winzip150.exe",@ScriptDir & "\Dir1\winzip150.exe") GUICtrlSetOnEventEx($controlID2,$BN_CLICKED,"Clicked_Pause_Buttons") GUICtrlSetOnEventEx($controlID2 + 1,$BN_CLICKED,"Clicked_Cancel_Buttons") ;---------------------------Memory---------------------------------------------------------------------------------------------- $controlID3 = DownloaderMultiFiles($Array,"http://www.flash-swf-converter.com/downloads/swfconverter.exe","",True) ;True Memory GUICtrlSetOnEventEx($controlID3,$BN_CLICKED,"Clicked_Pause_Buttons") GUICtrlSetOnEventEx($controlID3 + 1,$BN_CLICKED,"Clicked_Cancel_Buttons") ;---------------------------Memory---------------------------------------------------------------------------------------------- $controlID4 = DownloaderMultiFiles($Array,"http://www.win-rar.com/fileadmin/winrar-versions/wrar420.exe",@ScriptDir & "\Dir2\wrar420.exe") GUICtrlSetOnEventEx($controlID4,$BN_CLICKED,"Clicked_Pause_Buttons") GUICtrlSetOnEventEx($controlID4 + 1,$BN_CLICKED,"Clicked_Cancel_Buttons") $controlID5 = DownloaderMultiFiles($Array,"http://bookstore.ashrae.biz/journal/download.php?file=ASHRAE-D-AJ10Jan05-20091230.pdf",@ScriptDir & "\Dir2\20091230.pdf") GUICtrlSetOnEventEx($controlID5,$BN_CLICKED,"Clicked_Pause_Buttons") GUICtrlSetOnEventEx($controlID5 + 1,$BN_CLICKED,"Clicked_Cancel_Buttons") While 1 ProgressLoop() ;---------------------------Memory---------------------------------------------- $DownlHandle = EnvGet(($controlID3 + 1)) $InfoArray = DownloadGetInfo($DownlHandle) if Not @error Then $Complete = $InfoArray[1] if $Complete Then Local $nBytes $hLockData = $InfoArray[9] $FileSize = $InfoArray[6] ;-----------------For Unknown Size -------------------------- $MemData = $InfoArray[10] $FileSize = _MemGlobalSize($MemData) ;-----------------For Unknown Size -------------------------- $hFile = _WinAPI_CreateFile(@ScriptDir & "\Dir2\" & "Memory_swfconverter.exe",1) _WinAPI_WriteFile($hFile,$hLockData,$FileSize,$nBytes) _WinAPI_CloseHandle($hFile) DownloadFreeHLockHandle($DownlHandle) EndIf EndIf ;---------------------------Memory---------------------------------------------- if CloseThreadLoop() Then MsgBox(0,"Msg","ThreadClose") ExitLoop EndIf WEnd GUIDelete($Array[0][0]) $Array = 0 $controlID1 = DownloaderMultiFiles($Array,"http://msft.digitalrivercontent.net/win/X17-59463.iso",@ScriptDir & "\Dir1\X17-59463.iso") GUICtrlSetOnEventEx($controlID1,$BN_CLICKED,"Clicked_Pause_Buttons") GUICtrlSetOnEventEx($controlID1 + 1,$BN_CLICKED,"Clicked_Cancel_Buttons") While 1 ProgressLoop() if CloseThreadLoop() Then MsgBox(0,"Msg","ThreadClose") ExitLoop EndIf WEnd Func Clicked_Pause_Buttons($ControlID,$NotificationCode) $WPARAM = OnEventExGetWParam($ControlID,$NotificationCode) $LPARAM = OnEventExGetLParam($ControlID,$NotificationCode) $HWND = OnEventExGetHWND($ControlID,$NotificationCode) For $i = 0 To UBound($Array) - 1 if $ControlID = $Array[$i][5] Then ExitLoop Next $Array[$i][9] = Not $Array[$i][9] if ($Array[$i][9]) Then GUICtrlSetData($ControlID,"Reset") Else GUICtrlSetData($ControlID,"Pause") EndIf $DownlHandle = EnvGet($ControlID) DownloadReSetPause(Ptr($DownlHandle)) EndFunc Func Clicked_Cancel_Buttons($ControlID,$NotificationCode) $WPARAM = OnEventExGetWParam($ControlID,$NotificationCode) $LPARAM = OnEventExGetLParam($ControlID,$NotificationCode) $HWND = OnEventExGetHWND($ControlID,$NotificationCode) $DownlHandle = EnvGet($ControlID) DownloadCancel(Ptr($DownlHandle)) EndFunc Func ProgressLoop() Local $CompleteAll = False For $i = 0 To UBound($Array) - 1 $ProgressTime = $Array[$i][8] Sleep($ProgressTime) $InfoArray = DownloadGetInfo($Array[$i][7]) if Not @error Then $MemBool = $InfoArray[0] $Complete = $InfoArray[1] $MovePos = $InfoArray[5] $FileSize = $InfoArray[6] GUICtrlSetData($Array[$i][3],(100 / $FileSize) * $MovePos) if ($MovePos) Then if ($FileSize) Then GUICtrlSetData($Array[$i][4],"( " & StringLeft(int($MovePos / 1024) / 1000 ,12) _ & " OF " & StringLeft(int($FileSize /1024) / 1000 ,12) & " ) MB") Else GUICtrlSetData($Array[$i][4],"( " & StringLeft(int($MovePos / 1024) / 1000 ,12) _ & " OF Unknown ) MB") EndIf Else GUICtrlSetData($Array[$i][4],"( " & StringLeft(int($MovePos / 1024) / 1000 ,12) _ & " OF " & StringLeft(int($FileSize /1024) / 1000 ,12) & " ) MB") EndIf If ($Complete) Then GUICtrlSetBkColor($Array[$i][4] - 2, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetBkColor($Array[$i][4], $GUI_BKCOLOR_TRANSPARENT) if Not($MemBool) Then DownloadFreeHLockHandle($Array[$i][7]) Else $CompleteAll = True EndIf EndIf Next Return $CompleteAll EndFunc Func DownloaderMultiFiles(ByRef $Array,$link,$FileName,$MemBool = False,$ProgressTime = 100) if Not IsArray($Array) Then Dim $Array[1][10] $Array[0][0] = GUICreate("Downloader Progress", 785, 160, 5, 200, _ BitOR($WS_MINIMIZEBOX,$WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW _ ,$WS_GROUP,$WS_BORDER,$WS_CLIPSIBLINGS)) GUISetState(@SW_SHOW) Else ReDim $Array[UBound($Array) + 1][10] EndIf If Not($MemBool) Then $OutDir = StringSplit($FileName,"\") if Not FileExists(StringTrimRight($FileName,StringLen($OutDir[$OutDir[0]]))) _ Then DirCreate(StringTrimRight($FileName,StringLen($OutDir[$OutDir[0]]))) $Array[UBound($Array) - 1][1] = $link $Array[UBound($Array) - 1][2] = $FileName GUICtrlCreateLabel(StringLeft($OutDir[$OutDir[0]],23), 10, 10 + ((UBound($Array) - 1) * 30), 170, 20, BitOR($SS_CENTER,$WS_BORDER)) Else $Array[UBound($Array) - 1][1] = $link GUICtrlCreateLabel("< [ Memory ] >", 10, 10 + ((UBound($Array) - 1) * 30), 170, 20, BitOR($SS_CENTER,$WS_BORDER)) EndIf GUICtrlSetFont(-1, 10, 600, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, 0xFFFFFF) $Array[UBound($Array) - 1][3] = GUICtrlCreateProgress(190, 10 + ((UBound($Array) - 1) * 30), 200, 20) $Array[UBound($Array) - 1][4] = GUICtrlCreateLabel("", 400, 10 + ((UBound($Array) - 1) * 30), 250, 20,BitOR($SS_CENTER,$WS_BORDER)) GUICtrlSetFont(-1, 10, 600, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, 0xFFFFFF) $Array[UBound($Array) - 1][5] = GUICtrlCreateButton("Pause", 655, 10 + ((UBound($Array) - 1) * 30), 60,20) GUICtrlSetFont(-1, 10, 600, 0, "MS Sans Serif") $Array[UBound($Array) - 1][6] = GUICtrlCreateButton("Cancel", 720, 10 + ((UBound($Array) - 1) * 30), 60,20) GUICtrlSetFont(-1, 10, 600, 0, "MS Sans Serif") $Array[UBound($Array) - 1][7] = DownloadFile($Array[UBound($Array) - 1][1],30000,$MemBool,$Array[UBound($Array) - 1][2]) EnvSet($Array[UBound($Array) - 1][5],$Array[UBound($Array) - 1][7]) EnvSet($Array[UBound($Array) - 1][6],$Array[UBound($Array) - 1][7]) $Array[UBound($Array) - 1][8] = $ProgressTime Return $Array[UBound($Array) - 1][5] EndFunc GUICtrlSetOnEventEx.au3 #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $NotifyStruct = 0 , $TagNotifyStruct = "" ; GUICtrlSetOnEventEx($Control_ID_HWnd,$NotificationCode,$Function) ;$NotificationCode ==> (WM_COMMAND Notification Code And WM_NOTIFY Notification Code) ;$Function ==> ($ControlID,$NotificationCode) ; Return :Note use Func GUICtrlSetOnEventEx($Control_ID_HWnd,$NotificationCode,$Function) $handle = DLLCallbackRegister($Function,"none","int;int") if $handle = 0 Then Return False DllCallbackFree($handle) if IsHWnd($Control_ID_HWnd) Then $hWnd = $Control_ID_HWnd $ControlID = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $hWnd) If @error Then Return False $ControlID = $ControlID[0] if Not ($ControlID) Then Return False Else $ControlID = $Control_ID_HWnd $hWnd = GUICtrlGetHandle($ControlID) if Not IsHWnd($hWnd) Then Return False EndIf $iNotificationCode = $NotificationCode if StringInStr($NotificationCode,"-") Then _ $iNotificationCode = StringReplace($NotificationCode,"-","A") if Not IsDllStruct($NotifyStruct) Then Local $count = 1 $Len = StringLen($Function) $TagNotifyStruct = _ "int count;WPARAM WPARAM;LPARAM LPARAM;int Test;int " & String($hWnd & $iNotificationCode) & _ ";HWND HWND" & String($count) & ";int ControlID" & String($count) & ";int NotificationCode" & _ String($count) & ";char Function" & String($count) & "[" & String($Len) & "]" $NotifyStruct = DllStructCreate($TagNotifyStruct) DllStructSetData($NotifyStruct,"count",$count) DllStructSetData($NotifyStruct,String($hWnd & $iNotificationCode),$count) DllStructSetData($NotifyStruct,"HWND" & String($count),$hWnd) DllStructSetData($NotifyStruct,"ControlID" & String($count),$ControlID) DllStructSetData($NotifyStruct,"NotificationCode" & String($count),$NotificationCode) DllStructSetData($NotifyStruct,"Function" & String($count),$Function) Else $count = DllStructGetData($NotifyStruct,String($hWnd & $iNotificationCode)) if ($count) Then Return False Local $count = DllStructGetData($NotifyStruct,"count") + 1 $Len = StringLen($Function) $TagNotifyStruct &= _ ";int " & String($hWnd & $iNotificationCode) & ";HWND HWND" & String($count) & _ ";int NotificationCode" & String($count) & ";int ControlID" & String($count) & _ ";char Function" & String($count) & "[" & String($Len) & "]" $iLength = DllStructGetSize($NotifyStruct) $iNotifyStruct = DllStructCreate($TagNotifyStruct) DllCall("kernel32.dll","none","RtlMoveMemory","ptr",DllStructGetPtr($iNotifyStruct) _ ,"ptr",DllStructGetPtr($NotifyStruct),"ulong_ptr",$iLength) $NotifyStruct = $iNotifyStruct DllStructSetData($NotifyStruct,"count",$count) DllStructSetData($NotifyStruct,String($hWnd & $iNotificationCode),$count) DllStructSetData($NotifyStruct,"HWND" & String($count),$hWnd) DllStructSetData($NotifyStruct,"ControlID" & String($count),$ControlID) DllStructSetData($NotifyStruct,"NotificationCode" & String($count),$NotificationCode) DllStructSetData($NotifyStruct,"Function" & String($count),$Function) EndIf GUIRegisterMsg($WM_NOTIFY,"OnEventExProc") GUIRegisterMsg($WM_COMMAND,"OnEventExProc") Return True EndFunc Func OnEventExProc($hWnd,$Msg,$wParam,$lParam) Select Case $Msg = $WM_NOTIFY Local $OnEventExtagNMHDR = "hwnd hWndFrom;uint_ptr IDFrom;INT Code" $tNMHDR = DllStructCreate($OnEventExtagNMHDR, $lParam) $MsgHwnd = DllStructGetData($tNMHDR, "hWndFrom") $MsgCode = DllStructGetData($tNMHDR, "Code") Case $Msg = $WM_COMMAND $MsgHwnd = $lParam $MsgCode = BitShift($wParam, 16) EndSelect $iMsgCode = $MsgCode if StringInStr($MsgCode,"-") Then _ $iMsgCode = StringReplace($MsgCode,"-","A") $count = DllStructGetData($NotifyStruct,String($MsgHwnd & $iMsgCode)) if Not ($count) Then Return $GUI_RUNDEFMSG DllStructSetData($NotifyStruct,"WPARAM",$wParam) DllStructSetData($NotifyStruct,"LPARAM",$lParam) $OnEvHWND = DllStructGetData($NotifyStruct,"HWND" & String($count)) $ControlID = DllStructGetData($NotifyStruct,"ControlID" & String($count)) $OnEvNotificationCode = DllStructGetData($NotifyStruct,"NotificationCode" & String($count)) $OnEvFunction = DllStructGetData($NotifyStruct,"Function" & String($count)) DllStructSetData($NotifyStruct,"Test",1) if ($MsgHwnd = $OnEvHWND And $MsgCode = $OnEvNotificationCode) Then _ Call($OnEvFunction,$ControlID,$OnEvNotificationCode) DllStructSetData($NotifyStruct,"Test",0) Return $GUI_RUNDEFMSG EndFunc Func OnEventExGetWParam($ControlID,$NotificationCode) $Test = DllStructGetData($NotifyStruct,"Test") if Not ($Test) Then Return False $hWnd = GUICtrlGetHandle($ControlID) if Not IsHWnd($hWnd) Then Return False $iNotificationCode = $NotificationCode if StringInStr($NotificationCode,"-") Then _ $iNotificationCode = StringReplace($NotificationCode,"-","A") $count = DllStructGetData($NotifyStruct,String($hWnd & $iNotificationCode)) if Not ($count) Then Return False Return DllStructGetData($NotifyStruct,"WPARAM") EndFunc Func OnEventExGetLParam($ControlID,$NotificationCode) $Test = DllStructGetData($NotifyStruct,"Test") if Not ($Test) Then Return False $hWnd = GUICtrlGetHandle($ControlID) if Not IsHWnd($hWnd) Then Return False $iNotificationCode = $NotificationCode if StringInStr($NotificationCode,"-") Then _ $iNotificationCode = StringReplace($NotificationCode,"-","A") $count = DllStructGetData($NotifyStruct,String($hWnd & $iNotificationCode)) if Not ($count) Then Return False Return DllStructGetData($NotifyStruct,"LPARAM") EndFunc Func OnEventExGetHWND($ControlID,$NotificationCode) $Test = DllStructGetData($NotifyStruct,"Test") if Not ($Test) Then Return False $hWnd = GUICtrlGetHandle($ControlID) if Not IsHWnd($hWnd) Then Return False $iNotificationCode = $NotificationCode if StringInStr($NotificationCode,"-") Then _ $iNotificationCode = StringReplace($NotificationCode,"-","A") $count = DllStructGetData($NotifyStruct,String($hWnd & $iNotificationCode)) if Not ($count) Then Return False Return DllStructGetData($NotifyStruct,"HWND" & String($count)) EndFunc1 point
-
Android development
JohnOne reacted to JLogan3o13 for a topic
I believe the SDK still houses an emulator, for testing on different versions. http://developer.android.com/tools/devices/emulator.html There is also an open source emulator that installs into virtualbox, which is supposed to be faster than the one above (haven't gotten around to trying it, but on my todo list). It supports 2.3-4.4 and is free for non-commercial use: http://www.genymotion.com/1 point -
1 point
-
the "close" tool tip OnAutoitExit
argumentum reacted to Exit for a topic
Thanks for your compliment.1 point -
Something like this ? #include <Array.au3> Local $aArray[4][3] = [["col 0", "col1", "col2"], ["abc", "efg", 0], ["abc", 0, "def"], ["hij", "klm", "nop"]] Local $iCount = 0, $sTemp For $i = 0 To UBound($aArray, 1) - 1 $iDelete = 0 For $j = 0 To UBound($aArray, 2) - 1 $aArray[ $iCount][$j] = $aArray[$i][$j] If $aArray[$i][$j] == 0 OR $aArray[$i][$j] = "" Then $iDelete = 1 Next If NOT $iDelete Then $iCount += 1 Next Redim $aArray[ $iCount][UBound($aArray, 2) ] _ArrayDisplay($aArray)1 point
-
the "close" tool tip OnAutoitExit
argumentum reacted to Melba23 for a topic
argumentum, I only get the tooltip if I hover over the [X] for a few seconds. Even if it is being displayed it vanishes immediately I click the [X]. As I said I have never seen a tooltip under those conditions - but if deleting the GUI before exit prevents it on your machine, so well and good. M231 point -
Thank you Exit very much, it worked and yes it worked only with German keyboard only. So final conclusion is to use { } brackets send("{CTRLDOWN}{ALTDOWN}{+}{CTRLUP}{ALTUP}") or Send("!^{+}") Regards, Shakti1 point
-
1 point
-
Android development
JohnOne reacted to Richard Robertson for a topic
The app has enough bad reviews and even notes from the developer that it doesn't work on a good number of devices. It's hardware specific, which means that only the weird factory-unlocked devices work probably. I've seen Androids that act like they are rooted right out of the box and they all have weird hardware.1 point -
You can even use WinGetPos on a control, and it will give you exactly what you need. #include <Array.au3> Run("notepad.exe") $h = WinWaitActive("[CLASS:Notepad]") $a = WinGetPos($h) $s = _ArrayToString($a) ConsoleWrite($s & @CRLF) $h2 = ControlGetHandle($h,"","Edit1") $a = WinGetPos($h2) $s = _ArrayToString($a) ConsoleWrite($s & @CRLF)1 point
-
Dropdown menu
DigitalFacade82 reacted to Melba23 for a topic
david1337, Something like this should be what you want: #include <GUIConstantsEx.au3> #include <Array.au3> ; Array to hold data of employer and phone number Global $aData[5][2] = [["Employer 1", "111-111-1111"], _ ["Employer 2", "222-222-2222"], _ ["Employer 3", "333-333-3333"], _ ["Employer 4", "444-444-4444"], _ ["Cancel", ""]] ; Extract employer names $sComboData = "" For $i = 0 To UBound($aData) - 1 $sComboData &= "|" & $aData[$i][0] Next Example() Func Example() Local $Button_1, $Button_2, $Button_3, $Button_4, $msg, $hGUI_Child Local $hGUI = GUICreate("David Linder script®", 380, 130) ; will create a dialog box that when displayed is centered Opt("GUICoordMode", 4) $Button_1 = GUICtrlCreateButton("Stille vagten over - Lync 2010", 23, 30, 150) $Button_2 = GUICtrlCreateButton("Slå vagten fra - Lync 2010", 203, 30, 150) $Button_3 = GUICtrlCreateButton("Stille vagten over - Lync 2013", 23, 80, 150) $Button_4 = GUICtrlCreateButton("Slå vagten fra Lync 2013", 203, 80, 150) GUISetState() ; will display a dialog box with 2 button ; Run the GUI until the dialog is closed While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $Button_1 ;If WinExists("Microsoft Lync") Then ; Create dialog and show combo Local $hGUI_Child = GUICreate("Select Employer", 200, 80, -1, -1, Default, Default, $hGUI) GUISetBkColor(0xFF0000) $cCombo = GUICtrlCreateCombo("", 25, 10, 150, 20) GUICtrlSetData($cCombo, $sComboData) ; Create a disabled button $cAction = GUICtrlCreateButton("Action", 60, 40, 80, 30) GUICtrlSetState($cAction, $GUI_DISABLE) GUISetState(@SW_SHOW, $hGUI_Child) ; Wait for a selection While 1 Switch GUIGetMsg() ; Close GUI if [X] clicked Case $GUI_EVENT_CLOSE Exit Case $cCombo ; See if cancel selected If GUICtrlRead($cCombo) = "Cancel" Then ; Delete the combo and GUI GUICtrlDelete($cCombo) GUIDelete($hGUI_Child) ; Return to main loop ExitLoop Else ;Enable button GUICtrlSetState($cAction, $GUI_ENABLE) EndIf Case $cAction ; Look for the employer in the array - but ignore the "Cancel" element $iIndex = _ArraySearch($aData, GUICtrlRead($cCombo), 0, UBound($aData) - 1) ; If found If $iIndex <> -1 Then ; Use the related number MsgBox(0, "Selection", "Number to use: " & $aData[$iIndex][1]) EndIf ; Delete the GUI GUIDelete($hGUI_Child) ; Return to main loop ExitLoop EndSwitch WEnd ;Else ;MsgBox(4096, "Fejl", "Du har umiddelbart ikke en Lync 2010 kørende") ;EndIf Case $Button_2 Case $Button_3 ;If WinExists("Lync") Then While 1 $sInput = InputBox("David Linder script®", "Indtast mobilnummeret du vil stille over til:", "", "", 250, 125) If @error <> 0 Then Exit If StringStripWS($sInput, 3) <> "" Then EndIf WEnd ;Else ;MsgBox(4096, "Fejl", "Du har umiddelbart ikke en Lync 2013 kørende") ;EndIf Case $Button_4 EndSwitch WEnd EndFunc ;==>Example Yes, using GUICtrlSetColor - but there is a bug deep in the AutoIt core code which means that all sorts of unwanted things (trapping the ENTER key, inability to use button styles, etc) can occur so I strongly recommend that you do not do it. M231 point -
New MVPs
DigitalFacade82 reacted to Melba23 for a topic
In case anyone had not noticed, I am happy to announce that we have three new MVPs: PhoenixXL, FireFox and kylomas. I am sure you will all join in with my hearty congratulations to them all. M231 point