volumeSerialNumber

package module
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 16, 2024 License: MIT Imports: 5 Imported by: 0

README

Volume serial number

This package provides many functions, but most important are GetVolumeSerialNumber and SetVolumeSerialNumber. These functions use uint64 for storing serial number. If serial number is 4 bytes long then it uses only 4 low bytes of uint64. Serial number contains parsed value in native byte order. To print it in often used format use binary.Write with binary.BigEndian byte order. Checkout source code for more explanations.

Supported file systems

  • FAT12
  • FAT16
  • FAT32
  • exFAT
  • NTFS

Supported OS

Windows

Tested on XP 32 bit and Windows 10 32 and 64 bit.

[!Warning] To use these functions drive name must be in format \\\\.\\C: (this is escaped string).

Linux

Must be supported if you can somehow get right drive path without offset (with access to FAT/exFAT/NTFS's Boot Sector'). No OS specific functions were used — only os.Read, os.File.Seek and os.File.Write for disk manipulations. But untested.

Documentation

Index

Constants

View Source
const (
	FAT_TYPE_UNKNOWN = iota
	FAT_TYPE_FAT12   = iota
	FAT_TYPE_FAT16   = iota
	FAT_TYPE_FAT32   = iota
	FAT_TYPE_EXFAT   = iota
)
View Source
const (
	FILE_SYSTEM_NTFS  = iota
	FILE_SYSTEM_FAT12 = FAT_TYPE_FAT12
	FILE_SYSTEM_FAT16 = FAT_TYPE_FAT16
	FILE_SYSTEM_FAT32 = FAT_TYPE_FAT32
	FILE_SYSTEM_EXFAT = FAT_TYPE_EXFAT
)

Variables

This section is empty.

Functions

func GetFileSystem

func GetFileSystem(firstDiskSector []byte) (file_system int, err error)

func GetVolumeSerialNumber

func GetVolumeSerialNumber(drive string) (volume_sn uint64, err error)

func GetVolumeSerialNumberAddr

func GetVolumeSerialNumberAddr(firstDiskSector []byte) (addr int64, err error)

func GetVolumeSerialNumberSize

func GetVolumeSerialNumberSize(firstDiskSector []byte) (size int64, err error)

func ReadDriveSector

func ReadDriveSector(
	drive string,
	offset int64,
	sectorSize uint64,
) (result []byte, err error)

func SetVolumeSerialNumber

func SetVolumeSerialNumber(drive string, volume_sn uint64) (err error)

func WriteDriveSector

func WriteDriveSector(drive string, offset int64, sector []byte) (err error)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL