Re: Dealing with HANDLEs
- From: "m" <m@xxx>
- Date: Sat, 2 Dec 2006 11:25:27 -0500
<snip>
void GetPointerOfProcessFromList( CProcess* pProcess)
This worked in debug. But in release it didn't seem to return the
pointer correctly, and that's why it called OpenProcess on the object
again. When I changed the function to return the pointer it worked:
CProcess* GetPointerOfProcessFromList( CProcess* pProcess)
Strange, I thought if I pass a pointer, it's like by ref, I can change its
address and it changes the passed object, not a copy of it. Also, it
worked in debug. I know it's getting out of the scope of this thread...
but just wanted to mention what the issue was.
This can't work ever; and if it does, it it by coincidence. This is basic
language info but FYI:
When you pass a pointer (non const), you can modify whatever it pointed to
by that pointer but the value of the pointer is stored on the stack, just
like any other parameter, and so cannot be modified. if you want to modify
the value of a pointer (ie make it point to somthing else), then you must
pass a pointer to the pointer.
for example:
void func1(CProcess** ppProcess)
{
CProcess* pProcess = *ppProcess; // get the input value
// do stuff and assign to pProcess
// now set the output
*ppProcess = pProcess;
}
// sample call
func1(&pProcess);
.
- References:
- Dealing with HANDLEs
- From: Ben Menashe
- Re: Dealing with HANDLEs
- From: Arnaud Debaene
- Re: Dealing with HANDLEs
- From: Pavel Lebedinsky [MSFT]
- Re: Dealing with HANDLEs
- From: adebaene
- Re: Dealing with HANDLEs
- From: Jake Forson
- Re: Dealing with HANDLEs
- From: Le Chaud Lapin
- Re: Dealing with HANDLEs
- From: adebaene
- Re: Dealing with HANDLEs
- From: Le Chaud Lapin
- Re: Dealing with HANDLEs
- From: Ben Menashe
- Re: Dealing with HANDLEs
- From: Ben Menashe
- Dealing with HANDLEs
- Prev by Date: Re: How to get imagebase after a DLL gets loaded
- Next by Date: HyperThread CPU YIELD instruction
- Previous by thread: Re: Dealing with HANDLEs
- Next by thread: Re: Could I launch my thread by "CreateThread()" without "WaitForSingleObject()" ?
- Index(es):
Relevant Pages
|