Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class KReader
- {
- public:
- KReader() : m_hDriver(0), m_PUID(0), m_PUBase(0)
- {
- m_isConnected = false;
- m_hDriver = CreateFileA(DRIVERNAME, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);
- if (!m_hDriver || m_hDriver == INVALID_HANDLE_VALUE)
- {
- m_isConnected = false;
- //ExitProcess(0);
- }
- else
- {
- m_isConnected = true;
- }
- }
- ~KReader()
- {
- CloseHandle(m_hDriver);
- }
- /*
- * CLASS METHODS
- */
- bool SetPUID(ULONG PUID)
- {
- DWORD at;
- // create a struct that requests the base address
- readStruct rStruct{ 0, 0, 0, 0, PROTO_SET_PID , PUID };
- // send the struct to IOCTL
- WriteFile(m_hDriver, (LPCVOID)&rStruct, sizeof(ReadStruct), &at, NULL);
- return true;
- }
- HANDLE readPUID()
- {
- HANDLE PUID = 0;
- DWORD at;
- void* read = nullptr;
- // create a struct that requests the base address
- readStruct rStruct{ (uint64_t)&PUID, (uint64_t)read, sizeof(HANDLE), (uint32_t)GetCurrentProcessId(), PROTO_GET_PUID,0 };
- // send the struct to IOCTL
- WriteFile(m_hDriver, (LPCVOID)&rStruct, sizeof(ReadStruct), &at, NULL);
- if (PUID)
- {
- m_PUID = PUID;
- }
- return PUID;
- }
- int64_t readPUBase()
- {
- int64_t base = 0;
- DWORD at;
- void* read = nullptr;
- // create a struct that requests the base address
- readStruct rStruct{ (uint64_t)&base, (uint64_t)read, sizeof(int64_t), (uint32_t)GetCurrentProcessId(), PROTO_GET_BASEADDR,0 };
- // send the struct to IOCTL
- WriteFile(m_hDriver, (LPCVOID)&rStruct, sizeof(ReadStruct), &at, NULL);
- if (base)
- {
- m_PUBase = base;
- }
- return base;
- }
- template<typename T>
- T RPM(const int64_t& w_read, const SIZE_T& Size) const
- {
- T writeMe;
- DWORD at;
- readStruct rStruct{ (uint64_t)&writeMe, (uint64_t)w_read, Size, (uint32_t)GetCurrentProcessId(), PROTO_NORMAL_READ,0 };
- // send the struct to IOCTL
- WriteFile(m_hDriver, (LPCVOID)&rStruct, sizeof(ReadStruct), &at, NULL);
- return writeMe;
- }
- template<typename T>
- T RPM(const int64_t& w_read) const
- {
- T writeMe;
- DWORD at;
- readStruct rStruct{ (uint64_t)&writeMe, (uint64_t)w_read, sizeof(T), (uint32_t)GetCurrentProcessId(), PROTO_NORMAL_READ,0 };
- // send the struct to IOCTL
- WriteFile(m_hDriver, (LPCVOID)&rStruct, sizeof(ReadStruct), &at, NULL);
- return writeMe;
- }
- template<typename T> void WPM(const int64_t& address_to_write, T value_to_write, ULONGLONG size)
- {
- readStruct write_struct{ (uint64_t)&value_to_write, (uint64_t)address_to_write, size, (uint32_t)GetCurrentProcessId(), PROTO_NORMAL_WRITE ,0 };
- // send the struct to IOCTL
- DWORD at;
- WriteFile(m_hDriver, (LPCVOID)&rStruct, sizeof(ReadStruct), &at, NULL);
- }
- template<typename T> void WPM(const int64_t& address_to_write, T value_to_write)
- {
- readStruct write_struct{ (uint64_t)&value_to_write, (uint64_t)address_to_write, sizeof(T), (uint32_t)GetCurrentProcessId(), PROTO_NORMAL_WRITE };
- // send the struct to IOCTL
- DWORD at;
- WriteFile(m_hDriver, (LPCVOID)&write_struct, sizeof(ReadStruct), &at, NULL);
- }
- BOOL writeSize(const int64_t& buffer, const BYTE* gOffset, ULONGLONG size) const
- {
- readStruct rStruct{ (uint64_t)gOffset, (uint64_t)buffer, size, (uint32_t)GetCurrentProcessId(), PROTO_NORMAL_WRITE,0 };
- // send the struct to IOCTL
- DWORD at;
- return WriteFile(m_hDriver, (LPCVOID)&rStruct, sizeof(ReadStruct), &at, NULL);
- }
- void writeAll(const int64_t& w_read, const PVOID& w_write, ULONGLONG size) const
- {
- readStruct rStruct{ (uint64_t)w_write, (uint64_t)w_read, size, (uint32_t)GetCurrentProcessId(), PROTO_NORMAL_WRITE,0 };
- // send the struct to IOCTL
- DWORD at;
- WriteFile(m_hDriver, (LPCVOID)&rStruct, sizeof(ReadStruct), &at, NULL);
- }
- bool iowrite(uint64_t address, PVOID data, ULONGLONG size) const
- {
- readStruct rStruct{ (uint64_t)data, (uint64_t)address, size, (uint32_t)GetCurrentProcessId(), PROTO_NORMAL_WRITE,0 };
- DWORD at;
- /*rStruct.GameAddressOffset = address;
- rStruct.UserBufferAdress = (uintptr_t)data;
- rStruct.UserPID = (uint32_t)GetCurrentProcessId();
- rStruct.GAMEPID = this->m_PUID;
- rStruct.ProtocolMsg = PROTO_NORMAL_READ;
- rStruct.ReadSize = size;*/
- // send the struct to IOCTL
- return WriteFile(m_hDriver, (LPCVOID)&rStruct, sizeof(ReadStruct), &at, NULL);
- }
- bool ioread(uint64_t address, PVOID data, ULONGLONG size) const
- {
- readStruct rStruct{ (uint64_t)data, (uint64_t)address, size, (uint32_t)GetCurrentProcessId(), PROTO_NORMAL_READ,0 };
- DWORD at;
- /*rStruct.GameAddressOffset = address;
- rStruct.UserBufferAdress = (uintptr_t)data;
- rStruct.UserPID = (uint32_t)GetCurrentProcessId();
- rStruct.GAMEPID = this->m_PUID;
- rStruct.ProtocolMsg = PROTO_NORMAL_READ;
- rStruct.ReadSize = size;*/
- // send the struct to IOCTL
- return WriteFile(m_hDriver, (LPCVOID)&rStruct, sizeof(ReadStruct), &at, NULL);
- }
- BYTE* readSize(const int64_t& w_read, const uint32_t& w_readSize) const
- {
- BYTE* writeMe = new BYTE[w_readSize];
- // memset(paluu, 0, readSize);
- DWORD at;
- if (PROTO_NORMAL_READ == PROTO_NORMAL_READ)
- {
- readStruct rStruct{ (uint64_t)writeMe, (uint64_t)w_read, w_readSize - 2, (uint32_t)GetCurrentProcessId(), PROTO_NORMAL_READ,0 };
- // send the struct to IOCTL
- WriteFile(m_hDriver, (LPCVOID)&rStruct, sizeof(ReadStruct), &at, NULL);
- }
- if (*writeMe == 0)
- {
- delete writeMe;
- return NULL;
- }
- return writeMe;
- }
- void deletedriver()
- {
- DWORD at;
- // create a struct that requests the base address
- readStruct rStruct{ 0, 0, 0, (uint32_t)GetCurrentProcessId(), PROTO_DELETE_DRIVER ,0 };
- // send the struct to IOCTL
- WriteFile(m_hDriver, (LPCVOID)&rStruct, sizeof(ReadStruct), &at, NULL);
- }
- void deletedriver7()
- {
- DWORD at;
- // create a struct that requests the base address
- readStruct rStruct{ 0, 0, 0, (uint32_t)GetCurrentProcessId(), PROTO_DELETE_DRIVER7 ,0 };
- // send the struct to IOCTL
- WriteFile(m_hDriver, (LPCVOID)&rStruct, sizeof(ReadStruct), &at, NULL);
- }
- void cleandriver()
- {
- DWORD at;
- // create a struct that requests the base address
- readStruct rStruct{ 0, 0, 0, (uint32_t)GetCurrentProcessId(), PROTO_CLEAR_DRIVER,0 };
- // send the struct to IOCTL
- WriteFile(m_hDriver, (LPCVOID)&rStruct, sizeof(ReadStruct), &at, NULL);
- }
- /*
- * GETTERS AND SETTERS
- */
- HANDLE getKernHandle() const
- {
- return m_hDriver;
- }
- HANDLE getPUID() const
- {
- return m_PUID;
- }
- int64_t getPUBase() const
- {
- return m_PUBase;
- }
- bool isReading() const
- {
- return m_readActive;
- }
- bool isConnected() const
- {
- return m_isConnected;
- }
- private:
- HANDLE m_hDriver;
- HANDLE m_PUID;
- int64_t m_PUBase;
- bool m_readActive;
- bool m_isConnected;
- };
- extern KReader* mem;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement