is it somehow possible to change hard disk's volume serial number from windows? i know i can read that information using GetVolumeInformation (program like norton system info will do that) but i couldnt find clue how to change it
if this is not possible from win32 then i guess i will have to deal with that from pure dos, but i am not so good with interupts and segment:offset stuff as with win32 apis

please help if you have any info
Posted on 2002-09-14 17:40:28 by Mikky
You can change it by writing into the first sector of the hard disk... you can read it that way, too.

Edit: Under WinNT/2K you can use CreateFile with \\.\C: to open the disk. Under Win9x/ME use DeviceIoControl. Then just use WriteFile / ReadFile :)
Posted on 2002-09-14 17:57:40 by bazik
Hi Mikky,

For DOS very easy,


hddseri label word
dw 0 ; zero
dw 0 ; seri low
dw 0 ; seri high
db 11 dup (0) ; Fat type
db 8 dup (0) ; volume label


push cs
push cs
pop ds
pop es
mov ax,06900h ; get serial/volume
lea dx, hddseri
xor bx,bx
int 21h

mov ax,06901 ; set serial/volume
lea dx,hddseri
xor bx,bx
mov word ptr [hddseri+2],05678h ; serinum high here
mov word ptr [hddseri+4],01234h ; serinum low here
int 21h
int 20h

if you use WinXP change int 20h to:

mov ax,04c00h
int 21h

have nice days,

BTW: sorry source file not included because, i coded with debug.
Posted on 2002-09-14 19:00:33 by CYDONIA
CYDONIA thanks, i thought that i have to exit windows into real dos in order to do such thing but i was wrong :)

bazik, how did u got ur hex editor to show on that memory location? how can i open boot sector for reading/writing?

i am not very familiar with vxd stuff so i couldnt figure out DeviceIoControl() very well
Posted on 2002-09-14 21:30:26 by Mikky
That is the partition serial number.. and can be changed in the ways bazik and CYDONIA told you. The hard disk serial number is another thing (hardware), which is extremely useful and cannot be changed. If you need to read it, I have code to share somewhere, just ask and I'll search for it.
Posted on 2002-09-15 03:51:23 by Maverick
If I remember rightly, the GetFileInformationByHandle() API can get volume serial numbers....
Posted on 2002-09-15 04:19:06 by Fordy

bazik, how did u got ur hex editor to show on that memory location? how can i open boot sector for reading/writing?

i am not very familiar with vxd stuff so i couldnt figure out DeviceIoControl() very well

Under Win2K/NT use CreateFile with "\\.\C:" as file name (look up the CreateFile in your API docs for more info). Then just use ReadFile, WriteFile on that handle.
Dunno if you need to write a VXD for using DeviceIoControl, but I doubt it :/
BTW, the hex editor I use is "Hex Workshop". The best Hex Editor I know ;)
Posted on 2002-09-15 05:31:18 by bazik
Yes please, Maverick.
I'd be much interested in seeing your code to get harddisk(hardware) serial numbers.

I saw some website (which I think also was posted as a reference in past in a similar post) but the way it was done was with a vxd under win9x and another way in NT/2k/XP. I wonder if it's possible to do without using vxd's or external files for that matter but directly from your own code keeping it all in a single program.

Thanks in advance.

// CyberHeg
Posted on 2002-09-16 02:57:22 by CyberHeg
Sorry, but my code is for my own OS and hits the hardware ports directly.

Tell me if you're still interested.
Posted on 2002-09-16 03:03:13 by Maverick
I guess even if I got it then I probably wouldn't be able to use it from windows so it would be of no use for me then.

Maybe you (or others) know some other references about how to obtain this data and maybe other serial numbers like from cd-rom drives.

I'd be interested in any static data which doesn't change when formating your HD or changes Windows version.

Thanks anyway...

// CyberHeg
Posted on 2002-09-16 04:41:19 by CyberHeg
Yes, the HD serial number is static (is the one also reported on the HD physical label).

At the time I worked on this, I saw that there was no way to read it using BIOS (nor DOS, for the matter) services.

I can imagine why you want to read the serial number.. I myself am using this, together with various cards rev numbers and CPU rev and serial number to identify uniquely the hardware of machines I sell (with my own OS and software) for telephonic/ambiental interception, so to protect them from cloning and thus piracy.

I guess under WinNT talking to a driver is the way to go, but under Win9x you may directly talk to the ports, or talk to a VxD.
Posted on 2002-09-16 05:04:24 by Maverick
There are two version first version at the bottom worked on bot win9x and win2k when I tried and It does not need any vxd.
Posted on 2002-09-16 06:23:31 by LaptoniC