0

how to get harddrive serial number(not the volume # wich change at each reinstall of windows) in C or asm, without wmi (cause wmi required admin right). Any clue would be helpfull cause right now i found nothing on web in C without wmi, in dayss of searching... Thank you. EDIT : For windows system

user2101247
  • 149
  • 1
  • 1
  • 5
  • 2
    I think it likely that the serial number is considered confidential information, so you cannot get it without administrator privilege. – Harry Johnston Feb 26 '13 at 02:54
  • You most probably won't be able to do this without privileged instructions. – Daniel Kamil Kozar Feb 26 '13 at 06:47
  • @ Harry : serial# is not on cpu anymore for that reason, so that's why there is a variable for it now, but hard drive too...? Anyway even if mac add can be fake, it still a relaible way of id-ing computer, thus non confidential. Thank for uncertain info : at least its info. @Daniel : ok thanks too – user2101247 Feb 26 '13 at 06:50
  • In Windows you'd have to use `DeviceIoControl` and issue IDENTIFY commands using ATA passthrough to the drive. You would require admin-level access – Nik Bougalis Apr 09 '13 at 00:41
  • *cause wmi required admin right* - Are you sure about that? Have you tried it? Doing `wmic diskdrive get name, serialnumber` from a non-admin account worked correctly for me. Programmatically what you're looking for is something like [this](https://forums.codeguru.com/showthread.php?545649-WinAPI-How-to-Get-Hard-Disk-Serial-Number), but opening up a physical disk like that almost certainly requires admin rights. – David Wohlferd Sep 30 '21 at 00:46

2 Answers2

1

Please try my open source tool, DiskId32, which also has the source code at http://www.winsim.com/diskid32/diskid32.html . I only have an Win32 version at this time. Maybe some day I will add a Win64 version.

Lynn McGuire
  • 161
  • 1
  • 1
  • 5
  • Wow thanks : aaalmost solved my problem. But like you said on your website : "It runs under Windows 9X, Win NT, Win 2K and Win XP (Pro/Home)." and "has occasional problems on Windows XP, Windows 2003 Server and Vista" ... So it look hard to get those hd infos : bravo for your program! Porting it to w7 would be long/hard i guess? 55% of OS are W7 now, so...(for my self i'm in the XP resistance mouvement! ;p ) – user2101247 Mar 03 '13 at 01:24
0

Hard drive serial number and other information about the harddrive like firmware version, etc. can only be obtained using SMART as far as I know and that requires special ioctls to the the block device node (/dev/sda or /dev/sdb) which is usually not available to a regular user.

I know there is a tool called smartctl which does exactly this:

sudo smartctl -i /dev/sda

Similar tools exist (hdparm, lshw, etc.) as well.

As far as trying to figure it out this info without being a privileged user, it might be possible only if it is exposed via /proc or /sys which I highly doubt is being done in the current SATA block device drivers.

Tuxdude
  • 47,485
  • 15
  • 109
  • 110