Re: Returning Properly from Assembly .lib

Tech-Archive recommends: Fix windows errors by optimizing your registry



Ahhhhh..... Thanks! If I understand correctly, and for example, my CPUID
routine should include a cmp, which results in either 1 or 0. In my driver
..c code I would write something like, "if(!mycpuid()) {blahblahblah;} else
{taaadaaaataaa;}.

"Skywing [MVP]" wrote:

As in you don't call subfunctions from within your assembly functions.

--
Ken Johnson (Skywing)
Windows SDK MVP
http://www.nynaeve.net
"hypervista@xxxxxxxxxxxxxxxxx"
<hypervistanewsgroupsnospam@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:26CF5778-4C3C-4B77-B5D3-4064B7F8CCDF@xxxxxxxxxxxxxxxx
Thank you Ivan. I searched leaf functions, but afraid I'm a bit lost in
this
regard. Can you give me a link to an example of a leaf function, or could
you outline a brief leaf function to get me started. Thanks again.

"Ivan Brugiolo [MSFT]" wrote:

It's likely to be a mismatched calling convention when you invoke
DbgPrint in you ASM file.
I would recomend to make the ASM functions `leaf` functions
(AKA: they do not call anything else), and, instead, calling your
DbgPrint
from a C code, where the compiler knows how to pop the params off the
stack.

--
--
This posting is provided "AS IS" with no warranties, and confers no
rights.
Use of any included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


"hypervista@xxxxxxxxxxxxxxxxx"
<hypervistanewsgroupsnospam@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:8B83D53F-07F7-48D6-9CCE-D6DA57B12439@xxxxxxxxxxxxxxxx
Hello - I think I need asistance in returning properly from my asm
code,
which I have linked into my driver via a .lib file.

For now, the .asm file simpy calls a CPUID function and returns.
Later, I
need to RDMSR and WRMSR, but thought I'd start out with the relatively
easy
CPUID portion of my project.
I've included a call to DbgPrint in my .asm code so I can see if things
are
going as planned. Immediately after my call to DbgPrint, I exit and
return.
During Windbg session, I see my DbgPrint message and then the driver
immediately crashes. Fyi, my driver name is hypervista. The error
immediately following my DbgPrint message is:

Access violation - code c0000005 (!!! second chance !!!)
hypervista!__security_cookie <PERF> (hypervista+0xa00):
f81aba00 0000 add [eax],al

The a portion of the verbose analysis is:

FAULTING_IP:
hypervista!__security_cookie <PERF> (hypervista+0xa00)+0
f81aba00 0000 add [eax],al

EXCEPTION_RECORD: ffffffff -- (.exr ffffffffffffffff)
ExceptionAddress: f81aba00 (hypervista!__security_cookie <PERF>
(hypervista+0xa00))
ExceptionCode: c0000005 (Access violation)
ExceptionFlags: 00000000
NumberParameters: 2
Parameter[0]: 00000001
Parameter[1]: 00000000
Attempt to write to address 00000000

ERROR_CODE: (NTSTATUS) 0xc0000005 - The instruction at "0x%08lx"
referenced
memory at "0x%08lx". The memory could not be "%s".

WRITE_ADDRESS: 00000000

I think I'm either not returning properly or not fixing up the
registers/memory, but not really sure.

Your help is greatly appreciated. Thanks.







.



Relevant Pages

  • Re: Returning Properly from Assembly .lib
    ... Can you give me a link to an example of a leaf function, ... >> DbgPrint in you ASM file. ... >>> which I have linked into my driver via a .lib file. ... the .asm file simpy calls a CPUID function and returns. ...
    (microsoft.public.development.device.drivers)
  • Re: Returning Properly from Assembly .lib
    ... DbgPrint in you ASM file. ... > which I have linked into my driver via a .lib file. ...
    (microsoft.public.development.device.drivers)
  • Re: Returning Properly from Assembly .lib
    ... It's likely to be a mismatched calling convention when you invoke ... DbgPrint in you ASM file. ... the .asm file simpy calls a CPUID function and returns. ... I see my DbgPrint message and then the driver ...
    (microsoft.public.development.device.drivers)
  • Re: Returning Properly from Assembly .lib
    ... Can you give me a link to an example of a leaf function, ... DbgPrint in you ASM file. ... the .asm file simpy calls a CPUID function and returns. ... I see my DbgPrint message and then the driver ...
    (microsoft.public.development.device.drivers)
  • Re: User-land Callback From Driver
    ... EPROCESS a structure that changes fairly often, ... Windows 2k/XP/2k3 Filesystem and Driver Consulting ... I use the EPROCESS of my application inside the driver callback to go into ... DbgPrint("Process Created.\n"); ...
    (microsoft.public.development.device.drivers)