| 239 | } |
| 240 | |
| 241 | bool ValidateNamedPipeConnection(DWORD remote_pid) |
| 242 | { |
| 243 | wstring exePathSelf; |
| 244 | |
| 245 | if (!GetExePathFromProcessId(GetCurrentProcessId(), exePathSelf)) { |
| 246 | return false; |
| 247 | } |
| 248 | |
| 249 | if (!VerifyEmbeddedSignature(exePathSelf.c_str())) { |
| 250 | // if we aren't signed, then allow the other end to not be signed |
| 251 | return true; |
| 252 | } |
| 253 | |
| 254 | wstring cnSelf; |
| 255 | |
| 256 | if (GetCommonName(exePathSelf.c_str(), cnSelf) != 0) { |
| 257 | return false; |
| 258 | } |
| 259 | |
| 260 | if (cnSelf.length() < 1) { |
| 261 | return false; |
| 262 | } |
| 263 | |
| 264 | wstring exePathRemote; |
| 265 | |
| 266 | if (!GetExePathFromProcessId(remote_pid, exePathRemote)) { |
| 267 | return false; |
| 268 | } |
| 269 | |
| 270 | if (!VerifyEmbeddedSignature(exePathRemote.c_str())) { |
| 271 | return false; |
| 272 | } |
| 273 | |
| 274 | wstring cnRemote; |
| 275 | |
| 276 | if (GetCommonName(exePathRemote.c_str(), cnRemote) != 0) { |
| 277 | return false; |
| 278 | } |
| 279 | |
| 280 | return cnRemote == cnSelf; |
| 281 | } |
| 282 |
no test coverage detected