#ifndef IPC_H
#define IPC_H

#include <Windows.h>

#define IPC_BUFFER_LEN 4096 //4k buffer size

#define SOR 0x11 //start of record tag
#define EOR 0x99 //end of record tag
#define PAD 0xF0 //pad char

typedef enum
{
	IPC_DATA_UNKNOWN = 0,
	IPC_DATA_KEYBOARD
}IPC_DATA_TYPE, *PIPC_DATA_TYPE;

#pragma pack(push, 1)
typedef struct
{
	BYTE    StartOfRecord;
	DWORD	Length;
	BYTE	Type;
	DWORD   dwTimestamp;
	LPVOID	Buffer;
	BYTE    EndOfRecord;
} IPC_DATA, *PIPC_DATA;

typedef struct
{
	UINT   Message;
	HWND   Window;
	WPARAM WParam;
	LPARAM LParam;
} KBD_DATA, *PKBD_DATA;

#pragma pop(1)

//functions prototypes
int IPCRead(HANDLE hProcess, LPVOID lpMemAddr, PIPC_DATA pIpcData, LPVOID *lpRecord);
BOOL IPCWrite(LPVOID lpMemAddr, PIPC_DATA pIpcData);
BOOL IPCZeroMemory(HANDLE hProcess, LPVOID lpMemAddr, SIZE_T length);

typedef BOOL(*pIPCWrite)(LPVOID lpMemAddr, PIPC_DATA pIpcData);

DWORD WINAPI IPCWorkerThread(LPVOID lpParams);

#endif