This particular piece of code which i took from the
net is giving compiletime error. why
for (int i = 0; i MajorFunction) ++i)
DriverObject->MajorFunction[i] = DispatchAny;
Start your day with Yahoo! - Make it your home page!
http://www.yahoo.com/r/hs
This is a trick question, right?
There’s two bugs in it - you have two closing parentheses and no
comparison operator. Wouldn’t you want:
for (int i = 0; i < MajorFunction; ++i)
DriverObject->MajorFunction[i] = DispatchAny;
Instead?
Regards,
Tony
Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com
Looking forward to seeing you at the next OSR File Systems class in Los
Angeles, CA October 24-27, 2005.
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Eswari
Sent: Thursday, October 20, 2005 10:25 AM
To: ntdev redirect
Subject: [ntdev] Sorry for asking
This particular piece of code which i took from the
net is giving compiletime error. why
for (int i = 0; i MajorFunction) ++i)
DriverObject->MajorFunction[i] = DispatchAny;
Start your day with Yahoo! - Make it your home page!
http://www.yahoo.com/r/hs
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@osr.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
“Eswari” wrote in message news:xxxxx@ntdev…
> This particular piece of code which i took from the
> net is giving compiletime error. why
>
> for (int i = 0; i MajorFunction) ++i)
> DriverObject->MajorFunction[i] = DispatchAny;
>
If you are building a ‘C’ driver, then you can’t decalre “int i” inline
wherever you want to like you can in C++. Declare “int i” in ‘C’ style:
int i;
…
for ( i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
{
}
Thomas F. Divine, Windows DDK MVP
http://www.pcausa.com
I’ll jump in with one other point. After you have done this, hopefully you
are going back and filling in all the specific dispatch routines that you
really want to montitor (this is a filter driver, or else you probably
should not be doing this).
Some of the worst code in a driver, is when you create the “universal IRP
handler”, these just become a headache to maintain.
–
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Remove StopSpam from the email to reply
“Thomas F. Divine” wrote in message news:xxxxx@ntdev…
>
> “Eswari” wrote in message news:xxxxx@ntdev…
>> This particular piece of code which i took from the
>> net is giving compiletime error. why
>>
>> for (int i = 0; i MajorFunction) ++i)
>> DriverObject->MajorFunction[i] = DispatchAny;
>>
>
> If you are building a ‘C’ driver, then you can’t decalre “int i” inline
> wherever you want to like you can in C++. Declare “int i” in ‘C’ style:
>
> int i;
>
> …
>
>
> for ( i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
> {
> }
>
> Thomas F. Divine, Windows DDK MVP
> http://www.pcausa.com
>
>
>
Change
for (int i = 0; i MajorFunction) ++i)
to
for (int i = 0; i MajorFunction; ++i)
Rick…
Still won’t work. You cleaned up the parenthetical problem but bungled the
comparison operator between “i MajorFunction”.
–
The personal opinion of
Gary G. Little
wrote in message news:xxxxx@ntdev…
> Change
> for (int i = 0; i MajorFunction) ++i)
> to
> for (int i = 0; i MajorFunction; ++i)
>
> Rick…
>
>Still won’t work. You cleaned up the parenthetical problem but bungled the
comparison operator between “i MajorFunction”.
I know. I’d do well to not be in such a hurry in the future.
Actually, had I read ALL my email first, I would have seen other
answers and realized it wasn’t worth commenting on at all.
Rick…
Actually I like to do this:
{
int i;
for(…)
{
…
}
}
The extra braces allow defining the loop counter right there.
The other thing is, by the time you go through the trouble of
declaring i, I sometimes like to use a while loop better than a
for loop:
{
int i=0;
while (i < LoopLimit)
{
…
i++;
}
}
I like these “superlocal” variables that only live within a
block. Somehow I feel more in control! And I also find it
cleaner. In fact, I like to use extra braces in other
conditions, for example,
GRAB_THAT_MUTEX(myMutex);
{
… Critical section goes here…
}
RELEASE_THAT_MUTEX(myMutex);
Kind of makes clear what’s going on, and promotes clearly nested
code, which tends to avoid leaving mutexes or semaphores
dangling, or releasing them out of order.
Alberto.
----- Original Message -----
From: “Thomas F. Divine”
Newsgroups: ntdev
To: “Windows System Software Devs Interest List”
Sent: Thursday, October 20, 2005 10:38 AM
Subject: Re:[ntdev] Sorry for asking
>
> “Eswari” wrote in message
> news:xxxxx@ntdev…
>> This particular piece of code which i took from the
>> net is giving compiletime error. why
>>
>> for (int i = 0; i MajorFunction) ++i)
>> DriverObject->MajorFunction[i] = DispatchAny;
>>
>
> If you are building a ‘C’ driver, then you can’t decalre “int
> i” inline wherever you want to like you can in C++. Declare
> “int i” in ‘C’ style:
>
> int i;
>
> …
>
>
> for ( i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
> {
> }
>
> Thomas F. Divine, Windows DDK MVP
> http://www.pcausa.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@ieee.org
> To unsubscribe send a blank email to
> xxxxx@lists.osr.com
There is a book, often called K&R, written by messrs kernighan and richie
http://www.amazon.com/exec/obidos/tg/detail/-/0131103628/qid=1129880369/sr=8-1/ref=pd_bbs_1/002-5533888-8621615?v=glance&s=books&n=507846.
It is an old book but it is a good book. It will tell you about the c
language. It might be a good idea to have a read of this book and think
about what you read therein.
“Eswari” wrote in message news:xxxxx@ntdev…
> This particular piece of code which i took from the
> net is giving compiletime error. why
>
> for (int i = 0; i MajorFunction) ++i)
> DriverObject->MajorFunction[i] = DispatchAny;
>
>
>
>
> __________________________________
> Start your day with Yahoo! - Make it your home page!
> http://www.yahoo.com/r/hs
>