Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //I'm using a custom header GetProcessID.h to get the pId of Populous TB, you can
- //use your own process, i'm not going to release that header file since its not mine.
- #include "stdafx.h"
- #include <windows.h>
- #include "GetProcessID.h"
- #include <iostream>
- #include <string>
- #include <stdio.h>
- #include <tchar.h>
- #include <thread>
- using namespace std;
- DWORD GetPID (LPCTSTR processName);
- bool WriteMem (LPCTSTR processName, LPVOID location, byte value);
- int ReadMem (LPCTSTR processName, LPVOID location);
- void Memloop();
- int tribecol = 0;
- int main(int argc, char* argv[])
- {
- SetConsoleTitle("Populous Tribe Changer");
- cout << "Welcome to Populous Tribe Changer!\n\n";
- int popOpen = 0;
- while (popOpen == 0) {
- if (GetPID("matchmaker") > 0) {
- cerr << "\nPopulous Reincarnated Matchmaker must be closed!" << endl;
- } else {
- if (GetPID("poptb") > 0) {
- cout << "blue = 0, red = 1, yellow = 2, green = 3" << endl;
- cout << "Please enter tribe color #: ";
- cin >> tribecol;
- popOpen = 1;
- } else {
- cout << "Please open Populous (Software)!" << endl;
- }
- }
- Sleep(2000);
- }
- thread t1(Memloop);
- t1.detach();
- while (true) {
- cout << "Would you like to change colors? #: ";
- cin >> tribecol;
- cout << "Your new color has been set, you may need to restart the level to gain control. " << endl;
- }
- getchar();
- return 0;
- }
- void Memloop() {
- while (true) {
- if (GetPID("matchmaker") > 0) {
- cerr << "\nPopulous Reincarnated Matchmaker must be closed!" << endl;
- } else {
- if (GetPID("poptb") > 0) {
- WriteMem("poptb", (LPVOID)0x884C88, tribecol);
- }
- }
- Sleep(2000);
- }
- }
- bool WriteMem (LPCTSTR processName, LPVOID location, byte value) {
- HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, false, GetPID(processName));
- if (!hProc) {
- cerr << "Cannot write memory, is populous open? running as admin?" << endl;
- return false;
- }else {
- int isSuccessful = WriteProcessMemory(hProc, location, &value, sizeof(&value), NULL);
- if (isSuccessful > 0) {
- return true;
- } else {
- return false;
- }
- CloseHandle(hProc);
- }
- }
- int ReadMem (LPCTSTR processName, LPVOID location) {
- int output;
- HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, false, GetPID(processName));
- if (!hProc) {
- cerr << "Cannot read memory, is populous open? running as admin?" << endl;
- return 0;
- }else {
- int MemRd = ReadProcessMemory(hProc, location, &output, sizeof(&output), NULL);
- return output;
- CloseHandle(hProc);
- }
- }
- DWORD GetPID (LPCTSTR processName) {
- std::vector<DWORD> SetOfPID;
- GetProcessID(processName,SetOfPID);
- if (SetOfPID.empty()) {
- return 0;
- }
- return SetOfPID[0];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement