DDK method of adding x64 assembly when writing 64-bit drivers

Source: Internet
Author: User

The previous article explained how to add the x64 assembly when writing x64 applications, and here is how to add x64 assembly when writing x64 drivers.

I. Writing function functions separately in ASM files

For example, to implement a 64-bit addition function, the prototype is as follows:

ULONG64 Myadd (ULONG64 u1,ulong64 U2);

Then the source directory (typically the directory where the sources file is located) creates a new folder named AMD64.

Then create a new file and write the following:

. Codemyadd PROC    add  rcx,rdx    mov  rax,rcx     ret  Myadd Endpend

Save it as myadd.asm and store it in the AMD64 folder you just created.

and add the following declaration in the source file that references it:

Extern_c ULONG64 Myadd (ULONG64 u1,ulong64 U2);

Ii. Modification of sources file

Add a row to the sources file:

Amd64_sources = Amd64\asm.asm   

After the original sources do not add this file, and then you can! It's simple enough to pass the test!

This newly added item only works when compiling the x64 driver and is automatically ignored when compiling the x86 driver, so that you do not need to modify any settings even if you switch the compilation environment.

Reference:

http://bbs.pediy.com/showthread.php?p=1185534



DDK method of adding x64 assembly when writing 64-bit drivers

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.