PC Review


Reply
Thread Tools Rate Thread

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

 
 
Skybuck Flying
Guest
Posts: n/a
 
      7th Aug 2009
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.


 
Reply With Quote
 
 
 
 
Skybuck Flying
Guest
Posts: n/a
 
      8th Aug 2009
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.


 
Reply With Quote
 
 
 
 
Skybuck Flying
Guest
Posts: n/a
 
      8th Aug 2009
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" <(E-Mail Removed)> wrote in message
news:26c69$4a7d9ff9$d53372a9$(E-Mail Removed)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.
>



 
Reply With Quote
 
Skybuck Flying
Guest
Posts: n/a
 
      8th Aug 2009
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.


 
Reply With Quote
 
Skybuck Flying
Guest
Posts: n/a
 
      8th Aug 2009
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.


 
Reply With Quote
 
Skybuck Flying
Guest
Posts: n/a
 
      8th Aug 2009
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" <(E-Mail Removed)> wrote in message
news:a12c$4a7deced$d53372a9$(E-Mail Removed)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.
>



 
Reply With Quote
 
Skybuck Flying
Guest
Posts: n/a
 
      8th Aug 2009
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" <(E-Mail Removed)> wrote in message
news:a3f20$4a7dedf3$d53372a9$(E-Mail Removed)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" <(E-Mail Removed)> wrote in message
> news:a12c$4a7deced$d53372a9$(E-Mail Removed)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.
>>

>
>



 
Reply With Quote
 
Skybuck Flying
Guest
Posts: n/a
 
      8th Aug 2009
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.


 
Reply With Quote
 
Skybuck Flying
Guest
Posts: n/a
 
      8th Aug 2009
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.


 
Reply With Quote
 
Skybuck Flying
Guest
Posts: n/a
 
      9th Aug 2009
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.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
if less then zero put zero if greater then zero state number =?Utf-8?B?UGFtZWxhIEplYW4=?= Microsoft Excel Worksheet Functions 2 17th Oct 2006 08:36 PM
Wrapping DeviceIoControl() for IOCTL_VIDEO_QUERY_DISPLAY_BRIGHTNES =?Utf-8?B?ZXdvbw==?= Microsoft Dot NET 0 11th May 2005 09:31 PM
Calling DeviceIOControl() causes XP freeze on hyperthread cpu Robert Windows XP Drivers 1 10th Feb 2004 12:18 AM
P/Invoke DeviceIoControl Alexander Guhl Microsoft Dot NET Compact Framework 6 15th Jan 2004 02:13 PM
DeviceIoControl to compress files Jules Crown Microsoft C# .NET 2 15th Jul 2003 04:21 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:55 AM.