Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to read FAT table in memory?

Posted on 1997-08-04
4
Medium Priority
?
261 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
AVaulin earned 200 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
Suggested Courses

618 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