Jump to content

Search the Community

Showing results for tags 'dllcall()'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 3 results

  1. Hello, I've been looking into offloading a couple functions outside of the main script as they are blocking. Such as FileCopy, PlaySound and anything else that has to parse large number of folders. So I've looked into C++ and dll files with the help of this topic among others. However I can't quite figure out how to work with these files. As of right now when I'm calling the file the script pauses until the function within the dll finishes running. I'm not sure if this has to do with the fact that AutoIt is waiting for a return. Is there a way to not need a return from let's say function number 1, but wait for return from function number 2 somewhere in the loop? In the future I will need to do both. Have the function execute without having any return and have another one return value while still not pausing main script in AutoIt. Does any of this have to do with DllCallbackRegister or is the pausing due to MessageBox function in C++ hanging main script because it was executed under it? $dll = DllOpen("A:\DLL functions\functions\Debug\functions.dll") If Random(1, 2, 1) = 1 Then DllCall($dll, "none:cdecl", "PlaySound", "str", "A:\test.wav") Else $aReturn = DllCall($dll, "int:cdecl", "Test", "int", 2, "int", 3) ConsoleWrite('Return: ' & $aReturn[0]) EndIf DllClose($dll) My C++ code looks like this (first time trying C++): Header: #ifndef _DLL_TUTORIAL_H_ #define _DLL_TUTORIAL_H_ #include <iostream> #define DECLDIR __declspec(dllexport) extern "C" { // Functions DECLDIR int Test(int a, int b); DECLDIR void PlaySound(const char* c); } #endif CPP file: #include <iostream> #include <Windows.h> #include <pch.h> #include "Header.h" #include <iostream> #include <string> extern "C" { DECLDIR int Test(int a, int b) //Function 1 { int sum = a + b; //std::string text = "Result is: " + std::to_string(sum); //MessageBox(0, TEXT(text.c_str()), TEXT("Title"), 0); return sum; } DECLDIR void PlaySound(const char* c) //Function 2 { //std::cout << "DLL Called!" << std::endl; std::string text = "Passed from AutoIt - "; text += c; MessageBox(0, TEXT(text.c_str()), TEXT("Title"), 0); return; //------------------------------------------------------------ //PlaySound() } } functions.dll
  2. I'm trying to understand the use of TreeWalker and DllCall()s. My ultimate goal is to use TreeWalker to list all children of webpages. I've been working through the files for UIASpy to understand the logic. After a weeks worth of searching for examples I'm still stuck on the reason for the repeated use of DllCalls in most of the functions. Here is an example - the function 'UIASpy_CheckWindows()' (located in UIASpy_Elements.au3) is called from file UIASpy_Gui.au3. In the function the following DllCall is used: DllCall( "user32.dll", "lresult", "SendMessageW", "hwnd", $hTV, "uint", $TVM_GETITEMW, "wparam", 0, "struct*", $tItem ) I understand that the function 'SendMessageW' in 'user32.dll' sends a message to the window $hTV. The message is '$TVM_GETNEXTITEM' and '$tItem' is a struct with additional information - Microsoft Doc -https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendmessagew. The window $hTV is created in UIASpy_Gui.au3 and that's where I get lost. Is there code in UIASpy_Gui.au3 that handles this message? I don't know what to look for. This procedure - Function called that contains DllCall (SendMessage) is repeatedly used. Thanks in advance.
  3. I do not know how to make it work: ;~ SearchAndReplace proc _targetadress : dword, _searchpattern : dword, _searchmask : dword, _replacepattern : dword, ;~ _replacemask : dword, _patternsize : dword, _searchsize : dword, _patchnumber : dword ;~ Local local_returnvalue : byte ;returns if something was patched ;~ Local local_match : dword ;counts how many matches Dll ASM code: ;********************************************************************************************** ;* Example (how to use) * ;* ------------------------------------------------------------------------------------------ * ;* search : 2A 45 EB ?? C3 ?? EF * ;* replace: 2A ?? ?? 10 33 C0 ?? * ;* * ;* .data * ;* SearchPattern db 02Ah, 045h, 0EBh, 000h, 0C3h, 000h, 0EFh * ;* SearchMask db 0, 0, 0, 1, 0, 1, 0 ;(1=Ignore Byte) * ;* * ;* ReplacePattern db 02Ah, 000h, 000h, 010h, 033h, 0C0h, 000h * ;* ReplaceMask db 0, 1, 1, 0, 0, 0, 1 ;(1=Ignore Byte) * ;* * ;* .const * ;* PatternSize equ 7 * ;* * ;* .code * ;* push -1 ;Replace Number (-1=ALL / 2=2nd match ...) * ;* push FileSize ;how many bytes to search from beginning from TargetAdress * ;* push PatternSize ;lenght of Pattern * ;* push offset ReplaceMask * ;* push offset ReplacePattern * ;* push offset SearchMask * ;* push offset SearchPattern * ;* push TargetAddress ;the memory address where the search starts * ;* call SearchAndReplace * ;* * ;* ReturnValue in eax (1=Success 0=Failed) * ;********************************************************************************************** .586 .model flat, stdcall option casemap :none SearchAndReplace PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD .code ;----this procedure is only for compiling a dll--- align 16 DllEntry proc _hinstance:DWORD, _reason:DWORD, _reserved1:DWORD mov eax,1 ;TRUE ret DllEntry endp align 16 SearchAndReplace proc _targetadress:dword,_searchpattern:dword,_searchmask:dword,_replacepattern:dword, _replacemask:dword,_patternsize:dword,_searchsize:dword,_patchnumber:dword LOCAL local_returnvalue :byte ;returns if something was patched LOCAL local_match :dword ;counts how many matches pushad mov local_returnvalue,0 mov local_match,0 mov edi,_targetadress mov esi,_searchpattern mov edx,_searchmask mov ebx,_patternsize xor ecx,ecx .while ecx!=_searchsize @search_again: ;---check if pattern exceed memory--- mov eax,ecx ;ecx=raw offset add eax,ebx ;raw offset + patternsize cmp eax,_searchsize ja @return ;if (raw offset + patternsize) > searchsize then bad! push ecx ;counter push esi ;searchpattern push edi ;targetaddress push edx ;searchmask mov ecx,ebx ;ebx=patternsize @cmp_mask: test ecx,ecx je @pattern_found cmp byte ptr[edx],1 ;searchmask je @ignore lodsb ;load searchbyte to al & inc esi scasb ;cmp al,targetadressbyte & inc edi jne @skip inc edx ;searchmask dec ecx ;patternsize jmp @cmp_mask @ignore: inc edi ;targetadress inc esi ;searchpattern inc edx ;searchmask dec ecx ;patternsize jmp @cmp_mask @skip: pop edx pop edi ;targetadress pop esi ;searchpattern pop ecx inc edi ;targetadress inc ecx ;counter .endw ;---scanned whole memory size--- jmp @return @pattern_found: inc local_match pop edx pop edi ;targetadress pop esi mov eax,_patchnumber cmp eax,-1 je @replace cmp local_match,eax je @replace pop ecx ;counter inc edi ;targetadress jmp @search_again ;---replace pattern--- @replace: mov esi,_replacepattern mov edx,_replacemask xor ecx,ecx .while ecx!=ebx ;ebx=patternsize @cmp_mask_2: cmp byte ptr[edx],1 je @ignore_2 lodsb ;load replacebyte to al from esi & inc esi stosb ;mov byte ptr[edi],al & inc edi jmp @nextbyte @ignore_2: inc edi ;targetadress inc esi ;replacepattern @nextbyte: inc edx ;replacemask inc ecx ;counter .endw mov local_returnvalue,1 ;yes, something was patched ;---search again?--- pop ecx ;counter-->scanned size cmp _patchnumber,-1 jne @return sub edi,ebx ;edi=targetadress ; countinue where stopped inc edi ;... inc ecx ;ecx=counter(pointer to offset) /bug fixed in v2.07 mov esi,_searchpattern mov edx,_searchmask jmp @search_again ;---return--- @return: popad movzx eax,local_returnvalue ret SearchAndReplace endp end DllEntry [SOLVED] snr.dup.search.and.replace.patchengine.sourcecode.src.zip
×
×
  • Create New...