Advertisement
Brandan

Populous Memory Editor

Dec 3rd, 2013
1,022
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.67 KB | None | 0 0
  1. //I'm using a custom header GetProcessID.h to get the pId of Populous TB, you can
  2. //use your own process, i'm not going to release that header file since its not mine.
  3.  
  4. #include "stdafx.h"
  5. #include <windows.h>
  6. #include "GetProcessID.h"
  7. #include <iostream>
  8. #include <string>
  9. #include <stdio.h>
  10. #include <tchar.h>
  11. #include <thread>
  12. using namespace std;
  13.  
  14. DWORD GetPID (LPCTSTR processName);
  15. bool WriteMem (LPCTSTR processName, LPVOID location, byte value);
  16. int ReadMem (LPCTSTR processName, LPVOID location);
  17. void Memloop();
  18. int tribecol = 0;
  19.  
  20. int main(int argc, char* argv[])
  21. {
  22.    
  23.     SetConsoleTitle("Populous Tribe Changer");
  24.  
  25.     cout << "Welcome to Populous Tribe Changer!\n\n";
  26.  
  27.     int popOpen = 0;
  28.  
  29.     while (popOpen == 0) {
  30.         if (GetPID("matchmaker") > 0) {
  31.             cerr << "\nPopulous Reincarnated Matchmaker must be closed!" << endl;
  32.         } else {
  33.             if (GetPID("poptb") > 0) {
  34.                 cout << "blue = 0, red = 1, yellow = 2, green = 3" << endl;
  35.                 cout << "Please enter tribe color #: ";
  36.                 cin >> tribecol;
  37.                 popOpen = 1;
  38.             } else {
  39.                 cout << "Please open Populous (Software)!" << endl;
  40.             }
  41.         }
  42.         Sleep(2000);
  43.     }
  44.  
  45.     thread t1(Memloop);
  46.     t1.detach();
  47.  
  48.     while (true) {
  49.         cout << "Would you like to change colors? #: ";
  50.         cin >> tribecol;
  51.         cout << "Your new color has been set, you may need to restart the level to gain control. " << endl;
  52.     }
  53.  
  54.     getchar();
  55.     return 0;
  56. }
  57.  
  58. void Memloop() {
  59.     while (true) {
  60.         if (GetPID("matchmaker") > 0) {
  61.             cerr << "\nPopulous Reincarnated Matchmaker must be closed!" << endl;
  62.         } else {
  63.             if (GetPID("poptb") > 0) {
  64.                 WriteMem("poptb", (LPVOID)0x884C88, tribecol);
  65.             }
  66.         }
  67.         Sleep(2000);
  68.     }
  69. }
  70.  
  71.  
  72. bool WriteMem (LPCTSTR processName, LPVOID location, byte value) {
  73.     HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, false, GetPID(processName));
  74.     if (!hProc) {
  75.         cerr << "Cannot write memory, is populous open? running as admin?" << endl;
  76.         return false;
  77.     }else {
  78.         int isSuccessful = WriteProcessMemory(hProc, location, &value, sizeof(&value), NULL);
  79.         if (isSuccessful > 0) {
  80.             return true;
  81.         } else {
  82.             return false;
  83.         }
  84.         CloseHandle(hProc);
  85.     }
  86. }
  87.  
  88. int ReadMem (LPCTSTR processName, LPVOID location) {
  89.     int output;
  90.     HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, false, GetPID(processName));
  91.     if (!hProc) {
  92.         cerr << "Cannot read memory, is populous open? running as admin?" << endl;
  93.         return 0;
  94.     }else {
  95.         int MemRd = ReadProcessMemory(hProc, location, &output, sizeof(&output), NULL);
  96.         return output;
  97.         CloseHandle(hProc);
  98.     }
  99. }
  100.  
  101. DWORD GetPID (LPCTSTR processName) {
  102.     std::vector<DWORD> SetOfPID;
  103.     GetProcessID(processName,SetOfPID);
  104.     if (SetOfPID.empty()) {
  105.         return 0;
  106.     }
  107.     return SetOfPID[0];
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement