Jump to content

Question about Dll/Functioncall


Recommended Posts

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

Link to comment
Share on other sites

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

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

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

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

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

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