[ros-kernel] Can someone give me a hand in here
Waldo Alvarez
wac at ghost.matcom.uh.cu
Fri Dec 19 13:09:46 CET 2003
On Thu, 18 Dec 2003, Skywing wrote:
> All of the x86 Windows calling conventions (that is,
> __cdecl/__fastcall/___stdcall/__thiscall variants) specify that the only
> nonvolatile registers are ecx, edx, and eax. Furthermore, eax [and possibly
> edx for 64-bit results] are used to return values in all x86 Windows calling
> conventions. So, the compiler will not save any other registers before
> calling your function. If you overwrite those registers without restoring
> their previous values before returning control, a variety of corruption
> problems can result.
Thanks for the info, I am not used to mix c and assembler, I used to do
this only in the turbo pascal days.
Waldo
>
> -----Original Message----- From: ros-kernel-bounces at reactos.com
> [mailto:ros-kernel-bounces at reactos.com] On Behalf Of Waldo Alvarez Sent:
> Thursday, December 18, 2003 11:25 AM To: ReactOS Kernel List Subject:
> RE: [ros-kernel] Can someone give me a hand in here
>
> On Wed, 17 Dec 2003, Skywing wrote:
>
> > You must never read past the terminating null, *especially* in kernel
> mode.
> > If the string is on a page boundary, that could cause a crash.
>
> Then I suppose I have to check for such a case, using an extra register or
> intentionally putting a 0 at page boundaries saving in the stack that
> final data, and walking through pages in such a way. There will be just a
> very ligth performance degradation.
>
> > The only registers that you don't need to save (on x86) are eax, ecx, and
> > edx.
>
> Yes I tested it saving ebx and still the same. Thanks for the info. But
> what's the reason? The compiler checks for it before the
> function is called everytime?
>
> > -----Original Message-----
> > From: ros-kernel-bounces at reactos.com
> [mailto:ros-kernel-bounces at reactos.com]
> > On Behalf Of Waldo Alvarez
> > Sent: Wednesday, December 17, 2003 1:21 PM
> > To: ReactOS Kernel List
> > Subject: [ros-kernel] Can someone give me a hand in here
> >
> > Hello:
> >
> > I was changing this file in ROS to speedup strlen but ReactOS
> > crashes with a page fault very quick since strlen is used almost
> > everywhere. But I'm not used to this kind of assembler format. Can someone
>
> > take a look at it. It could read at most 3 bytes beyond the ending 0 in
> > the string but i don't think it could be a problem since the page size is
> > 4 kb the other reason could be the ebx register I'm not saving. as opposed
>
> > to the previous function.
> >
> > Thanks in advance
> > Waldo Alvarez
> >
> >
> > _______________________________________________
> > Ros-kernel mailing list
> > Ros-kernel at reactos.com
> > http://reactos.com/mailman/listinfo/ros-kernel
> >
>
> _______________________________________________
> Ros-kernel mailing list
> Ros-kernel at reactos.com
> http://reactos.com/mailman/listinfo/ros-kernel
>
>
> _______________________________________________
> Ros-kernel mailing list
> Ros-kernel at reactos.com
> http://reactos.com/mailman/listinfo/ros-kernel
>
More information about the Ros-kernel
mailing list