Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- #include <Psapi.h>
- #include <stdio.h>
- #include <string>
- class Process
- {
- private:
- HANDLE Handle;
- public:
- int Id;
- Process(int id)
- {
- Handle = OpenProcess(PROCESS_QUERY_INFORMATION, false, id);
- Id = id;
- }
- std::string GetFileName()
- {
- LPTSTR fileName = LPTSTR("");
- GetProcessImageFileName(Handle, fileName, 10000);
- return std::string((char*)fileName);
- }
- void Terminate()
- {
- TerminateProcess(Handle, 0);
- }
- void WriteMemory(unsigned long start, byte* bytes)
- {
- WriteProcessMemory(Handle, LPVOID(start), bytes, sizeof(bytes), nullptr);
- }
- byte* ReadMemory(unsigned long start, unsigned long bytesLength)
- {
- LPVOID result;
- ReadProcessMemory(Handle, LPVOID(start), result, SIZE_T(bytesLength), nullptr);
- return (byte*)result;
- }
- };
- int main()
- {
- int pid = 6460;
- Process googleChrome(pid);
- googleChrome.GetFileName();
- }
Add Comment
Please, Sign In to add comment