Re: INVALID_HANDLE_VALUE vs. NULL
- From: "Doug G" <nospam@xxxxxxxxxxxxx>
- Date: Wed, 14 Jun 2006 04:14:34 GMT
"Gary Chanson" <gchanson@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:%23m4JX9KWFHA.2572@xxxxxxxxxxxxxxxxxxxxxxx
handle
"Frank A. Uepping" <trash@xxxxxxxxxxxxxxx> wrote in message
news:d654rh$q10$1@xxxxxxxxxxxxxxxxxxxxx
Hello,
there seems to be two representations for an invalid handle:
INVALID_HANDLE_VALUE and NULL.
Can somebody explain this discrepancy?
NULL is a valid value for a file handle (although there are a few
based functions which violate this). For file handles,INVALID_HANDLE_VALUE
= -1.
On the other hand, GDI and user handles can never be NULL and use this
value for invalid handles.
--
-GJC [MS Windows SDK MVP]
-Software Consultant (Embedded systems and Real Time Controls)
- http://www.mvps.org/ArcaneIncantations/consulting.htm
-gchanson@xxxxxxxx
I may be getting my operating systems mixed up, but I thought that almost
all virtual-memory operating systems set the page at address zero
(0x000...0) to be an invalid page so that a page fault is generated by any
type of access to that address. The reason for this is that making a
reference through a NULL pointer is one of the most common programming bugs,
and by making this page invalid it will cause a crash or other exception if
you make this mistake. I have worked on a few non-VM systems where zero was
a valid address, and that would cause all sorts of system problems when a
program with NULL in a structure pointer would trash the low memory area of
the system, wiping out interrupt vectors, boot code, or other important
stuff!
So assuming that a "handle" is used internally as a structure (object)
pointer, I would be very surprised to find that NULL (0) would be a valid
value.
.
- Follow-Ups:
- Re: INVALID_HANDLE_VALUE vs. NULL
- From: Vipin
- Re: INVALID_HANDLE_VALUE vs. NULL
- From: David J. Craig
- Re: INVALID_HANDLE_VALUE vs. NULL
- References:
- Re: INVALID_HANDLE_VALUE vs. NULL
- From: Gary Chanson
- Re: INVALID_HANDLE_VALUE vs. NULL
- Prev by Date: Re: INVALID_HANDLE_VALUE vs. NULL
- Next by Date: Problems reading disk partitions with IOCTL_DISK_GET_DRIVE_LAYOUT_
- Previous by thread: Re: INVALID_HANDLE_VALUE vs. NULL
- Next by thread: Re: INVALID_HANDLE_VALUE vs. NULL
- Index(es):
Relevant Pages
|