Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Memory.h"
- CMemory Memory;
- void CMemory::getHandle()
- {
- HANDLE hPID = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
- PROCESSENTRY32 ProcEntry;
- ProcEntry.dwSize = sizeof(ProcEntry);
- do
- {
- if (!strcmp(ProcEntry.szExeFile, "csgo.exe"))
- {
- Offsets.PID = ProcEntry.th32ProcessID;
- CloseHandle(hPID);
- Offsets.handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, Offsets.PID);
- std::cout << "Process found!\n";
- std::this_thread::sleep_for(std::chrono::milliseconds(1000));
- system("cls"); //Not best method to clean console, but works :)
- return;
- }
- } while (Process32Next(hPID, &ProcEntry));
- CloseHandle(hPID);
- std::cout << "Process not found.." << std::endl;
- Sleep(1000);
- exit(0);
- }
- int CMemory::getModule(const char* moduleName)
- {
- HANDLE hModule = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, Offsets.PID);
- MODULEENTRY32 mEntry;
- mEntry.dwSize = sizeof(mEntry);
- while (Module32Next(hModule, &mEntry)) {
- if (!strcmp(mEntry.szModule, moduleName))
- {
- std::cout << moduleName << " found!\n";
- std::this_thread::sleep_for(std::chrono::milliseconds(1000));
- system("cls");
- CloseHandle(hModule);
- return (DWORD)mEntry.modBaseAddr;
- }
- }
- CloseHandle(hModule);
- return 0;
- }
- #pragma once
- #include <iostream>
- #include <Windows.h>
- #include <TlHelp32.h>
- #include <thread>
- #include "Offsets.h"
- class CMemory
- {
- public:
- void getHandle();
- int getModule(const char* moduleName);
- };
- extern CMemory Memory;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement