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
#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>
#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
&
StdAfx.cpp
#include "stdafx.h"
&
resource.h
#define IDI_MAINICON 101
#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
#include "stdafx.h"
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
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(...)
{
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(...)
{
return -1;
}
try
{
for (int i=0; i<13; i++)
::WriteProcessMemory(pInfo.hProcess,
lpBaseAddress[i],
&bToWrite[i],
1,
&dNumberOfBytesReadWritten);
::ResumeThread(pInfo.hThread);
}
catch(...)
{
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 ;)