none
Custom IOCTL in Compact 2013 NDIS 6.0 miniport driver RRS feed

  • Question

  • The miniport driver requires a custom operation like configuring a specific register at the Ethernet controller. The access must be synchronized with the other operation of the miniport.

    How can I send a custom IOCTL to the miniport driver from a service or application in user mode?

    I have registered the OID code 0xFFA0C905 to SupportedOidList with the NdisMSetMiniportAttributes call. But a try to call DeviceIoControl with this value a dwCommand is rejected by NDIS.


    • Edited by Harper23 Wednesday, February 11, 2015 9:02 AM
    Wednesday, February 11, 2015 9:01 AM

All replies

  • Hi,

    Can you post the error code from NDIS. Set for OIDs other than the ones provided by Microsoft should be possible.

    Check the code once again and maybe try using a different OID code value.

    Regards,

    Balaji.

    Thursday, February 12, 2015 6:37 AM
  • > Can you post the error code from NDIS. Set for OIDs other than the ones provided by Microsoft should be possible.

    Can you elaborate this a bit more? How do I send an OID from a normal application? The error code was 0xC0000001.



    • Edited by Harper23 Thursday, February 12, 2015 11:42 AM
    Thursday, February 12, 2015 9:26 AM
  • Hi,

    You may base your code on this sample:

    Lets say you define a custom OID to be OID_NDIS_CUSTOM then,

    #define OID_NDIS_CUSTOM                 0xFF100001

    static BOOL IssueSetOid(HANDLE  hAdapter,
            TCHAR   *DevName,
            DWORD   OidCode,
            PUCHAR  pData,
            int     Length)
    {
        PNDISUIO_SET_OID Oid;
        DWORD            dwReturnedBytes;
        PUCHAR           buffer;
        unsigned int     len = sizeof(NDISUIO_SET_OID) + Length;
        BOOL             success;
    
        buffer = (PUCHAR) malloc(len);
    
        if (NULL == buffer) {
            return FALSE;
        }
    
        memset(buffer, 0, sizeof(NDISUIO_SET_OID));
        Oid = (NDISUIO_SET_OID *)buffer;
        Oid->Oid = OidCode;
        Oid->ptcDeviceName = DevName;
    
        if (Length > 0) {
            memcpy(Oid->Data,pData,Length);
        }
    
        // Pass the IOCTL to the device
        success = DeviceIoControl(hAdapter,
                IOCTL_NDISUIO_SET_OID_VALUE,
                buffer,
                len,
                NULL,
                0,
                &dwReturnedBytes,
                NULL);
    
        free(buffer);
    
        return success;
    }
    


    The above code can be used to push the OID request to the driver. Also, the SetInformationHandler in your miniport driver or MiniportOidRequest can handle your OID request for processing.

    Before you call the DeviceIoControl with  IOCTL_NDISUIO_SET_OID_VALUE do remember to do:

    hAdapter = CreateFile( NDISUIO_DEVICE_NAME, GENERIC_READ | GENERIC_WRITE,
                FILE_SHARE_READ | FILE_SHARE_WRITE,
                NULL, OPEN_EXISTING,
                FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
                INVALID_HANDLE_VALUE );

    The above code would give you a handle to NDISUIO. Use the adapter name to issue set requests to the driver.

    PS: Above was just a sample. Not all error handling / checks might be present.

    Hope this helps.

    Regards,

    Balaji.

    Thursday, February 12, 2015 9:51 AM