Jump to content

Passing Arguments on a DLL Function


Ace08
 Share

Recommended Posts

Hi guys this will be my 1st time with dllcalls so please bear with me. a certain company was able to provide us with an encryption dll, the problem is that when i try to execute the func nothing happens.

The syntax for the dll func is this:

encryptFile(strPath, strSourceFile, strPassword, strMessage, strTargetFile)

what i did was this:

Global dll = "C:\ENC DEC DLL\EncDec.dll"
$Call = DllCall(dll, " BOOLEAN", "encryptFile(c:\ENC DEC DLL, samplefile.TXT, password, unable to encrypt)")
msgbox(0,"test dll", $Call)

I think i'm wrong to use encryptFile(c:\ENC DEC DLL, samplefile.TXT, password, unable to encrypt) inside the DllCall but i don't know where i'm supposed to put the arguments for this function.

Work smarter not harder.My First Posted Script: DataBase

Link to comment
Share on other sites

Ohhhhh sorry about that my bad and thanks D4RKON3 for the help however i tried both your code and mine(added the missing $) but still nothing happens. i'm getting a bit frustrated here :D its much easier to debug a code with errors rather than those without. can you guys confirm that i used the dllcall func correctly? if so i think i should ask the company about their dll.

Work smarter not harder.My First Posted Script: DataBase

Link to comment
Share on other sites

read up on dllcall in the help file, youre doing most wrong.. firstly though you need to find the full prototype for this function:

encryptFile(strPath, strSourceFile, strPassword, strMessage, strTargetFile)

which calling convention? 32/64 bit dll? what types are the arguments, c-style strings? if so, unicode / ansi / multibyte? etc :D

e: also, what does it return, and what type?

Edited by Shaggi

Ever wanted to call functions in another process? ProcessCall UDFConsole stuff: Console UDFC Preprocessor for AutoIt OMG

Link to comment
Share on other sites

Thanks Shaggi for the help i did look in the help file and that is why i was able to formulate the code posted above which unfortunately is'nt working T_T

its a 64bit dll running on a 64 bit PC for the arguments i have attached the documentation below

Returns a Boolean value indicating whether the encryption is successful.

Syntax

encryptFile(strPath, strSourceFile, strPassword, strMessage, strTargetFile)

The encryptFile function syntax has these arguments:

Part Description

strPath Required (String expression). The path or location of file to be encrypted

strSourceFile Required (String expression). The filename of file to be encrypted

strPassword Required (String expression). The password that will be used during encryption. (Note: The password must be encrypt by the encrypt decrypt

program)

strMessage Required (String expression). Returning error message during encryption. If

strMessage is empty (“”) the encryption is successful otherwise, the error

description during encryption will be the value for strMessage.

strTargetFile Optional (String expression). The filename that will be used after the

encryption. If omitted. The encrypted file will be the source filename with the

extension name of “ENC”.

Edited by Ace08

Work smarter not harder.My First Posted Script: DataBase

Link to comment
Share on other sites

are you sure this is a c/c++ dll? its weird they dont specify exact types... anyway, from the information given, you can try this:

Func encryptFile($sPath, $sSourceFile, $sPass, $sMsg, $sTarget)
    $aRet = DllCall("C:ENC DEC DLLEncDec.dll","bool","encryptFile", _
    "str",$sPath,"str",$sSourceFile,"str",$sPass,"str",$sMsg,"str",$sTarget)
    If NOT @Error AND IsArray($aRet) AND $aRet[0] Then
        Return True
    Else
        Return False
    EndIF
EndFunc
if its unicode strings, you can change each "str" to "wstr" Edited by Shaggi

Ever wanted to call functions in another process? ProcessCall UDFConsole stuff: Console UDFC Preprocessor for AutoIt OMG

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...