Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <stdio.h>
- #define CTL_READ 0x10
- #define CTL_WRITE 0x11
- typedef struct _KRNL_REQUEST
- {
- ULONG pId;
- ULONG Address;
- ULONG ReadSize;
- ULONG Value;
- }KRNL_REQUEST, *PKRNL_REQUEST;
- boolean Read(DWORD pId, DWORD ReadAddress, DWORD* ReturnValue, DWORD ReadSize)
- {
- HANDLE hFile = CreateFile("\\\\.\\Example", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
- if (hFile == INVALID_HANDLE_VALUE)
- {
- printf("Could not open handle! Error Code: %X\n", GetLastError());
- system("pause");
- return 0;
- }
- if (hFile)
- {
- KRNL_REQUEST ReadRequest;
- ReadRequest.Address = ReadAddress;
- ReadRequest.pId = GetCurrentProcessId();
- ReadRequest.ReadSize = ReadSize;
- ReadRequest.Value = 0;
- if (!DeviceIoControl(hFile, CTL_READ, &ReadRequest, sizeof(ReadRequest), &ReadRequest, sizeof(ReadRequest), NULL, NULL))
- {
- printf("Device Could not be contacted! Error Code: %X\n", GetLastError());
- CloseHandle(hFile);
- system("pause");
- return 0;
- }
- *ReturnValue = ReadRequest.Value;
- CloseHandle(hFile);
- }
- return 1;
- }
- int _cdecl main(void)
- {
- float i = 10.5f;
- float ReturnVal = 0;
- Read(GetCurrentProcessId(), &i, &ReturnVal, sizeof(ReturnVal));
- printf("Return Value: %f", ReturnVal);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement