Page Fault

> 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.

I have given example ASM. I am not writing programm in assembly.

C programm will not throw only warning. What will happen if it throws an
error for Parameter mismatch. Is it good or bad ?

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.

This is equal to warning in C langauge for Parameter mismatch( That means
Stupid ) . It will only PUSH no POP. Why should it PUSH when nobody is there
to POP ?

If i pass less parameters. Why compiler is giving Error ?

Why not Warning ?

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

Lemme put it this way. Some assemblers are capable to tthrow such errors
when a function is called trough a CALL or Invoke like macro.

> Why should it PUSH when nobody is there to POP ?

A good assembler should generate exactly the code your write.It should not
make any assumptions of what you wanted to do. You write code at the
lowest possible level , so
you should know what you are doing. And there are situations when you on
purpose push something without pop-ing it , but you ensure stack cleanup
trough other means. not every push has to have a coresponding pop. I would
avoid any assembler which is stupid enough
to make assumptions about the code I write.

If it is good or bad to force the compiler to generate an error instead a
warning ? Is a question of taste , and personal style of programing. The way
in which you configure your work enviroment is totaly up to you.

This thread is aleready too long & kinda futile, so I will finish here.
Every tool have it’s own manual or documentation which should be read , and
the programer should be aware of the meaning of any error or warning
throwed. Id say , even before writing a single serious line of code , a
programmer should get used with his work enviroment , and the tools he uses.
Some ppl have a nice term for this situation: RTFM

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

> > No way satish. If you write code in assembly , and you are stupid enough
> to
> > ruin the stack , then your fate is well deserved.
>
> This is equal to warning in C langauge for Parameter mismatch( That means
> Stupid ) . It will only PUSH no POP. Why should it PUSH when nobody is
there
> to POP ?
>
> If i pass less parameters. Why compiler is giving Error ?
>
> Why not Warning ?
>
> 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

Ok guys, enough already… Ever heard of function overloading? The C compiler
will do an extra push and not do any pops because it doesn’t unload the
stack that way. It subtracts the correct amount fron the esp to accomplish
the same thing as a whole bunch of pop,pop,pop, ‘s’.

Offline with this dribble I say!
Dennis

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of danp
Sent: Tuesday, May 22, 2001 2:31 AM
To: File Systems Developers
Subject: [ntfsd] Re: Page Fault

Lemme put it this way. Some assemblers are capable to tthrow such errors
when a function is called trough a CALL or Invoke like macro.

> Why should it PUSH when nobody is there to POP ?

A good assembler should generate exactly the code your write.It should not
make any assumptions of what you wanted to do. You write code at the
lowest possible level , so
you should know what you are doing. And there are situations when you on
purpose push something without pop-ing it , but you ensure stack cleanup
trough other means. not every push has to have a coresponding pop. I would
avoid any assembler which is stupid enough
to make assumptions about the code I write.

If it is good or bad to force the compiler to generate an error instead a
warning ? Is a question of taste , and personal style of programing. The way
in which you configure your work enviroment is totaly up to you.

This thread is aleready too long & kinda futile, so I will finish here.
Every tool have it’s own manual or documentation which should be read , and
the programer should be aware of the meaning of any error or warning
throwed. Id say , even before writing a single serious line of code , a
programmer should get used with his work enviroment , and the tools he uses.
Some ppl have a nice term for this situation: RTFM

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

> > No way satish. If you write code in assembly , and you are stupid enough
> to
> > ruin the stack , then your fate is well deserved.
>
> This is equal to warning in C langauge for Parameter mismatch( That means
> Stupid ) . It will only PUSH no POP. Why should it PUSH when nobody is
there
> to POP ?
>
> If i pass less parameters. Why compiler is giving Error ?
>
> Why not Warning ?
>
> 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: xxxxx@caminosoft.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

Ok Guys Enoughhhhhhhhh :slight_smile:

// C Programm
BOOLEAN DumbFunction ( IN PWCHAR pszFileName, IN HANDLE *phHandle )
{
RtlInitUnicodeString(&UnicodeFileName, pszFileName, TRUE);
if ( !UnicodeFileName.Buffer )
return ( FALSE );
return ( FALSE );
}
// Dis-Assemble Part
BOOLEAN DumbFunction ( IN PWCHAR pszFileName, IN HANDLE *phHandle )
{

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

}

// Dis-assembly part. This is DDK Library Function
VOID RtlInitUnicodeString( IN OUT PUNICODE_STRING DestinationString, IN
PCWSTR SourceString )
{
PUSH EDI
MOV EDI,[ESP+0C]
MOV EDX,[ESP+08]
MOV DWORD PTR [EDX],00000000
MOV [EDX+04], EDI
OR EDI,EDI
JZ 80401B14
0R ECX,-01
XOR EAX,EAX
REPNZ SCASW
NOT ECX
SHL ECX,1
MOV [EDX+02],CX
DEC ECX
DEC ECX
MOV [EDX],CX
POP EDI
RET 0008
}

Here nobody is reducing Stack.

I am offiline now in this topic :slight_smile:

Regards,
Satish K.S

Ok guys, enough already… Ever heard of function overloading? The C
compiler
will do an extra push and not do any pops because it doesn’t unload the
stack that way. It subtracts the correct amount fron the esp to accomplish
the same thing as a whole bunch of pop,pop,pop, ‘s’.

Offline with this dribble I say!
Dennis


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

“RET 0008” reduces the stack. Look it up in the Intel Instruction Set
Reference. You can download it for free from Intel’s website.

-----Original Message-----
From: Satish [mailto:xxxxx@aalayance.com]
Sent: Wednesday, May 23, 2001 1:28 AM
To: File Systems Developers
Subject: [ntfsd] Re: Page Fault

Ok Guys Enoughhhhhhhhh :slight_smile:

// C Programm
BOOLEAN DumbFunction ( IN PWCHAR pszFileName, IN HANDLE *phHandle )
{
RtlInitUnicodeString(&UnicodeFileName, pszFileName, TRUE);
if ( !UnicodeFileName.Buffer )
return ( FALSE );
return ( FALSE );
}
// Dis-Assemble Part
BOOLEAN DumbFunction ( IN PWCHAR pszFileName, IN HANDLE *phHandle )
{

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

}

// Dis-assembly part. This is DDK Library Function
VOID RtlInitUnicodeString( IN OUT PUNICODE_STRING
DestinationString, IN
PCWSTR SourceString )
{
PUSH EDI
MOV EDI,[ESP+0C]
MOV EDX,[ESP+08]
MOV DWORD PTR [EDX],00000000
MOV [EDX+04], EDI
OR EDI,EDI
JZ 80401B14
0R ECX,-01
XOR EAX,EAX
REPNZ SCASW
NOT ECX
SHL ECX,1
MOV [EDX+02],CX
DEC ECX
DEC ECX
MOV [EDX],CX
POP EDI
RET 0008
}

Here nobody is reducing Stack.

I am offiline now in this topic :slight_smile:

Regards,
Satish K.S

> Ok guys, enough already… Ever heard of function overloading? The C
compiler
> will do an extra push and not do any pops because it
doesn’t unload the
> stack that way. It subtracts the correct amount fron the
esp to accomplish
> the same thing as a whole bunch of pop,pop,pop, ‘s’.
>
> Offline with this dribble I say!
> Dennis
>


You are currently subscribed to ntfsd as: xxxxx@nsisw.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

> “RET 0008” reduces the stack. Look it up in the Intel Instruction Set

Reference. You can download it for free from Intel’s website.

Thanks a lot man :slight_smile:

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

Hi all,

This topic has annoyed me greatly.
I remember K.S. wanted to rewrite the hole
NT native story to use it statically.
So do this for Rtl, Ke (whatever) and make sure they
incorporate another calling convention. Let the caller
adjust the stack after call. You would never see the problem.

Regards,
Alex


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