Worker Thread and GetOverlappedResult.....

Hi,
I use overlapped Io in my application to interact with my tdi filter driver.The Main thread in aplication opens the device with FILE_FLAG_OVERLAPPED,creates a worker thread which issues the DeviceIoControl Commands on behalf of application.
Now the Thread tries to use Overlapped Io In Device Io Control call.I see the request going from user mode to kernel mode and completing in driver in Windbg But In User mode the thread which is waiting using GetOverlappedResult Call does not get wake up ?It hangs forever.if i dont use overlapped things work fine.

Is there any problem like the thread which opened the device using CreateFile Can Only issue the overlapped Io Request ?Since the handle is within the same process i do not think this could be a problem, But one the same hand Irp has got a thread Filed in Tail.overlay which probably relates to the current thread am i right ?

Is the change of Thread is the problem ?
How can i overcome this problem ? By opening the device in the worker thread proc ?
Please throw some light on the issue …
any help is appreciated…

–Subodh

There are no such restrictions on which thread may issue overlapped I/O.
You are probably issuing the overlapped I/O incorrectly. What
completion mechanism are you using?

It sounds like you are using GetOverlappedResult in blocking mode (bWait
= TRUE). If so, then you are either providing an event handle in
OVERLAPPED.hEvent, or you are not. If you are not providing an event
handle, then GetOverlappedResult is trying to block on the file handle
– which is why it is blocking forever.

You need to do one of the following:

  1. Create an event object, and set OVERLAPPED.hEvent to the event’s
    handle, before calling DeviceIoControl. GetOverlappedResult should then
    behave as you expect.

Or, 2) Set OVERLAPPED.hEvent to the file handle before calling
DeviceIoControl. This allows you to use the file handle itself as a
dispatcher object, and it will be signaled with the DeviceIoControl
request succeeds. I do NOT suggest doing this, though – it is sloppy,
and you’ll cause problems for yourself when you try to issue more than
one overlapped operation at a time.

Or, 3) Use a different completion mechanism, e.g. I/O completion ports.

– arlie

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of subodh gupta
Sent: Tuesday, September 30, 2003 4:25 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Worker Thread and GetOverlappedResult…

Hi,
I use overlapped Io in my application to interact with my tdi filter
driver.The Main thread in aplication opens the device with
FILE_FLAG_OVERLAPPED,creates a worker thread which issues the
DeviceIoControl Commands on behalf of application.
Now the Thread tries to use Overlapped Io In Device Io Control call.I
see the request going from user mode to kernel mode and completing in
driver in Windbg But In User mode the thread which is waiting using
GetOverlappedResult Call does not get wake up ?It hangs forever.if i
dont use overlapped things work fine.

Is there any problem like the thread which opened the device using
CreateFile Can Only issue the overlapped Io Request ?Since the handle is
within the same process i do not think this could be a problem, But one
the same hand Irp has got a thread Filed in Tail.overlay which probably
relates to the current thread am i right ?

Is the change of Thread is the problem ?
How can i overcome this problem ? By opening the device in the worker
thread proc ?
Please throw some light on the issue …
any help is appreciated…

–Subodh

Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@sublinear.org
To unsubscribe send a blank email to xxxxx@lists.osr.com

MessageThanks arlie, Thanks a lot for sheding light on both the methods.For me Me simply specifying Overlapped = {0}; and Waiting on the file Handle works.Event method Still does not works:).
Regards…
Subodh
----- Original Message -----
From: Arlie Davis
To: Windows System Software Devs Interest List
Sent: Friday, October 03, 2003 7:46 PM
Subject: [ntdev] RE: Worker Thread and GetOverlappedResult…

There are no such restrictions on which thread may issue overlapped I/O. You are probably issuing the overlapped I/O incorrectly. What completion mechanism are you using?

It sounds like you are using GetOverlappedResult in blocking mode (bWait = TRUE). If so, then you are either providing an event handle in OVERLAPPED.hEvent, or you are not. If you are not providing an event handle, then GetOverlappedResult is trying to block on the file handle – which is why it is blocking forever.

You need to do one of the following:

  1. Create an event object, and set OVERLAPPED.hEvent to the event’s handle, before calling DeviceIoControl. GetOverlappedResult should then behave as you expect.

Or, 2) Set OVERLAPPED.hEvent to the file handle before calling DeviceIoControl. This allows you to use the file handle itself as a dispatcher object, and it will be signaled with the DeviceIoControl request succeeds. I do NOT suggest doing this, though – it is sloppy, and you’ll cause problems for yourself when you try to issue more than one overlapped operation at a time.

Or, 3) Use a different completion mechanism, e.g. I/O completion ports.

– arlie

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of subodh gupta
Sent: Tuesday, September 30, 2003 4:25 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Worker Thread and GetOverlappedResult…

Hi,
I use overlapped Io in my application to interact with my tdi filter driver.The Main thread in aplication opens the device with FILE_FLAG_OVERLAPPED,creates a worker thread which issues the DeviceIoControl Commands on behalf of application.
Now the Thread tries to use Overlapped Io In Device Io Control call.I see the request going from user mode to kernel mode and completing in driver in Windbg But In User mode the thread which is waiting using GetOverlappedResult Call does not get wake up ?It hangs forever.if i dont use overlapped things work fine.

Is there any problem like the thread which opened the device using CreateFile Can Only issue the overlapped Io Request ?Since the handle is within the same process i do not think this could be a problem, But one the same hand Irp has got a thread Filed in Tail.overlay which probably relates to the current thread am i right ?

Is the change of Thread is the problem ?
How can i overcome this problem ? By opening the device in the worker thread proc ?
Please throw some light on the issue …
any help is appreciated…

–Subodh

Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@sublinear.org
To unsubscribe send a blank email to xxxxx@lists.osr.com

Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@softhome.net
To unsubscribe send a blank email to xxxxx@lists.osr.com

Caveat:
Be careful when initializing structures with = {0}. Our group now
considers this a “bad” programming practice, because we got bitten by
come very obscure rules in the C spec. Here’s why:

Consider the following structure:
// #pragma pack(1) for this struct…
typedef struct _MY_STRUCT {
union { UCHAR a; } OneChar;
union { ULONG b; } OneUlong;
} MY_STRUCT, *PMY_STRUCT;

If you were to zero out the struct using the following line:
MY_STRUCT tmp = {0};

It would not behave as you may expect – only the first byte would be
set to zero! Why? Because by using the “{}” notation, you are filling
in the values within the struct, and C says that all non-specified items
get zero-filled. However, in the case of a union, the C compiler just
picks the first (undefined which is first?) union to fill to satisfy
this requirement.

Moral of the story: Always RtlZeroMemory() your structs, and remove the
“= {0};” constructs.

I hope this helps someone out there…
.

-----Original Message-----
From: subodh gupta [mailto:xxxxx@softhome.net]
Sent: Tuesday, September 30, 2003 8:27 PM
Subject: RE: Worker Thread and GetOverlappedResult…

Thanks arlie, Thanks a lot for sheding light on both the methods.For me
Me simply specifying Overlapped = {0}; and Waiting on the file Handle
works.Event method Still does not works:).
Regards…
Subodh

----- Original Message -----
From: Arlie Davis mailto:xxxxx
To: Windows System Software Devs Interest List
mailto:xxxxx
Sent: Friday, October 03, 2003 7:46 PM
Subject: [ntdev] RE: Worker Thread and GetOverlappedResult…

There are no such restrictions on which thread may issue
overlapped I/O. You are probably issuing the overlapped I/O
incorrectly. What completion mechanism are you using?

It sounds like you are using GetOverlappedResult in blocking
mode (bWait = TRUE). If so, then you are either providing an event
handle in OVERLAPPED.hEvent, or you are not. If you are not providing
an event handle, then GetOverlappedResult is trying to block on the file
handle – which is why it is blocking forever.

You need to do one of the following:

1) Create an event object, and set OVERLAPPED.hEvent to the
event’s handle, before calling DeviceIoControl. GetOverlappedResult
should then behave as you expect.

Or, 2) Set OVERLAPPED.hEvent to the file handle before calling
DeviceIoControl. This allows you to use the file handle itself as a
dispatcher object, and it will be signaled with the DeviceIoControl
request succeeds. I do NOT suggest doing this, though – it is sloppy,
and you’ll cause problems for yourself when you try to issue more than
one overlapped operation at a time.

Or, 3) Use a different completion mechanism, e.g. I/O completion
ports.

– arlie

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of subodh gupta
Sent: Tuesday, September 30, 2003 4:25 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Worker Thread and
GetOverlappedResult…

Hi,
I use overlapped Io in my application to interact with
my tdi filter driver.The Main thread in aplication opens the device with
FILE_FLAG_OVERLAPPED,creates a worker thread which issues the
DeviceIoControl Commands on behalf of application.
Now the Thread tries to use Overlapped Io In Device Io
Control call.I see the request going from user mode to kernel mode and
completing in driver in Windbg But In User mode the thread which is
waiting using GetOverlappedResult Call does not get wake up ?It hangs
forever.if i dont use overlapped things work fine.

Is there any problem like the thread which opened the
device using CreateFile Can Only issue the overlapped Io Request ?Since
the handle is within the same process i do not think this could be a
problem, But one the same hand Irp has got a thread Filed in
Tail.overlay which probably relates to the current thread am i right ?

Is the change of Thread is the problem ?
How can i overcome this problem ? By opening the device
in the worker thread proc ?
Please throw some light on the issue …
any help is appreciated…

–Subodh

Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as:
xxxxx@sublinear.org
To unsubscribe send a blank email to
xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as:
xxxxx@softhome.net
To unsubscribe send a blank email to
xxxxx@lists.osr.com</mailto:xxxxx></mailto:xxxxx>

Actually, the moral of the story is, know the language spec. Initializing
Union variables is an ANSI C innovation, so, use it the way the spec says it
should be used !

By the way, I can’t compile it as you wrote. So, I changed it to reflect
what I think you mean, apologies in advance if I misread you ! But this kind
of thing belongs in a constructor. If you use “.cpp” as your file extension,
you can do this:

struct s
{
union
{
char a;
long b;
};
s(long x) { b = x; }
};

Works beautifully, and cleanly too. You can even have another constructor
for the char:

struct s
{
union
{
char a;
long b;
};
s(long x) { b = x; }
s(char x) { a = x; /* TODO: whatever else you might want to do to munge
your char ! */ }
};

Or, you can use inheritance to get rid of that union altogether, and write
something like

struct s { };
struct l : public s { long b; l(long x) { b = x; } };
struct c : public s { char a; c(char x) { a = x; } };

So that you write “l my_l(92345)” for a long or “c my_c(‘a’)” for a char.

Alberto.

-----Original Message-----
From: Henry Gabryjelski [mailto:xxxxx@windows.microsoft.com]
Sent: Thursday, October 09, 2003 11:08 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] RE: Worker Thread and GetOverlappedResult…

Caveat:
Be careful when initializing structures with = {0}. Our group now
considers this a “bad” programming practice, because we got bitten by
come very obscure rules in the C spec. Here’s why:

Consider the following structure:
// #pragma pack(1) for this struct…
typedef struct _MY_STRUCT {
union { UCHAR a; } OneChar;
union { ULONG b; } OneUlong;
} MY_STRUCT, *PMY_STRUCT;

If you were to zero out the struct using the following line:
MY_STRUCT tmp = {0};

It would not behave as you may expect – only the first byte would be
set to zero! Why? Because by using the “{}” notation, you are filling
in the values within the struct, and C says that all non-specified items
get zero-filled. However, in the case of a union, the C compiler just
picks the first (undefined which is first?) union to fill to satisfy
this requirement.

Moral of the story: Always RtlZeroMemory() your structs, and remove the
“= {0};” constructs.

I hope this helps someone out there…
.

-----Original Message-----
From: subodh gupta [mailto:xxxxx@softhome.net]
Sent: Tuesday, September 30, 2003 8:27 PM
Subject: RE: Worker Thread and GetOverlappedResult…

Thanks arlie, Thanks a lot for sheding light on both the methods.For me
Me simply specifying Overlapped = {0}; and Waiting on the file Handle
works.Event method Still does not works:).
Regards…
Subodh

----- Original Message -----
From: Arlie Davis mailto:xxxxx
To: Windows System Software Devs Interest List
mailto:xxxxx
Sent: Friday, October 03, 2003 7:46 PM
Subject: [ntdev] RE: Worker Thread and GetOverlappedResult…

There are no such restrictions on which thread may issue
overlapped I/O. You are probably issuing the overlapped I/O
incorrectly. What completion mechanism are you using?

It sounds like you are using GetOverlappedResult in blocking
mode (bWait = TRUE). If so, then you are either providing an event
handle in OVERLAPPED.hEvent, or you are not. If you are not providing
an event handle, then GetOverlappedResult is trying to block on the file
handle – which is why it is blocking forever.

You need to do one of the following:

1) Create an event object, and set OVERLAPPED.hEvent to the
event’s handle, before calling DeviceIoControl. GetOverlappedResult
should then behave as you expect.

Or, 2) Set OVERLAPPED.hEvent to the file handle before calling
DeviceIoControl. This allows you to use the file handle itself as a
dispatcher object, and it will be signaled with the DeviceIoControl
request succeeds. I do NOT suggest doing this, though – it is sloppy,
and you’ll cause problems for yourself when you try to issue more than
one overlapped operation at a time.

Or, 3) Use a different completion mechanism, e.g. I/O completion
ports.

– arlie

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of subodh gupta
Sent: Tuesday, September 30, 2003 4:25 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Worker Thread and
GetOverlappedResult…

Hi,
I use overlapped Io in my application to interact with
my tdi filter driver.The Main thread in aplication opens the device with
FILE_FLAG_OVERLAPPED,creates a worker thread which issues the
DeviceIoControl Commands on behalf of application.
Now the Thread tries to use Overlapped Io In Device Io
Control call.I see the request going from user mode to kernel mode and
completing in driver in Windbg But In User mode the thread which is
waiting using GetOverlappedResult Call does not get wake up ?It hangs
forever.if i dont use overlapped things work fine.

Is there any problem like the thread which opened the
device using CreateFile Can Only issue the overlapped Io Request ?Since
the handle is within the same process i do not think this could be a
problem, But one the same hand Irp has got a thread Filed in
Tail.overlay which probably relates to the current thread am i right ?

Is the change of Thread is the problem ?
How can i overcome this problem ? By opening the device
in the worker thread proc ?
Please throw some light on the issue …
any help is appreciated…

–Subodh

Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as:
xxxxx@sublinear.org
To unsubscribe send a blank email to
xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as:
xxxxx@softhome.net
To unsubscribe send a blank email to
xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it.</mailto:xxxxx></mailto:xxxxx>

Not always true. For example, I just wrote this:

#pragma pack(push)
#pragma pack(1)

typedef struct _MY_STRUCT {
union { UCHAR a; } OneChar;
union { ULONG b; } OneUlong;
} MY_STRUCT, *PMY_STRUCT;

MY_STRUCT zits = {0};

#pragma pack(pop)

I put this into a user-space program and built it with the most recent
(build-3790) DDK. I got all 5 zeroes.

Now, since it’s possible that by chance the space in the structure had been
zeroes to begin with, I did the same with Visual Studio 6 and VC++ 6. There
I could observe the structure before allocation (I guess the IDE knows where
to look on the stack for the structure-to-be). All 5 bytes started by being
filled with 0xCC. Once allocation and initialization were done, all 5 had
0x0.

But I take your larger point, that the result of using {0} can be surprising
and is better avoided.

Henry Gabryjelski wrote:

Caveat:
Be careful when initializing structures with = {0}. Our group now
considers this a “bad” programming practice, because we got bitten by
come very obscure rules in the C spec.


If replying by e-mail, please remove “nospam.” from the address.

James Antognini
Windows DDK MVP

> union

{
char a;
long b;
};
s(long x) { b = x; }
};

Works beautifully, and cleanly too. You can even have another constructor

The number of dark and obscure C++ features connected to unions is tremendous.
Union is a low-level construct, and it is incompatible with OOP. So, C++
designers made lots of ugly patches to the language specs to solve this
incompatibility.

I would strongly suggest reading the language spec (the one from MSDN Library
can suite, since the particular compiler’s version is always better) before
adding any C++ stuff like constructors, base classes or virtual methods to
unions.

I can pick the book by Stroustrup/Ellis and list everything connected to unions
to this forum. From now, I only remember that the object which is a constructor
or destructor cannot be a union field.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

“Henry Gabryjelski” wrote in message
news:xxxxx@ntdev…
>
> Be careful when initializing structures with = {0}. Our group now
> considers this a “bad” programming practice, because we got bitten by
> come very obscure rules in the C spec. Here’s why:
>
> Consider the following structure:
> // #pragma pack(1) for this struct…
> typedef struct _MY_STRUCT {
> union { UCHAR a; } OneChar;
> union { ULONG b; } OneUlong;
> } MY_STRUCT, *PMY_STRUCT;
>
> If you were to zero out the struct using the following line:
> MY_STRUCT tmp = {0};
>
> It would not behave as you may expect – only the first byte would be
> set to zero! Why? Because by using the “{}” notation, you are filling
> in the values within the struct, and C says that all non-specified items
> get zero-filled. However, in the case of a union, the C compiler just
> picks the first (undefined which is first?) union to fill to satisfy
> this requirement.
>
> Moral of the story: Always RtlZeroMemory() your structs, and remove the
> “= {0};” constructs.

Hmmm … I’d say the moral of the story is to know the language you
are programming in. Are you sure your example is correct? If in
your example tmp.OneUlong.b is not initialized to 0, then you’ve
found a bug in the compiler.

If you meant your example to be something like

typedef struct {
union {
char a;
long b;
} OneUnion;
} MY_STRUCT;

MY_STRUCT tmp = {0};

then tmp.OneUnion.a will be initialized to zero. The value you get
by reading tmp.OneUnion.b is implementation defined - it should be
specified in the particular compiler’s documentation. This is the
normal situation when writing to one member of a union then reading
from another. Since the things in a union overlap the same space,
the compiler can obviously only sensibly initialize one of them.

‘first’ is very well defined - it has its obvious meaning!

> Always RtlZeroMemory() your structs

Fine unless your structs contain pointers or floating point numbers
and you care about being portable. I’d say use {0} and understand
the language!

This works fine in MSVC 6, and at this level the union is pretty inocuous. I
agree however that it’s a good idea to use inheritance instead of an union.

Alberto.

-----Original Message-----
From: Maxim S. Shatskih [mailto:xxxxx@storagecraft.com]
Sent: Thursday, October 09, 2003 4:56 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] RE: Worker Thread and GetOverlappedResult…

union
{
char a;
long b;
};
s(long x) { b = x; }
};

Works beautifully, and cleanly too. You can even have another constructor

The number of dark and obscure C++ features connected to unions is
tremendous.
Union is a low-level construct, and it is incompatible with OOP. So, C++
designers made lots of ugly patches to the language specs to solve this
incompatibility.

I would strongly suggest reading the language spec (the one from MSDN
Library
can suite, since the particular compiler’s version is always better) before
adding any C++ stuff like constructors, base classes or virtual methods to
unions.

I can pick the book by Stroustrup/Ellis and list everything connected to
unions
to this forum. From now, I only remember that the object which is a
constructor
or destructor cannot be a union field.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it.

Absolutely true. Code error on my part; put both UCHAR and ULONG into a
single union instead of the current two unions to see the issue. Also
see post by Alberto Moreira who noted my mistake. :slight_smile:

Corrected struct:

#pragma pack(push)
#pragma pack(1)
typedef struct _MY_STRUCT {
union { UCHAR a; ULONG b; } BadThingsToGoodPeople;
} MY_STRUCT, *PMY_STRUCT;
MY_STRUCT zits = {0};
#pragma pack(pop);

Sorry about that.
.

-----Original Message-----
From: James Antognini [mailto:xxxxx@mindspring.nospam.com]
Sent: Thursday, October 09, 2003 9:07 AM
Subject: Re: Worker Thread and GetOverlappedResult…

Not always true. For example, I just wrote this:

#pragma pack(push)
#pragma pack(1)

typedef struct _MY_STRUCT {
union { UCHAR a; } OneChar;
union { ULONG b; } OneUlong;
} MY_STRUCT, *PMY_STRUCT;

MY_STRUCT zits = {0};

#pragma pack(pop)

I put this into a user-space program and built it with the most recent
(build-3790) DDK. I got all 5 zeroes.

Now, since it’s possible that by chance the space in the structure had
been
zeroes to begin with, I did the same with Visual Studio 6 and VC++ 6.
There
I could observe the structure before allocation (I guess the IDE knows
where
to look on the stack for the structure-to-be). All 5 bytes started by
being
filled with 0xCC. Once allocation and initialization were done, all 5
had
0x0.

But I take your larger point, that the result of using {0} can be
surprising
and is better avoided.

Henry Gabryjelski wrote:

Caveat:
Be careful when initializing structures with = {0}. Our group now
considers this a “bad” programming practice, because we got bitten by
come very obscure rules in the C spec.


If replying by e-mail, please remove “nospam.” from the address.

James Antognini
Windows DDK MVP

Yeah,I just missed this possibile caveat but i also see all the members set
to 0 in my VC 6 IDE same as james.
Subodh
----- Original Message -----
From: “James Antognini”
Newsgroups: ntdev
To: “Windows System Software Devs Interest List”
Sent: Thursday, October 09, 2003 9:37 PM
Subject: [ntdev] Re: Worker Thread and GetOverlappedResult…

> Not always true. For example, I just wrote this:
>
> #pragma pack(push)
> #pragma pack(1)
>
> typedef struct _MY_STRUCT {
> union { UCHAR a; } OneChar;
> union { ULONG b; } OneUlong;
> } MY_STRUCT, *PMY_STRUCT;
>
> MY_STRUCT zits = {0};
>
> #pragma pack(pop)
>
> I put this into a user-space program and built it with the most recent
> (build-3790) DDK. I got all 5 zeroes.
>
> Now, since it’s possible that by chance the space in the structure had
been
> zeroes to begin with, I did the same with Visual Studio 6 and VC++ 6.
There
> I could observe the structure before allocation (I guess the IDE knows
where
> to look on the stack for the structure-to-be). All 5 bytes started by
being
> filled with 0xCC. Once allocation and initialization were done, all 5 had
> 0x0.
>
> But I take your larger point, that the result of using {0} can be
surprising
> and is better avoided.
>
> Henry Gabryjelski wrote:
>
> > Caveat:
> > Be careful when initializing structures with = {0}. Our group now
> > considers this a “bad” programming practice, because we got bitten by
> > come very obscure rules in the C spec.
>
> –
> If replying by e-mail, please remove “nospam.” from the address.
>
> James Antognini
> Windows DDK MVP
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@softhome.net
> To unsubscribe send a blank email to xxxxx@lists.osr.com