Skip to content

Commit b293174

Browse files
committed
Added experimental memory mapped file creation
1 parent c088a2d commit b293174

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

sys/Device.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,11 @@ typedef struct _DEVICE_CONTEXT
287287
//
288288
HANDLE ConfigurationReloadWaitHandle;
289289

290+
//
291+
// Handle to shared memory for XInput Bridge DLL IPC
292+
//
293+
HANDLE XInputBridgeInputReportHandle;
294+
290295
} DEVICE_CONTEXT, * PDEVICE_CONTEXT;
291296

292297
//

sys/DsHidMiniDrv.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,40 @@ DMF_DsHidMini_Open(
245245
//
246246
numInstances++;
247247

248+
//
249+
// Admins & System: all access
250+
// Everyone: read access
251+
//
252+
PWSTR szSD = L"D:(A;OICI;GA;;;BA)(A;OICI;GA;;;SY)(A;OICI;GR;;;WD)";
253+
SECURITY_ATTRIBUTES sa;
254+
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
255+
sa.bInheritHandle = FALSE;
256+
ConvertStringSecurityDescriptorToSecurityDescriptorW(
257+
szSD,
258+
SDDL_REVISION_1,
259+
&((&sa)->lpSecurityDescriptor),
260+
NULL
261+
);
262+
263+
PCWSTR objName = L"Global\\MyFileMappingObject";
264+
265+
pDevCtx->XInputBridgeInputReportHandle = CreateFileMappingW(
266+
INVALID_HANDLE_VALUE,
267+
&sa,
268+
PAGE_READWRITE,
269+
0,
270+
sizeof(DS3_RAW_INPUT_REPORT),
271+
objName
272+
);
273+
274+
if (pDevCtx->XInputBridgeInputReportHandle == NULL)
275+
{
276+
TraceError(
277+
TRACE_DSHIDMINIDRV,
278+
"Failed to create file mapping"
279+
);
280+
}
281+
248282
FuncExit(TRACE_DSHIDMINIDRV, "status=%!STATUS!", status);
249283

250284
return status;
@@ -279,6 +313,11 @@ DMF_DsHidMini_Close(
279313
//
280314
numInstances--;
281315

316+
if (pDevCtx->XInputBridgeInputReportHandle)
317+
{
318+
CloseHandle(pDevCtx->XInputBridgeInputReportHandle);
319+
}
320+
282321
FuncExitNoReturn(TRACE_DSHIDMINIDRV);
283322
}
284323

0 commit comments

Comments
 (0)