Click here to Skip to main content
15,886,873 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionC++ memory freeing Pin
mike741116-Dec-23 3:04
mike741116-Dec-23 3:04 
AnswerRe: C++ memory freeing Pin
Richard MacCutchan16-Dec-23 3:21
mveRichard MacCutchan16-Dec-23 3:21 
AnswerRe: C++ memory freeing Pin
Mircea Neacsu16-Dec-23 3:21
Mircea Neacsu16-Dec-23 3:21 
GeneralRe: C++ memory freeing Pin
Daniel Pfeffer21-Dec-23 9:41
professionalDaniel Pfeffer21-Dec-23 9:41 
GeneralRe: C++ memory freeing Pin
Mircea Neacsu21-Dec-23 15:26
Mircea Neacsu21-Dec-23 15:26 
AnswerRe: C++ memory freeing Pin
jschell18-Dec-23 5:30
jschell18-Dec-23 5:30 
GeneralRe: C++ memory freeing Pin
k505418-Dec-23 6:14
mvek505418-Dec-23 6:14 
QuestionFinding the Parent Process Pin
Richard Andrew x6415-Dec-23 8:21
professionalRichard Andrew x6415-Dec-23 8:21 
I'm using NtQueryInformationProcess[^] to find the parent process of a specified process. I'm passing a PROCESS_BASIC_INFORMATION structure and using the InheritedFromUniqueProcessId member to get the parent.

I then call this function recursively with each parent process to find the parent of the parent, and so on.

The problem is that sometimes it starts returning process IDs that it has already returned in earlier calls, leading to infinite recursion.

For instance, in successive calls it will return process IDs 3, then 2, then 1. Then when called for process ID 1 it will return 3 again! How can this be?

I can easily work around this by checking to see if the returned parent process ID was already returned earlier in the call stack, and if it was, breaking out of the loop.

But my question is, why?



The difficult we do right away...
...the impossible takes slightly longer.

AnswerRe: Finding the Parent Process Pin
Gerry Schmitz15-Dec-23 8:32
mveGerry Schmitz15-Dec-23 8:32 
GeneralRe: Finding the Parent Process Pin
Richard Andrew x6415-Dec-23 8:47
professionalRichard Andrew x6415-Dec-23 8:47 
GeneralRe: Finding the Parent Process Pin
Gerry Schmitz15-Dec-23 12:36
mveGerry Schmitz15-Dec-23 12:36 
GeneralRe: Finding the Parent Process Pin
Richard Andrew x6415-Dec-23 12:41
professionalRichard Andrew x6415-Dec-23 12:41 
SuggestionRe: Finding the Parent Process Pin
David Crow15-Dec-23 10:53
David Crow15-Dec-23 10:53 
GeneralRe: Finding the Parent Process Pin
Richard Andrew x6415-Dec-23 11:00
professionalRichard Andrew x6415-Dec-23 11:00 
GeneralRe: Finding the Parent Process Pin
jschell18-Dec-23 5:43
jschell18-Dec-23 5:43 
AnswerRe: Finding the Parent Process Pin
jschell18-Dec-23 5:46
jschell18-Dec-23 5:46 
GeneralRe: Finding the Parent Process Pin
Richard Andrew x6418-Dec-23 6:23
professionalRichard Andrew x6418-Dec-23 6:23 
Questionlinker cannot find shared library... Pin
Salvatore Terress12-Dec-23 6:49
Salvatore Terress12-Dec-23 6:49 
AnswerRe: linker cannot find shared library... Pin
k505412-Dec-23 9:13
mvek505412-Dec-23 9:13 
GeneralRe: linker cannot find shared library... Pin
Salvatore Terress12-Dec-23 17:32
Salvatore Terress12-Dec-23 17:32 
GeneralRe: linker cannot find shared library... Pin
Richard MacCutchan12-Dec-23 22:03
mveRichard MacCutchan12-Dec-23 22:03 
GeneralRe: linker cannot find shared library... Pin
k505413-Dec-23 5:32
mvek505413-Dec-23 5:32 
GeneralRe: linker cannot find shared library... Pin
Richard MacCutchan13-Dec-23 5:58
mveRichard MacCutchan13-Dec-23 5:58 
AnswerRe: linker cannot find shared library... Pin
jschell13-Dec-23 3:47
jschell13-Dec-23 3:47 
GeneralRe: linker cannot find shared library... Pin
Richard MacCutchan13-Dec-23 3:51
mveRichard MacCutchan13-Dec-23 3:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.