USB Specification and Windows limitation on Serial Numbers


A lot can be read and a whole lot more can be interpreted when reading those specifications 😉 , that is the problem with all those abstract documentations. I have observed during my testing at SCM Microsystems that when devices with same serial numbers are connected it may crash the system, which i have always seen on Win9x systems and think on WinXp as well.

Windows uses serial numbers in devices to uniquely identify one device from another when plugged in to the system, say for example to identify one USB cam to another cam. But USB specification says that they devices “can” have serial numbers and hence it is not a requirement that all devices must have serial number. So how does windows identify devices that does not have serial number ? simple it generates a number based on the hub & port combination on which it is connected. Though this does not guarantee uniqueness this is how windows works and you have to deal with it ;). Lets see an example for both of these scenarios

here is a scenario where there is a unique serial number, the huge number after the last “\” is the serial number in this case


here is a scenario where the system generated a number when the device does not have a serial number


How to identify if a device has serial number or not ? simple, only windows generated numbers will have “&” in them. so if the number has “&” it was generated by windows else it is the number from the device.

Now that you know that a device “can” have a serial number, lets move to the next problem, which is much more subtle. What are the restrictions or rules about serial number if the device has a serial number ? hmm… interesting :).  Windows places a clear requirement that if the devices have serial number they must be unique. there is also a test case that performs this check in Microsoft’s Driver Test Manager that is used to certify devices and drivers.

So if you have an USB device that has a serial number it must be unique for it to work in Windows based systems properly.Connecting multiple devices with same serial number is known to crash the system.

All these are common knowledge to lots of device driver developers, so what’s the point of this blog ? 🙂 well the point was to notify a subtle information that was missed by many including myself till yesterday. That is the USB specification does not place any restriction on the serial numbers. here is a passage from “USB in nutshell” when explaining device descriptors

Three string descriptors exist to provide details of the manufacturer, product and serial number.
There is no requirement to have string descriptors. If no string descriptor is present, a index of zero
should be used.

So, All the USB spec says is that the device can have serial number and it must be set zero if it does not want to have serial number. It is Windows that enforces the restriction that the serial numbers, if in case your device happens to support one, must be unique between two devices.

PS: An interesting article by Raymond Chen on why windows needs unique serial number for devices can be found here 🙂


status update

Leave a comment

Two months in to new year here is the first post :).

Whats keeping me busy ? well new place and new company both keeping me real busy and am enjoying it for now.

SCM was a great place to work and still is. But after more than two years working in smartcard device drivers it was time to lookout for other challenges and that has now brought me to Samsung Software center.

Worked on a lot of cool stuff and learning a lot lot more within the last two months, hope the time ahead will continue to be as intersting. planning to convert a couple of ideas in to blog articles 🙂 convertion of plans will take time ;).

till then its “Chao” for now

WinDbg Commands – No opcode


The incredible collection of commands in Windbg never fails to impress me whenever i come across a new one.  Just found a new command to disable opcode display from openrce forum.

I have avoided the opcodes till now or putting it another way the opcodes never bothered me 😉 but windbg provides options to disable opcodes in console during debugging as well.

.asm no_code_bytes

The no_code_bytes option for the .asm command disables display of opcodes. The documentation says that this is for x86 target only. The following dump was from x64 vista so think the document is yet to be updated. here is the example of this command

0:000> u
00000000`7727053a    c3                          ret
00000000`7727053b    666690              xchg    ax,ax
00000000`7727053e    6690                    xchg    ax,ax
00000000`77270540   4c8bd1                 mov     r10,rcx
00000000`77270543   b82a000000    mov     eax,2Ah
00000000`77270548   0f05                      syscall

00000000`7727054a    c3                          ret
00000000`7727054b    666690              xchg    ax,ax

0:000> .asm no_code_bytes
Assembly options: no_code_bytes
0:000> u
00000000`7727054e     xchg       ax,ax
00000000`77270550    mov        r10,rcx
00000000`77270553    mov        eax,2Bh
00000000`77270558    syscall
00000000`7727055a    ret
00000000`7727055b    xchg       ax,ax
00000000`7727055e    xchg       ax,ax

Also checkout following related command 🙂

.prompt_allow (options)

bye for now

Update: corrected typo of parameter from no_opcode_bytes to no_code_bytes

People and Technology @ TechVista 2008


You know you are really interested in something when you wake up even before the alarm goes.  October 1, 2008 was one of those special days. It was when TechVista, the annual MSR (Microsoft Research India) was organised in Chennai. Sure, I would have loved to be at other events, but those will have to wait for another time ;).

India Heritage Project demo
Dr.P.Anandan kicked off the event with his speech introducing the other guests. One of the much talked about projects for the event was the demo of “India Digital Heritage Project”. The demo was a silverlight app with photosynth used to show the history and heritage of Srivilliputhur Andal temple.  But it would have been a good demo for those who haven’t seen photosynth in action before. The demo was mentioned as unpolished explicitly before and after the demo. As an application it was very good and is good at its intended purpose of using technology to show the richness of a heritage site. I just had a feeling that there wasn’t any research involved in this project. That aside it was a good demo of capabilities of Photosynth, HDview and silverlight ;), with a local flavour if I might add. 

Morning sessions
The first session was by legendry Prof. John Hopcroft titled “Computer Science in the Future”. The talk was on effectively using all the information available online and how it will improve over next few years. What was really interesting 🙂 was chat the students had with him before the start of the session. One of the questions was when he started writing his famous book. To which he replied that the book initially was just notes he prepared for his classes during the early 1960s.

Next walked inDr.Rick Szeliskifor his talk titled “Weaving the World’s Photos”. His talk was interesting for it is his team that released Photosynth, HDview and quite few other important software. Some the future goals mentioned at the end of the talk were support for using these tools in large scale scenes, supporting the lighting, time of day and weather changes. A typical example being a monument being covered in snow during winter. Ability to capture these events and time would be a great improvement. Another interesting link provided as part of his talk was whose aim according to their website is “to collect geographically representative photographs and information for every square kilometre of Great Britain and Ireland“. Further detailing of his talk would amount to reproduction of his talk 😉 so let me stop here for now.

The third and final talk of the morning session was by Prof. Shafi Goldwasser titled “Program Obfuscation and One-Time Programs”. This was one of the sessions I was eagerly waiting for after reading some articles in and The talk was proposing use of a hardware key she called “Read Once Key” to support execution of any program a predefined number of times only. Now after working in a Smartcard environment for more than 2 years my first question during the Q&A session was her reason to not consider smartcards. Although I am aware of limitations of contactless smartcards I am yet to come across a limitation of the good old contact ( sim based cards for those unfamiliar with smartcards) based smartcards. Even though I did ask a couple of other questions during the lunch break I failed to understand the logic behind advantage of the proposed device over a smartcard. One limitation regarding smartcards I can accept is the possibility of “Side channel attacks“. May be later if and when I get to meet her I must have another discussion on the advantages of ROK.

After a good Q&A session I walked out of the hall to realize the HUGE number of students present in the event. The Chennai student partners seem to have done a very good job of pushing the event to all colleges in Chennai. The side effect being me struggling to get anything to eat during the lunch. After a small discussion with Ravi, Rajesh, Krishna on upcoming events in CNUG I had time to checkout just one small project being displayed. Another highlight of the event was “PhD Posters”, exhibit of projects done by students from different leading institutions.

Afternoon Session: 
Dr. Rick Rashid, talked about the contributions of Microsoft Research and about the important projects done at MSR over these 17 years. Some of the projects mentioned were sensecam, photosynth, and surface. One project that was mentioned on the sidelines was mylifebits. I loved the project when it was first demoed at channel9. Just the storage information of various forms of data was extracted for the slides. He also talked about a project being worked on that will help kids learn to program similar to the one Randy paush mentioned in his last lecture.But overall was good presentation, a demonstration of all the achievements of MSR. Like all events someone has to handle the first session after lunch and here this session happened to be that :).

Then walked in Prof. Shree Nayar for his talk titled “Computational Cameras: Redefining the Image”. There wasn’t any expectation for me for this session but the way he handled the session and the demos he showed simply kept me mesmerised at the projects he has worked on. Starting from the convex lens before camera for making conference cams to the project that extracts images from people’s iris in normal photos to project that separates direct light and general light in normal photos. If there was any time during the day I thought about taking up research it was during this session :D. I am sure the sessions were recorded and this session is a must watch for all those interested in photography/ image analysis/ computer vision. This section will be updated once I get a link to the recording of this session.

The final session of the day was by Dr. Vijay Chandru , Chairman, Co-Founder & Chief Executive Officer, Strand Life Sciences. He talk was titled “Computational Biology and Vice Versa”. He was talking on the biotechnology, its advances over time. He spoke more on it except that that was all I understood. 

Friends Meet
Dhawal and his friend Subhamoy Mandal came to the city for attending the event. It was good time I personally had and I am sure aswin too would feel the same too. We were chatting on a number of topics that included Subhamoy repairing his cell phone 🙂 , Subhamoy trying to bring Dhawal into research and Dhawal trying to bring Subhamoy into corporate environment. We had a mini-Geek meet 🙂 with just four of us discussing on a number of technical things. Finally like all good things I had to say good night for these guys booked ticket back to Bangalore that very night :). It was a great day learning a lot and meeting a number of very good people. 

Well that was a long blog, longer than I want it to be but it is ok I think since there has been none for a long time as well 🙂 


WDF: Study guide

Leave a comment

The nice guys at WDF team have released a detailed word document containing links to a number of articles relating to UMDF, KMDF and other topics like SDV,prefast for drivers etc.  Though these links are for articles/ documents that are already available online it is good to have them all listed in one place, organised in way for anyone to learn WDF. maybe thats why its named “Windows Driver Foundation: A Syllabus” ;). the best part is the evaluation and grading part of the course 🙂

Midterm 1: WinHEC 2007 technical sessions and hands-on labs.

Midterm 2: Testing with the current release of the Windows Driver Kit (WDK).

Final exam: Your first KMDF or UMDF driver.

Grading policy: Self-assessment through Driver Verifier, PREfast, Static Driver Verifier, and WDK tests for drivers.

so go ahead and grab the document located here 🙂

and all the best for the exams 😉

bye for now

Hough Transforms

Leave a comment

yeup i left the SOM image analysis before completing it and may be some time before start this again. just wanted to update about the new short article upon it has been there for quite some time but yet to get links on home page dont know why 🙂 . any way it will act as a good continuation along with the other methods of analysis from the previous blog post, using hough Transforms to find edges or more accurately shapes inside images. any more info and this blog will become a copy so head out to the article to read it yourself 🙂

An Introduction to Hough Transforms  By James Matthews

astha pronto 🙂

Kernel Debugging tutorial for WinDbg


One of the difficulties in using a debugger as powerful as WinDbg is the need to know the various commands and when to use them. There are lots of articles about windbg but the most comprehensive for a beginner is the tutorial that comes with the installation of windbg,  the appropriately named “Kernel_debugging_tutorial.doc”.

The document begins with setting up a debugging session between the host and the target system and goes on to explain some the most common commands with good example. Why blog about something that is part of application you ask ? 🙂 here is why, the document is not part of the start menu items nor is it available from the application. In order to open it you have to browse to the windbg installation folder.

This tutorial is a must read for its simplicity and coverage of advanced topics with ease. here is an example for a situation i faced before reading this tutorial. while debugging with windbg i found some local variables to be missing from the locals window and i couldn’t track them.I overcame the limitation temporarily by using globals. later i posted a newsgroup question as to why this happens and Ivan of Microsoft was kind enough to point to me that optimization was causing this. When i was reading through the tutorial i was surprised to find a section titled “Dealing with code optimization” , that goes on to explain that this is usually seen with free build or build with optimizations turned on.

A big thanks for the person(s) who wrote this tutorial, which is a good read for even those with moderate familiarity to Windbg. 🙂

 if you are looking for a step by step guide to use windbg another good starting point is Ilias’s blog post of the same topic

another good referance point is , which also has links to download latest versions of Windbg.

bye for now 🙂

Older Entries