MCPcopy Create free account
hub / github.com/bailey27/cppcryptfs / OnCopyData

Method OnCopyData

cppcryptfs/ui/CryptPropertySheet.cpp:267–353  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

265}
266
267BOOL CCryptPropertySheet::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct)
268{
269 // TODO: Add your message handler code here and/or call default
270
271 if (pCopyDataStruct &&
272 pCopyDataStruct->dwData == CPPCRYPTFS_COPYDATA_PIPE &&
273 pCopyDataStruct->cbData == sizeof(HANDLE)) {
274
275 auto hPipe = *reinterpret_cast<HANDLE*>(pCopyDataStruct->lpData);
276
277 DWORD client_process_id = 0;
278
279 if (!GetNamedPipeClientProcessId(hPipe, &client_process_id)) {
280 return FALSE;
281 }
282
283 bool denyOtherSessions = false;
284 CryptSettings::getInstance().GetSettingCurrent(DENY_OTHER_SESSIONS, denyOtherSessions);
285
286 bool denyServices = false;
287 CryptSettings::getInstance().GetSettingCurrent(DENY_SERVICES, denyServices);
288
289 if (denyOtherSessions || denyServices) {
290
291 DWORD theirSessionId;
292 if (!ProcessIdToSessionId(client_process_id, &theirSessionId)) {
293 CloseHandle(hPipe);
294 return FALSE;
295 }
296
297 if (theirSessionId == 0 && denyServices) {
298 CloseHandle(hPipe);
299 return FALSE;
300 }
301
302 if (denyOtherSessions && theirSessionId != 0) {
303 static DWORD mySessionId;
304 static once_flag once;
305 static bool got_my_sessionid = false;
306 call_once(once, [&]() {
307 if (ProcessIdToSessionId(GetCurrentProcessId(), &mySessionId)) {
308 got_my_sessionid = true;
309 }
310 });
311
312 if (!got_my_sessionid) {
313 CloseHandle(hPipe);
314 return FALSE;
315 }
316
317
318 if (theirSessionId != mySessionId) {
319 CloseHandle(hPipe);
320 return FALSE;
321 }
322 }
323 }
324

Callers

nothing calls this directly

Calls 6

ReadFromNamedPipeFunction · 0.85
ConsoleErrMesPipeFunction · 0.85
GetSettingCurrentMethod · 0.80
IsLockedMethod · 0.80
ProcessCommandLineMethod · 0.45

Tested by

no test coverage detected