| 450 | |
| 451 | |
| 452 | DWORD |
| 453 | getppid(DWORD dwPid) |
| 454 | { |
| 455 | HANDLE hSnapshot; |
| 456 | PROCESSENTRY32 pe32; |
| 457 | DWORD ppid = 0, pid = dwPid; |
| 458 | |
| 459 | hSnapshot = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 ); |
| 460 | __try{ |
| 461 | if( hSnapshot == INVALID_HANDLE_VALUE ) __leave; |
| 462 | |
| 463 | ZeroMemory( &pe32, sizeof( pe32 ) ); |
| 464 | pe32.dwSize = sizeof( pe32 ); |
| 465 | if( !Process32First( hSnapshot, &pe32 ) ) __leave; |
| 466 | |
| 467 | do{ |
| 468 | if( pe32.th32ProcessID == pid ){ |
| 469 | ppid = pe32.th32ParentProcessID; |
| 470 | break; |
| 471 | } |
| 472 | }while( Process32Next( hSnapshot, &pe32 ) ); |
| 473 | |
| 474 | } |
| 475 | __finally{ |
| 476 | if( hSnapshot != INVALID_HANDLE_VALUE ) CloseHandle( hSnapshot ); |
| 477 | } |
| 478 | return ppid; |
| 479 | } |
| 480 | |
| 481 | |
| 482 | bool |
nothing calls this directly
no outgoing calls
no test coverage detected