| 217 | } |
| 218 | |
| 219 | wil::unique_hfile OpenPipe() |
| 220 | { |
| 221 | std::wstring pipeName = LR"_(\\.\pipe\SubtitleFontAutoLoaderRpc-)_"; |
| 222 | pipeName += GetCurrentProcessUserSid(); |
| 223 | wil::unique_hfile pipe(CreateFileW( |
| 224 | pipeName.c_str(), |
| 225 | GENERIC_READ | GENERIC_WRITE, |
| 226 | 0, |
| 227 | nullptr, |
| 228 | OPEN_EXISTING, |
| 229 | 0, |
| 230 | nullptr)); |
| 231 | if (!pipe.is_valid()) |
| 232 | { |
| 233 | if (GetLastError() == ERROR_PIPE_BUSY) |
| 234 | { |
| 235 | // wait previous request finish |
| 236 | THROW_LAST_ERROR_IF(WaitNamedPipeW(pipeName.c_str(), NMPWAIT_USE_DEFAULT_WAIT) == FALSE); |
| 237 | pipe.reset(CreateFileW( |
| 238 | pipeName.c_str(), |
| 239 | GENERIC_READ | GENERIC_WRITE, |
| 240 | 0, |
| 241 | nullptr, |
| 242 | OPEN_EXISTING, |
| 243 | 0, |
| 244 | nullptr)); |
| 245 | } |
| 246 | THROW_LAST_ERROR_IF(!pipe.is_valid()); |
| 247 | } |
| 248 | |
| 249 | return pipe; |
| 250 | } |
| 251 | |
| 252 | void SendRequst(wil::unique_hfile& pipe, const FontQueryRequest& request) |
| 253 | { |
no test coverage detected