Click here to Skip to main content
15,895,823 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to create a simple Loader, so I created a new Win32 Project. All went right but when I tryed to add
::AfxMessageBox()
Function I got compiler Error.

This is my code:
StdAfx.h
// stdafx.h : include file for standard system include files,
//  or project specific include files that are used frequently, but
//      are changed infrequently
//

#if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
#define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#define WIN32_LEAN_AND_MEAN		// Exclude rarely-used stuff from Windows headers

#include <windows.h>


// TODO: reference additional headers your program requires here

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)

&
StdAfx.cpp
// stdafx.cpp : source file that includes just the standard includes
//  EasyServerLoader.pch will be the pre-compiled header
//  stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file

&
resource.h
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by EasyServerLoader.rc
//
#define IDI_MAINICON                    101
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        102
#define _APS_NEXT_COMMAND_VALUE         40001
#define _APS_NEXT_CONTROL_VALUE         1000
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif

& the main cpp file is
EasyServerLoader.cpp
// EasyServerLoader.cpp : Defines the entry point for the application.
//

#include "stdafx.h"

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
 	// TODO: Place code here.
	PROCESS_INFORMATION	pInfo;
	STARTUPINFO			sInfo;

	sInfo.cb				= sizeof(STARTUPINFO);
	sInfo.lpReserved		= NULL;
	sInfo.lpReserved2		= NULL;
	sInfo.cbReserved2		= 0;
	sInfo.lpDesktop			= NULL;
	sInfo.lpTitle			= NULL;
	sInfo.dwFlags			= 0;
	sInfo.dwX				= 0;
	sInfo.dwY				= 0;
	sInfo.dwFillAttribute	= 0;
	sInfo.wShowWindow		= SW_SHOW;

	try
	{
		::CreateProcess("EasyServer.exe",
						NULL,
						NULL,
						NULL,
						FALSE,
						CREATE_SUSPENDED,
						NULL,
						NULL,
						&sInfo,
						&pInfo);
	}
	catch(...)
	{
		//::AfxMessageBox("Oops!, Something went wrong!");
		return -1;
	}

	BYTE	bToWrite[13] = {0x01,
							0x01,
							0x01,
							0xB2,
							0xFE,
							0xB8,
							0xFE,
							0x68,
							0xB8,
							0x12,
							0x48,
							0x90,
							0x90};
	LPVOID	lpBaseAddress[13] = {(void*)0x62DD74,
								 (void*)0x62E272,
								 (void*)0x62E31A,
								 (void*)0x62E389,
								 (void*)0x62E38A,
								 (void*)0x62E469,
								 (void*)0x62E46A,
								 (void*)0x644561,
								 (void*)0x644562,
								 (void*)0x644563,
								 (void*)0x644564,
								 (void*)0x644566,
								 (void*)0x644567};
	DWORD	dNumberOfBytesReadWritten;
	
	BYTE	bRead;
	LPVOID	lpLastAddress = (void*)0x6645FA;
	
	try
	{
		do
		{
			::ResumeThread(pInfo.hThread);
			::Sleep(1);
			::SuspendThread(pInfo.hThread);
			::ReadProcessMemory(pInfo.hProcess,
								lpLastAddress,
								&bRead,
								1,
								&dNumberOfBytesReadWritten);
		}while (bRead != 0x72);
		::ResumeThread(pInfo.hThread);
		::Sleep(100);
		::SuspendThread(pInfo.hThread);
	}
	catch(...)
	{
		//::AfxMessageBox("Oops!, Something went wrong!");
		return -1;
	}

	try
	{
		for (int i=0; i<13; i++)
			::WriteProcessMemory(pInfo.hProcess,
								 lpBaseAddress[i],
								 &bToWrite[i],
								 1,
								 &dNumberOfBytesReadWritten);
		::ResumeThread(pInfo.hThread);
	}
	catch(...)
	{
		//::AfxMessageBox("Oops!, Something went wrong!");
		return -1;
	}
	
	return 0;
}


Help me please to solve this issue.
& I need code block of getting "EasyServer.exe" file size using
GetFileSize()
function also.

Thank you anyway ;)
Posted
Updated 24-Oct-10 10:43am
v3

1 solution

AfxMessageBox is an MFC function. In a non-MFC app, use the MessageBox API function.

Example:

C++
MessageBox (NULL, "message", "title", MB_OK);
 
Share this answer
 
v2
Comments
Mr. Tomay 24-Oct-10 19:18pm    
Thank you for your help.
What about GetFileSize() ?
Nish Nishant 24-Oct-10 19:23pm    
Can you post that as a separate question please? That way the QA thread will remain lucid and associated with a single topic for anyone searching for the same thing in future. Thanks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900