Jump to content

Building a dll [Solved]


JohnOne
 Share

Recommended Posts

Why would you have to do this?

Just create a function that the user of your DLL has to call directly after DLLOpen.

*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

Yes, and the function works, but im having a problem telling when its executing because I'm not getting any console output until the dll is closed.

I'm in way over my head here now, I dont want to be wasting anyones time.

Edited by JohnOne

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

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Well, if you want it for AutoIt, create a function that loads the DLL and executes the function at once. Such wrappers for DLLOpen are included in most libraries using dlls like GDI+, MySQL, ...

This means, the users do not have to call DLLOpen, only xour custom func. Additional parameters for DLLOpen wouldn't be easier I bet.

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

Yes, and the function works, but im having a problem telling when its executing because I'm not getting any console output until the dll is closed.

I'm in way over my head here now, I dont want to be wasting anyones time.

You should flush. Just like when peeing.

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

You should flush. Just like when peeing.

I've got a feeling that you gave me a hint there, its just a little to cryptic for a numpty like me.

I'm feeling like bit of a dullard regarding dlls at the moment, a 'dllard' if you will.

But I'm still looking into my problems.

EDIT:

In the end I wound up adding a flag in the dll code, so the function I wanted to run upon DllOpen runs before the first function call, then the flag is set so it dosent run again.

For reference, the function called here

case DLL_PROCESS_ATTACH:
   function();
   break;

Only seems to execute wnen the dll is closed/closing.

Edited by JohnOne

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

Monkey's are, like, natures humans.

Link to comment
Share on other sites

That function is executed when it should be executed, you can be sure of that.

Question is what is function()? I could speculate the content of that function and probably wouldn't be too wrong; and not because I'm smart, but because you are too obvious ;).

Show me yours and I'll show you... what I meant up there. Don't be shy.

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

I'l take you at your word, but I still dont get it, all the indication tell me the code isnt being executed until DllMain returns.

But as always I'm up for a bit of education.

int mainrtn(void);

BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
                     )
{
    switch (ul_reason_for_call)
    {
    case DLL_PROCESS_ATTACH:
        mainrtn();
    case DLL_THREAD_ATTACH:
    case DLL_THREAD_DETACH:
    case DLL_PROCESS_DETACH:
        break;
    }
    return TRUE;
}

//Function declaration
extern "C" LPSTR __stdcall retstr(double s); 

//Functions
LPSTR __stdcall retstr(double s)
{
    if (s == 100000)
        {
            std::cout<<"Sweet";
            return "Sweet";
        }
    std::cout<<"Sour";
    return "Sour";
}

int mainrtn()
{
    std::cout<<"Called"<<"\n";
    return 0;
}

$dllopen = DllOpen("TestDll.dll")

$call = DllCall($dllopen, "str", "retstr", "double", 100000)

If @error Then
    ConsoleWrite(@error & @CRLF)
    Exit
Else
    ConsoleWrite($call[0] & @CRLF)
EndIf

$call = DllCall($dllopen, "str", "retstr", "double", 100000)
ConsoleWrite($call[0] & @CRLF)

$call = DllCall($dllopen, "str", "retstr", "double", 100000)
ConsoleWrite($call[0] & @CRLF)

DllClose($dllopen)

Sweet

Sweet

Sweet

Sweet

Sweet

Sweet

Called

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

Monkey's are, like, natures humans.

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