Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - bfwlegend

Pages: [1]
1
Armed Assault 2 / C++ Auto-Change memory
« on: June 26, 2012, 09:02:06 pm »
So I'm trying to get my mod-app to automatically change the memory so when I press ESCx2 my mod-apps will load, I can do it with CheatEngine but I like it to be automatic, I've made something and was trying to get it to work but I can't see to get my memory to come out as a string (I need to read/write as string not byte) and I was wondering if anyone could help me out, thanks :)
(It's lacking some of the features I also didn't add WriteProcessMemory yet to it)
Code: [Select]
// Arma 2 Hecks.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <Windows.h>
#include <string>
#include <tlhelp32.h>

#pragma comment(lib, "user32.lib")

using namespace std;

DWORD FindProcessId(const std::wstring& processName);

int _tmain(int argc, _TCHAR* argv[])
{
std::cout << "Welcome to Das Arma mod-apps for Arma 2 OA" << endl;
std::wstring processName;

std::wcout << "Enter ArmA2OA's process name, usally ""ArmA2OA.exe"": ";
std::getline(std::wcin, processName);
std::cout << "Look for the Arma2OA window now..." << endl;
DWORD ProcessId = FindProcessId(processName);

if (ProcessId == 0){
cout << "ERROR: Could not find "<< processName.c_str() << endl;
}
else{
cout << "Arma 2 OA window found ID: "<< ProcessId << endl;
cout << "Executing functions on "<< processName.c_str() << endl;
HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, ProcessId);
if (!hProc){
cout << "FAILED! on: Opening process" << endl;
}else{
cout << "Opened process" << endl;

DWORD Pointer = 0xFC7EBED5;
DWORD Pointed;
DWORD Pointstring;
DWORD CurrentInjection;
WORD Offset = 0x0025;
//ReadProcessMemory(hProc,(LPCVOID)(Pointer), &Pointed,59,NULL);
ReadProcessMemory(hProc,(LPCVOID)(Pointer), &CurrentInjection,4,NULL);

cout << "Done!: " << CurrentInjection << endl;
}

}



system("PAUSE");
return 0;
}

DWORD FindProcessId(const std::wstring& processName)
{
PROCESSENTRY32 processInfo;
processInfo.dwSize = sizeof(processInfo);

HANDLE processesSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
if ( processesSnapshot == INVALID_HANDLE_VALUE )
return 0;

Process32First(processesSnapshot, &processInfo);
if ( !processName.compare(processInfo.szExeFile) )
{
CloseHandle(processesSnapshot);
return processInfo.th32ProcessID;
}

while ( Process32Next(processesSnapshot, &processInfo) )
{
if ( !processName.compare(processInfo.szExeFile) )
{
CloseHandle(processesSnapshot);
return processInfo.th32ProcessID;
}
}

CloseHandle(processesSnapshot);
return 0;
}


Pages: [1]