netvmini, DeviceIoControl with buffers (success), BytesReturned always zero ?

Discussion in 'Windows XP Drivers' started by Skybuck Flying, Aug 7, 2009.

  1. Hello,

    I installed two Microsoft Virtual Network Adapters (netvmini.sys).(WinXP x64
    Pro)

    In the user code below (translated from C example to Delphi)
    one of the adapters is opened, and DeviceIoControl with buffers is
    attempted.

    However DeviceIoControl always returns with success and BytesReturned zero
    ?!?

    I test by opening a game that sends network traffic over the virtual network
    adapters.
    The status window shows packets are being sent.

    Why are these packets not returned in the DeviceIoControl buffers ?

    Below is the c-to-delphi translated "user" code:
    (all functions execute "successfull")

    // *** begin of test program ***

    program TestProgram;

    {$APPTYPE CONSOLE}

    uses
    SysUtils,
    Windows;

    const
    IOCTL_NETVMINI_READ_DATA = 2244608;
    IOCTL_NETVMINI_WRITE_DATA = 2260996;

    procedure Main;
    var
    vHandle : Thandle;
    vBytesReturned : longword;

    vInputBuffer : packed array[0..66000] of byte;
    vOutputBuffer : packed array[0..66000] of byte;

    begin
    writeln('program started');

    vHandle :=
    CreateFile
    (
    '\\.\NETVMINI',
    GENERIC_READ or GENERIC_WRITE,//FILE_READ_ATTRIBUTES | SYNCHRONIZE,
    FILE_SHARE_READ,
    nil, // no SECURITY_ATTRIBUTES structure
    OPEN_EXISTING, // No special create flags
    FILE_ATTRIBUTE_NORMAL, // No special attributes
    longword(nil)
    );

    if vHandle <> INVALID_HANDLE_VALUE then
    begin
    writeln('open netvmini successfull.');

    // send ioclt requests

    // begin of while-experiment-test
    while true do
    begin

    // doesn't seem to work, always returns 0 bytes returned ?!

    // read request
    if DeviceIoControl
    (
    vHandle,
    IOCTL_NETVMINI_READ_DATA,
    @vInputBuffer[0], 66000,
    @vOutputBuffer[0], 66000,
    vBytesReturned, nil
    ) then
    begin
    writeln('read IOCTL to netvmini successfull.');
    writeln('vBytesReturned: ', vBytesReturned );

    if vBytesReturned <> 0 then
    begin
    writeln('bingo');
    readln;
    end;
    end else
    begin
    writeln('read IOCTL to netvmini failed.');
    end;

    // write request
    if DeviceIoControl
    (
    vHandle,
    IOCTL_NETVMINI_WRITE_DATA,
    @vInputBuffer[0], 66000,
    @vOutputBuffer[0], 66000,
    vBytesReturned, nil
    ) then
    begin
    writeln('write IOCTL to netvmini successfull.');
    writeln('vBytesReturned: ', vBytesReturned );

    if vBytesReturned <> 0 then
    begin
    writeln('bingo');
    readln;
    end;
    end else
    begin
    writeln('write IOCTL to netvmini failed.');
    end;

    // end of while-experiment-test
    end;

    if CloseHandle( vHandle ) then
    begin
    writeln('close netvmini successfull.');
    end else
    begin
    writeln('close netvmini failed.');
    end;

    end else
    begin
    writeln('open netvmini failed.');
    end;

    writeln('program finished');
    end;


    begin
    try
    Main;
    except
    on E:Exception do
    Writeln(E.Classname, ': ', E.Message);
    end;
    ReadLn;
    end.

    // *** end of test program ***

    Bye,
    Skybuck.
     
    Skybuck Flying, Aug 7, 2009
    #1
    1. Advertisements

  2. Example converted to C.

    Still don't work... let me know if it works on your computer ;)

    // *** start of test program ***

    // TestProgram.cpp : Defines the entry point for the console application.
    //

    #include "stdafx.h"

    //#define UNICODE 1
    //#define INITGUID
    //#pragma warning(disable:4201) // nameless struct/union warning
    #include <windows.h>
    //#include <stdlib.h>
    //#include <string.h>
    //#include <setupapi.h>
    //#include <dbt.h>
    //#include <winioctl.h>

    /*

    Delphi version 0.01 and 0.02 created on 7 august 2009 by Skybuck Flying.
    Delphi-To-C version 0.02 created on 8 august 2009 by Skybuck Flying.

    */

    void Main()
    {
    int IOCTL_NETVMINI_READ_DATA = 2244608;
    int IOCTL_NETVMINI_WRITE_DATA = 2260996;


    HANDLE vHandle;
    DWORD vBytesReturned;

    short unsigned int vInputBuffer[66000];
    short unsigned int vOutputBuffer[66000];

    printf("program started\n");

    vHandle =
    CreateFile
    (
    TEXT("\\\\.\\NETVMINI"),
    GENERIC_READ | GENERIC_WRITE,//FILE_READ_ATTRIBUTES | SYNCHRONIZE,
    FILE_SHARE_READ,
    NULL, // no SECURITY_ATTRIBUTES structure
    OPEN_EXISTING, // No special create flags
    FILE_ATTRIBUTE_NORMAL, // No special attributes
    NULL
    );

    if (vHandle != INVALID_HANDLE_VALUE)
    {
    printf("open netvmini successfull.\n");

    // send ioclt requests

    while (1)
    {
    // doesn"t seem to work, always returns 0 bytes returned ?!

    // read request
    if (DeviceIoControl
    (
    vHandle,
    IOCTL_NETVMINI_READ_DATA,
    &vInputBuffer[0], 66000,
    &vOutputBuffer[0], 66000,
    &vBytesReturned, NULL
    ) != 0)
    {
    printf("read IOCTL to netvmini successfull.\n");
    printf("vBytesReturned: %d \n", vBytesReturned );

    if (vBytesReturned != 0)
    {
    printf("bingo");
    getchar();
    }
    } else
    {
    printf("read IOCTL to netvmini failed.\n");
    }

    // write request
    if (DeviceIoControl
    (
    vHandle,
    IOCTL_NETVMINI_WRITE_DATA,
    &vInputBuffer[0], 66000,
    &vOutputBuffer[0], 66000,
    &vBytesReturned, NULL
    ) != 0)
    {
    printf("write IOCTL to netvmini successfull.\n");
    printf("vBytesReturned: %d \n", vBytesReturned );

    if (vBytesReturned != 0)
    {
    printf("bingo\n");
    getchar();
    }
    } else
    {
    printf("write IOCTL to netvmini failed.\n");
    }

    }

    if (CloseHandle( vHandle ) != 0)
    {
    printf("close netvmini successfull.\n");
    } else
    {
    printf("close netvmini failed.\n");
    }

    } else
    {
    printf("open netvmini failed.\n");
    }

    printf("program finished\n");
    }

    int _tmain(int argc, _TCHAR* argv[])
    {
    Main();
    getchar();
    return 0;
    }

    // *** end of test program ***

    Bye,
    Skybuck.
     
    Skybuck Flying, Aug 8, 2009
    #2
    1. Advertisements

  3. I also tried adding the original constants with the include directives:

    #define IOCTL_NETVMINI_READ_DATA \
    CTL_CODE (FILE_DEVICE_UNKNOWN, 0, METHOD_BUFFERED, FILE_READ_ACCESS)

    #define IOCTL_NETVMINI_WRITE_DATA \
    CTL_CODE (FILE_DEVICE_UNKNOWN, 1, METHOD_BUFFERED, FILE_WRITE_ACCESS)

    Doesn't matter, it still don't work, same values I guess ;)

    Bye,
    Skybuck.

    "Skybuck Flying" <> wrote in message
    news:26c69$4a7d9ff9$d53372a9$1.nb.home.nl...
    > Example converted to C.
    >
    > Still don't work... let me know if it works on your computer ;)
    >
    > // *** start of test program ***
    >
    > // TestProgram.cpp : Defines the entry point for the console application.
    > //
    >
    > #include "stdafx.h"
    >
    > //#define UNICODE 1
    > //#define INITGUID
    > //#pragma warning(disable:4201) // nameless struct/union warning
    > #include <windows.h>
    > //#include <stdlib.h>
    > //#include <string.h>
    > //#include <setupapi.h>
    > //#include <dbt.h>
    > //#include <winioctl.h>
    >
    > /*
    >
    > Delphi version 0.01 and 0.02 created on 7 august 2009 by Skybuck Flying.
    > Delphi-To-C version 0.02 created on 8 august 2009 by Skybuck Flying.
    >
    > */
    >
    > void Main()
    > {
    > int IOCTL_NETVMINI_READ_DATA = 2244608;
    > int IOCTL_NETVMINI_WRITE_DATA = 2260996;
    >
    >
    > HANDLE vHandle;
    > DWORD vBytesReturned;
    >
    > short unsigned int vInputBuffer[66000];
    > short unsigned int vOutputBuffer[66000];
    >
    > printf("program started\n");
    >
    > vHandle =
    > CreateFile
    > (
    > TEXT("\\\\.\\NETVMINI"),
    > GENERIC_READ | GENERIC_WRITE,//FILE_READ_ATTRIBUTES | SYNCHRONIZE,
    > FILE_SHARE_READ,
    > NULL, // no SECURITY_ATTRIBUTES structure
    > OPEN_EXISTING, // No special create flags
    > FILE_ATTRIBUTE_NORMAL, // No special attributes
    > NULL
    > );
    >
    > if (vHandle != INVALID_HANDLE_VALUE)
    > {
    > printf("open netvmini successfull.\n");
    >
    > // send ioclt requests
    >
    > while (1)
    > {
    > // doesn"t seem to work, always returns 0 bytes returned ?!
    >
    > // read request
    > if (DeviceIoControl
    > (
    > vHandle,
    > IOCTL_NETVMINI_READ_DATA,
    > &vInputBuffer[0], 66000,
    > &vOutputBuffer[0], 66000,
    > &vBytesReturned, NULL
    > ) != 0)
    > {
    > printf("read IOCTL to netvmini successfull.\n");
    > printf("vBytesReturned: %d \n", vBytesReturned );
    >
    > if (vBytesReturned != 0)
    > {
    > printf("bingo");
    > getchar();
    > }
    > } else
    > {
    > printf("read IOCTL to netvmini failed.\n");
    > }
    >
    > // write request
    > if (DeviceIoControl
    > (
    > vHandle,
    > IOCTL_NETVMINI_WRITE_DATA,
    > &vInputBuffer[0], 66000,
    > &vOutputBuffer[0], 66000,
    > &vBytesReturned, NULL
    > ) != 0)
    > {
    > printf("write IOCTL to netvmini successfull.\n");
    > printf("vBytesReturned: %d \n", vBytesReturned );
    >
    > if (vBytesReturned != 0)
    > {
    > printf("bingo\n");
    > getchar();
    > }
    > } else
    > {
    > printf("write IOCTL to netvmini failed.\n");
    > }
    >
    > }
    >
    > if (CloseHandle( vHandle ) != 0)
    > {
    > printf("close netvmini successfull.\n");
    > } else
    > {
    > printf("close netvmini failed.\n");
    > }
    >
    > } else
    > {
    > printf("open netvmini failed.\n");
    > }
    >
    > printf("program finished\n");
    > }
    >
    > int _tmain(int argc, _TCHAR* argv[])
    > {
    > Main();
    > getchar();
    > return 0;
    > }
    >
    > // *** end of test program ***
    >
    > Bye,
    > Skybuck.
    >
     
    Skybuck Flying, Aug 8, 2009
    #3
  4. I also just tested and tried to bind and ip/udp broadcast to the virtual
    network adapters.

    The blue lights in the notification area don't lit up...

    (XP x64 Pro)

    Bye,
    Skybuck.
     
    Skybuck Flying, Aug 8, 2009
    #4
  5. Problems, problems, problems.

    Wasting time, Wasting time, Wasting Time.

    I am done with windows for the coming days.

    All I want to do is create a virtual private network technology for the game
    company of heroes.

    And windows has not helped me achieved this goal for the past 15 years.

    Tomorrow I will install linux plus wine, plus company of heroes.

    And then I will see how hard it is to actually create vpn technology on
    linux.

    And if it works then my next pc will contain linux and microsoft can go to
    hell forever ;)

    Bye,
    Skybuck.
     
    Skybuck Flying, Aug 8, 2009
    #5
  6. Now my windows can't even shutdown the c ?! WTF ?!

    Might be because of tunngle and it's bad drivers ? maybe ?

    Maybe IE8 problem ?

    Maybe VMware problem ?

    Maybe hack who knows ?!

    Tomorrow I give windows one more try... and if it's still not working then I
    give linux a try !

    Bye,
    Skybuck.

    "Skybuck Flying" <> wrote in message
    news:a12c$4a7deced$d53372a9$1.nb.home.nl...
    > Problems, problems, problems.
    >
    > Wasting time, Wasting time, Wasting Time.
    >
    > I am done with windows for the coming days.
    >
    > All I want to do is create a virtual private network technology for the
    > game company of heroes.
    >
    > And windows has not helped me achieved this goal for the past 15 years.
    >
    > Tomorrow I will install linux plus wine, plus company of heroes.
    >
    > And then I will see how hard it is to actually create vpn technology on
    > linux.
    >
    > And if it works then my next pc will contain linux and microsoft can go to
    > hell forever ;)
    >
    > Bye,
    > Skybuck.
    >
     
    Skybuck Flying, Aug 8, 2009
    #6
  7. I gave windows 7 one last try because I couldn't believe it was actually
    this bad.

    But apperently it is !

    What a time waster !

    Tomorrow it's linux time ;)

    Bye,
    Skybuck.

    "Skybuck Flying" <> wrote in message
    news:a3f20$4a7dedf3$d53372a9$1.nb.home.nl...
    > Now my windows can't even shutdown the c ?! WTF ?!
    >
    > Might be because of tunngle and it's bad drivers ? maybe ?
    >
    > Maybe IE8 problem ?
    >
    > Maybe VMware problem ?
    >
    > Maybe hack who knows ?!
    >
    > Tomorrow I give windows one more try... and if it's still not working then
    > I give linux a try !
    >
    > Bye,
    > Skybuck.
    >
    > "Skybuck Flying" <> wrote in message
    > news:a12c$4a7deced$d53372a9$1.nb.home.nl...
    >> Problems, problems, problems.
    >>
    >> Wasting time, Wasting time, Wasting Time.
    >>
    >> I am done with windows for the coming days.
    >>
    >> All I want to do is create a virtual private network technology for the
    >> game company of heroes.
    >>
    >> And windows has not helped me achieved this goal for the past 15 years.
    >>
    >> Tomorrow I will install linux plus wine, plus company of heroes.
    >>
    >> And then I will see how hard it is to actually create vpn technology on
    >> linux.
    >>
    >> And if it works then my next pc will contain linux and microsoft can go
    >> to hell forever ;)
    >>
    >> Bye,
    >> Skybuck.
    >>

    >
    >
     
    Skybuck Flying, Aug 8, 2009
    #7
  8. No,

    Apperently the infinite search is a problem in windows 7.

    But there is a way around with via "add legacy hardware".

    I managed to install the driver.

    Windows 7 bitched a lot about it not being signed and such.

    Now the big question is does it have tcp/ip bindings ?!?

    So far it's hard to tell because the smart idiots/assholes decided to change
    the whole ****ing windows gui so everybody from xp will be searching their
    ass off...

    Now I have to search where the **** the settings are if they are somewhere
    at all ?!

    Bye,
    Skybuck.
     
    Skybuck Flying, Aug 8, 2009
    #8
  9. Well can't get the tcp/ip binding to the mtf driver.

    I decided to try out the test programs anyway...

    And discovered something weird.

    The C program doesn't even work on Windows 7 !?!?

    It was compile with visual studio 2008... and when the exe is started a
    complaint is displayed:

    Something like:

    "Side-by-Side bullshit not working".

    Well I must say my impression of Windows 7 after actually trying to use it
    for something...

    Something I am usually/normally pretty good with and that is basic windows
    networking... my impression of windows 7 has totally changed.

    I think windows 7 might actually be a more/worse piece of crap than Vista ?!

    I even encoutered sloppy typo's ?!

    A couple of years ago I thought Microsoft would die in about 10 years...

    Now a few years later it seems it's happening...

    It's amazing to actually see it happen before my own eyes ! ;)

    Bye,
    Skybuck.
     
    Skybuck Flying, Aug 8, 2009
    #9
  10. Ok,

    Driver signing check disabled...

    The C short example program doesn't work.

    The Delphi program can't open the netvmini.

    The long C example that came with it... does show a list of stuff..

    It shows microsoft virtual network adapter etc...

    But when it tries to do a IOCTL it doesn't work..

    It said failed...

    maybe this is because there is no connectivity...

    So I shall try to enable the vm connection and see if that has something to
    do with it...

    Kinda strange though... it shouldn't matter that much ?

    I even had a loopback adapter

    I also installed some kind of point to point thing a few minutes back to see
    if that fixed the driver problem.

    I don't know if that might be causing problems... I don't see it anywhere ?!
    ;)

    Ok gonna try a reboot and such.

    Bye,
    Skybuck.
     
    Skybuck Flying, Aug 9, 2009
    #10
  11. "Run as administrator" allows the netvmini to be openened.

    Apperently the IOCTL code doesn't do anything except dbgprint a message...
    probably called a "trace message" or so... and then it simply breaks ?!

    So no wonder there is no data returned...

    I also wonder if overlapped i/o and completion routines/callbacks are
    possible with these drivers ? I am not sure...

    This one is called a "serialized miniport" driver... not sure what that
    means ?

    Probably means overlapped i/o not possible ???

    If not possible then buffers via ioctl will have to be copied into and
    outfrom the driver... and so the driver would then need it's own internal
    buffers...
    for receiving and then copieing to user receive buffers.. and send buffers..
    to copy send buffers from user... to be able to later send...

    And copieing would be bad for performance :( but ok, better something than
    nothing ;) :)

    Would be cool if overlapped i/o was possible ??? Anybody know if it's
    possible ?

    Bye,
    Skybuck.
     
    Skybuck Flying, Aug 9, 2009
    #11
  12. Skybuck Flying

    Pavel A. Guest

    Hi,

    Try this: http://logmein.com/products/hamachi/

    You've made really amazing progress for a beginner, but apparently
    doing what you want is too hard without learning a bit first.
    There are no tutorials like "learn yourself Visual basic in 24 minutes"
    for network drivers, unfortunately :(

    Have fun with linux.
    --pa


    "Skybuck Flying" <> wrote in message
    news:c2ae1$4a7e668b$d53372a9$1.nb.home.nl...
    > "Run as administrator" allows the netvmini to be openened.
    >
    > Apperently the IOCTL code doesn't do anything except dbgprint a message...
    > probably called a "trace message" or so... and then it simply breaks ?!
    >
    > So no wonder there is no data returned...
    >
    > I also wonder if overlapped i/o and completion routines/callbacks are
    > possible with these drivers ? I am not sure...
    >
    > This one is called a "serialized miniport" driver... not sure what that
    > means ?
    >
    > Probably means overlapped i/o not possible ???
    >
    > If not possible then buffers via ioctl will have to be copied into and
    > outfrom the driver... and so the driver would then need it's own internal
    > buffers...
    > for receiving and then copieing to user receive buffers.. and send
    > buffers.. to copy send buffers from user... to be able to later send...
    >
    > And copieing would be bad for performance :( but ok, better something than
    > nothing ;) :)
    >
    > Would be cool if overlapped i/o was possible ??? Anybody know if it's
    > possible ?
    >
    > Bye,
    > Skybuck.
    >
    >
    >
    >
     
    Pavel A., Aug 9, 2009
    #12
  13. Hamachi has tremendous lag, and somewhat packet loss.

    I hope to do much better than it...

    However seeing the lag (?) in DebugView makes me doubt a bit ;) :)

    Bye,
    Skybuck.

    "Pavel A." <> wrote in message
    news:D...
    > Hi,
    >
    > Try this: http://logmein.com/products/hamachi/
    >
    > You've made really amazing progress for a beginner, but apparently
    > doing what you want is too hard without learning a bit first.
    > There are no tutorials like "learn yourself Visual basic in 24 minutes"
    > for network drivers, unfortunately :(
    >
    > Have fun with linux.
    > --pa
    >
    >
    > "Skybuck Flying" <> wrote in message
    > news:c2ae1$4a7e668b$d53372a9$1.nb.home.nl...
    >> "Run as administrator" allows the netvmini to be openened.
    >>
    >> Apperently the IOCTL code doesn't do anything except dbgprint a
    >> message... probably called a "trace message" or so... and then it simply
    >> breaks ?!
    >>
    >> So no wonder there is no data returned...
    >>
    >> I also wonder if overlapped i/o and completion routines/callbacks are
    >> possible with these drivers ? I am not sure...
    >>
    >> This one is called a "serialized miniport" driver... not sure what that
    >> means ?
    >>
    >> Probably means overlapped i/o not possible ???
    >>
    >> If not possible then buffers via ioctl will have to be copied into and
    >> outfrom the driver... and so the driver would then need it's own internal
    >> buffers...
    >> for receiving and then copieing to user receive buffers.. and send
    >> buffers.. to copy send buffers from user... to be able to later send...
    >>
    >> And copieing would be bad for performance :( but ok, better something
    >> than nothing ;) :)
    >>
    >> Would be cool if overlapped i/o was possible ??? Anybody know if it's
    >> possible ?
    >>
    >> Bye,
    >> Skybuck.
    >>
    >>
    >>
    >>
     
    Skybuck Flying, Aug 10, 2009
    #13
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Robert
    Replies:
    1
    Views:
    469
    Pavel A.
    Feb 9, 2004
  2. Asadujjaman
    Replies:
    0
    Views:
    3,160
    Asadujjaman
    Apr 29, 2007
  3. Skybuck Flying

    Unable to bind tcp/ip to netvmini driver in Windows 7 ?!?!

    Skybuck Flying, Aug 8, 2009, in forum: Windows XP Drivers
    Replies:
    24
    Views:
    1,498
    Maxim S. Shatskih
    Aug 9, 2009
  4. Skybuck Flying
    Replies:
    3
    Views:
    858
    Skybuck Flying
    Aug 9, 2009
  5. Skybuck Flying

    First log from netvmini.sys on Windows 7 x64 (Ultimate)

    Skybuck Flying, Aug 9, 2009, in forum: Windows XP Drivers
    Replies:
    6
    Views:
    1,089
    PA Bear [MS MVP]
    Aug 9, 2009
Loading...

Share This Page