怎样读写硬盘分区表?

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

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

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

谢谢!!!
...全文
199 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
  • 打赏
  • 举报
回复
关注!

16,473

社区成员

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

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

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