maximoreira
Membro
Ando a testar um codigo em c++ de dll injection com a libraria detours.h, já instalei o detours 3.0 da microsoft e msm assim nao consigo correr o seguinte codigo:
Tenho erro nas linhas
122 C:\Users\win-7\Desktop\dllInjection\txt\main3.cpp invalid conversion from `int (*)(HWND__*, CHAR*, int)' to `void*'
Algum experts nesta area de dll injection que me seja capaz de explicar o q se passa aqui?
Código:
#include <Windows.h>
#include "detours.h"
#include <tchar.h>
#include <stdio.h>
// Function pointer to the original (un-detoured) DrawText API
static int (WINAPI * TrueGetWindowTextA)(HWND hWnd, LPSTR lpString, int nMaxCount) = GetWindowTextA;
static int (WINAPI * TrueGetWindowTextW)(HWND hWnd, LPWSTR lpString, int nMaxCount) = GetWindowTextW;
void writeToFile(LPCWSTR text)
{
FILE *out;
if (!(out = fopen("C:\\out.txt", "a+"))) {
MessageBox (0, TEXT("ERROR FILE"), TEXT("ERROR FILE"), MB_ICONINFORMATION);
return;
}
fwprintf(out, text);
fclose(out);
}
int WINAPI MyGetWindowTextA(HWND hWnd, LPSTR lpString, int nMaxCount)
{
int retVal = TrueGetWindowTextA(hWnd, lpString, nMaxCount);
if (retVal != 0)
{
int charCount = strlen(lpString) + 1;
LPWSTR pwszUniBuff = new wchar_t[charCount];
if (0 != MultiByteToWideChar(CP_ACP, 0, lpString, -1, pwszUniBuff, charCount ) )
{
//writeToFile(lpString);
}
delete [] pwszUniBuff;
}
return retVal;
}
int WINAPI MyGetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
{
int retVal = TrueGetWindowTextW(hWnd, lpString, nMaxCount);
if (retVal != 0)
{
//writeToFile(lpString);
}
return retVal;
}
bool InstallDetour(void** originalFunction, void* newFunction)
{
LONG lError = DetourTransactionBegin();
if (lError != NO_ERROR)
return false;
lError = DetourUpdateThread(GetCurrentThread());
if (lError != NO_ERROR)
{
DetourTransactionAbort();
return false;
}
lError = DetourAttach(originalFunction, newFunction);
if (lError != NO_ERROR)
{
DetourTransactionAbort();
return false;
}
lError = DetourTransactionCommit();
if (lError != NO_ERROR)
{
DetourTransactionAbort();
return false;
}
return true;
}
bool UninstallDetour(void* originalFunction, void* newFunction)
{
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourDetach(&originalFunction, newFunction);
DetourTransactionCommit();
return true;
}
bool Init()
{
InstallDetour((void**)&TrueGetWindowTextA, MyGetWindowTextA);
InstallDetour((void**)&TrueGetWindowTextW, MyGetWindowTextW);
return true;
}
void Exit()
{
UninstallDetour(TrueGetWindowTextA, MyGetWindowTextA);
UninstallDetour(TrueGetWindowTextW, MyGetWindowTextW);
}
Tenho erro nas linhas
Código:
InstallDetour((void**)&TrueGetWindowTextA, MyGetWindowTextA);
InstallDetour((void**)&TrueGetWindowTextW, MyGetWindowTextW);
Algum experts nesta area de dll injection que me seja capaz de explicar o q se passa aqui?