Created
February 9, 2024 22:26
-
-
Save rbmm/8ce74bf1fd661cb0355441c90b0b090a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BOOL IsParentExplorer() | |
{ | |
if (HWND hwnd = GetShellWindow()) | |
{ | |
ULONG dwProcessId; | |
if (GetWindowThreadProcessId(hwnd, &dwProcessId)) | |
{ | |
PROCESS_BASIC_INFORMATION pbi; | |
if (0 <= NtQueryInformationProcess(NtCurrentProcess(), ProcessBasicInformation, &pbi, sizeof(pbi), 0)) | |
{ | |
return pbi.InheritedFromUniqueProcessId == (HANDLE)(ULONG_PTR)dwProcessId; | |
} | |
} | |
} | |
return FALSE; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment