Editing Large Disks in Windows 95/98/ME/NT/2000/XP

.

Environment: Windows 95/98/ME/NT/2000/XP

Introduction

In this article, I have concentrated on the FAT file system. All the variations of FAT are being covered, as shown below:

  • FAT -- the 12-bit and 16-bit file systems
  • VFAT -- the FAT with long file names
  • FAT32 -- the latest breed of the file system that is handled, starting from Win95 OSR 2 to Windows XP. NT 4 does not handle the FAT32 file system; however, using the utility that I have provided in this article, it is possible to read even FAT32 in NT.

Int 13h Extensions

Int 13h Extension handling is necessary because in the old BIOS it is not possible to read beyond 8 gigabytes of hard disk space because of register restrictions, which is the mechanism for reading and writing disks. I have handled int 13h extensions in the thunk 16-bit DLL. Certain BIOS interrupts are added and this allows up to two-power 64-bit number of sectors to be accessed. This is way beyond anyone's imagination and can be used for decades without further altering the BIOS. NT internally handles int 13h extensions, so there is no need to handle the extensions separately.

Inside Programming

The utility has been developed using Visual C++ 6 and DDK. It also uses some programs such as THUNK.EXE from Platform SDK for compiling the thunk script. The thunk DLLs can be used without changing them in any programs. There is also a device driver for reading CMOS memory for knowing the number of floppy disks in the system. I used BC++ 3.1 for compiling the 16-bit thunk DLL. The main project uses MFC and was compiled using VC++ 6.

The BootInd at the top should be 0x80 to denote the active partition. For other partitions it should be 0. The SysInd has the following values and meanings:

Value Meaning
#define PART_UNKNOWN 0x00 Unknown
#define PART_DOS2_FAT 0x01 12-bit FAT
#define PART_DOS3_FAT 0x04 16-bit FAT. Partition smaller than 32MB
#define PART_EXTENDED 0x05 Extended MS-DOS Partition
#define PART_DOS4_FAT 0x06 16-bit FAT. Partition larger than or equal to 32MB
#define PART_DOS32 0x0B 32-bit FAT. Partition up to 2047GB
#define PART_DOS32X 0x0C Same as PART_DOS32(0Bh), but uses Logical Block Address Int 13h extensions
#define PART_DOSX13 0x0E Same as PART_DOS4_FAT(06h), but uses Logical Block Address Int 13h extensions
#define PART_DOSX13X 0x0F Same as PART_EXTENDED(05h), but uses Logical Block Address Int 13h extensions

The NTFS currently has a value as 7, but I am not dealing with it in this article.

The Head, Sector, and Cylinder have the values of the start of the partition. Note that these are byte values; hence for disks larger than 8 gigabytes, these values cannot be trusted and only the RelativeSector signifies the right values. The Last values signify the end of the partition. NumberSectors is the number of sectors for a partition belonging to this structure definition. The partitions have been extended to handle many drives in the partition. This is accomplished by the following method: The partition pointing to a Extended partition table, which has the same structure but with an arrangement like linked lists. There must be one Primary partition and an extended partition that has a drive and pointer to another (extended) partition table.

This setup continues until there are no more extended partitions. I have given the deciphering of this setup in the code. Full, working MFC-based source code to the EditDisk is provided online; you can download it from the Windows Developer Magazine Web site. The partition table sector is loaded in the memory using the thunk DLLs if it is Windows 95/98/Me and the CreateFile if it is Windows NT/2000/XP. Note that the disk is loaded in the memory as if the disk were a file using ReadFile in NT. And then it is checked for the various partition types and action is taken accordingly to display it. Then the packet is prepared to point to the child items and initialized accordingly. The other items of the expansion are handled similarly.

Downloads

Download source -- 8 KB



About the Author

Vinoj Kumar

I have been programming for the past 16 years. I started programming in 1990. I came to Windows in 1993. I have authored a book called, "Classic Utilities Using Assembly Language" , 1995. In my free time I listen a lot to Kenny G sax all the albums and Valentine Classics Songs. I like to watch a lot of TinTin adventure Comics. I am currently working in K7 Computing antivirus company (www.k7computing.com) as Senior Technical Lead. My contact is: Phone: +91 944 411 7353

Comments

  • I am looking for Thunk.exe

    Posted by Legacy on 01/15/2004 12:00am

    Originally posted by: G�bor Kov�cs-Dob�k

    My problem is, that I could not find Thunk.exe comiler. Can you help me where can I find it?

    • Platform SDK

      Posted by vinojkumar on 04/20/2004 02:48am

      The Win32 Platform SDK has THUNK.EXE.

      Reply
    Reply
  • steps for compilation

    Posted by Legacy on 11/01/2002 12:00am

    Originally posted by: nitin sinha

    i m using this thunking concept for the first time.. i have been able to make the thunk script and the .asm and .obj file. but i am unable to link the dll's to the .obj files. can anyone please let me know the exact steps right from writing the thunk script. sorry for any silly questions as i am new to this. any help will be appreciated.thanks in advance.

    Reply
  • How can I fill s_partition structure without using the VXD?

    Posted by Legacy on 10/17/2002 12:00am

    Originally posted by: ugluk

    How can I fill the s_partition structure in win9x without using the VXD? The structure is described as following.

    s_partition STRUC
    Part_BootInd DB ?
    Part_FirstHead DB ?
    Part_FirstSector DB ?
    Part_FirstTrack DB ?
    Part_FileSystem DB ?
    Part_LastHead DB ?
    Part_LastSector DB ?
    Part_LastTrack DB ?
    Part_StartSector DD ?
    Part_NumSectors DD ?
    s_partition ENDS

    I am not to familiar with ASM so don't be too hard on me :).
    Thanks.

    Reply
  • vxd source code?

    Posted by Legacy on 10/11/2002 12:00am

    Originally posted by: cosmos

    Excellent work.
    Thank you very much.You have really done a wonderful job.
    i am able to run your program successfully.
    but, I got one problem.
    where ... vxd source code?

    Reply
  • Win 32 Dynamic-Link Library OR MFC AppWizard(dll).

    Posted by Legacy on 08/27/2002 12:00am

    Originally posted by: Davinder pal singh

    for the purpose of making 32 bit dll which option should be selected File->New->Win 32 Dynamic-Link Library or
    File->New->MFC AppWizard(dll).

    thanx.
    Davinder

    Reply
  • You made my day

    Posted by Legacy on 08/07/2002 12:00am

    Originally posted by: Davinder Pal Singh

    Thank you very much.You have really done a wonderful job.
    You have put in lots of labour.After some initial problems,
    i am able to run your program successfully.You have made my day.
    Regards
    Davinder

    Reply
  • Adding one more function causing problem.....

    Posted by Legacy on 07/25/2002 12:00am

    Originally posted by: KVRN Kiran Kumar

    Hi,

    Excellent work. Now, I got one problem. Might be a bit different.

    I tried to add one more function to the code you have given. That is to get the disk parameters (interrupt 13h and service 48h). The moment I add one more function to the thunk script (thk file) and did all the steps, the 32bit dll is denying to load.

    The steps I followed are:

    Added one more function to the .thk file.
    Compiled that file got .asm file.
    Created the .obj files of 16 & 32 bit
    Added that function to the 16 & 32 bit dlls
    Used RC.exe to make the 16bit dll as version 4.0

    If I remove that function from the thunk script (.thk file) it is running properly.

    Any ideas?

    KVRN Kiran Kumar.

    Reply
  • Cannot compile disk32.dll... missing thk32.obj

    Posted by Legacy on 05/28/2002 12:00am

    Originally posted by: Tim

    missing file while compiling ->thk32.obj

    • "Solution"

      Posted by shafkat on 03/06/2005 01:35pm

      i faced the same problem. do the following... first compile the disk.thk file with thunk.exe using the following command thunk -t thk disk.thk -o disk.asm now using ml (you'll find it in MASM) create the obj file using the following command: ml /DIS_32 /c /W3 /nologo /coff /Fo thk32.obj disk.asm Now use this thk32.obj and link it to build disk32.dll now copy disk32.dll,disk16.dll,thk32.obj and disk.vxd in the folder where the win32 exe will reside. now running the program will not cause any problem. Mohammad Shafkat Amin Anik

      Reply
    • where to find thk32.obj

      Posted by klingonprogrammer on 03/29/2004 05:16pm

      This file is part of the Win32 SDK. You need to get that from Microsoft.

      Reply
    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: May 6, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT While you likely have very good reasons for remaining on WinXP after end of support -- an estimated 20-30% of worldwide devices still are -- the bottom line is your security risk is now significant. In the absence of security patches, attackers will certainly turn their attention to this new opportunity. Join Lumension Vice President Paul Zimski in this one-hour webcast to discuss risk and, more importantly, 5 pragmatic risk mitigation techniques …

  • It's time high-level executives and IT compliance officers recognize and acknowledge the danger of malicious insiders, an increased attack surface and the potential for breaches caused by employee error or negligence. See why there is extra emphasis on insider threats.

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds