Click here to Skip to main content
15,920,217 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: returning CMap object Pin
Antti Keskinen10-Dec-04 4:44
Antti Keskinen10-Dec-04 4:44 
GeneralRe: returning CMap object Pin
Cedric Moonen10-Dec-04 5:10
Cedric Moonen10-Dec-04 5:10 
GeneralCListCtrl Text Color Pin
Neelesh K J Jain10-Dec-04 1:19
Neelesh K J Jain10-Dec-04 1:19 
GeneralRe: CListCtrl Text Color Pin
Jim Crafton10-Dec-04 6:38
Jim Crafton10-Dec-04 6:38 
Generalserial com / usb Pin
doneirik10-Dec-04 1:16
doneirik10-Dec-04 1:16 
GeneralRe: serial com / usb Pin
Cedric Moonen10-Dec-04 1:27
Cedric Moonen10-Dec-04 1:27 
GeneralRe: serial com / usb Pin
doneirik10-Dec-04 3:10
doneirik10-Dec-04 3:10 
GeneralRe: serial com / usb Pin
Antti Keskinen10-Dec-04 4:07
Antti Keskinen10-Dec-04 4:07 
I'm not entirely sure if your boss is right or wrong because I don't know the configuration of your computer systems.

The USB is a bus that resides in the computer. The low-level drivers (supplied by Microsoft) allow the bus to enumerate and identify a piece of hardware and then send a request to the registry to find the correct function driver for the device by using the vendor and product IDs returned by the USB Descriptors. This is how the bus works in a nutshell.

Your computer systems might have a pseudo-device driver that emulates a COM port. When this driver is loaded, it opens a handle to the low-level bus drivers and then creates a virtual COM port device. After this, passing a USB packet into the COM port is routed directly to the low-level drivers and thus into the bus. Needless to say, an errorneous packet might cause misbehaviour on the system. This is probably what your boss had in mind. You should ask him for clarification, though.

When this pseudo-device driver is not in use, all devices attached to the bus are represented by device objects. For each hardware device object that has a suitable function driver available and loaded, a driver object also exists. Additionally, possible filter driver objects may exist. You can use the WinObj object viewer (Google for it) to view all hardware device objects, driver objects and other object currently existing in your system. The same program can be used to obtain a valid name for a driver/device object. If you are operating on kernel mode, you can use this low-level name to open a handle into the driver/device. In user mode, only the symbolic link names, and a restricted list of device names, are available due to security restrictions imposed by Windows NT/2000/XP framework.

You can view all these through WinObj. The symbolic names can be found in the 'GLOBAL??' subtree. Actual device names can be found from 'Device' subtree. For reference, try looking for a normal COM port. You can find it lying around there somewhere. "\Device\Serial0" is COM1 for me.

From this list (Global??), you can even identify your USB device by looking at the vendor and product IDs. To get a rough idea who's device you're looking at, you can use the Linux-USB group's list, which is "somewhat" regularly updated. It can be found here[^]. All USB devices are listed in form "USB#Vid_xxxx&Pid_xxxx&MI_xx#.....". The first is the vendor ID, the next the product ID. The last one I'm not sure of.

Remember that a device might have multiple entries in WinObj's GLOBAL?? subtree. The one we are interested in is \Device\USBPDO-X which refers to a physical device object in the USB bus. Opening a handle to this device allows you to read/write from as if reading/writing a file. Security restrictions might apply, though. You can view these through WinObj as well. If you can't view the properties of an object, you don't have enough priviledges. Looking at the security tab, you can see which users have rights to read/write/modify a device.

For an example, Logitech has a vendor ID of 046d hex. I have the Logitech MX500 optical mouse attached, and it's product ID is c025 hex. Both of these are from Linux-USB list. Thus, in "GLOBAL??" I have an entry "USB#Vid_046d&Pid_c025 etc" which is a symbolink link to "\DEVICE\USBPDO-5". This is the physical device object for my MX500. Opening it's properties, I can see that in user mode, I only have 'query state' priviledge, allowing me to request status information about the device. If I was logged in as an administrator, I could also 'delete' the object, which means the device was logically detached from the bus. The bus would, however, soon re-detect the device, re-load the drivers and re-create the device objects.

I can't, in user mode, read or write from the device. For that purpose, I would need to write a kernel-mode program. This program should create a virtual device, say USB MX500 mouse, open the device handle for USBPDO-5, and route the commands sent to the virtual device to the physical device and back. A crude hack, I'd call it, but it would fill it's purpose Smile | :)

Well, that was a huge reply. Hope it's informative. I'm in consideration of writing an article about this matter, but my current thesis work is a priority.

-Antti Keskinen

----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
GeneralRe: serial com / usb Pin
Trollslayer10-Dec-04 5:23
mentorTrollslayer10-Dec-04 5:23 
GeneralRe: serial com / usb Pin
doneirik13-Dec-04 1:37
doneirik13-Dec-04 1:37 
GeneralDebug Assertion failed Error Pin
Shailaja10-Dec-04 1:08
Shailaja10-Dec-04 1:08 
GeneralRe: Debug Assertion failed Error Pin
Cedric Moonen10-Dec-04 1:15
Cedric Moonen10-Dec-04 1:15 
GeneralRe: Debug Assertion failed Error Pin
Shailaja10-Dec-04 1:22
Shailaja10-Dec-04 1:22 
GeneralRe: Debug Assertion failed Error Pin
ThatsAlok10-Dec-04 1:24
ThatsAlok10-Dec-04 1:24 
GeneralRe: Debug Assertion failed Error Pin
Shailaja10-Dec-04 1:37
Shailaja10-Dec-04 1:37 
GeneralRe: Debug Assertion failed Error Pin
ThatsAlok10-Dec-04 2:16
ThatsAlok10-Dec-04 2:16 
QuestionHow to use CTabCtrl Pin
toxcct9-Dec-04 23:55
toxcct9-Dec-04 23:55 
AnswerRe: How to use CTabCtrl Pin
Mircea Puiu10-Dec-04 0:41
Mircea Puiu10-Dec-04 0:41 
AnswerRe: How to use CTabCtrl Pin
Maximilien10-Dec-04 0:41
Maximilien10-Dec-04 0:41 
AnswerRe: How to use CTabCtrl Pin
Cedric Moonen10-Dec-04 0:55
Cedric Moonen10-Dec-04 0:55 
General:(( Help in CTypedPtrList / Clist Pin
M AZZAAAM9-Dec-04 23:16
M AZZAAAM9-Dec-04 23:16 
GeneralPb using the OFN_NOCHANGEDIR flag Pin
Forest20049-Dec-04 22:32
Forest20049-Dec-04 22:32 
Questionhow do u get the arrow key events in a window?? Pin
namaskaaram9-Dec-04 22:32
namaskaaram9-Dec-04 22:32 
AnswerRe: how do u get the arrow key events in a window?? Pin
ThatsAlok10-Dec-04 0:00
ThatsAlok10-Dec-04 0:00 
GeneralCreation of DLL from ActiveX control Pin
tspramod9-Dec-04 22:25
tspramod9-Dec-04 22:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.