RE: [GD-Windows] Finding routine that's crashing
Brought to you by:
vexxed72
From: Brian S. <bs...@mi...> - 2002-08-14 16:09:21
|
My MSDN (July 2001, guess I need to update) says: The process handle passed to SymInitialize can be=20 any unique value, except in the case=20 when fInvadeProcess is TRUE.=20 This is why you might see sample code from John Robbins that just uses "(HANDLE)1" as the first argument; if he's setting fInvadeProcess to false, it doesn't really matter what value he uses. It also says: hProcess=20 [in] Handle to the process for which symbols are=20 to be maintained. If the application is a debugger,=20 use the process handle for the object being debugged,=20 otherwise use the GetCurrentProcess function=20 to obtain the process handle.=20 Windows 95/98/Me: Use the process identifier, not=20 the process handle.=20 That last bit is key. On 2000 and XP, you can use GetCurrentProcess() to get a pseudo-handle to the process or you can call OpenProcess(...as below...) to get a real handle to it. Both should work AFAIK. On 95/98/Me, you would instead use (HANDLE)GetCurrentProcessId(). This doesn't mean that the process ID is a substitute for the process handle, this is just a quirk of dbghelp (again AFAIK). (and Windows Me is a 9x variant, Colin accidentally lumped it in with 2k and XP) I sent Colin some code that handles all these variations, but I unfortunately only have it on at home - on my Macintosh :). Feel free to ping him for a copy, or I can post it to the list later if it would be helpful... --brian > -----Original Message----- > From: Timur Davidenko [mailto:ti...@cr...]=20 > Sent: Wednesday, August 14, 2002 1:26 AM > To: Gam...@li... > Subject: RE: [GD-Windows] Finding routine that's crashing >=20 >=20 > Actually mine MSDN (VS.Net) says: >=20 > -------------------------------------------------------------- > ------------ > SymInitialize > BOOL SymInitialize( > HANDLE hProcess, =20 > PSTR UserSearchPath, =20 > BOOL fInvadeProcess =20 > ); >=20 > hProcess=20 > [in] Handle to the process for which symbols are to be=20 > maintained. If the application is a debugger, use the process=20 > handle for the object being debugged, otherwise use the=20 > GetCurrentProcess function to obtain the process handle.=20 > -------------------------------------------------------------- > ------------ >=20 > and i use GetCurrentProcess() and everything works... > so i dont sure why you use this GetCurrentProcessId() and it=20 > works, may be on win2k processId will be equal to process handle. >=20 > _________________ > Timur Davidenko. > Crytek Studios (www.crytek.com) >=20 > > -----Original Message----- > > From: Colin Fahey [mailto:cp...@ea...] > > Sent: Thursday, August 08, 2002 3:32 AM > > To: Colin Fahey; Gam...@li... > > Subject: Re: [GD-Windows] Finding routine that's crashing > >=20 > >=20 > >=20 > > 2002 August 7th > > Wednesday > >=20 > >=20 > > In the e-mail I posted three seconds ago, I wrote: > > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= > >=20 > > [5] It is absolutely critical to use the proper HANDLE to > > indicate the process in all of the symbol handler functions. > > You must determine your platform, and then: > >=20 > > [a] Under Windows 98, use the following HANDLE: > >=20 > > ::OpenProcess(PROCESS_ALL_ACCESS, FALSE,=20 > > ::GetCurrentProcessId()); > >=20 > > [b] Under Windows 2000, Windows XP, Windows Me, use the=20 > > following HANDLE: > >=20 > > (HANDLE)GetCurrentProcessId() > >=20 > > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= > >=20 > > But I mixed up [a] and [b]! The HANDLE's should be swapped! > >=20 > > Yes...It is "absolutely critical" to use the proper handle... ;-) > >=20 > > So much for my "public service" effort! > >=20 > > --- Colin |