Hilfe bei Detour (C++)

08/27/2012 20:59 AutoitScript#1
Hi,

Habe gerade das Tutorial von MrSmith durchgemacht. Hat super geklappt.
Jetzt habe ich mir ein kleines Testprogramm geschrieben, in dem ich ebenfalls die MessageBoxW Funktion detouren möchte. In Olly habe ich flgendes gefunden:
Code:
idata:00482684 ; int __stdcall MessageBoxW(HWND hWnd,LPCWSTR lpText,LPCWSTR lpCaption,UINT uType)
Mein Code:
Code:
#include <detours.h>

#pragma comment(lib,"detours")

typedef int (__stdcall *MyType)(HWND,LPCWSTR,LPCWSTR,UINT);

MyType Original = NULL;

int __stdcall MessageBoxWDetour(HWND Window, LPCWSTR Text, LPCWSTR Caption, UINT Type)
{
	Text = L"lol'd";
	return Original(Window, Text, Caption, Type);
}

BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
					 )
{
	switch (ul_reason_for_call)
	{
	case DLL_PROCESS_ATTACH:
		MessageBoxA(0,"Attached","Info",0);
		Original=(MyType)DetourFunction((PBYTE)0x00482684,(PBYTE)MessageBoxWDetour);
		break;
	case DLL_PROCESS_DETACH:
		MessageBoxA(0,"Dettached","Info",0);
		break;
	}
	return TRUE;
}
Wenn ich die Dll dann injecte crasht das Prog.

PS: Bin C++ "Anfänger", beherrsche jedoch C# recht gut.


Mfg AutoitScript
08/27/2012 21:22 SmackJew#2
Was soll die Adresse?

Code:
Original=(MyType)DetourFunction((PBYTE)MessageBoxW,(PBYTE)MessageBoxWDetour);
08/28/2012 19:45 MrSm!th#3
#moved