Jump to content
Sign in to follow this  
dromenox

DLL Error

Recommended Posts

dromenox
I will create a program and will use AutoIt to make the GUI and C++ to do some things that are not possible in AutoIt. So I was thinking of making a DLL in C++ and call it from AutoIt. 
 
I made a simple example to test DLL. Is working properly, but then the AutoIt closes and not show the return. 
 
Here are the codes:
 
DLL:
 
#include <windows.h>

extern "C" __declspec(dllexport) int MyMsg(char *tit, char *txt);

__declspec(dllexport) int MyMsg(char *tit, char *txt)
{
     MessageBoxA(NULL, txt, tit, 0);
     return 83; // test return
}

AutoIt:

$ret = DllCall ( "MyDLL.dll", "int", "MyMsg", "str", "test_title", "str", "test_msg")
ConsoleWrite($ret[0]) ; 83
Edited by dromenox

Share this post


Link to post
Share on other sites
dromenox

I suggest you read the help file regarding DllCall, specifically about the calling method/convention.

I based on it :)

Edited by dromenox

Share this post


Link to post
Share on other sites
jchd

The keyword here is "cdecl"...


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)

Share this post


Link to post
Share on other sites
jchd

Show the crashing code.


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)

Share this post


Link to post
Share on other sites
dromenox

Access Violation.

Have you ever created and successfully called a dll function from AutoIt?

No, it's the first time. The function is being called. The only problem is that after the AutoIt closes.

Share this post


Link to post
Share on other sites
trancexx

...So, it's this:

$ret = DllCall ("MyDLL.dll", "int:cdecl", "MyMsg", "str", "test_title", "str", "test_msg")

 


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
dromenox

 

...So, it's this:

$ret = DllCall ("MyDLL.dll", "int:cdecl", "MyMsg", "str", "test_title", "str", "test_msg")

Perfect!

Share this post


Link to post
Share on other sites
JohnOne

Woah, woah!

I suggest you read the help file regarding DllCall, specifically about the calling method/convention.

 

The keyword here is "cdecl"...

 

Dont worked

What about that then?


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
trancexx

Perfect!

Both others said exactly what to do, I only draw it for you.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
dromenox

Woah, woah!

 

What about that then?

 

I had put it in the DLL :) But thanks !

Do not know if it's possible to do, but I want to create a program in AutoIt that serves as a GUI to make hooks into other programs. For example, I would select an open process in my program and when this process run a particular function, like printf, in addition to performing the function normally a function of my program would be called with the parameters of the original function. 
 
It would be perfect if this code worked properly since it would only use AutoIt. 
 
 
But as is not working, I wanted to create a DLL in C ++ to the hook. Then I inject a DLL in process with AutoIt. This DLL would be in an infinite loop within the process. When the DLL detect the hook would call a function within my AutoIt program. 
 
I can do this? 
 
I had put it in the DLL :)

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  

×