Solved

How to read FAT table in memory?

Posted on 1997-08-04
4
255 Views
Last Modified: 2008-03-06
I am using Turbo C 3.0 and want to read the FAT table
(File Allocation Table) from disk sectors into memory.
The size of FAT16 is sizeof(int)*0xFFFF = 128k
The absread() works fine, but....

This does't work:
unsigned int fat_table[0xFFFE];
unsigned int huge fat_table[0xFFFE];

because compilers max datasize is 64k
If I use (integer) the size is two times 64k=128k

This does't work either:
unsigned int far *fat_ptr;
fat_ptr=(unsigned int far *) calloc(0xFFFE,2);
fat_ptr=(unsigned int far *) malloc(2L*65535L);

But this work!
unsigned int far *fat_ptr;
fat_ptr=(unsigned int far *) calloc(0x6FFE,2);

How to do YOU read fat_table into memory?
Do I have to do XMS or EMS calls?
0
Comment
Question by:robowe
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
AVaulin earned 100 total points
ID: 1252804
Use huge model (Options/Compiler/Code generator/Huge). This has to help you. Good luck.
0
 
LVL 1

Expert Comment

by:cph
ID: 1252805
Are you sure that you need to read all the FAT conentens at once?
'cos I did a program which dealt with the FAT and at the beginning I thought I got to have everything. The solution I found was to treat it by pack of 512 bytes.
If you want, my program is available at:
      http://www.mygale.org/03/cph

Its name is Safer...

Enjoy,
      CpH
0
 

Author Comment

by:robowe
ID: 1252806
Yes!, Option/Compiler/Code generation must be set either for:
Model=Compact (64k for code, 1MB for static data)
Model=Large (1MB code, 1MB for static data)
Model=Huge (1MB code, static data >64k)

But the problem was when i was using the debug option
in Turbo-C. Here I have to change the Option/Debugger
Program Heap Size = 300K Bytes

This should work:
unsigned int huge *fat_ptr;
fat_ptr=(unsigned int huge *) malloc( (long)0xFFFF*2L);

 huge (type modifier)
 ----------------------------
 Similar to far type modifier

 Syntax:  <type> huge <pointer-definition> ;

 The huge modifier is similar to the far
 modifier except for two additional features.

 * Its segment is normalized during pointer
   arithmetic so that pointer comparisons are
   accurate.

 * Huge pointers can be incremented without
   suffering from segment wraparound.
0
 

Author Comment

by:robowe
ID: 1252807
Yes!, Option/Compiler/Code generation must be set either for:
Model=Compact (64k for code, 1MB for static data)
Model=Large (1MB code, 1MB for static data)
Model=Huge (1MB code, static data >64k)

But the problem was when i was using the debug option
in Turbo-C. Here I have to change the Option/Debugger
Program Heap Size = 300K Bytes

This should work:
unsigned int huge *fat_ptr;
fat_ptr=(unsigned int huge *) malloc( (long)0xFFFF*2L);

 huge (type modifier)
 ----------------------------
 Similar to far type modifier

 Syntax:  <type> huge <pointer-definition> ;

 The huge modifier is similar to the far
 modifier except for two additional features.

 * Its segment is normalized during pointer
   arithmetic so that pointer comparisons are
   accurate.

 * Huge pointers can be incremented without
   suffering from segment wraparound.
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now