Jump to content

Help with DLLCall


Recommended Posts

Hi friends,

I'm working on a licensing project and we are using LexActicvator of Cryptlex.

I'm trying to call a function of a DLL using DLLCall method. I'm calling the method 'SetProductFile' of DLL 'LexActivator_64.dll'. The parameter to the method is path to the product file and the method should return 1 on successful execution. But the method always returns 7 in my test run.

#define LA_E_PFILE ((HRESULT)0x00000007L)
 
/*
    CODE: LA_E_FPATH
 
    MESSAGE: Invalid product file path.
*/
 
The DLL and the product file I use are attached, please save to the script folder to test the script.
Can anyone please help? I'm stuck for many days.
Link to the documentation 
 
#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <WinAPIReg.au3>
#include <WinAPI.au3>
#include<array.au3>
#include <WinAPISys.au3>

$sDLLPath = @ScriptDir& "\LexActivator_64.dll" ;Path to DLL file
$sDataFilePath = @ScriptDir& "\Product.dat" ;Path to product data file

$hDLL = DllOpen ( $sDLLPath) ;Opening DLL
If $hDLL = -1 Then ;If error
    Msgbox(0,"Error", "Couldn't open the DLL file.")
    exit
EndIf

If Not FileExists($sDataFilePath) Then ;Checking product file
    Msgbox(0,"Error", "Product file does not exist.")
    exit
EndIf

$aArray = DllCall ( $hDLL , "int:cdecl", "SetProductFile", "STR", $sDataFilePath ) ;calling SetProductFile method
If @error Then ;If error
    MsgBox(0, "Error","Error occured while calling DLL method: " &  @error)
Else
    Msgbox(0,"Result","Result received: " & $aArray[0]) ;result
EndIF

DllClose ( $hDLL )

 

LexActivator_64.dll

Product.dat

Link to comment
Share on other sites

I was unable to locate an API documentation. What are the C prototypes of the functions you'll be using?

Note that the return type should be int64 and the path wstr (most probably).

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Hi,

Thank you so much for your reply. They do not have any explicit API documentations than the sample codes provided. Please see the following portion of vb code provided. 

'
        '            FUNCTION: SetProductFile()
        '
        '            PURPOSE: Sets the path of the Product.dat file. This should be
        '            used if your application and Product.dat file are in different
        '            folders or you have renamed the Product.dat file.
        '
        '            If this function is used, it must be called on every start of
        '            your program before any other functions are called.
        '
        '            PARAMETERS:
        '            * filePath - path of the product file (Product.dat)
        '
        '            RETURN CODES: LA_OK, LA_E_FPATH, LA_E_PFILE
        '
        '            NOTE: If this function fails to set the path of product file, none of the
        '            other functions will work.
        '        


        Public Shared Function SetProductFile(filePath As String) As Integer
#If LA_ANY_CPU Then
            Return If(IntPtr.Size = 8, Native.SetProductFile_x64(filePath), Native.SetProductFile(filePath))
#Else
            Return Native.SetProductFile(filePath)
#End If

        End Function

 

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

×
×
  • Create New...