CloseHandle with 0xffffffff parameter

Marco Bizzarri <m.bizzarri at icube.it> emmebi at icube.it
Wed Aug 1 07:02:47 CDT 2001


On Wed, 1 Aug 2001, Marcus Meissner wrote:

> On Wed, Aug 01, 2001 at 12:06:14PM +0200, Marco Bizzarri wrote:
> > Hi All.
> > 
> > While trying to make an application working under wine, I've stumped 
> > into the following trace fragment, obtained with --debugmsg +relay:
> > 
> > 
> > 
> > 081612c8:Call kernel32.CreateFileA(405f6454 
> > "c:\\rs\\project\\apitest\\vc\\32\\apitestvc60\\debug\\ret_dll.pdb",80000000,00000001,00000000,00000003,00000080,00000000) 
> > ret=404aa001
> > 081612c8:Ret  kernel32.CreateFileA() retval=ffffffff ret=404aa001
> > 081612c8:Call kernel32.CloseHandle(ffffffff) ret=404aa0bd
> > 081612c8:Ret  kernel32.CloseHandle() retval=00000000 ret=404aa0bd
> > 
> > As you can see, the program is trying to open a file, which is not 
> > found. An invalid handle (ffffffff) is returned. The program however 
> > closes the handle.
> > 
> > My question is: is this correct? Should the CloseHandle check to see if 
> > it is a correct handle?
> 
> Nope. Just bad checks in the debugger.
> 
> Ciao, Marcus
> 
> Changelog:
> 	Check for -1 as the undefined value for handles before CloseHandle.
> 
> Index: msc.c
> ===================================================================
> RCS file: /home/wine/wine/debugger/msc.c,v
> retrieving revision 1.41
> diff -u -r1.41 msc.c
> --- msc.c	2001/07/23 00:04:00	1.41
> +++ msc.c	2001/08/01 10:22:33
> @@ -119,8 +119,8 @@
>  static void	DEBUG_UnmapDebugInfoFile(HANDLE hFile, HANDLE hMap, void* addr)
>  {
>     if (addr) UnmapViewOfFile(addr);
> -   if (hMap) CloseHandle(hMap);
> -   if (hFile) CloseHandle(hFile);
> +   if (hMap!=INVALID_HANDLE_VALUE) CloseHandle(hMap);
> +   if (hFile!=INVALID_HANDLE_VALUE) CloseHandle(hFile);
>  }
>  
>  
> 

I don't want to appear dump, but shouldn't you check for hMap != 0 and
hFile != 0?

Indeed, after applying your patch, now I'm seeing some
CloseHandle(00000000)

Thanx
Marco

-- 
Marco Bizzarri - Responsabile Tecnico - Icube S.r.l.
Sede:   Via Ridolfi 15 - 56124 Pisa (PI), Italia 
E-mail: m.bizzarri at icube.it		WWW: www.icube.it	
Tel: 	(+39) 050 97 02 07		Fax: (+39) 050 31 36 588	





More information about the wine-patches mailing list