Sign in to follow this  
Followers 0
aquila

Question about Dll/Functioncall

18 posts in this topic

#1 ·  Posted (edited)

Hello,

I have an exe file where I can watch the functions with Dependency Walker. Am I able to use this functions with dllcall or something like that? If yes, are there any examples?

Maybe a crap question but :D At dll its the same so why not calling an exe file, lol.

Edited by aquila

Share this post


Link to post
Share on other sites



Check the help file and the forums for examples on how to use DllCall.

For information on the particular DLL you're using, you'd have to check with the vendor/developer.


[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I tried some crap and now i have this:

$dll = DllOpen("kernel32.dll")
$a = DllCall($dll, "ptr", "LoadLibrary", "str", "C:\Test\test.exe")
$b = DllCall($dll, "ptr", "GetProcAddress", "ptr", $a[0], "str", "SomeFunction")
$c = DllCall($dll, "none:cdecl", $b[0], "str", "test test")
MsgBox(0, "", $c)

The exe is an c++ exe from a friend and has only one parameter with "str", showing a MsgBox. But this doesn't work. Any ideas from the Dll pro's :D ?

I think the 3rd dllcall is completely incorrect, but i don't know what to change :D

Hm, so noone any idea?

Edited by aquila

Share this post


Link to post
Share on other sites

Guys, I need really a lil help, so if someone knows something about this, tell me. I thank to every answer!

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

As far as I know, AutoIt does not have a way to call function pointers.

You could instead call the function yourself. DllCall("test.exe", "none:cdecl", "SomeFunction", "str", "test test")

Edited by Richard Robertson

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Thx 4 answer! Yes, I also thought about that.

It's crashing. I have the same function in my test.dll. There is it working with that call. So i started to use google with 'call function in exe' and i get some scripts in c++/vb/delphi/whatever with dllcalls of LoadLibrary and GetProcAddress. That's why I try this. I think the first 2 calls are correct. But I don't now the third, calling the function :D

Edited by aquila

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

You can't. I'm not sure why AutoIt is failing. What error was provided?

Edited by Richard Robertson

Share this post


Link to post
Share on other sites

AutoIT3.exe ended.rc:-1073741819

Share this post


Link to post
Share on other sites

So anyone knows, if I call LoadLibrary and GetProcAddress, how the 3rd. Call has to look? I have no idea what to add at the DllName and Function name? Function name = return of GetProcAddress?

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

First try to use DLLcall in stdcall mode, so remove :cdecl :D

//Edit: Are you sure it has no return value? Try also dword or ptr instead of none :D

//Edit2: You could also add DLLOpen and check what happens then.

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

I tried. I added now an archive with the files. Maybe you can take a look inside.

Test.rar

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

OK, should be a bug in DLLCall. Although MemoryDLLCall uses this func, too, it works. Strange...

The UDF can be found here: http://www.autoitscript.com/forum/index.php?showtopic=77463

#include <MemoryDLL.au3>
...
MemoryFuncCall("none:cdecl", $b[0], "str", "Test")

//Edit: NO, sorry, this code also crashes when using the exe instead of the dll.

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

Something is wrong, that's for sure.

All looks fine but still crashes. I can see two possible problems. First one is the issue with DllMain, but that is highly unlikely.

Second problem could be the entry point to the app.

I don't know how your code looks but as I can see (using my supernatural abilities - yeah right :D ) you are actually calling SomeFunction to show "Nachricht aus der EXE" message. Rewrite the code to avoid that and try then.

This all could be just a bunch of... nothing. But do try. It's interesting.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

Second problem could be the entry point to the app.

Hm, $b[0] is always 0x020A12F0, when I take a look with Dependency Walker, it's 0x000012F0, so. Must this two values be the same?

Share this post


Link to post
Share on other sites

No.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

This "The Nachricht aus der EXE" appears cause the exe is calling the function with that parameter as string. I did this because i don't want an empty exe file with funcs only, I want to call a function of an exe file which can do also other things. So just call this function, and use it :D (Showing the messagebox or get a return) You understand?

Share this post


Link to post
Share on other sites

This "The Nachricht aus der EXE" appears cause the exe is calling the function with that parameter as string. I did this because i don't want an empty exe file with funcs only, I want to call a function of an exe file which can do also other things. So just call this function, and use it :D (Showing the messagebox or get a return) You understand?

My understanding of your actions is irrelevant. <- scared a bit?

I'm kidding.

Did you try like I said?

Btw, this I find interesting... Can you run this code (or somebody else):

DllCall("netsh.exe", "dword:cdecl", "PrintMessage", "wstr", "Something to print")

ConsoleWrite(@CRLF)

$a_hCall = DllCall("kernel32.dll", "hwnd", "LoadLibraryExW", "wstr", @AutoItExe, "hwnd", 0, "int", 34)
$hModule = $a_hCall[0]

$a_iCall = DllCall("netsh.exe", "dword:cdecl", "PrintMessageFromModule", "hwnd", $hModule, "dword", 166)
$a_iCall = DllCall("netsh.exe", "dword:cdecl", "PrintMessage", "wstr", @CRLF)

It fails with system I'm currently running (XP SP3), but works for another instalation of the same system (again XP SP3).

Fails with Vista and Vista SP1.

Strange I tell you.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

Hehe :D .

Had no time to test it, the dll & exe is from a friend and he wasn't online since yesterday.

Unfortunately, the Code is crashing. Using XP Sp2.

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