Created
June 3, 2020 09:14
-
-
Save giacomof/94efe0e3f80edf371b6e5554c845b235 to your computer and use it in GitHub Desktop.
Redout Shared Memory Taker example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <windows.h> | |
#include <stdio.h> | |
#include <conio.h> | |
#include <tchar.h> | |
#include <math.h> | |
#pragma comment(lib, "user32.lib") | |
#define BUF_SIZE 256 | |
TCHAR szName[] = TEXT("Global\\RedoutSimulatorParams"); | |
typedef struct { | |
float F32QuatX; | |
float F32QuatY; | |
float F32QuatZ; | |
float F32QuatW; | |
float F32XAcceG; | |
float F32YAcceG; | |
float F32ZAcceG; | |
}GAME_PARA; | |
int _tmain() | |
{ | |
HANDLE hMapFile; | |
GAME_PARA* pBuf = 0; | |
hMapFile = OpenFileMapping( | |
FILE_MAP_ALL_ACCESS, // read/write access | |
FALSE, // do not inherit the name | |
szName); // name of mapping object | |
if (hMapFile == NULL) | |
{ | |
_tprintf(TEXT("Could not open file mapping object (%d).\n"), | |
GetLastError()); | |
return 1; | |
} | |
bool exit = false; | |
while (exit == false) | |
{ | |
if (GetAsyncKeyState(VK_ESCAPE)) | |
{ | |
exit = true; | |
} | |
pBuf = (GAME_PARA*)MapViewOfFile(hMapFile, // handle to map object | |
FILE_MAP_ALL_ACCESS, // read/write permission | |
0, | |
0, | |
BUF_SIZE); | |
if (pBuf == NULL) | |
{ | |
_tprintf(TEXT("Could not map view of file (%d).\n"), | |
GetLastError()); | |
CloseHandle(hMapFile); | |
return 1; | |
} | |
printf("QX: %f, QY: %f, QZ: %f, QW: %f -- GX: %f, GY: %f, GZ: %f\n", | |
pBuf->F32QuatX, | |
pBuf->F32QuatY, | |
pBuf->F32QuatZ, | |
pBuf->F32QuatW, | |
pBuf->F32XAcceG, | |
pBuf->F32YAcceG, | |
pBuf->F32ZAcceG); | |
} | |
UnmapViewOfFile(pBuf); | |
CloseHandle(hMapFile); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment