HelloAuto Posted April 12, 2021 Share Posted April 12, 2021 (edited) Hey everyone, I have a DLL file that I need to use to decrypt text strings by using DllCall in AutoIT. However, I can't seem to get my syntax right in AutoIT to get it to work. I know the DLL works, because I have written code in VB.net to open the DLL, pass in the encrypted string and reference the hidden key in the DLL. I just pass in the encrypted string as a command line argument, and it prints the decrypted string in the console. Here is my VB.net code (the DLL file is added as a reference in the project. The DLL file name is "Master.Test.dll"): Imports Master.Test.Decryption Public Class DECRYPT Public Sub DECRYPT_Load() Handles MyBase.Load Me.Visible = False Me.ShowInTaskbar = False Dim Args = Environment.GetCommandLineArgs() Dim Decrypted As String = "" If Args.Length > 1 Then Dim Encrypted As String = Args(1) If Encrypted.Substring(Encrypted.Length - 1, 1) = "=" And Encrypted.Length Mod 4 = 0 Then Decrypted = Encrypt.Decrypt(Encrypted, Encrypt.HIDDEN_Key) End If End If If Decrypted.Length > 0 Then Console.WriteLine(Decrypted) End If Application.Exit() End Sub End Class Here is my code in AutoIT to open the DLL, make the DLL call, and write the results to the console, but I just continue to get errors or "0". Const $DllFile = "C:\TEST\Master.Test.dll" Const $Encrypted = "encryptedstring" ;replace with encrypted string Local $tDll = DllOpen($DllFile) $tResults = DllCall($tDll, "str", "Master.Test.Decryption.Encrypt.Decrypt", "str", $Encrypted, "str", "Master.Test.Decryption.Encrypt.HIDDEN_Key") DllClose($DllFile) ConsoleWrite("Decrypted: " & $tResults) The console output: Decrypted: 0+>12:34:15 AutoIt3.exe ended.rc:0 I tried using "$tResults[0]", because I think the return value should be in an array format from what I've read while searching. However, this returns the error: Subscript used on non-accessible variable. I'm not sure what else to do. I even tried passing in the hidden key in the DLL manually as it's own string, instead of trying to reference it in the DLL. However, this ends with the same result. So, I must be doing something else wrong. Edited April 12, 2021 by HelloAuto Link to comment Share on other sites More sharing options...
Nine Posted April 12, 2021 Share Posted April 12, 2021 You should test @error first. I don't think you need "Master.Test.Decryption" prefix. and passing "Master.Test.Decryption.Encrypt.HIDDEN_Key" will not be converted in the dll as it is expecting the true key (I believe). You may need to use 'cdecl' method. Have you look at the dll with dllexp ? It may give you more information about the function visibility. HelloAuto 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
HelloAuto Posted April 12, 2021 Author Share Posted April 12, 2021 38 minutes ago, Nine said: You should test @error first. I don't think you need "Master.Test.Decryption" prefix. and passing "Master.Test.Decryption.Encrypt.HIDDEN_Key" will not be converted in the dll as it is expecting the true key (I believe). You may need to use 'cdecl' method. Have you look at the dll with dllexp ? It may give you more information about the function visibility. Thank you. I tried everything you mentioned, but it still returns "0". "@error" shows "0" too. I even passed in the hidden key value manually. Here is my updated code: Const $DllFile = "C:\TEST\Master.Test.dll" Const $Encrypted = "encryptedstring" Local $tDll = DllOpen($DllFile) $tResults = DllCall($tDll, "str:cdecl", "Encrypt.Decrypt", "str", $Encrypted, "str", "HIDDENKEYVALUE") DllClose($DllFile) ConsoleWrite("Decrypted: " & @error & @CRLF) ConsoleWrite("Decrypted: " & $tResults & @CRLF) Oddly, when I used dllexp, I get nothing. I have to use dotPeek in order to find the function names. It's weird that they work in VB.net, but not AutoIT. Link to comment Share on other sites More sharing options...
Nine Posted April 12, 2021 Share Posted April 12, 2021 You are using @error wrongly, it should immediately follow the dllcall as it is erased with dllclose. Please modify script and report on @error as I am pretty sure, it will be non-zero. HelloAuto 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
HelloAuto Posted April 12, 2021 Author Share Posted April 12, 2021 5 minutes ago, Nine said: You are using @error wrongly, it should immediately follow the dllcall as it is erased with dllclose. Please modify script and report on @error as I am pretty sure, it will be non-zero. You're right. My apologies. I updated the code, and it returns just the number "3" for @error. Although, I'm not sure what that means, or how to troubleshoot it. Link to comment Share on other sites More sharing options...
Nine Posted April 12, 2021 Share Posted April 12, 2021 Quote 3 = "function" not found in the DLL file From help file. It is quite obvious. Either there is an error in spelling the function name or the function is not exported correctly. Not an AutoIt issue anymore... HelloAuto 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
HelloAuto Posted April 12, 2021 Author Share Posted April 12, 2021 2 minutes ago, Nine said: From help file. It is quite obvious. Either there is an error in spelling the function name or the function is not exported correctly. Not an AutoIt issue anymore... I'm not saying it's a problem with AutoIT. I think it's a problem with the syntax I'm using. However, I can't figure out what it wants to call the function. I know how to do it in VB.net, and it works fine. I just want to replicate that in AutoIT. Is that possible? Link to comment Share on other sites More sharing options...
LarsJ Posted April 12, 2021 Share Posted April 12, 2021 And you're sure that your dll file is a standard Windows dll file implemented in unmanaged code e.g. C or C++ which can be used in AutoIt? HelloAuto 1 Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
HelloAuto Posted April 12, 2021 Author Share Posted April 12, 2021 1 minute ago, LarsJ said: And you're sure that your dll file is a standard Windows dll file implemented in unmanaged code e.g. C or C++ which can be used in AutoIt? Unfortunately, it's not my DLL file. It was provided to me. I thought I could use DllCall() to call any Dll with functions. I even turned my VB.net code into an EXE. I then tried to use that EXE in AutoIT using the Run() function, which worked fine, until I tried to use the GUI Wrapper to compile it. I then get an error stating "Error: The requested action with this object has failed", whenever I actually run the compiled application. Link to comment Share on other sites More sharing options...
LarsJ Posted April 12, 2021 Share Posted April 12, 2021 I'm pretty sure your dll file is a .NET assembly dll file implemented in managed code e.g. C#, It's indicated simply by the name. It cannot be used immediately in AutoIt. Your best chance of using a .NET assembly dll file in AutoIt is through the code in this thread. HelloAuto 1 Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
HelloAuto Posted April 12, 2021 Author Share Posted April 12, 2021 37 minutes ago, LarsJ said: I'm pretty sure your dll file is a .NET assembly dll file implemented in managed code e.g. C#, It's indicated simply by the name. It cannot be used immediately in AutoIt. Your best chance of using a .NET assembly dll file in AutoIt is through the code in this thread. This looks like it may lead me to my answer. I wish I found it sooner in my searching. Thank you. Link to comment Share on other sites More sharing options...
Nine Posted April 12, 2021 Share Posted April 12, 2021 If you want (may be not) my appreciation of the situation. You are forcing the usage of a DLL while there is multiple UDF (in AutoIt) that can address your users requirements. I would strongly suggest to take a step back to understand the true needs and then decide of the appropriate solution. HelloAuto 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
HelloAuto Posted April 12, 2021 Author Share Posted April 12, 2021 51 minutes ago, Nine said: If you want (may be not) my appreciation of the situation. You are forcing the usage of a DLL while there is multiple UDF (in AutoIt) that can address your users requirements. I would strongly suggest to take a step back to understand the true needs and then decide of the appropriate solution. Yes, I'm brand new to AutoIT, and am trying to satisfy a request to modify an existing AutoIT solution, using other tools that already exist outside AutoIT. I think I have found an even easier solution using Crypt.au3 in AutoIT though. Thank you all for the help! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now