Solved

How to read FAT table in memory?

Posted on 1997-08-04
4
253 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Goodbye, so long 10 92
Convert image to byte array 8 174
Problem with form project 66 314
libcurl and C++ - Post JSON Data 8 1,080
Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.

747 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

8 Experts available now in Live!

Get 1:1 Help Now