DEVICE EXTENSION to usb camera

Hello,
I search DEVICE EXTENSION for building filter driver to usb camera, can you help me with it ?

xxxxx@gmail.com wrote:

I search DEVICE EXTENSION for building filter driver to usb camera, can you help me with it ?

I’m sorry, I don’t understand what you are asking. What is the overall
goal are you trying to achieve?


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

I need the structure of DEVICE EXTENSION to usb camera.
For example for keyboard the device extension is:
typedef struct _DEVICE_EXTENSION
{
PDEVICE_OBJECT pKeyboardDevice;
PETHREAD pThreadObj;
bool bThreadTerminate;
HANDLE hLogFile;
KEY_STATE kState;
KSEMAPHORE semQueue;
KSPIN_LOCK lockQueue;
LIST_ENTRY QueueListHead;
}DEVICE_EXTENSION, *PDEVICE_EXTENSION;

xxxxx@gmail.com wrote:

I need the structure of DEVICE EXTENSION to usb camera.

No, you don’t. You didn’t answer my question. What is the overall goal
you are trying to achieve? What information do you think you will get
from this?

A device extension is just a structure, private to each driver, that
holds its state information. There isn’t a single “device extension”
for a particular type of device. It’s true that usbvideo.sys has a
device extension, but the contents are internal to that device. Other
camera drivers will have their own private device extensions.


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

My purpose is to create filter driver. I understand what you say, but I confused about how the convert from the PVOID to PDEVICE_EXTENSION happen. For example:
PDEVICE_OBJECT fido;
UNICODE_STRING DeviceName;
NTSTATUS status = IoCreateDevice(DriverObject,
sizeof(DEVICE_EXTENSION), &devname, FILE_DEVICE_UNKNOWN,
0, FALSE, &fido);
PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION)fido->DeviceExtension;

So I have a differnt structure for device exnesion according to my choice, how the convert happen?

Tnx for the fast answer.

You’re not converting any structures, you’re just casting a pointer to
PVOID to a pointer to PDEVICE_EXTENSION.

The value you have in DeviceExtension is just a pointer to a memory
location which has a valid size of sizeof(DEVICE_EXTENSION). The OS doesn’t
care how your driver interprets that memory location or what it stores
there.

Before you start developing drivers I suggest you start by getting familiar
with pointers :).

On 11 September 2015 at 22:07, wrote:

> My purpose is to create filter driver. I understand what you say, but I
> confused about how the convert from the PVOID to PDEVICE_EXTENSION happen.
> For example:
> PDEVICE_OBJECT fido;
> UNICODE_STRING DeviceName;
> NTSTATUS status = IoCreateDevice(DriverObject,
> sizeof(DEVICE_EXTENSION), &devname, FILE_DEVICE_UNKNOWN,
> 0, FALSE, &fido);
> PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION)fido->DeviceExtension;
>
> So I have a differnt structure for device exnesion according to my choice,
> how the convert happen?
>
> Tnx for the fast answer.
>
>
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
>
> OSR is HIRING!! See http://www.osr.com/careers
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

I know what is pointer. I meant how I know what is stored in that memory, and how to build a compatible structure od device extension ? As Tim say foe each device there is another device extension, so if I write filter driver to device I need to know his device extension structure.

No you do not need to know the device extension of the driver you are
filtering. Device extensions are purely local storage for the driver you
are writing. For most drivers the device extension is whatever structure
you wish to define.

Don Burn
Windows Driver Consulting
Website: http://www.windrvr.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@gmail.com
Sent: Friday, September 11, 2015 3:39 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] DEVICE EXTENSION to usb camera

I know what is pointer. I meant how I know what is stored in that memory,
and how to build a compatible structure od device extension ? As Tim say foe
each device there is another device extension, so if I write filter driver
to device I need to know his device extension structure.


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Ok, thank you.

xxxxx@gmail.com wrote:

My purpose is to create filter driver.

To do what, exactly? Cameras have some unique attributes that makes
filtering them a bit tricky. There may be better ways.

I understand what you say, but I confused about how the convert from the PVOID to PDEVICE_EXTENSION happen. For example:
PDEVICE_OBJECT fido;
UNICODE_STRING DeviceName;
NTSTATUS status = IoCreateDevice(DriverObject,
sizeof(DEVICE_EXTENSION), &devname, FILE_DEVICE_UNKNOWN,
0, FALSE, &fido);
PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION)fido->DeviceExtension;

There is no excuse today for creating a filter driver in straight WDM.
You need to use KMDF. It handles all of the things that people do wrong
in filter drivers.


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