Jump to content

Fatal Dll Error... :(


Recommended Posts

Hi all.

I have a DEMO crypto DLL which is quite nice - the DLL should work without registration from within the application folder (I won't be able to register it on the end system due to admin rights issues), and i have has some success with calls from VBA etc. However,from AutoIt the DLL will not execute. All methods are functions in the DLL... the DLL needs to be initialised before use - this is the call that is failing (and I have also noticed that cwebpage.dll calls are no longer working - value of $dll after DllOpen is -1. The path is correct - odd one ?!?). I have re-installed latest beta without effect.

'VB CODE
Declare Function Init Lib "crypt.dll" (ByRef regcode As String) As Boolean
Declare Function GetVersion Lib "crypt.dll" () As String
Init("DEMO")
MsgBox (GetVersion())

;My AutoIt Effort :(
$dll = DllOpen("edcrypt.dll")
$init = DllCall($dll,"int","Init","str","DEMO")
$version = DllCall($dll,"str","GetVersion")
With this code, Beta Run from ScIte dies, stating that "AutoIt has encountered a fatal crash as a result of: Unable to execute DLLCall: $init = DllCall($dll,"int","Init","str","DEMO")

I have tested DLL call with another function (screen capture), and that works... so I figure that it is a problem with my DLL structure / call, or maybe some 'feature' of this DLL that is incompatible with AutoIt calls. Any guidance appreciated. TIA.

[typo]

Edited by plastix
Link to comment
Share on other sites

Thanks.Tried:

$init = DllCall($dll,"int:cdecl","Init","str","DEMO")
...but still the same error. The docs with the DLL don't mention anything at all. Yes, was a typo (amended)

For ease, i have uploaded ZIP containing DLL & test code. TIA all :think:

DLL info (using Nirsoft DLLexp):

Function Name    : GetVersion
Address        : 0x00455528
Relative Address  : 0x00055528
Ordinal        : 12 (0xc)

Function Name    : Init
Address        : 0x00455288
Relative Address  : 0x00055288
Ordinal        : 16 (0x10)

crypt.zip

Edited by plastix
Link to comment
Share on other sites

Thanks.Tried:

$init = DllCall($dll,"int:cdecl","Init","str","DEMO")
...but still the same error. The docs with the DLL don't mention anything at all. Yes, was a typo (amended)

For ease, i have uploaded ZIP containing DLL & test code. TIA all :)

DLL info (using Nirsoft DLLexp):

Function Name    : GetVersion
Address        : 0x00455528
Relative Address  : 0x00055528
Ordinal        : 12 (0xc)

Function Name    : Init
Address        : 0x00455288
Relative Address  : 0x00055288
Ordinal        : 16 (0x10)
Don't think "int" and "Init" will cooperate wery well? You probably have to pass a number :(

EDIT: Shit, think it's time to call it the day. "int" is return value and "Init" the function to call. :">

Edited by Uten
Link to comment
Share on other sites

:) at least Uten answer avoid crash but I don't really understand how this dll work.

It is generated a lot of error during initialisation (DllOpen) and after I cannot understand why a string can be passed byref. Who will allocated the right size to be returned?

Another point where do come from the msgbox during the init call with a window title "AutoIt3"? Is it a spyware? No string in the Dll have this value.

Link to comment
Share on other sites

:( at least Uten answer avoid crash but I don't really understand how this dll work.

It is generated a lot of error during initialisation (DllOpen) and after I cannot understand why a string can be passed byref. Who will allocated the right size to be returned?

Another point where do come from the msgbox during the init call with a window title "AutoIt3"? Is it a spyware? No string in the Dll have this value.

I'm not uptodate in the C/C++ department but I thought you passed a string by ref when you passed a pointer to a char array? I't will be the receivers responsibility to handel the pointer and what it points to. As the api states that the Init function expects a pointer to a string (char array) the Init function just have to scan for the \0 terminator. Please feel fre to arrest me if I'm wrong :)

Wont you get AutoIt3 from the process executing the dll call.? I did not try to run from a compiled script so the process should be AutoIt3.exe

Edited by Uten
Link to comment
Share on other sites

I'm not uptodate in the C/C++ department but I thought you passed a string by ref when you passed a pointer to a char array? I't will be the receivers responsibility to handel the pointer and what it points to. As the api states that the Init function expects a pointer to a string (char array) the Init function just have to scan for the \0 terminator. Please feel fre to arrest me if I'm wrong :)

Wont you get AutoIt3 from the process executing the dll call.? I did not try to run from a compiled script so the process should be AutoIt3.exe

For me when you pass a parameter byref it is because you want to update it. So come the question of the size of the string. usually you have another parameter defining the maximum size reserve by the caller.

For AutoIt3 I compile it and true the new name was display. The conclusion is the dll is setting the title of the message box equal to the name of the exe. :(

Link to comment
Share on other sites

Yes, you could change the content of the string. And to the caller that should probably be expected. That is why I passed a variable and not a fixed string in the dllcall.

Link to comment
Share on other sites

Yes, you could change the content of the string. And to the caller that should probably be expected. That is why I passed a variable and not a fixed string in the dllcall.

How can you be for sure the dll will not return more what is allocated by the caller?

Who is suppose to change the string? The DLL?

Link to comment
Share on other sites

How can you be for sure the dll will not return more what is allocated by the caller?

Who is suppose to change the string? The DLL?

If the dll has to change the string at the end of the pointer it could. But then it is responsible for allocating the necessary space. When the caller want to use the string at the pointer again it has to check and not assume the size (witch it should anyhow after trusting a pointer to a library).

I would guess that the Init function does not change the string but that some of the other functions has the same calling convention, do changes.

I would also guess that the designer of the library has done it like this because it avoids costly memcpy calls.

As I said earlier my C/C++ skills are fading :) So I could be wrong.

Link to comment
Share on other sites

hi all.actually, the version of the DLL is 3.1.1 (or close enough) - so that would be the correct version info...

i will try to test later (away from home pc atm).

many thanks for all your efforts. The DLL is a derivative of a previous self-registering OCX control library. The DLL "boasts" a fully integrated memory managament system (as i understand) for ease of use for the end-user... just pass it the file / data, and it will do the rest and return the relevant success code / string etc etc

Thanks again.

Link to comment
Share on other sites

OK. tested this a bit. I think the bottom line is the DLL is "non-standard"... I have a purchased unlock code, which works for the DLL in VB / VBA, but causes a fatal crash via AutoIt. Using a random string for the unlock code seems to get the Demo Mode message from the DLL, but still doesn't pull out version information for me. I haven't tried any other calls...

Thanks for all your attempts. Cheers.

Link to comment
Share on other sites

OK. tested this a bit. I think the bottom line is the DLL is "non-standard"... I have a purchased unlock code, which works for the DLL in VB / VBA, but causes a fatal crash via AutoIt. Using a random string for the unlock code seems to get the Demo Mode message from the DLL, but still doesn't pull out version information for me. I haven't tried any other calls...

Thanks for all your attempts. Cheers.

Just a question does your unlock code replace the string "DEMO" in the init code?

If yes I assume that the long_ptr is not the correct type for calling the Dll.

:)

Link to comment
Share on other sites

Just a question does your unlock code replace the string "DEMO" in the init code?

If yes I assume that the long_ptr is not the correct type for calling the Dll.

:)

yep. i used 'str' originally - that's what resulted in the fatal error.

Link to comment
Share on other sites

yep. i used 'str' originally - that's what resulted in the fatal error.

plastix,

A String datatype in Visual Basic is not like a "char *" in C/C++. It is a Wide (Unicode) String type.

So your DLLCall should be:

$str="DEMO"
$init = DllCall($dll,"int","Init","wstr",$str)

Your script is not returning the version number, because you use the syntax of DLLCall incorrectly.

DLLCall returns an Array, in which element number 0 is the return value of the function. So the second part of the script should be:

$Res = DllCall($dll,"str","GetVersion")
if not @error then msgbox(0,"version?",$Res[0])

Which will return version 4.0.

On the web site of Softuarium I noticed they also offer an ActiveX control version of edcrypt.dll. That would be a better combination with AutoIt, because you don't have to puzzle around with datatypes in DLLcall lines.

Regards,

-Sven

Link to comment
Share on other sites

Hi SvenP

Thanks for your reply.

The ActiveX control, to my knowledge, would require registering - which i am unable to do on the registry etc locked pc's i have in mind... which is why i am trying this approach. Sadly, when supplying a valid unlock code, i still get a fatal error - using a non-valid code gets the "demo" info popup... odd one. Maybe i'm using the unlock call incorrectly, or maybe it truly is non-standard. Never mind.

Many thanks again for your guideance. Cheers :)

Link to comment
Share on other sites

plastix,

A String datatype in Visual Basic is not like a "char *" in C/C++. It is a Wide (Unicode) String type.

So your DLLCall should be:

$str="DEMO"
$init = DllCall($dll,"int","Init","wstr",$str)

Your script is not returning the version number, because you use the syntax of DLLCall incorrectly.

DLLCall returns an Array, in which element number 0 is the return value of the function. So the second part of the script should be:

$Res = DllCall($dll,"str","GetVersion")
if not @error then msgbox(0,"version?",$Res[0])

Which will return version 4.0.

I thought VB only did this when calling com dll's? I think VB (6.0) does some memcpy magic when calling a win32 type dll. If I recall right this is explained by Matthew Curland in his Advanced Visual Basic 6 book. I dont have the book available so I can't check it.

But your probably right about the "wstr" in this call. You got the version number, so the Init call did not crash :)

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...