| 37 | using namespace std; |
| 38 | |
| 39 | const wchar_t* GetNamedPipeName(bool check_env) |
| 40 | { |
| 41 | static wstring pipe_name; |
| 42 | static once_flag once; |
| 43 | |
| 44 | call_once(once, [&]() { |
| 45 | wstring session_decoration; |
| 46 | if (check_env) { |
| 47 | wchar_t ses_env[128]; |
| 48 | size_t retlen = 0; |
| 49 | auto err = _wgetenv_s(&retlen, ses_env, L"CPPCRYPTFS_SESSIONID"); |
| 50 | if (err == 0 && retlen > 0) { |
| 51 | session_decoration = ses_env; |
| 52 | } |
| 53 | } |
| 54 | if (session_decoration.length() == 0) { |
| 55 | DWORD sessionid; |
| 56 | if (ProcessIdToSessionId(GetCurrentProcessId(), &sessionid)) { |
| 57 | session_decoration = to_wstring(sessionid); |
| 58 | } |
| 59 | } |
| 60 | pipe_name = CMD_NAMED_PIPE_BASE + wstring(L"_") + session_decoration; |
| 61 | }); |
| 62 | |
| 63 | return pipe_name.c_str(); |
| 64 | } |
no outgoing calls
no test coverage detected