netvmini sample and Interrupt Vector

Hi, there’s a miniport sample in the WDK-netvmini.

it called NdisMQueryAdapterResource to get interrupt related information, but when i debug it ,it failed. how to solve this problem?

Well,

a) You don’t give us much information to go on. “I tried this, it failed, why?” isn’t really a question anyone is likely to be able to answer.

b) Isn’t NdisMQueryAdapterResource a deprecated function?

Peter
OSR
@OSRDrivers
(venturing into NDIS territory, where he has no business at all being)

水镜 wrote:

Hi, there’s a miniport sample in the WDK-netvmini.

it called NdisMQueryAdapterResource to get interrupt related
information, but when i debug it ,it failed. how to solve this problem?

It is a virtual driver. There is no hardware, so there won’t be any
resources. What error do you get? How did you install the driver?


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

my OS is windowsxp, the version of NDIS is 5.1, so NdisMQueryAdapterResource is the right function, and the wdk manual also says NDIS 5.1 should use NdisMQueryAdapterResource.

after the netvmini sample called the NdisMQueryAdapterResource, the value of the status parameter is 0xC0000001.

as Tim Roberts said, netvmini is a virtual driver, there’s no hardware. i install the driver by adding hardware in control panel.

> after the netvmini sample called the NdisMQueryAdapterResource

This function is not for virtual drivers, as it was already said here.


Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com

> This function is not for virtual drivers, as it was already said here.

Hi, how could i install a ISR handler for the virtual driver?

Under what conditions would your ISR run. There is no facility to have “interrupts” connected to a virtual NIC.

A common case is your virtual NIC is on a virtual bus, and your virtual bus might want to notify the virtual NIC of an async event. In this case, you should have an interface to your virtual bus to register a notification callback when the async event happens. The QueryInterface structures are commonly used for this kind of inter driver communication.

Jan

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of 357836635@qq.com
Sent: Tuesday, May 13, 2014 5:48 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] netvmini sample and Interrupt Vector

This function is not for virtual drivers, as it was already said here.

Hi, how could i install a ISR handler for the virtual driver?

> Hi, how could i install a ISR handler for the virtual driver?

You cannot.

Virtual drivers cannot have ISRs by very definition. They cannot have hardware.


Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com

Question: Why does netvmini call NdisMQueryAdapterResources?

The polite answer: netvmini is trying to leave you a helpful chunk of code. If you were to port netvmini to real hardware with real resources, then that little chunk of code would be of modest assistance in verifying the adapter is getting the right resources.

The realistic answer: netvmini can trace its lineage from the e100bex driver. That chunk of code was actually meaningful on the e100, since that PCI card actually *does* have resources. netvmini was created by taking e100, then ripping out the hardware edge. The developer who created netvmini decided that this little bit of code was still interesting and somewhat hardware-agnostic, so the code remained. If netvmini had been built from scratch, the developer almost certainly wouldn’t have bothered to include this.

Question: *Should* netvmini call NdisMQueryAdapterResources?

Opinionated answer: Honestly, I don’t think that chunk of code is adding a lot of value. As you’ve observed, it doesn’t do anything out-of-the-box. And these days, “!ndiskd.miniport -hw” gives you better information on-demand, without needing a bunch of DbgPrints.

Snarky answer: It’s not. The latest version of netvmini doesn’t have this code anymore.

Hi.thanks all for give me the informations.at this time, i do not know how to solve my problem.

here is my project in detail:
i am developing a Virtualization system based on Intel VT and WindowsXP.
when my system running, WindowsXP runs in guest mode. my VMM runs in root mode.
I want to take control the network communication of WindowsXP.so i have written a NIC driver in VMM, the driver is working fine.it can receive and send.
now, i want to deliver the NIC’s data to WIndowsXP through Interrupt Enjection(deliver a virtual interrupt from VMM to WindowsXP).
i do not want to provide a emulation of some kind of NIC in WindowsXP.so the netvmini was a right choice for me. but the most difficult thing is to install a ISR for netvmini. now i know the netvmini can not satify my requirement.

but is there any other way to help solve my situation? i am new in Windows Driver develop.So, if you have any idea please tell me. thanks.

(forgive my poor english #^_^)

> i do not want to provide a emulation of some kind of NIC in WindowsXP

If you do interrupt injection - then you should emulate some real-world NIC hardware, the way most VM hypervisors do (and also Hyper-V for Legacy Network Adapter).

Or, if you hypervisor has some message-sending channel to the guest, available from the guest side using some special CPU opcodes or such (like Hyper-V’s VMBus, which is used for modern network adapters), you can use netvmini in a guest on top of this facility by your virtualization system.


Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com

357836635@qq.com wrote:

here is my project in detail:
i am developing a Virtualization system based on Intel VT and WindowsXP.
when my system running, WindowsXP runs in guest mode. my VMM runs in root mode.
I want to take control the network communication of WindowsXP.so i have written a NIC driver in VMM, the driver is working fine.it can receive and send.
now, i want to deliver the NIC’s data to WIndowsXP through Interrupt Enjection(deliver a virtual interrupt from VMM to WindowsXP).
i do not want to provide a emulation of some kind of NIC in WindowsXP.so the netvmini was a right choice for me. but the most difficult thing is to install a ISR for netvmini. now i know the netvmini can not satify my requirement.

Remember that Windows XP doesn’t have any idea that there is a
hypervisor. It doesn’t understand the concept of a “virtual
interrupt”. To XP, all interrupts are real interrupts. Thus, if you
expect XP to handle an interrupt, it has to believe that there is a
piece of hardware that is requesting that interrupt.

So, you will need to create fake hardware of some kind. It doesn’t
necessary have to be a full NIC, although that’s probably easier.

If you have a private communication path to the hypervisor, you could
use that, but that’s not using the XP interrupt scheme.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Hi, I think if it possible to install a ISR directly into WindowsXP’s IDT?
For example, get the WindowsXP’s IDT through instruction, find a null IDT entry(which now i found that vector 0x20 is NULL entry), initialize the entry as interrupt gate, store my ISR’s addres into that gate.

I do not assure if there’s any risk.

On May 15, 2014, at 11:59 PM, 357836635@qq.com wrote:

Hi, I think if it possible to install a ISR directly into WindowsXP’s IDT?
For example, get the WindowsXP’s IDT through instruction, find a null IDT entry(which now i found that vector 0x20 is NULL entry), initialize the entry as interrupt gate, store my ISR’s addres into that gate.

You already know, I assume, that this is not the right solution. You can?t just go banging around in the IDT. There are other system structures that track interrupts, and your modification will not be tracked in those structures.

Your hypervisor must already be creating fake PCI devices for other purposes. Just create one more and give it an interrupt. Problem solved, in a completely supported way.

Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

> Hi, I think if it possible to install a ISR directly into WindowsXP’s IDT?

Why doing such a perversion just for a virtual NIC? there are much better ways to do this, described above in the thread.


Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com