Sign in to follow this  
Followers 0
Richard Robertson

DllOpen failure extra info

13 posts in this topic

Is there any way I can get more detailed information as to why my dll cannot be opened? I have written a Windows DLL in C++ and DllOpen is failing with a -1 return value.

This doesn't tell me why it didn't work.

Share this post


Link to post
Share on other sites



Call GetLastError().

Share this post


Link to post
Share on other sites

Heh, I didn't think of that. I'll sort that out and see what happens.

Share this post


Link to post
Share on other sites

I tried it, got a 126, which meant it couldn't find it, so I relocated some files.

I fixed that and got a 6, which means it is an invalid handle. This doesn't help me.

Share this post


Link to post
Share on other sites

I tried it, got a 126, which meant it couldn't find it, so I relocated some files.

I fixed that and got a 6, which means it is an invalid handle. This doesn't help me.

can you post the DLL?

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

It is a dll I have custom written to tackle the managed code calling. It is a standard WIN32 dll.

http://freehost07.websamba.com/goobco/netinterop.dll

I can provide source if necessary.

get a copy of "PE Explorer" and have a look at your exported symbols.

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

I have the PE Explorer already, but how do I know what the exports are? I've only used it to get resources.

Using the dependency walker, I see all the functions are listed as exported symbols.

It isn't calling the functions that is the problem though, it is the loading of the dll.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

I have the PE Explorer already, but how do I know what the exports are? I've only used it to get resources.

Ctrl+E in "PE Explorer"

Using the dependency walker, I see all the functions are listed as exported symbols.

It isn't calling the functions that is the problem though, it is the loading of the dll.

1.) I can load the DLL without errors with AU3 3.2.2.0. As I don't know how DllLoad is implemented (most certainly via LoadLibrary()) I can't tell you exactly what the problem is with your error code "6".

2.) Even if you can load the DLL you will get into trouble when you try to call the exported functions, as you exported them with the C++ decorated names. Again, I don't know how DllCall is implemented, but I don't think that DllCall will handle all the different decoration styles of the various C++ compilers.

Read this: http://en.wikipedia.org/wiki/Name_mangling

BTW: If you can't figure it out, post the code and a description how you compiled the DLL.

Cheers

Kurt

Edited by /dev/null

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

1.) I can load the DLL without errors with AU3 3.2.2.0. As I don't know how DllLoad is implemented (most certainly via LoadLibrary()) I can't tell you exactly what the problem is with your error code "6".

It may be a leftover error code from some other function call. IceKirby will need to check that the DLL actually loaded okay by checking the return value of DllOpen().

2.) Even if you can load the DLL you will get into trouble when you try to call the exported functions, as you exported them with the C++ decorated names. Again, I don't know how DllCall is implemented, but I don't think that DllCall will handle all the different decoration styles of the various C++ compilers.

There's no magic to it. To use the functions, you call them by whatever name they are exported as. For example, to call Delete(), you would pass "?Delete@@YAXH@Z" to DllCall().

IceKirby, I see no reason the DLL won't load unless you've implemented DllMain() wrong or something.

Share this post


Link to post
Share on other sites

In DllMain, all it does is initialize a static variable on process attach.

DllOpen was returning -1.

I didn't know I would need to call the weird names. How do I export names like "Delete"?

I don't recall if I was testing before upgrading or after, so I will try again now that I know it is upgraded.

Share this post


Link to post
Share on other sites

You'll probably want to make all the functions use __stdcall (WINAPI) for their calling convention or you'll need to specify cdecl with AutoIt when you use DllCall(). As for exporting the symbols, I usually use a definition file but there are other ways. MSDN can show you a couple different ways.

Share this post


Link to post
Share on other sites

I forgot about __stdcall. I'll fix those and try again.

Share this post


Link to post
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
Sign in to follow this  
Followers 0