Link to home
Start Free TrialLog in
Avatar of TheFunkSoulBrother
TheFunkSoulBrother

asked on

get real HDD serial number under Vista with activated User Account Control (UAC)

I'm using the code of Diskid32 to retrieve a computers real HDD serial number.
http://www.winsim.com/diskid32/diskid32.html

It works fine with Windows XP and Vista when UAC is inactive.
But it doesn't work when UAC is activated. Vista somehow protects the HDD from being accessed by my program.

I also tried to read out the serial using WMI and the Win32_PhysicalMedia interface but it behaves like this:
inactive UAC: S01UJ20Y630275 is returned when querying for the serial number
active UAC: 30535531324a5930333632303537202020202020 is returned by the same query
Ergo: WMI doesn't work either, Vista protects the real HDD serial from being read out



Is there any way to get the real HDD serial number under Vista with activated UAC?



--- Remark: Diskid32 works like this:

    *  Windows 95 / 98 / ME: Uses a VXD for talking directly to the IDE hard drives
    * Vista / Windows NT / 2000 / XP (administrator rights): Uses the PhysicalDrive interface
    * Windows NT / 2000 / XP (user rights only): Uses the SCSI back door to access the IDE hard drives
    * Vista / Windows XP (guest rights only): Uses the PhysicalDrive interface
Avatar of dlan75
dlan75
Flag of France image

Hi,
Have you tried running your program as administrator? (I don't mean with an admin account but by right clicking the exe and selecting run as administrator) That might help.
ASKER CERTIFIED SOLUTION
Avatar of pjasnos
pjasnos
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of TheFunkSoulBrother
TheFunkSoulBrother

ASKER

Wow!! You're great! Thank you so much!
What a funny behavior of Vista...

Would you say that it is the best solution to read the HDD serial via WMI?
WMI seems to be quite slow.
Actually, WMI is MS recommended solution (which means they would not break it by adding any more security features). Yes, WMI may be little bit slow, but are you going to need to check the HDD serial no. 200 times per second? I don't think so, so the the time taken doesn't matter here. And all future versions of windows should be compatible with this method (I would say it is very near certainty), while diskid32 methods are certainly a security risk (especially those using SCSI backdoor) and could (IMO should) be braken by the next scheduled patch release or service pack (the latter being more probable).

So, at least for things that include reading things one time (HDD s/n, Processor s/N etc.) you should use WMI.
And BTW, it wasn't very hard to guess it, provided you observe that hex code for space is 0x20, after "de-hexing" the s/n i observed it is simply mangled (little/big endian change), so wrote additional function to correct it, and it worked :), hopefully :). I'm glad if I can help someone :).
Christ, sorry for poor grammar of my first post --> braken = broken there ;).