怎样读写硬盘分区表?

greentape 2001-01-10 09:43:00
接到一个任务, 需要为一个软件在它装的目标计算机
上做标记, 为了保护版权.(多少天过期那种的)

我见过有些软件做得特别狠, 硬盘不重新分区的话
就别想再次安装, 使用它. 只是重装os什么的根本不
行.

我怀疑它是在分区表上做了手脚, 用Visual c++
怎样访问分区表? 哪里有相关资料介绍分区表原理
的?

谢谢!!!
...全文
240 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
wang1st 2001-01-10
  • 打赏
  • 举报
回复
如果写在分区表的话,重新格式化删除写入的标记。
wang1st 2001-01-10
  • 打赏
  • 举报
回复
在win95/8中直接读取硬盘有点难度,要么编写vxd,要么使用thunk调用16位的DLL。NT下直接用DeviceIoControl可以解决。
我做过一个共享软件就是用了这个技术,不过写硬盘一定要小心。注意NT,lilo,BootMagic等程序会在硬盘的第一柱第一面除第一扇的其他地方写入的信息(有些为硬盘分区表的备分),不要冲掉这些数据,否则用户可能不能启动计算机。
关于使用thunk技术,可以查看MSDN上Article ID: Q137176 的文章,这篇文章说明了为什么在9x下DeviceIoControl失效的问题。
Kevin_qing 2001-01-10
  • 打赏
  • 举报
回复
DOS下是用int 13h来访问分区表的。win9x对此有限制。
另外现在打多用的是fat32了,所以不建议在fat上面动手脚,不过可以将你的信息写在启动区的空白处。

资料:

The File Allocation Table of contents of a computer disk which tells what sectors are used for what file. The File Allocation Table (also know as FAT), is located in the first 63 sectors of a bootable disk (floppy or hard). You visually cannot see this. The FAT follows the boot sector.

The FAT file system revolves around the File Allocation Table for which it is named. Each logical volume has its own FAT, which serves two important functions: it contains the allocation information for each file on the volume in the form of linked lists of allocation units and it indicates which allocation units are free for assignment to a file that is being created or extended.

The File Allocation Table (FAT) was designed and coded in Feb., 1976 by a kid named Bill Gates during a five day stay at the Hilton Hotel in Albuquerque. He developed it for a version of Basic that could store programs and data on floppy disks. The FAT design was incorporated by Tim Patterson in an early version of an operating system for the Intel 8086 chip. Gates bought the rights to the system, then rewrote it to create the first version of DOS. As a direct result, Gates is the richest man in America.

The FAT file system is simple and reliable. It does not lose data because the computer crashed in the middle of an update. It does not use a lot of memory. It does, however, do a lot of extra administrative I/O to different areas of the partition. The directory is allocated at the start of the partition and it contains the table of free space. To write a new data set, or to add data to an old one, the disk arm must be constantly moved between the location of the directory and the place where the data is being written. Without optimization, a file can end up fragmented into many small pieces.

When the system crashes, no data is lost. However, a FAT system may have removed disk area from the chain of free space, but may not have yet assigned it to any permanent new data set. The CHKDSK or SCANDISK utility examines the FAT table to determine the status of every record on disk. The records which are not part of any data set may be returned to the free space chain.

After CHKDSK finds unallocated sectors, it asks you whether they should be turned into files. If you were in the middle of creating a new file and the system crashed, and the data that was lost is extremely valuable, you might answer Yes. If you do answer Yes you can scan the recovered file scraps for the information you lost. Otherwise, answer No and the unallocated space will be recycled as free space.

If the FAT table (Table 1) becomes corrupted, or what is known as disk errors, there is a second (backup) table (Table 2) available for programs like Scandisk uses to fix the FAT (Table 1). A corrupt FAT can cause you to get the message "No Bootable Media". At this point if Scandisk cannot fix it you will need to format and start over. It is recommended that you Low Level Format and reinstall Windows. If the Windows Setup program complains about the drive, replace the drive with a new one.

By design FAT supports a maximum of 64K allocation units. When the disk partition is 32 megabytes or less, an allocation unit is a 512 byte sector. However, as the disk gets larger, the units get larger. A 64 megabyte disk partition has 1K allocation units. A 128 meg partition has 2K units. A 256 meg partition has 4K allocation units. Each file occupies one or more allocation unit. As the allocation units get larger, any large number of small files wastes a lot of disk space.

The classical FAT directory structure (before NT and Windows 95) limits file names to eight characters with a three character extension (as in the name "AUTOEXEC.BAT"). This 8.3 naming convention was borrowed from earlier DEC minicomputers. The FAT structure also maintains for each file a set of attributes (is it a System data set, should it be Hidden in the DIR display, should it be Archived next time the disk is backed up, is it Read-only). There is also a data and time stamp when the file was last changed.

OS/2 allows a FAT file to have additional Extended Attributes. Since there is no room for these attributes in the FAT directory, OS/2 creates a separate hidden file on the disk volume named "EA DATA. SF" and stores the information there.

FAT has been around for a long time, so its problems have been carefully studied. Every version of DOS and Windows (except NT) comes with a DEFRAG program that will reorganize the directory, files, and free space to maximize performance. Effective use of RAM as a disk cache can address some of the I/O problems. Our QikFix program has a Memory Utilization program to help optimize the swap file and a Cache utility to optimize the disk cache.


yx718 2001-01-10
  • 打赏
  • 举报
回复
关注!
DiskGenius是一款硬盘分区及数据恢复软件。它是在最初的DOS版的基础上开发而成的。Windows版本的DiskGenius软件,除了继承并增强了DOS版的大部分功能外(少部分没有实现的功能将会陆续加入),还增加了许多新的功能。如:已删除文件恢复、分区复制、分区备份、硬盘复制等功能。另外还增加了对VMWare虚拟硬盘的支持。更多功能正在制作并在不断完善中。另外,应广大用户的要求,新的DOS版本也在制作当中,不久即将发布。 DiskGenius软件的主要功能及特点如下:   1、支持传统的MBR分区表格式及较新的GUID分区表格式。   2、支持基本的分区建立、删除、隐藏等操作。可指定详细的分区参数;   3、支持IDE、SCSI、SATA等各种类型的硬盘。支持U盘、USB硬盘、存储卡(闪存卡);   4、支持FAT12、FAT16、FAT32、NTFS文件系统;   5、支持EXT2/EXT3文件系统的文件读取操作。支持Linux LVM2磁盘管理方式;   6、可以快速格式化FAT12、FAT16、FAT32、NTFS分区。格式化时可设定簇大小、支持NTFS文件系统的压缩属性;   7、可浏览包括隐藏分区在内的任意分区内的任意文件,包括通过正常方法不能访问的文件。可通过直接读写磁盘扇区的方式读写文件、强制删除文件;   8、支持盘符的分配及删除;   9、支持FAT12、FAT16、FAT32、NTFS分区的已删除文件恢复、分区误格式化后的文件恢复。成功率较高;   10、增强的已丢失分区恢复(重建分区表)功能,恢复过程中,可即时显示搜索到的分区参数及分区内的文件。搜索完成后,可在不保存分区表的情况下恢复分区内的文件;   11、提供分区表的备份与恢复功能;   12、可将整个分区备份到一个镜像文件中,可在必要时(如分区损坏)恢复。支持在Windows运行状态下备份系统盘;   13、支持分区复制操作。并提供“全部复制”、“按结构复制”、“按文件复制”等三种复制方式,以满足不同需求;   14、支持硬盘复制功能。同样提供与分区复制相同的三种复制方式;   15、支持VMWare虚拟硬盘文件(“.vmdk”文件)。打开虚拟硬盘文件后,即可像操作普通硬盘一样操作虚拟硬盘;   16、可在不启动VMWare虚拟机的情况下从虚拟硬盘复制文件、恢复虚拟硬盘内的已删除文件(包括格式化后的文件恢复)、向虚拟硬盘复制文件等;   17、支持 ".img" ".ima" 磁盘及分区映像文件的制作及读写操作;   18、支持USB-FDD、USB-ZIP模式启动盘的制作及其文件操作功能;   19、支持磁盘坏道检测与修复功能。

16,551

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧