Jump to content
Sign in to follow this  
dromenox

Call function from DLL

Recommended Posts

dromenox
Well, I'll make a program that will serve as a GUI to make hooks. My program will inject a DLL made ​​in C ++ in a process. What I wanted to do is that when the hooked function was called the DLL somehow call a function in AutoIt with the parameters of the hooked function. 
 
In short I want the DLL call a function within my AutoIt program passing parameters.

Share this post


Link to post
Share on other sites
dromenox

My DLL Code:

#include <windows.h>
#include <detours.h>
#include <stdio.h>

#define ADDRESS 0x4016B0
int (__cdecl* originalFunction)(int, int);

int hookedFunction(int a, int b)  
{                                 
    // MyFunc(a, b); Example
    return originalFunction(a, b);
}

BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
{
    switch (dwReason)
    {
    case DLL_PROCESS_ATTACH:
        originalFunction = (int(__cdecl*)(int, int))DetourFunction((PBYTE)ADDRESS, (PBYTE)hookedFunction); //Magic
        break;
    }
    return TRUE;
}

My AutoIt code:

Func MyFunc($a, $b)
   ConsoleWrite($a, $b)
EndFunc

While 1

Wend

could help me do this in my case?

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  

×