Skip to content

Instantly share code, notes, and snippets.

@rbmm
Created February 9, 2024 22:26
Show Gist options
  • Save rbmm/8ce74bf1fd661cb0355441c90b0b090a to your computer and use it in GitHub Desktop.
Save rbmm/8ce74bf1fd661cb0355441c90b0b090a to your computer and use it in GitHub Desktop.
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