|
发表于 2016-8-17 15:39:55
|
显示全部楼层
修改卷序列号:- #include
- const $ioctl_lock_volume = 0x90018
- const $ioctl_unlock_volume = 0x9001c
- const $tagdrive_per_sector_data = "ubyte sectordata[512]"
- local $hdrive, $iaccessmask, $pbuffer, $pserial
- local $tbuffer, $tserial, $sdrive = "c:", $bnewserial = 0x11111111
- $iaccessmask = bitor($generic_read, $generic_write)
- $pbuffer = _cm_heap_alloc(512)
- switch drivegetfilesystem($sdrive)
- case "ntfs"
- $pserial = $pbuffer 72
- case "fat32"
- $pserial = $pbuffer 67
- case else
- _cm_heap_free($pbuffer)
- msgbox(48, "error!", $sdrive & " not support.")
- exit
- endswitch
- $hdrive = _cm_create_file("\\." & $sdrive, $iaccessmask, 3, 0, 3, 0)
- _cm_device_io_control($hdrive, $ioctl_lock_volume, 0, 0, 0, 0)
- _cm_read_device($hdrive, $pbuffer, 512)
- _cm_device_io_control($hdrive, $ioctl_unlock_volume, 0, 0, 0, 0)
- _cm_close_handle($hdrive)
- $tbuffer = dllstructcreate($tagdrive_per_sector_data, $pbuffer)
- $tserial = dllstructcreate("hwnd serial", $pserial)
- dllstructsetdata($tserial, "serial", $bnewserial)
- $hdrive = _cm_create_file("\\." & $sdrive, $iaccessmask, 3, 0, 3, 0)
- _cm_device_io_control($hdrive, $ioctl_lock_volume, 0, 0, 0, 0)
- _cm_write_device($hdrive, $pbuffer, 512)
- _cm_device_io_control($hdrive, $ioctl_unlock_volume, 0, 0, 0, 0)
- _cm_close_handle($hdrive)
- msgbox(64, "", "done!")
- if (drivegetfilesystem($sdrive) = "ntfs") then
- msgbox(48, "", "a system reboot is required to update the serial number.")
- endif
- opt("trayiconhide", 1)
- processclose(@autoitpid)
复制代码 |
|