Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.
7744 Discussions

Can't call an assembly function from a .cpp file with all in the same project

realzaheerabbas
Beginner
343 Views

This is the scenario that I am working with. I have a 64 bit kernel mode driver project that I'm compiling and building in Visual Studio 2019 community with the target OS being windows 8.1 64 bit. This project contains an MyASM.asm file which in turn has a single assembly function defined (see below). The project compiles and builds successfully. So far so good. Now the problem that I'm having is when I try calling this single assembly function from main.cpp file the system crashes by freezing and locking up no BSOD. What can be causing this to happen ? Have I got the syntax correct for the .asm file am I missing anything ?

================================= MyASM.asm file ====================================
EXTERN DbgPrint:PROC

.data
    dbgString byte "ATest() routine has been CALLED!\n", 0

.code

main PROC

main ENDP

ATest PROC PUBLIC

    ;MOV RDX, Offset dbgString
    ;PUSH [RDX]
    ;CALL DbgPrint
    ;POP RDX        ;***check to see if DbgPrintEx cleans up the stack***
    ;RET

    SUB RSP, 40h
    MOV RCX, offset dbgString
    CALL DbgPrint
    ADD RSP, 40h
    RET

ATest ENDP

END

============================== main.cpp file ==============================
extern "C" void ATest(void);

NTSTATUS
DriverEntry(
    _In_ PDRIVER_OBJECT     DriverObject,
    _In_ PUNICODE_STRING    RegistryPath)
{
    // NTSTATUS variable to record success or failure
    NTSTATUS status = STATUS_SUCCESS;
    
    status = ByePgInitialize(SystemWideExceptionHandler, TRUE);
    if (!NT_SUCCESS(status)) return status;
    
    // Allocate the driver configuration object
    WDF_DRIVER_CONFIG config;

    // Print "Hello World" for DriverEntry
    //KdPrintEx((DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "KmdfHelloWorld: DriverEntry\n"));
    
    // Initialize the driver configuration object to register the entry point for the
    // EvtDeviceAdd callback, KmdfHelloWorldEvtDeviceAdd
    WDF_DRIVER_CONFIG_INIT(&config,
        KmdfHelloWorldEvtDeviceAdd
    );

    // Finally, create the driver object
    status = WdfDriverCreate(DriverObject,
        RegistryPath,
        WDF_NO_OBJECT_ATTRIBUTES,
        &config,
        WDF_NO_HANDLE
    );
    
    if (status != STATUS_SUCCESS)
        return STATUS_UNSUCCESSFUL;
    else
        ATest();
    
}

 

Labels (1)
0 Kudos
3 Replies
SantoshY_Intel
Moderator
317 Views

Hi,

 

Thank you for posting in Intel Communities.

 

Could you please provide us with the below details to investigate more on your issue?

  1. Complete sample reproducer code (include header section in code) or Complete Code as a Zip file if it is not confidential.
  2. Steps to reproduce your issue.
  3. The exact version of Visual Studio 2019.
  4. The version of the compiler you are using.

 

We can see that you are using Windows 8.1 which is not a supported target OS according to Intel® C++ Compiler Classic System Requirements & Intel® oneAPI DPC++/C++ Compiler System Requirements

 

We recommend you try again on any one of the supported Windows target OS.

SantoshY_Intel_0-1658128067199.png

 

 

Thanks & Regards,

Santosh

 

 

 

 

SantoshY_Intel
Moderator
289 Views

Hi,


We haven't heard back from you. Could you please provide an update on your issue? Also, please provide all the details that we requested in the above post.


Thanks & Regards,

Santosh


SantoshY_Intel
Moderator
241 Views

Hi,


We have not heard back from you. This thread will no longer be monitored by Intel. If you need further assistance, please post a new question.


Thanks & Regards,

Santosh


Reply