SharedUserData
(1)
SystemCallStub
(1)
NtCreateFile
(1)
CreateFile
(1)
Breakpoint
(1)
B825000000
(1)
Ba0003fe7f
(1)
E385527f
(1)

why it is "move eax, 25 h" in the first line of NtCreateFile?

Asked By lostlander
19-Nov-07 03:17 AM
I set  a breakpoint at Ntdll!NtCreateFile when I open a file from
notepad, and it breaks, however, the instruction displayed is "mov
eax, 25h", i simply don't why, and shouldn't it be something like

ntdll!NtCreateFile:
7c90d682 b825000000      mov     eax,25h
7c90d687 ba0003fe7f      mov     edx,offset SharedUserData!
SystemCallStub (7ffe0300)
7c90d68c ff12            call    dword ptr [edx]
7c90d68e c22c00          ret     2Ch


Anybody can explain to me, thanks..

Hi lostlander!Why do you expect it to be "push eax"?

Asked By Jochen Kalmbach [MVP]
18-Nov-07 08:28 AM
Hi lostlander!

Why do you expect it to be "push eax"?
NtCreateFile is only called from within the OS; not directly from your
application.

Why do you bother?

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/

Hi lostlander!

Asked By Jochen Kalmbach [MVP]
18-Nov-07 08:30 AM
Hi lostlander!


by the way: eax is normally the return value of a function. So it is
safe to override this register, as long as it is set to the correct
value on return...

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/

why it is "move eax, 25 h" in the first line of NtCreateFile?

Asked By lostlander
22-Nov-07 02:52 AM
That's exactly what I want, thanks really!!!
why it is "move eax, 25 h" in the first line of NtCreateFile?
Asked By Christian Kaiser
19-Nov-07 09:45 AM
Explanation: when calling the "SystemCallStub", EAX is the "index" of
the function to be called. So CreateFile() is the function with the
index 0x25.

It could have (by internal convention) been "push eax", but that would
have modified the stack, and is a wee bit slower than putting the
index in a register. As Jochen told you, EAX can be modified freely
(as it is the result of a C function), as no C compiler will expect it
to be persistent during the API call, so it can be used to pass some
information to the stub.

Christian
Post Question To EggHeadCafe