Skip to content

Commit 957b6ed

Browse files
Updates named pipe to allow connection of non-elevated helper app to elevated plugin. (#28)
* Updates named pipe to allow connection of non-elevated helper app to elevated plugin. * Updates version to 1.0.1
1 parent f16036c commit 957b6ed

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

buildspec.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"displayName": "Elgato Marketplace Connect",
4141
"versionMajor": 1,
4242
"versionMinor": 0,
43-
"versionPatch": 0,
43+
"versionPatch": 1,
4444
"buildNumber": 0,
4545
"releaseType": "release",
4646
"author": "Elgato",

loader/main.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,14 @@ int send_auth_to_obs(std::string payload) {
9191
std::string base_name = "\\\\.\\pipe\\" + pipe_name;
9292
std::string attempt_name;
9393
HANDLE pipe = INVALID_HANDLE_VALUE;
94+
SECURITY_ATTRIBUTES sa;
95+
SECURITY_DESCRIPTOR sd;
96+
InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);
97+
SetSecurityDescriptorDacl(&sd, TRUE, NULL, FALSE);
98+
sa.nLength = sizeof(sa);
99+
sa.lpSecurityDescriptor = &sd;
100+
sa.bInheritHandle = FALSE;
101+
94102
int connect_attempts_remaining = 6;
95103

96104
while (connect_attempts_remaining-- > 0 &&
@@ -100,7 +108,7 @@ int send_auth_to_obs(std::string payload) {
100108
attempt_name = base_name + std::to_string(pipe_number);
101109
printf("Attempting %s\n", attempt_name.c_str());
102110
pipe = CreateFileA(attempt_name.c_str(), GENERIC_WRITE,
103-
0, NULL, OPEN_EXISTING, 0, NULL);
111+
0, &sa, OPEN_EXISTING, 0, NULL);
104112
if (pipe != INVALID_HANDLE_VALUE) {
105113
printf("Success\n");
106114
break;

src/platform.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,25 @@ bool listen_on_pipe(const std::string &pipe_name,
182182
obs_log(LOG_INFO, "Creating pipe...");
183183
HANDLE pipe = INVALID_HANDLE_VALUE;
184184

185+
SECURITY_ATTRIBUTES sa;
186+
SECURITY_DESCRIPTOR sd;
187+
InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);
188+
SetSecurityDescriptorDacl(&sd, TRUE, NULL, FALSE);
189+
sa.nLength = sizeof(sa);
190+
sa.lpSecurityDescriptor = &sd;
191+
sa.bInheritHandle = FALSE;
192+
185193
while (pipe_number < 10) {
186194
attempt_name = base_name + std::to_string(pipe_number);
187195
pipe = CreateNamedPipeA(
188-
attempt_name.c_str(), PIPE_ACCESS_INBOUND,
189-
PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE |
190-
PIPE_WAIT | PIPE_REJECT_REMOTE_CLIENTS,
191-
1, 1024, 1024, 0, NULL);
196+
attempt_name.c_str(),
197+
PIPE_ACCESS_DUPLEX,
198+
PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
199+
PIPE_UNLIMITED_INSTANCES,
200+
512, 512,
201+
0,
202+
&sa
203+
);
192204
if (pipe != INVALID_HANDLE_VALUE) {
193205
break;
194206
}

0 commit comments

Comments
 (0)