Click here to Skip to main content
15,909,030 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Why does the line "delete [] player_data_array;" give a Debug Error Pin
tippex129-Jun-08 10:08
tippex129-Jun-08 10:08 
GeneralRe: Why does the line "delete [] player_data_array;" give a Debug Error [modified] Pin
Mark Salsbery29-Jun-08 10:15
Mark Salsbery29-Jun-08 10:15 
GeneralRe: Why does the line "delete [] player_data_array;" give a Debug Error Pin
tippex129-Jun-08 11:29
tippex129-Jun-08 11:29 
GeneralRe: Why does the line "delete [] player_data_array;" give a Debug Error Pin
Mark Salsbery29-Jun-08 11:49
Mark Salsbery29-Jun-08 11:49 
GeneralRe: Why does the line "delete [] player_data_array;" give a Debug Error Pin
tippex11-Jul-08 3:27
tippex11-Jul-08 3:27 
GeneralRe: Why does the line "delete [] player_data_array;" give a Debug Error Pin
Mark Salsbery1-Jul-08 6:35
Mark Salsbery1-Jul-08 6:35 
GeneralRe: Why does the line "delete [] player_data_array;" give a Debug Error Pin
Stephen Hewitt29-Jun-08 15:15
Stephen Hewitt29-Jun-08 15:15 
QuestionIssue with calling the MessageBox Windows API from a DLL Pin
jbf15429-Jun-08 8:19
jbf15429-Jun-08 8:19 
I am experimenting with detours from Microsoft (http://research.microsoft.com/sn/detours/). I compile this to a DLL and inject the DLL into NOTEPAD.exe. I've tried both a static and dynamic injection. I am attempting to hook the MessageBox API. When loading up notepad when injected, the first MessageBox routine (before being hooked) gives an error (The application failed to initialize properly (0xc0000005)).

To test the that actual detours stuff is working, I made a console application instead of a DLL and ran the exact same code & the message box hook works.

As another sanity check, I completely removed the MessageBox hook and simple tried to call the MessageBox API from withing the injected DLL. I still get the same error.

Does anyone know when I can't call the API from a DLL but from a console application it works fine?

Below is my code:

#include "stdafx.h"
#include <windows.h>
#include <stdio.h>
#include <detours.h>
#include <string.h>

static int (WINAPI* winMessageBox)(
    HWND hWnd,
    LPCTSTR lpText,
    LPCTSTR lpCaption,
    UINT uType) = MessageBox;

int WINAPI __stdcall hookedMessageBox(      
	HWND hWnd,
	LPCTSTR lpText,
	LPCTSTR lpCaption,
	UINT uType) {
	return winMessageBox(hWnd, "This is a hooked message box!", "My Caption", uType);
}

BOOL APIENTRY DllMain( HANDLE hModule, 
                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved
					 )
{
	switch (ul_reason_for_call) {
		case DLL_PROCESS_ATTACH:
			MessageBox(NULL, "About to hook it", "HOOK STATUS", MB_OK);
			DetourRestoreAfterWith();
			DetourTransactionBegin();
			DetourAttach(&(PVOID&)winMessageBox, hookedMessageBox);
			DetourUpdateThread(GetCurrentThread());
			DetourTransactionCommit();
			MessageBox(NULL, "Function hooked!", "HOOK STATUS", MB_OK);
			break;
		case DLL_THREAD_ATTACH:
			break;
		case DLL_THREAD_DETACH:
			break;
		case DLL_PROCESS_DETACH:
			DetourTransactionBegin();
			DetourUpdateThread(GetCurrentThread());
			DetourDetach(&(PVOID&)winMessageBox, hookedMessageBox);
			DetourTransactionCommit();
			MessageBox(NULL, "Clearing hook!", "HOOK STATUS",MB_OK);
			break;
	}
    return TRUE;
}
</string.h></detours.h></stdio.h></windows.h>

AnswerRe: Issue with calling the MessageBox Windows API from a DLL Pin
dave_mm04-Dec-08 10:03
dave_mm04-Dec-08 10:03 
GeneralRe: Issue with calling the MessageBox Windows API from a DLL Pin
jbf1544-Dec-08 16:23
jbf1544-Dec-08 16:23 
QuestionNetwork programming (problem)???my server software is giving connection established but my client software is giving socket init failed Pin
bodhi201629-Jun-08 6:25
bodhi201629-Jun-08 6:25 
AnswerRe: Network programming (problem)???my server software is giving connection established but my client software is giving socket init failed Pin
Mark Salsbery29-Jun-08 8:18
Mark Salsbery29-Jun-08 8:18 
QuestionNeed Help... Pin
Rozz1829-Jun-08 0:36
Rozz1829-Jun-08 0:36 
AnswerRe: Need Help... Pin
rp_suman29-Jun-08 5:00
rp_suman29-Jun-08 5:00 
AnswerRe: Need Help... Pin
Baltoro29-Jun-08 11:37
Baltoro29-Jun-08 11:37 
GeneralRe: Need Help... Pin
Rozz1830-Jun-08 11:39
Rozz1830-Jun-08 11:39 
QuestionXP problem Pin
RomTibi28-Jun-08 19:48
RomTibi28-Jun-08 19:48 
AnswerRe: XP problem Pin
rp_suman29-Jun-08 4:52
rp_suman29-Jun-08 4:52 
GeneralRe: XP problem Pin
RomTibi6-Jul-08 5:48
RomTibi6-Jul-08 5:48 
AnswerRe: XP problem Pin
Ștefan-Mihai MOGA29-Jun-08 5:01
professionalȘtefan-Mihai MOGA29-Jun-08 5:01 
GeneralRe: XP problem Pin
RomTibi6-Jul-08 5:49
RomTibi6-Jul-08 5:49 
QuestionHow to get Thread State Pin
SalarSoft28-Jun-08 18:21
SalarSoft28-Jun-08 18:21 
AnswerRe: How to get Thread State Pin
rp_suman29-Jun-08 5:24
rp_suman29-Jun-08 5:24 
AnswerRe: How to get Thread State Pin
Mark Salsbery29-Jun-08 8:40
Mark Salsbery29-Jun-08 8:40 
GeneralRe: How to get Thread State Pin
SalarSoft29-Jun-08 18:20
SalarSoft29-Jun-08 18:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.