Page Fault

Hi all,

Coding causing Page Fault :

DumbFunction ( “FileName”, hHandle );
KeSetEvent ( PtrWaitForDeviceIOCompletionEvent, IO_NO_INCREMENT, FALSE );

Page Fault is comming while calling KeSetEvent function.

******************************************************************************************************************************

  1. I have tried by commenting DumbFunction Page fault is not comming.

  2. Page fault code :

BOOLEAN DumbFunction ( IN PWCHAR pszFileName, IN HANDLE *phHandle )
{
UNICODE_STRING UnicodeFileName ;
try
{
RtlInitUnicodeString(&UnicodeFileName, pszFileName, TRUE);
if ( !UnicodeFileName.Buffer )
return ( FALSE );
return ( FALSE );
}
finally
{
}
}

Before calling this function EDI ( Register ) will contain address for KeSetEvent. After returning from this function EDI will contain 00000001. So page fault is causing.

Stack Dump :
00000001 8042C9F3

Here before returning from programm 00000001 is poping to EDI.
8042C9F3 is the address of KeSetEvet.

That mean 1 POP instruction is Missing.

  1. Following function is working fine.
    BOOLEAN DumbFunction ( IN PWCHAR pszFileName, IN HANDLE *phHandle )
    {
    UNICODE_STRING UnicodeFileName ;
    try
    {
    }
    finally
    {
    }
    }

  2. Following function is working fine.
    BOOLEAN DumbFunction ( IN PWCHAR pszFileName, IN HANDLE *phHandle )
    {
    RtlInitUnicodeString(&UnicodeFileName, pszFileName, TRUE);
    if ( !UnicodeFileName.Buffer )
    return ( FALSE );
    return ( FALSE );
    }

The Dis-Assemble part of DumbFunction ( Which is causing Page Fault ) :
PUSH EBP
MOV EBP,ESP
PUSH FF
PUSH ED259258
PUSH ntoskrnl!_except_handler3
MOV EAX, FS:[00000000]
PUSH EAX
MOV FS:[00000000],ESP
SUB ESP,10
PUSH EBX
PUSH ESI
PUSH EDI
AND DWORD PTR [EBP-04],00
PUSH 01
PUSH DWORD PTR [EBP+08]
LEA EAX,[EBP-20]
PUSH EAX
CALL [ntoskrnl!RtlinitUnicodeString]
CMP DWORD PTR [EBP-1C],00
PUSH FF
LEA EAX, [EBP-10]
PUSH EAX
CALL ntoskrnl!_local_unwind32
POP ECX
POP ECX
XOR AL,AL
MOV ECX,[EBP-10]
MOV FS:[00000000],ECX
POP EDI
POP ESI
POP EBX
LEAVE
RET 0008

Suggest me something to proceede further.

Thanks in advance,
Satish K.S


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

VOID
RtlInitUnicodeString(
IN OUT PUNICODE_STRING DestinationString,
IN PCWSTR SourceString
);
Stdcall taking 2 parameters , not 3. Pay attention to details and API declarations .

From: Satish
To: File Systems Developers
Sent: Friday, May 18, 2001 5:20 PM
Subject: [ntfsd] Page Fault

Hi all,

Coding causing Page Fault :

DumbFunction ( “FileName”, hHandle );
KeSetEvent ( PtrWaitForDeviceIOCompletionEvent, IO_NO_INCREMENT, FALSE );

Page Fault is comming while calling KeSetEvent function.

******************************************************************************************************************************

  1. I have tried by commenting DumbFunction Page fault is not comming.

  2. Page fault code :

BOOLEAN DumbFunction ( IN PWCHAR pszFileName, IN HANDLE *phHandle )
{
UNICODE_STRING UnicodeFileName ;
try
{
RtlInitUnicodeString(&UnicodeFileName, pszFileName, TRUE);
if ( !UnicodeFileName.Buffer )
return ( FALSE );
return ( FALSE );
}
finally
{
}
}

Before calling this function EDI ( Register ) will contain address for KeSetEvent. After returning from this function EDI will contain 00000001. So page fault is causing.

Stack Dump :
00000001 8042C9F3

Here before returning from programm 00000001 is poping to EDI.
8042C9F3 is the address of KeSetEvet.

That mean 1 POP instruction is Missing.

  1. Following function is working fine.
    BOOLEAN DumbFunction ( IN PWCHAR pszFileName, IN HANDLE *phHandle )
    {
    UNICODE_STRING UnicodeFileName ;
    try
    {
    }
    finally
    {
    }
    }

  2. Following function is working fine.
    BOOLEAN DumbFunction ( IN PWCHAR pszFileName, IN HANDLE *phHandle )
    {
    RtlInitUnicodeString(&UnicodeFileName, pszFileName, TRUE);
    if ( !UnicodeFileName.Buffer )
    return ( FALSE );
    return ( FALSE );
    }

The Dis-Assemble part of DumbFunction ( Which is causing Page Fault ) :
PUSH EBP
MOV EBP,ESP
PUSH FF
PUSH ED259258
PUSH ntoskrnl!_except_handler3
MOV EAX, FS:[00000000]
PUSH EAX
MOV FS:[00000000],ESP
SUB ESP,10
PUSH EBX
PUSH ESI
PUSH EDI
AND DWORD PTR [EBP-04],00
PUSH 01
PUSH DWORD PTR [EBP+08]
LEA EAX,[EBP-20]
PUSH EAX
CALL [ntoskrnl!RtlinitUnicodeString]
CMP DWORD PTR [EBP-1C],00
PUSH FF
LEA EAX, [EBP-10]
PUSH EAX
CALL ntoskrnl!_local_unwind32
POP ECX
POP ECX
XOR AL,AL
MOV ECX,[EBP-10]
MOV FS:[00000000],ECX
POP EDI
POP ESI
POP EBX
LEAVE
RET 0008

Suggest me something to proceede further.

Thanks in advance,
Satish K.S


You are currently subscribed to ntfsd as: danp@jb.rdsor.ro
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Satish, I’m really curious how you?have forced the compiler to allow you
call some __stdcall function with different number of arguments with no
error.
Don’t you do too, Dan ?
?
Paul

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Dan Partelly
Sent: Friday, May 18, 2001 6:07 PM
To: File Systems Developers
Subject: [ntfsd] Re: Page Fault

VOID

RtlInitUnicodeString(

IN OUT PUNICODE_STRING DestinationString,

IN PCWSTR SourceString

);

Stdcall taking 2 parameters , not 3. Pay attention to details and API
declarations .
?
From: Satish

To: File Systems Developers
Sent: Friday, May 18, 2001 5:20 PM
Subject: [ntfsd] Page Fault

Hi all,
?
Coding causing Page Fault :
?
DumbFunction ( “FileName”, hHandle );
KeSetEvent ( PtrWaitForDeviceIOCompletionEvent, IO_NO_INCREMENT, FALSE
);

Page Fault is comming while calling KeSetEvent function.
?
************************************************************************
******************************************************
?

  1. I have tried by commenting DumbFunction Page fault is not comming.
    ?
  2. Page fault code :
    ?
    BOOLEAN DumbFunction ( IN PWCHAR pszFileName,? IN HANDLE *phHandle )
    {
    ??? UNICODE_STRING UnicodeFileName ;
    ??? try
    ??? {
    ??? ??? RtlInitUnicodeString(&UnicodeFileName, pszFileName, TRUE);
    ??? ??? if ( !UnicodeFileName.Buffer )
    ??? ??? ??? return ( FALSE );
    ??? ??? return ( FALSE );
    ??? }
    ??? finally
    ??? {
    ??? }
    }

Before calling this function EDI ( Register ) will contain address for
KeSetEvent. After returning from this function EDI will contain

  1. So page fault is causing.
    ?
    Stack Dump :
    00000001??? 8042C9F3
    ?
    Here before returning from programm 00000001 is poping to EDI.
    8042C9F3 is the address of KeSetEvet.
    ?
    That mean 1 POP instruction is Missing.
    ?
  1. Following function is working fine.

BOOLEAN DumbFunction ( IN PWCHAR pszFileName,? IN HANDLE *phHandle )
{
??? UNICODE_STRING UnicodeFileName ;
??? try
??? {
??? }
??? finally
??? {
??? }
}

  1. Following function is working fine.

BOOLEAN DumbFunction ( IN PWCHAR pszFileName,? IN HANDLE *phHandle )
{
??? RtlInitUnicodeString(&UnicodeFileName, pszFileName, TRUE);
??? ??? if ( !UnicodeFileName.Buffer )
??? ??? ??? return ( FALSE );
??? ??? return ( FALSE );
}

?
The Dis-Assemble part of DumbFunction ( Which is causing Page Fault ) :
PUSH??? EBP
MOV??? ??? EBP,ESP
PUSH ??? FF
PUSH??? ED259258
PUSH??? ntoskrnl!_except_handler3
MOV??? EAX, FS:[00000000]
PUSH??? EAX
MOV??? FS:[00000000],ESP
SUB??? ESP,10
PUSH??? EBX
PUSH ??? ESI
PUSH??? EDI
AND??? DWORD PTR [EBP-04],00
PUSH??? 01
PUSH ??? DWORD PTR [EBP+08]
LEA??? EAX,[EBP-20]
PUSH??? EAX
CALL??? [ntoskrnl!RtlinitUnicodeString]
CMP??? DWORD PTR [EBP-1C],00
PUSH??? FF
LEA??? EAX, [EBP-10]
PUSH??? EAX
CALL??? ntoskrnl!_local_unwind32
POP??? ECX
POP??? ECX
XOR??? AL,AL
MOV??? ECX,[EBP-10]
MOV??? FS:[00000000],ECX
POP??? EDI
POP??? ESI
POP??? EBX
LEAVE
RET??? 0008
?
Suggest me something to proceede further.
?
Thanks in advance,
Satish K.S
?
?
?

You are currently subscribed to ntfsd as: danp@jb.rdsor.ro
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntfsd as: xxxxx@compelson.com
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Dan Partelly,

Thanks a lot. It solved my Problem.

Anyway Compiler is too lazy to identify Number of Parameters also :slight_smile:

Regards,
Satish K.S

----- Original Message -----
From: Dan Partelly
To: File Systems Developers
Sent: Friday, May 18, 2001 9:37 PM
Subject: [ntfsd] Re: Page Fault

VOID
RtlInitUnicodeString(
IN OUT PUNICODE_STRING DestinationString,
IN PCWSTR SourceString
);
Stdcall taking 2 parameters , not 3. Pay attention to details and API declarations .

From: Satish
To: File Systems Developers
Sent: Friday, May 18, 2001 5:20 PM
Subject: [ntfsd] Page Fault

Hi all,

Coding causing Page Fault :

DumbFunction ( “FileName”, hHandle );
KeSetEvent ( PtrWaitForDeviceIOCompletionEvent, IO_NO_INCREMENT, FALSE );

Page Fault is comming while calling KeSetEvent function.

******************************************************************************************************************************

  1. I have tried by commenting DumbFunction Page fault is not comming.

  2. Page fault code :

BOOLEAN DumbFunction ( IN PWCHAR pszFileName, IN HANDLE *phHandle )
{
UNICODE_STRING UnicodeFileName ;
try
{
RtlInitUnicodeString(&UnicodeFileName, pszFileName, TRUE);
if ( !UnicodeFileName.Buffer )
return ( FALSE );
return ( FALSE );
}
finally
{
}
}

Before calling this function EDI ( Register ) will contain address for KeSetEvent. After returning from this function EDI will contain 00000001. So page fault is causing.

Stack Dump :
00000001 8042C9F3

Here before returning from programm 00000001 is poping to EDI.
8042C9F3 is the address of KeSetEvet.

That mean 1 POP instruction is Missing.

  1. Following function is working fine.
    BOOLEAN DumbFunction ( IN PWCHAR pszFileName, IN HANDLE *phHandle )
    {
    UNICODE_STRING UnicodeFileName ;
    try
    {
    }
    finally
    {
    }
    }

  2. Following function is working fine.
    BOOLEAN DumbFunction ( IN PWCHAR pszFileName, IN HANDLE *phHandle )
    {
    RtlInitUnicodeString(&UnicodeFileName, pszFileName, TRUE);
    if ( !UnicodeFileName.Buffer )
    return ( FALSE );
    return ( FALSE );
    }

The Dis-Assemble part of DumbFunction ( Which is causing Page Fault ) :
PUSH EBP
MOV EBP,ESP
PUSH FF
PUSH ED259258
PUSH ntoskrnl!_except_handler3
MOV EAX, FS:[00000000]
PUSH EAX
MOV FS:[00000000],ESP
SUB ESP,10
PUSH EBX
PUSH ESI
PUSH EDI
AND DWORD PTR [EBP-04],00
PUSH 01
PUSH DWORD PTR [EBP+08]
LEA EAX,[EBP-20]
PUSH EAX
CALL [ntoskrnl!RtlinitUnicodeString]
CMP DWORD PTR [EBP-1C],00
PUSH FF
LEA EAX, [EBP-10]
PUSH EAX
CALL ntoskrnl!_local_unwind32
POP ECX
POP ECX
XOR AL,AL
MOV ECX,[EBP-10]
MOV FS:[00000000],ECX
POP EDI
POP ESI
POP EBX
LEAVE
RET 0008

Suggest me something to proceede further.

Thanks in advance,
Satish K.S


You are currently subscribed to ntfsd as: danp@jb.rdsor.ro
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

You are currently subscribed to ntfsd as: xxxxx@aalayance.com
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Hello Satish,
What compiler are you using? I wan’t to avoid it in the future.
Anders

Friday, May 18, 2001, 9:32:07 AM, you wrote:

S> Dan Partelly,

S> Thanks a lot. It solved my Problem.

S> Anyway Compiler is too lazy to identify Number of Parameters also :slight_smile:

S> Regards,
S> Satish K.S

S> ----- Original Message -----
S> From: Dan Partelly
S> To: File Systems Developers
S> Sent: Friday, May 18, 2001 9:37 PM
S> Subject: [ntfsd] Re: Page Fault

S> VOID
S> RtlInitUnicodeString(
S> IN OUT PUNICODE_STRING DestinationString,
S> IN PCWSTR SourceString
S> );
S> Stdcall taking 2 parameters , not 3. Pay attention to details and API declarations .

S> From: Satish
S> To: File Systems Developers
S> Sent: Friday, May 18, 2001 5:20 PM
S> Subject: [ntfsd] Page Fault

S> Hi all,

S> Coding causing Page Fault :

S> DumbFunction ( “FileName”, hHandle );
S> KeSetEvent ( PtrWaitForDeviceIOCompletionEvent, IO_NO_INCREMENT, FALSE );

S> Page Fault is comming while calling KeSetEvent function.

S> ******************************************************************************************************************************

S> 1) I have tried by commenting DumbFunction Page fault is not comming.

S> 2) Page fault code :

S> BOOLEAN DumbFunction ( IN PWCHAR pszFileName, IN HANDLE *phHandle )
S> {
S> UNICODE_STRING UnicodeFileName ;
S> try
S> {
S> RtlInitUnicodeString(&UnicodeFileName, pszFileName, TRUE);
S> if ( !UnicodeFileName.Buffer )
S> return ( FALSE );
S> return ( FALSE );
S> }
S> finally
S> {
S> }
S> }

S> Before calling this function EDI ( Register ) will contain address for KeSetEvent. After returning from this function EDI will contain 00000001. So page fault is causing.

S> Stack Dump :
S> 00000001 8042C9F3

S> Here before returning from programm 00000001 is poping to EDI.
S> 8042C9F3 is the address of KeSetEvet.

S> That mean 1 POP instruction is Missing.

S> 3) Following function is working fine.
S> BOOLEAN DumbFunction ( IN PWCHAR pszFileName, IN HANDLE *phHandle )
S> {
S> UNICODE_STRING UnicodeFileName ;
S> try
S> {
S> }
S> finally
S> {
S> }
S> }

S> 4) Following function is working fine.
S> BOOLEAN DumbFunction ( IN PWCHAR pszFileName, IN HANDLE *phHandle )
S> {
S> RtlInitUnicodeString(&UnicodeFileName, pszFileName, TRUE);
S> if ( !UnicodeFileName.Buffer )
S> return ( FALSE );
S> return ( FALSE );
S> }

S> The Dis-Assemble part of DumbFunction ( Which is causing Page Fault ) :
S> PUSH EBP
S> MOV EBP,ESP
S> PUSH FF
S> PUSH ED259258
S> PUSH ntoskrnl!_except_handler3
S> MOV EAX, FS:[00000000]
S> PUSH EAX
S> MOV FS:[00000000],ESP
S> SUB ESP,10
S> PUSH EBX
S> PUSH ESI
S> PUSH EDI
S> AND DWORD PTR [EBP-04],00
S> PUSH 01
S> PUSH DWORD PTR [EBP+08]
S> LEA EAX,[EBP-20]
S> PUSH EAX
S> CALL [ntoskrnl!RtlinitUnicodeString]
S> CMP DWORD PTR [EBP-1C],00
S> PUSH FF
S> LEA EAX, [EBP-10]
S> PUSH EAX
S> CALL ntoskrnl!_local_unwind32
S> POP ECX
S> POP ECX
S> XOR AL,AL
S> MOV ECX,[EBP-10]
S> MOV FS:[00000000],ECX
S> POP EDI
S> POP ESI
S> POP EBX
S> LEAVE
S> RET 0008

S> Suggest me something to proceede further.

S> Thanks in advance,
S> Satish K.S

S> —
S> You are currently subscribed to ntfsd as: danp@jb.rdsor.ro
S> To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com
S> —
S> You are currently subscribed to ntfsd as: xxxxx@aalayance.com
S> To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

S> —
S> You are currently subscribed to ntfsd as: xxxxx@flaffer.com
S> To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


Best regards,
Anders mailto:xxxxx@flaffer.com


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

> I was also suprised, tried it and now see what happened. Compiler produces

only warning, not error:

d:\filedisk\driver\logoff.c(214) : warning C4020: ‘RtlInitUnicodeString’ :
too many actual parameters

Unfortunately, build.exe is so smart that filters out this warning on the
screen and one can believe there is no problem. Instead, it creates
build.wrn file with this warning and it is also in the build.log file.
Linker doesn’t complain about it probably because the way kernel functions
are exported – with no info about number of parameters. I believed this
info is stored in DDK LIBs but it was probably too optimistic assumption
:frowning:

Moral: don’t trust build screen output and always check for build.wrn and
build.err files. I run build from my programmers editor via batch which
checks for these files so never seen this problem before. Also, -w4
compiler parameter can help. Or better, use a good lint utility. Since I
started using PC-lint (http://www.gimpel.com), my drivers rarely cause
BSOD because of sloppy mistake and it saved me from many reboots.

Best regards,

Michal Vodicka
Veridicom
(RKK - Skytale)
[WWW: http://www.veridicom.com , http://www.skytale.com]


From: Hrdina Pavel[SMTP:xxxxx@compelson.com]
Reply To: File Systems Developers
Sent: Friday, May 18, 2001 6:34 PM
To: File Systems Developers
Subject: [ntfsd] Re: Page Fault

Satish, I’m really curious how you have forced the compiler to allow you
call some __stdcall function with different number of arguments with no
error.
Don’t you do too, Dan ?

Paul

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Dan Partelly
Sent: Friday, May 18, 2001 6:07 PM
To: File Systems Developers
Subject: [ntfsd] Re: Page Fault

VOID
RtlInitUnicodeString(
IN OUT PUNICODE_STRING DestinationString,
IN PCWSTR SourceString
);

Stdcall taking 2 parameters , not 3. Pay attention to details and
API declarations .


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Well , the number of parameters for a stdcall is always present in the name
of the extern generated by the compiler in
the object file , due to stdcall decoration . For example ,
RtlInitUnicodeString() will become _RtlInitUnicodeString@8.
The problem is , that even when we pass more than 2 parameters , in this
case 3, the compiler will generate the correct decorated name , that’s it ,
@8 and not @12 , because it will use the function declaration. The linker
itself will find without problems the function in ntoskrnl.lib , by name
matching. And after all , a linker’s job is not to check
the validity of the generated code , that is compiler’s bussiness.

----- Original Message -----
From: “Vodicka, Michal”
To: “File Systems Developers”
Sent: Saturday, May 19, 2001 10:24 PM
Subject: [ntfsd] Re: Page Fault

> > I was also suprised, tried it and now see what happened. Compiler
produces
> > only warning, not error:
> >
> > d:\filedisk\driver\logoff.c(214) : warning C4020: ‘RtlInitUnicodeString’
:
> > too many actual parameters
> >
> > Unfortunately, build.exe is so smart that filters out this warning on
the
> > screen and one can believe there is no problem. Instead, it creates
> > build.wrn file with this warning and it is also in the build.log file.
> > Linker doesn’t complain about it probably because the way kernel
functions
> > are exported – with no info about number of parameters. I believed this
> > info is stored in DDK LIBs but it was probably too optimistic assumption
> > :frowning:
> >
> > Moral: don’t trust build screen output and always check for build.wrn
and
> > build.err files. I run build from my programmers editor via batch which
> > checks for these files so never seen this problem before. Also, -w4
> > compiler parameter can help. Or better, use a good lint utility. Since I
> > started using PC-lint (http://www.gimpel.com), my drivers rarely cause
> > BSOD because of sloppy mistake and it saved me from many reboots.
> >
> > Best regards,
> >
> > Michal Vodicka
> > Veridicom
> > (RKK - Skytale)
> > [WWW: http://www.veridicom.com , http://www.skytale.com]
> >
> >
> >
> > ----------
> > From: Hrdina Pavel[SMTP:xxxxx@compelson.com]
> > Reply To: File Systems Developers
> > Sent: Friday, May 18, 2001 6:34 PM
> > To: File Systems Developers
> > Subject: [ntfsd] Re: Page Fault
> >
> > Satish, I’m really curious how you have forced the compiler to allow you
> > call some __stdcall function with different number of arguments with no
> > error.
> > Don’t you do too, Dan ?
> >
> > Paul
> >
> > -----Original Message-----
> > From: xxxxx@lists.osr.com
> > [mailto:xxxxx@lists.osr.com]On Behalf Of Dan Partelly
> > Sent: Friday, May 18, 2001 6:07 PM
> > To: File Systems Developers
> > Subject: [ntfsd] Re: Page Fault
> >
> >
> >
> > VOID
> > RtlInitUnicodeString(
> > IN OUT PUNICODE_STRING DestinationString,
> > IN PCWSTR SourceString
> > );
> >
> > Stdcall taking 2 parameters , not 3. Pay attention to details and
> > API declarations .
> >
>
> —
> You are currently subscribed to ntfsd as: danp@jb.rdsor.ro
> To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

BUILD: Version 4.03.2134

Regards,
Satish K.S

----- Original Message -----
From: “Anders Fogh”
To: “File Systems Developers”
Sent: Saturday, May 19, 2001 10:13 AM
Subject: [ntfsd] Re: Page Fault

> Hello Satish,
> What compiler are you using? I wan’t to avoid it in the future.
> Anders
>
> Friday, May 18, 2001, 9:32:07 AM, you wrote:
>
> S> Dan Partelly,
>
> S> Thanks a lot. It solved my Problem.
>
> S> Anyway Compiler is too lazy to identify Number of Parameters also :slight_smile:
>
> S> Regards,
> S> Satish K.S
>
> S> ----- Original Message -----
> S> From: Dan Partelly
> S> To: File Systems Developers
> S> Sent: Friday, May 18, 2001 9:37 PM
> S> Subject: [ntfsd] Re: Page Fault
>
>
> S> VOID
> S> RtlInitUnicodeString(
> S> IN OUT PUNICODE_STRING DestinationString,
> S> IN PCWSTR SourceString
> S> );
> S> Stdcall taking 2 parameters , not 3. Pay attention to details and API
declarations .
>
> S> From: Satish
> S> To: File Systems Developers
> S> Sent: Friday, May 18, 2001 5:20 PM
> S> Subject: [ntfsd] Page Fault
>
>
> S> Hi all,
>
> S> Coding causing Page Fault :
>
> S> DumbFunction ( “FileName”, hHandle );
> S> KeSetEvent ( PtrWaitForDeviceIOCompletionEvent, IO_NO_INCREMENT,
FALSE );
>
> S> Page Fault is comming while calling KeSetEvent function.
>
> S>
**************************

>
> S> 1) I have tried by commenting DumbFunction Page fault is not
comming.
>
> S> 2) Page fault code :
>
> S> BOOLEAN DumbFunction ( IN PWCHAR pszFileName, IN HANDLE
*phHandle )
> S> {
> S> UNICODE_STRING UnicodeFileName ;
> S> try
> S> {
> S> RtlInitUnicodeString(&UnicodeFileName, pszFileName, TRUE);
> S> if ( !UnicodeFileName.Buffer )
> S> return ( FALSE );
> S> return ( FALSE );
> S> }
> S> finally
> S> {
> S> }
> S> }
>
> S> Before calling this function EDI ( Register ) will contain address
for KeSetEvent. After returning from this function EDI will contain
00000001. So page fault is causing.
>
> S> Stack Dump :
> S> 00000001 8042C9F3
>
> S> Here before returning from programm 00000001 is poping to EDI.
> S> 8042C9F3 is the address of KeSetEvet.
>
> S> That mean 1 POP instruction is Missing.
>
> S> 3) Following function is working fine.
> S> BOOLEAN DumbFunction ( IN PWCHAR pszFileName, IN HANDLE
*phHandle )
> S> {
> S> UNICODE_STRING UnicodeFileName ;
> S> try
> S> {
> S> }
> S> finally
> S> {
> S> }
> S> }
>
> S> 4) Following function is working fine.
> S> BOOLEAN DumbFunction ( IN PWCHAR pszFileName, IN HANDLE
*phHandle )
> S> {
> S> RtlInitUnicodeString(&UnicodeFileName, pszFileName, TRUE);
> S> if ( !UnicodeFileName.Buffer )
> S> return ( FALSE );
> S> return ( FALSE );
> S> }
>
>
> S> The Dis-Assemble part of DumbFunction ( Which is causing Page
Fault ) :
> S> PUSH EBP
> S> MOV EBP,ESP
> S> PUSH FF
> S> PUSH ED259258
> S> PUSH ntoskrnl!_except_handler3
> S> MOV EAX, FS:[00000000]
> S> PUSH EAX
> S> MOV FS:[00000000],ESP
> S> SUB ESP,10
> S> PUSH EBX
> S> PUSH ESI
> S> PUSH EDI
> S> AND DWORD PTR [EBP-04],00
> S> PUSH 01
> S> PUSH DWORD PTR [EBP+08]
> S> LEA EAX,[EBP-20]
> S> PUSH EAX
> S> CALL [ntoskrnl!RtlinitUnicodeString]
> S> CMP DWORD PTR [EBP-1C],00
> S> PUSH FF
> S> LEA EAX, [EBP-10]
> S> PUSH EAX
> S> CALL ntoskrnl!_local_unwind32
> S> POP ECX
> S> POP ECX
> S> XOR AL,AL
> S> MOV ECX,[EBP-10]
> S> MOV FS:[00000000],ECX
> S> POP EDI
> S> POP ESI
> S> POP EBX
> S> LEAVE
> S> RET 0008
>
> S> Suggest me something to proceede further.
>
> S> Thanks in advance,
> S> Satish K.S
>
>
>
> S> —
> S> You are currently subscribed to ntfsd as: danp@jb.rdsor.ro
> S> To unsubscribe send a blank email to
leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com
> S> —
> S> You are currently subscribed to ntfsd as: xxxxx@aalayance.com
> S> To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>
>
> S> —
> S> You are currently subscribed to ntfsd as: xxxxx@flaffer.com
> S> To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>
>
>
> –
> Best regards,
> Anders mailto:xxxxx@flaffer.com
>
>
>
> —
> You are currently subscribed to ntfsd as: xxxxx@aalayance.com
> To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

> > I was also suprised, tried it and now see what happened. Compiler
produces

> only warning, not error:

Another surprise :slight_smile:

Pass any number of arguments to any DDK functions or User defined functions
it will take by just giving warning.

I have tried following DDK function :

KeGetCurrentIrql ( 1, 0, 1 );
ObReferenceObjectByHandle ( ) Append any no of arguments.
RtlInitUnicodeString(&UnicodeFileName, pszFileName, TRUE, TRUE, TRUE, TRUE,
TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE );

But the output of this is only BSOD.

Any options like “Treat all warnings as error” ? so that we can avoid these
things.

I have wasted my whole day to track my Page Fault.

Regards,
Satish K.S


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

I didnt not force compiler, it has done(BSOD) by compiler without much headace :slight_smile:

Regards,
Satish K.S
----- Original Message -----
From: Hrdina Pavel
To: File Systems Developers
Sent: Friday, May 18, 2001 10:04 PM
Subject: [ntfsd] Re: Page Fault

Satish, I’m really curious how you have forced the compiler to allow you
call some __stdcall function with different number of arguments with no error.
Don’t you do too, Dan ?

Paul
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com]On Behalf Of Dan Partelly
Sent: Friday, May 18, 2001 6:07 PM
To: File Systems Developers
Subject: [ntfsd] Re: Page Fault

VOID
RtlInitUnicodeString(
IN OUT PUNICODE_STRING DestinationString,
IN PCWSTR SourceString
);
Stdcall taking 2 parameters , not 3. Pay attention to details and API declarations .

From: Satish
To: File Systems Developers
Sent: Friday, May 18, 2001 5:20 PM
Subject: [ntfsd] Page Fault

Hi all,

Coding causing Page Fault :

DumbFunction ( “FileName”, hHandle );
KeSetEvent ( PtrWaitForDeviceIOCompletionEvent, IO_NO_INCREMENT, FALSE );

Page Fault is comming while calling KeSetEvent function.

******************************************************************************************************************************

  1. I have tried by commenting DumbFunction Page fault is not comming.

  2. Page fault code :

BOOLEAN DumbFunction ( IN PWCHAR pszFileName, IN HANDLE *phHandle )
{
UNICODE_STRING UnicodeFileName ;
try
{
RtlInitUnicodeString(&UnicodeFileName, pszFileName, TRUE);
if ( !UnicodeFileName.Buffer )
return ( FALSE );
return ( FALSE );
}
finally
{
}
}

Before calling this function EDI ( Register ) will contain address for KeSetEvent. After returning from this function EDI will contain 00000001. So page fault is causing.

Stack Dump :
00000001 8042C9F3

Here before returning from programm 00000001 is poping to EDI.
8042C9F3 is the address of KeSetEvet.

That mean 1 POP instruction is Missing.

  1. Following function is working fine.
    BOOLEAN DumbFunction ( IN PWCHAR pszFileName, IN HANDLE *phHandle )
    {
    UNICODE_STRING UnicodeFileName ;
    try
    {
    }
    finally
    {
    }
    }

  2. Following function is working fine.
    BOOLEAN DumbFunction ( IN PWCHAR pszFileName, IN HANDLE *phHandle )
    {
    RtlInitUnicodeString(&UnicodeFileName, pszFileName, TRUE);
    if ( !UnicodeFileName.Buffer )
    return ( FALSE );
    return ( FALSE );
    }

The Dis-Assemble part of DumbFunction ( Which is causing Page Fault ) :
PUSH EBP
MOV EBP,ESP
PUSH FF
PUSH ED259258
PUSH ntoskrnl!_except_handler3
MOV EAX, FS:[00000000]
PUSH EAX
MOV FS:[00000000],ESP
SUB ESP,10
PUSH EBX
PUSH ESI
PUSH EDI
AND DWORD PTR [EBP-04],00
PUSH 01
PUSH DWORD PTR [EBP+08]
LEA EAX,[EBP-20]
PUSH EAX
CALL [ntoskrnl!RtlinitUnicodeString]
CMP DWORD PTR [EBP-1C],00
PUSH FF
LEA EAX, [EBP-10]
PUSH EAX
CALL ntoskrnl!_local_unwind32
POP ECX
POP ECX
XOR AL,AL
MOV ECX,[EBP-10]
MOV FS:[00000000],ECX
POP EDI
POP ESI
POP EBX
LEAVE
RET 0008

Suggest me something to proceede further.

Thanks in advance,
Satish K.S


You are currently subscribed to ntfsd as: danp@jb.rdsor.ro
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

You are currently subscribed to ntfsd as: xxxxx@compelson.com
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

You are currently subscribed to ntfsd as: xxxxx@aalayance.com
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

> The problem is , that even when we pass more than 2 parameters , in this

case 3, the compiler will generate the correct decorated name , that’s it
,

The thing is that, according to the C rules, wrong number of parameters is
not an error, but a warning.
Not so in C++.
__stdcall has nothing to do with this.

Max


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

I agree on that , of course , I was speaking about the issue that the linker
should keep track of number of params , and why the linker linked sucesfully
the objects …

Dan

----- Original Message -----
From: “Maxim S. Shatskih”
To: “File Systems Developers”
Sent: Sunday, May 20, 2001 1:01 PM
Subject: [ntfsd] Re: Page Fault

> > The problem is , that even when we pass more than 2 parameters , in this
> > case 3, the compiler will generate the correct decorated name , that’s
it
> ,
>
> The thing is that, according to the C rules, wrong number of parameters is
> not an error, but a warning.
> Not so in C++.
> __stdcall has nothing to do with this.
>
> Max
>
>
>
> —
> You are currently subscribed to ntfsd as: danp@jb.rdsor.ro
> To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

> Any options like “Treat all warnings as error” ? so that we can avoid these

things.

/WX


Kind regards, Dejan M. CEO Alfa Co. www.alfaunits.co.yu and www.register.co.yu
E-mail : xxxxx@ptt.yu, xxxxx@register.co.yu and xxxxx@alfaunits.co.yu
ICQ# : 56570367
Professional file&system related components and libraries for Win32 developers.
Alfa File Monitor - #1 file monitoring system for Win32 developers.
Alfa File Protector - #1 file protection and hiding system for Win32 developers.

Alfa Units - #1 file and system handling units for Delphi.


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Hello Dejan,
redirect the warning to an error:
#pragma warning( error : 4020 )

regards,
Anders
Sunday, May 20, 2001, 9:45:16 AM, you wrote:

> Any options like “Treat all warnings as error” ? so that we can avoid these
> things.

DM> /WX

DM> –
DM> Kind regards, Dejan M. CEO Alfa Co. www.alfaunits.co.yu and www.register.co.yu
DM> E-mail : xxxxx@ptt.yu, xxxxx@register.co.yu and xxxxx@alfaunits.co.yu
DM> ICQ# : 56570367
DM> Professional file&system related components and libraries for Win32 developers.
DM> Alfa File Monitor - #1 file monitoring system for Win32 developers.
DM> Alfa File Protector - #1 file protection and hiding system for Win32 developers.

DM> Alfa Units - #1 file and system handling units for Delphi.

DM> —
DM> You are currently subscribed to ntfsd as: xxxxx@flaffer.com
DM> To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


Best regards,
Anders mailto:xxxxx@flaffer.com


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Anders and Dejan,

Thanks

Regards,
Satish K.S

Hello Dejan,
redirect the warning to an error:
#pragma warning( error : 4020 )

regards,
Anders
Sunday, May 20, 2001, 9:45:16 AM, you wrote:

>> Any options like “Treat all warnings as error” ? so that we can avoid
these
>> things.

DM> /WX

DM> –
DM> Kind regards, Dejan M. CEO Alfa Co. www.alfaunits.co.yu and
www.register.co.yu
DM> E-mail : xxxxx@ptt.yu, xxxxx@register.co.yu and
xxxxx@alfaunits.co.yu
DM> ICQ# : 56570367
DM> Professional file&system related components and libraries for Win32
developers.
DM> Alfa File Monitor - #1 file monitoring system for Win32 developers.
DM> Alfa File Protector - #1 file protection and hiding system for Win32
developers.

DM> Alfa Units - #1 file and system handling units for Delphi.

DM> —
DM> You are currently subscribed to ntfsd as: xxxxx@flaffer.com
DM> To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


Best regards,
Anders mailto:xxxxx@flaffer.com


You are currently subscribed to ntfsd as: xxxxx@aalayance.com
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

> ----------

From: Satish[SMTP:xxxxx@aalayance.com]
Reply To: File Systems Developers
Sent: Sunday, May 20, 2001 9:19 AM
To: File Systems Developers
Subject: [ntfsd] Re: Page Fault

Any options like “Treat all warnings as error” ? so that we can avoid
these
things.

Never ignore any warning, they mean something is wrong and if something is
wrong in driver code you’re at risk of BSOD. BSOD causes at least one
unnecessary reboot and wastes development time. That’s why I use lint, it
produces much more warnings than VC compiler and is able to find subtle
problems in the code. To avoid build output filtering use recommended /WX
switch or always check for build.wrn (buildfre.wrn, buildchk.wrn) file.

Best regards,

Michal Vodicka
Veridicom
(RKK - Skytale)
[WWW: http://www.veridicom.com , http://www.skytale.com]


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

> ----------

From: Dan Partelly[SMTP:danp@jb.rdsor.ro]
Reply To: File Systems Developers
Sent: Sunday, May 20, 2001 2:20 AM
To: File Systems Developers
Subject: [ntfsd] Re: Page Fault

Well , the number of parameters for a stdcall is always present in the
name
of the extern generated by the compiler in
the object file , due to stdcall decoration . For example ,
RtlInitUnicodeString() will become _RtlInitUnicodeString@8.
The problem is , that even when we pass more than 2 parameters , in this
case 3, the compiler will generate the correct decorated name , that’s it
,
@8 and not @12 , because it will use the function declaration.

This is what lead me to think something is wrong with libs, I thought it
would generate @12 name. You’re probably right it uses function declaration
instead, proper name is generated and linker has no problem.

Best regards,

Michal Vodicka
Veridicom
(RKK - Skytale)
[WWW: http://www.veridicom.com , http://www.skytale.com]


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

> Never ignore any warning, they mean something is wrong and if something is

wrong in driver code you’re at risk of BSOD. BSOD causes at least one
unnecessary reboot and wastes development time. That’s why I use lint, it
produces much more warnings than VC compiler and is able to find subtle
problems in the code. To avoid build output filtering use recommended /WX
switch or always check for build.wrn (buildfre.wrn, buildchk.wrn) file.

Also, if you want to convert sources. to DSP/DSW check out SrcToDsp from
NuMega.
VC produces just enough warnings. Just set the /W4 option.


Kind regards, Dejan M. CEO Alfa Co. www.alfaunits.co.yu and www.register.co.yu

E-mail : xxxxx@ptt.yu, xxxxx@register.co.yu and xxxxx@alfaunits.co.yu
ICQ# : 56570367
Professional file&system related components and libraries for Win32
developers.
Alfa File Monitor - #1 file monitoring system for Win32 developers.
Alfa File Protector - #1 file protection and hiding system for Win32
developers.
Alfa Units - #1 file and system handling units for Delphi.


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

> > Well , the number of parameters for a stdcall is always present in the

> name
> of the extern generated by the compiler in
> the object file , due to stdcall decoration . For example ,
> RtlInitUnicodeString() will become _RtlInitUnicodeString@8.
> The problem is , that even when we pass more than 2 parameters , in this
> case 3, the compiler will generate the correct decorated name , that’s
it
> ,
> @8 and not @12 , because it will use the function declaration.
>
This is what lead me to think something is wrong with libs, I thought it
would generate @12 name. You’re probably right it uses function
declaration
instead, proper name is generated and linker has no problem.

Either compiler should give Error or Linker should not link. If both is not
preventing this situation means it is really Problem.

I dont know why compiler assumes as warning or linker is linking without
linking problem.

While writing ASM programm … what will happen if we miss one POP
Instsruction ?? Somewhere it will crash.

Somewhere it has to prevent this Problem ( Linker or Compiler ).

Regards,
Satish K.S


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

No way satish. If you write code in assembly , and you are stupid enough to
ruin the stack , then your fate is well deserved. The linker has nothing to
do with checking your code for beeing correct . C Compiler will not thorw
an error , but a warning , and as Max said , this behaviour is the correct
one, for a C compiler. And your code does not miss a pop instructrion , it
has a sumplementary push.

----- Original Message -----
From: “Satish”
To: “File Systems Developers”
Sent: Tuesday, May 22, 2001 8:26 AM
Subject: [ntfsd] Re: Page Fault

> > > Well , the number of parameters for a stdcall is always present in the
> > > name
> > > of the extern generated by the compiler in
> > > the object file , due to stdcall decoration . For example ,
> > > RtlInitUnicodeString() will become _RtlInitUnicodeString@8.
> > > The problem is , that even when we pass more than 2 parameters , in
this
> > > case 3, the compiler will generate the correct decorated name , that’s
> it
> > > ,
> > > @8 and not @12 , because it will use the function declaration.
> > >
> > This is what lead me to think something is wrong with libs, I thought it
> > would generate @12 name. You’re probably right it uses function
> declaration
> > instead, proper name is generated and linker has no problem.
> >
>
> Either compiler should give Error or Linker should not link. If both is
not
> preventing this situation means it is really Problem.
>
> I dont know why compiler assumes as warning or linker is linking without
> linking problem.
>
> While writing ASM programm … what will happen if we miss one POP
> Instsruction ?? Somewhere it will crash.
>
> Somewhere it has to prevent this Problem ( Linker or Compiler ).
>
> Regards,
> Satish K.S
>
>
>
>
>
>
> —
> You are currently subscribed to ntfsd as: danp@jb.rdsor.ro
> To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com