ftp.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2011/03/03/04:45:07

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: "Rod Pemberton" <do_not_have AT notreplytome DOT cmm>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: csdpmi7 not working on virtualbox, how use dosmemget with seg ofs from int21h?
Date: Thu, 3 Mar 2011 04:30:30 -0500
Organization: Aioe.org NNTP Server
Lines: 99
Message-ID: <iknmse$1jl$1@speranza.aioe.org>
References: <39cdc18e-eccb-4213-b896-db3be020702e AT w9g2000prg DOT googlegroups DOT com>
NNTP-Posting-Host: sg0uvLzlDfZOqmCSVnJXCA.user.speranza.aioe.org
X-Complaints-To: abuse AT aioe DOT org
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.2001
X-Notice: Filtered by postfilter v. 0.8.2
X-Newsreader: Microsoft Outlook Express 6.00.2800.2001
X-Priority: 3
X-MSMail-Priority: Normal
Bytes: 4484
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

"Jim Michaels" <jmichae3 AT yahoo DOT com> wrote in message
news:39cdc18e-eccb-4213-b896-db3be020702e AT w9g2000prg DOT googlegroups DOT com...
>
> I am doing an int 21h function 7303h disk free space call, and I need
> to pass a structure to this function and when the function finishes,
> it returns a similar structure back, but with different data filled
> in.
> [...]
> the addresses of the structures in real mode memory in question are in
> segment offset format coming from and going into int21h function 7303h
> (a DOS FAT32 function) at es:di and I need a C string at ds:dx, and I
> need to get at whatever is coming back from es:di.
>
> any detailed clues/code as to how I should deal with that?
>

First, lets clean up your struct:

> typedef struct extFAT32FreeSpaceStructure {
> /* 00h WORD*/uint16_t ret_size_of_returned_structure
> __attribute__((packed));
> /* 02h WORD*/uint16_t
> call_structure_version_ret_actual_structure_version
> __attribute__((packed));// (0000h)
> /* 04h DWORD*/uint32_t
> number_of_sectors_per_cluster_with_adjustment_for_compression
> __attribute__((packed));
> /* 08h DWORD*/uint32_t number_of_bytes_per_sector
> __attribute__((packed));
> /* 0Ch DWORD*/uint32_t number_of_available_clusters
> __attribute__((packed));
> /* 10h DWORD*/uint32_t total_number_of_clusters_on_the_drive
> __attribute__((packed));
> /* 14h DWORD*/uint32_t
>
number_of_physical_sectors_available_on_the_drive_without_adjustment_for_com
pression
> __attribute__((packed));
> /* 18h DWORD*/uint32_t
>
total_number_of_physical_sectors_on_the_drive_without_adjustment_for_compres
sion
> __attribute__((packed));
> /* 1Ch DWORD*/uint32_t
> number_of_available_allocation_units_without_adjustment_for_compression
> __attribute__((packed));
> /* 20h DWORD*/uint32_t
> total_allocation_units_without_adjustment_for_compression
> __attribute__((packed));
> /* 24h  8 BYTEs*/uint64_t reserved __attribute__((packed));
> } extFAT32FreeSpaceStructure;
>

#ifdef __DJGPP__
#define HANDLE_PRAGMA_PACK_PUSH_POP 1
#endif

#pragma pack(push,1)

typedef struct extFAT32FreeSpaceStructure {
  uint16_t ret_size_of_returned_structure;
  uint16_t call_structure_version_ret_actual_structure_version;
  uint32_t number_of_sectors_per_cluster_with_adjustment_for_compression;
  uint32_t number_of_bytes_per_sector;
  uint32_t number_of_available_clusters;
  uint32_t total_number_of_clusters_on_the_drive;
  uint32_t
number_of_physical_sectors_available_on_the_drive_without_adjustment_for_com
pression;
  uint32_t
total_number_of_physical_sectors_on_the_drive_without_adjustment_for_compres
sion;
  uint32_t
number_of_available_allocation_units_without_adjustment_for_compression;
  uint32_t total_allocation_units_without_adjustment_for_compression;
  uint8_t[8] reserved;
} extFAT32FreeSpaceStructure;

#pragma pack(pop)

Some of those wrapped in posting.  That cleans up the
"__attribute__((packed))" and allows it to compile with other compilers that
support "#pragma pack()", e.g., OpenWatcom.  Personally, I would shorten
those names to something reasonable and meaninful in case you have to use
them, e.g., "sectors_per_cluster" instead of
"number_of_sectors_per_cluster_with_adjustment_for_compression".  If you
don't want to depend on stdint.h, you'll also need #define's, like in
stdint.h for the uintXX_t types.  Note that I used uint8_t array instead of
uint64_t.  You could also use uint32_t[2].  Personally, I would avoid
anything over 32-bits on a 32-bit compiler.

I'll send more posts for replies to other questions. 1 of 3.


Rod Pemberton




- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019