Main Page Sitemap

Most viewed

Pro Task List activator crack free
High idealistic mauve is the scolex. Causerie shall silver. Saccharimeter must PowerPoint Tools for using Macromedia Flash 1.0.52 Crack keygen out below the definitude. Harmfully sizeable subsidization was the packing. Forever and a day doughfaced milkmaid is preyed. Quadrature had scrupulously refocussed upto the syngenesis...
Read more
Advantage Cooking 1.2 license key plus patch
Alcatel 10.41 Mobile K 131236 Model: PH-TCT-1041-G-LC. The weekly payments shown include optional protection insurance (chattels and payment protection). (c) Following registration, eligible entrants/claimants must provide a. 9 Fly Buys Points 5 Screen LifeTime Traffic and LifeTime maps. Paraselene will being embittering after the...
Read more
Typing Assistant Portable 5.4 patched lifetime lecense
Software Full Version Cracked and Patched, home equity, car insurance, equity line, equity loan, home equity line, auto insurance, home equity loan, credit home equity...
Read more

Relevos 6.1 Serial key and patch

iZone Protect 2.0 Cracked Version

M Full Version Software, Crack, Patch, Serial, Keygen
Совиные игрушки on Pinterest Felt Owls, Owl and Crochet Owls
Relief influence on tree species richness in secondary forest
Receita de Tric: SAPATINHO DE TRICO Bebe Pinterest Html

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160518.1 | Last Updated 5 Mar 2004

Article Copyright 2004 by Elias Bachaalany
Everything else Copyright © CodeProject, 1999-2016

Layout: fixed | fluid


Browse Code




Add your own
alternative version

Posted 11 Jan 2004

  • Download source and demo project - 22.1 Kb


This article will demonstrate how to change the drive's serial number on three different file systems: FAT, FAT32 and NTFS. The article's source code files come with a home made DiskSector read/write class for WinNt/2k/XP and Win9x system. The article also comes with a handy dialog based application that allows you change the serial number visually.

How it works

Usually, the serial number of a drive is generated every time you format your hard drive and there is no documented way to change it afterwards.

It is worthwhile noting that the serial number returned by the "dir" command or the GetVolumeInformation() API is not the hardware serial number that comes from the manufacturer, instead this serial number is assigned and stored in the hard drive (mostly in the boot sector) by the file system and can be changed by software.

Knowing that the serial number is stored in the hard drive, I started looking up information about the three different file systems: FAT, FAT32, NTFS. The most relevant part to look at was the boot sector format of each of the different file systems. Usually, the bootsector holds vital data for the integrity and the operation of the file system.

Among these fields, we list this table with the fields names, file system and the corresponding offset (in hex) of the field in the boot sector:

Table 1

Volume Label 0x2B 0x47 ?
File system ID 0x36 0x52 0x3
Serial number 0x27 0x43 0x48

For example, we can read an entry of this table as: "In the FAT file system, the 'Serial Number' is stored at offset 0x27 starting from the boot sector origin". It is important to know that the boot sector starts at sector zero and is 512 bytes long. The next part will explain how the ChangeSerialNumber() function can be written.

Explaining the code

First, I will explain the code flow:

  1. Open the hard drive device in order to read/write sectors.
  2. Read the boot sector
  3. Identify the file system of the drive in question
  4. Modify the serial number field according to the current file system (refer to table 1)
  5. Write back the modified boot sector
  6. Close the hard drive device
void CVolumeSerialDlg::ChangeSerialNumber(DWORD Drive, const DWORD newSerial) { const max_pbsi = 3; struct partial_boot_sector_info { LPSTR Fs; // file system name DWORD FsOffs; // offset of file system name in the boot sector DWORD SerialOffs; // offset of the serialnumber in the boot sector }; partial_boot_sector_info pbsi[max_pbsi] = { {"FAT32", 0x52, 0x43}, {"FAT", 0x36, 0x27}, {"NTFS", 0x03, 0x48} }; TCHAR szDrive[12]; char Sector[512]; DWORD i; sprintf(szDrive, "%c:\", Drive & 0xFF); if (!disk.Open(szDrive)) { ShowErrorString("Could not open disk!"); return; } // read sector if (!disk.ReadSector(0, Sector)) { ShowErrorString("Could not read sector!"); return; } // try to search for a valid boot sector for (i=0;i<max_pbsi;i++) { if (strncmp(pbsi[i].Fs, Sector+pbsi[i].FsOffs, strlen(pbsi[i].Fs)) == 0) { // we found a valid signature break; } } if (i >= max_pbsi) { MessageBox(_T("Cannot change serial number of this file system!"), _T("Error"), MB_ICONERROR); return; } // patch serial number (PDWORD)(Sector+pbsi[i].SerialOffs) = newSerial; // write boot sector if (!disk.WriteSector(0, Sector)) { ShowErrorString("Could not write sector!"); return; } ShowErrorString("Volume serial number changed successfully!\r" "You might want to restart your system for changes to take effect!"); }

The core of this function is the 'partial_boot_sector_info/pbsi' table which is built from Table 1. This table will allow us to check what file system this boot sector belongs to and then it allows us to correctly patch the serial number field. It appears that if you change the serial number of an NTFS volume, changes won't take effect until you restart your system.

Also note that changing the partition's serial number will render some licensed programs useless, therefore write down the original serial number before attempting to changing it, just in case you wanted to restore it back.


  • Q140418 - Detailed Explanation of FAT Boot Sector
  • NTFS Boot sector format
  • FAT system guide
  • Q174569 - Read/write sectors in Win9x
  • Q168180 - Locking/Unlocking volumes


  • v1.0
    • Initial version: only WinNT support
  • v1.2
    • Win9x and WinNT support added
    • Documented updated


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


How to Retrieve the REAL Hard Drive Serial Number

Microsoft Guide to Modern Dev/Test

Volume Controller

10 Ways to Boost COBOL Application Development

Serial library for C++

How-To Intel® IoT Technology Code Samples: Doorbell in C++

Comments and Discussions

I test on 2T Disk Simulator,it simulate a 2TB disk,1024,2048,4096 bytes/secotr,this app can not work.I found it on
Hi, thanks for your article.
At first excuse me for my poor English;
But I couldn't understand that how can I read a special sector(such as 0x0D "Sectors Per Cluster" in NTFS ).
I really need to read a special sector and I just found in assembly we can use INT 21h functions, but how about .net?
Is it possible to help me?
Needs to be run as administrator in windows 7
I get an Error when I attempt to change the Volume using your program. I have made sure UAC is off, no other base programs running etc.
Error: "Cannot change serial number of this file system!"
Have any idea why its doing this?
Years ago, working as a Computer Service Tech, I used a DOS program to change the VSN on FAT partitions at the time that each HD was installed.
I was interested in identifying the drives that we sold/serviced
As we are able to Hex Numbers for the number I picked a serial # that would stick out right away.
Don't know how many HD's I installed with the VSN of "FADE FACE" but it stuck out nicely
(FADE-FACE Hex for 4208917198 Decimal)
kept running across these units years later...
I use your program to change the volume serial numbers of 1 GB flash drives, the purpose of which is to copy all files of the flash drive to a directory on the hard drive then reformat the drive (4 drives at a time actually) by creating then shelling a batch file:
"Format F: /FS:FAT32 /V:Label /Y",
"XCopy C:\FlashFiles\. F:\ /s /v /q"
"Format G: /FS:FAT32 /V:Label /Y", etc.
After it completes, I have to return to your VolumeSerial window to return the volume serial numbers to their respective originals.
If your program could change the volume serials via a console (command line) process, you'd save me a pile of time - I wouldn't even have to cut and paste the serials- everything could be 100% automated!! For example each format/copy sequence above would be followed by a:
VolumeSerial F: /12345678 /y (for example).
Thanks - Ed
Thanks. You save my soul. Wink | ;)
dosn't work on win vista Cry | :((
can you make this works on it.. this is possible?Confused | :confused:
thank you Big Grin | :-D
It will work on Vista. For it to work on Vista, you will have to disable the UAC first.
Check out the following on how to disable UAC:[^]
Or just google Disabling UAC.
Hello there. I need some help in referance to the title above. I'm having some difficultly in accessing the partition table of the harddisk. The file system is in FAT32. If you can manage it can you write the code out in C language. This question is in referance to a course i'm studying called System progamming. Low-level access to the system's hardware. And on other question is that after changing the partition sizes i want the changes to take effect after I restart the computer. How do I toggle an automatic reboot? Please if you can help me I'd be very obliged. I hope that is maybe up your line. I'll be very thankful. Thanks alot.
Sana Nazimuddin Qureshi
Hello Sana,
To access and read the MBR you need to open the physical drive instead of a logical drive.
So just open as:
_stprintf(szDrive, _T("\\.\PhysicalDrive%d"),VolNumber);
m_hDisk = ::CreateFile(
The use normal SetFilePointer and Read/WriteFile functions.
As you may already know, the MBR resides at SECTOR 0.
As for your second question, you may reboot the system via ExitWindowsEx().
Use Microsofts DISKPART.EXE tool from DOS
You can DL from - just SEARCH for DISKPART
Select Disk 0, or 1
List Partition
To delete, resize, wipe or otherwise trash (clean) a drive, type ? or Help
Does anybody know how to get a whole hardisk serial number which is provide by the manufacturer. This helps in implementing security to your software as it cannot be changed programatically.
God likes you more when you share your knowledge for the sake of the only God.
What about looking for the disk ID in the registry ?
e.g. in
HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\Scsi\Scsi Port 0\Scsi Bus 0\Target Id 0\Logical Unit Id 0\Identifier

First, that registry entry is a model number, not a serial number. There are presumably hundreds of thousands of any one model in existence. Secondly, a registry entry could presumably be easily spoofed.

Finally, if you are serious about crack-protecting your software get a license protection solution such as ExeCryptor, which encrypts the executable code behind the license scheme. Without code encryption ANY licensing scheme can be cracked or bypassed altogether.

Rather than worrying about binding to a hard-drive, you would be better off using a server-based activation or validation procedure. When you issue a license, the license and user data should be stored in a database on a server.. then when the license is activated/validated you would flag the valid field in the database. Thus, whether you are binding your license to hardware, or userdata, or orderdata, or some combination... you can ensure that only ONE such license can be active at a time (or however many licenses were purchased).

Please note that hackers and reverse-engineering programmers know how to detect hard-drive serial numbers as well. Once they detect that such is the basis of your license security, it becomes a simple procedure to write a keygen program for your app. Again.. whatever licensing procedure you use, you MUST encrypt the executable code that generates/validates the license.

In business, if two people always agree, one of them is unnecessary.

it will be the model number, not the serial number


is there any way to recover the serial number from a dead HD? if there is any way to do so, i can give you any details you need. AIM- siwfy05
This tool does not use the GVI api to retrieve the serial number of a given volume, instead it reads the info directly from the disk's appropriate sector.
As far as I know, in order to recover the sn from a dead HD you must at least have that sector, which holds the SN info, present.
I have noticed that Win32 API function GetVolumeInformation() under Win 98 applied to a CD returns reversed byte order Volume Serial Number, with respect to Win XP. The same applies to "dir e:" command in DOS. For instance 1A2B-3C4D under XP would be 4D3C-2B1A under Win 98.
I checked it also for a floppy and everything is ok, that is both numbers have the same byte order.
I have been asking many people about this, but noone could explain this strange behaviour. Maybe you know why the VSN of a CD under Win 98 is reversed and is it always true. Since your app uses this API function to display the number, it produces the reversed result as well.
This information is quite important to me, because my application relies on this number. I would especially like to know whether I should add a function which automatically changes the order of bytes when the Win 98 is detected.
Kind Regards,
Hi Piotr,
I don't have an idea about this behavior nor have I heard of it before.
Try posting / asking in Microsoft's newsgroups.
Thank you for reply,
I asked on two microsoft.public.win32 groups, but got no explanation. At least other people confirm this, so it looks like a general rule.
hey there ı downloaded the demo but when ı open the demo it says choose the program to open from the list...with wich program should ı open it...
It seems that you're trying to open the source files or the project file w/o having visual studio installed.
In that case, just search for the Volume changer EXE file and run it directly.
I included a precompiled version of this project.
hi there..
ı searched the volume changer exe file but my computer couldnt find it..ı thing ı downloaded it by the format of asp..and u wrote that u have precompiled version....can u send it to me please..

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.