Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- #include <Psapi.h>
- #include <stdio.h>
- #include <string>
- typedef std::string string;
- class Process
- {
- private:
- HANDLE Handle;
- public:
- int Id;
- Process(int id)
- {
- Handle = OpenProcess(PROCESS_QUERY_INFORMATION, false, id);
- Id = id;
- }
- string GetFileName()
- {
- TCHAR tCharFn[MAX_PATH];
- char charFn[MAX_PATH];
- GetProcessImageFileName(Handle, tCharFn, 10000);
- wcstombs(charFn, tCharFn, wcslen(tCharFn) + 1);
- return charFn;
- }
- 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;
- }
- };
- class Console
- {
- public:
- static void WriteLine(string message)
- {
- Write(message + "\r\n");
- }
- static void Write(string message)
- {
- printf(message.c_str());
- }
- };
- int main()
- {
- int pid = 6460;
- Process googleChrome(pid);
- Console::WriteLine(googleChrome.GetFileName());
- Sleep(100000);
- return 0;
- }
Add Comment
Please, Sign In to add comment