none
Error code 1 with IOCTL_MINIPORT_PROCESS_SERVICE_IRP RRS feed

  • Question

  • #include "stdafx.h"
    #include <windows.h>
    #include <tchar.h>
    #include <stdio.h>
    #include <devioctl.h>
    #include <ntddscsi.h>
    #include <viri_ioctl.h>

    #define BUFSIZE MAX_PATH

    void __cdecl _tmain(int argc, char *argv[])
    {
    TCHAR Path[BUFSIZE];
    HANDLE hFile;
    DWORD dwRet;

    hFile = CreateFile((LPCWSTR)argv[1],
    GENERIC_READ | GENERIC_WRITE,
    0,
    NULL,
    OPEN_EXISTING,
    FILE_FLAG_OVERLAPPED,
    NULL);



    if (hFile == INVALID_HANDLE_VALUE)
    {
    printf("Could not open file (error %d\n)", GetLastError());
    return;
    }

    dwRet = GetFinalPathNameByHandle(hFile, Path, BUFSIZE, VOLUME_NAME_NT);
    if (dwRet < BUFSIZE)
    {
    _tprintf(TEXT("\nThe final path is: %s\n"), Path);
    }
    else printf("\nThe required buffer size is %d.\n", dwRet);

    int a;

    LPVOID lpInBuffer = NULL;
    LPVOID lpOutBuffer = NULL;
    DWORD nInBufferSize = NULL;
    DWORD nOutBufferSize = NULL;
    LPDWORD lpBytesReturned = NULL;
    LPOVERLAPPED lpOverlapped = NULL;
    DWORD myVal;
    struct _COMMAND_IN * psCmd = 0x0000000000000000;
    psCmd->IoControlMajor = VIRI_IOCTL_GET_CURRENT_GW;


    a = DeviceIoControl(hFile, IOCTL_MINIPORT_PROCESS_SERVICE_IRP, lpInBuffer , sizeof(lpInBuffer ), lpOutBuffer, nOutBufferSize, lpBytesReturned, lpOverlapped);
    printf("\nIOCTL SENT? %d \n", a);
    DWORD dw = GetLastError();
    printf("\nIOCTL ERROR STATUS :  %d.\n", dw);

    CloseHandle(hFile);
    }

    I call the program on my PCI storage device

    myTest.exe \\.\PHYSICALDRIVE1 

    I get an error status 1.

    But I know for a fact that the driver does support IOCTL_MINIPORT_PROCESS_SERVICE_IRP as I ave seen it on windbg. 

    Does error code 1 mean that the ioctl is not supported or that I am passing the wrong parameters?

    Thursday, May 8, 2014 11:35 AM

Answers

  • Well the first question is did you write the virtual miniport that is controlling \\.\PHYSICALDRIVE1?  Since this IOCTL is for virtual miniports, and does not have to be supported, the failure you describe is the most likely outcome.  Also, your DeviceIoControl call should have lpBytesReturned or lpOverlapped as non-NULL it is an invalid call if they are both NULL (I have not tested what the error result would be).


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    Thursday, May 8, 2014 11:49 AM

All replies

  • #include "stdafx.h"
    #include <windows.h>
    #include <tchar.h>
    #include <stdio.h>
    #include <devioctl.h>
    #include <ntddscsi.h>
    #include <viri_ioctl.h>

    #define BUFSIZE MAX_PATH

    void __cdecl _tmain(int argc, char *argv[])
    {
    TCHAR Path[BUFSIZE];
    HANDLE hFile;
    DWORD dwRet;

    hFile = CreateFile((LPCWSTR)argv[1],
    GENERIC_READ | GENERIC_WRITE,
    0,
    NULL,
    OPEN_EXISTING,
    FILE_FLAG_OVERLAPPED,
    NULL);



    if (hFile == INVALID_HANDLE_VALUE)
    {
    printf("Could not open file (error %d\n)", GetLastError());
    return;
    }

    dwRet = GetFinalPathNameByHandle(hFile, Path, BUFSIZE, VOLUME_NAME_NT);
    if (dwRet < BUFSIZE)
    {
    _tprintf(TEXT("\nThe final path is: %s\n"), Path);
    }
    else printf("\nThe required buffer size is %d.\n", dwRet);

    int a;

    LPVOID lpInBuffer = NULL;
    LPVOID lpOutBuffer = NULL;
    DWORD nInBufferSize = NULL;
    DWORD nOutBufferSize = NULL;
    LPDWORD lpBytesReturned = NULL;
    LPOVERLAPPED lpOverlapped = NULL;
    DWORD myVal;
    struct _COMMAND_IN * psCmd = 0x0000000000000000;
    psCmd->IoControlMajor = VIRI_IOCTL_GET_CURRENT_GW;


    a = DeviceIoControl(hFile, IOCTL_MINIPORT_PROCESS_SERVICE_IRP, lpInBuffer , sizeof(lpInBuffer ), lpOutBuffer, nOutBufferSize, lpBytesReturned, lpOverlapped);
    printf("\nIOCTL SENT? %d \n", a);
    DWORD dw = GetLastError();
    printf("\nIOCTL ERROR STATUS :  %d.\n", dw);

    CloseHandle(hFile);
    }

    I call the program on my PCI storage device

    myTest.exe \\.\PHYSICALDRIVE1 

    I get an error status 1.

    But I know for a fact that the driver does support IOCTL_MINIPORT_PROCESS_SERVICE_IRP as I ave seen it on windbg. 

    Does error code 1 mean that the ioctl is not supported or that I am passing the wrong parameters?

    I also getFinalPathByName handle returns :

    The final path is: ?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????.?←☻

    Is \\.\PHYSICALDRIVE1 the right argument to pass to createFile?

    Thursday, May 8, 2014 11:39 AM
  • Well the first question is did you write the virtual miniport that is controlling \\.\PHYSICALDRIVE1?  Since this IOCTL is for virtual miniports, and does not have to be supported, the failure you describe is the most likely outcome.  Also, your DeviceIoControl call should have lpBytesReturned or lpOverlapped as non-NULL it is an invalid call if they are both NULL (I have not tested what the error result would be).


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    Thursday, May 8, 2014 11:49 AM