Skip to content

Commit 4abd171

Browse files
Use default security attributes for named pipes (#1116)
1 parent af4f9a9 commit 4abd171

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

server/desktop/src/main/java/dev/slimevr/desktop/platform/windows/WindowsNamedPipeBridge.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ boolean GetOverlappedResult(
3434
public class WindowsNamedPipeBridge extends SteamVRBridge {
3535
private static final Kernel32 k32 = Kernel32.INSTANCE;
3636
private static final Kernel32IO k32io = Kernel32IO.INSTANCE;
37+
private static final Advapi32 adv32 = Advapi32.INSTANCE;
3738

3839
protected final String pipeName;
3940
private final byte[] buffArray = new byte[2048];
@@ -251,6 +252,20 @@ private void resetPipe() {
251252

252253
private void createPipe() throws IOException {
253254
try {
255+
WinNT.SECURITY_DESCRIPTOR descriptor = new WinNT.SECURITY_DESCRIPTOR(64 * 1024);
256+
adv32.InitializeSecurityDescriptor(descriptor, WinNT.SECURITY_DESCRIPTOR_REVISION);
257+
adv32.SetSecurityDescriptorDacl(descriptor, true, null, false);
258+
adv32
259+
.SetSecurityDescriptorControl(
260+
descriptor,
261+
(short) WinNT.SE_DACL_PROTECTED,
262+
(short) WinNT.SE_DACL_PROTECTED
263+
);
264+
265+
WinBase.SECURITY_ATTRIBUTES attributes = new WinBase.SECURITY_ATTRIBUTES();
266+
attributes.lpSecurityDescriptor = descriptor.getPointer();
267+
attributes.bInheritHandle = false;
268+
254269
pipe = new WindowsPipe(
255270
k32
256271
.CreateNamedPipe(
@@ -261,7 +276,7 @@ private void createPipe() throws IOException {
261276
1024 * 16, // nOutBufferSize,
262277
1024 * 16, // nInBufferSize,
263278
0, // nDefaultTimeOut,
264-
null // lpSecurityAttributes
279+
attributes // lpSecurityAttributes
265280
),
266281
pipeName
267282
);

0 commit comments

Comments
 (0)