| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | read from cd rom |
NH> can anybody tell me how to read a sector from cd rom ?
Rather than debug your code, I'll give you some of mine that has worked for me:
#include
#include
#include
#define INCL_DOS
#define INCL_DOSDEVIOCTL
#define INCL_NOPMAPI
#include
//#include "y:/cdioctl.h"
#pragma pack(1)
/*------------------------------------------------*
* Cat 0x80, Func 0x72: Read Long *
*------------------------------------------------*/
struct ReadLong {
ULONG ID_code;
UCHAR address_mode;
USHORT transfer_count;
ULONG start_sector;
UCHAR reserved;
UCHAR interleave_size;
UCHAR interleave_skip_factor;
};
#pragma pack()
HFILE opendrive(char *drstr, char mode)
{
HFILE fh;
ULONG usAction, stat;
ULONG open_mode;
ULONG bCmd;
open_mode = OPEN_FLAGS_DASD | OPEN_SHARE_DENYREADWRITE
| OPEN_FLAGS_WRITE_THROUGH | OPEN_FLAGS_FAIL_ON_ERROR
| OPEN_FLAGS_NOINHERIT;
if(mode == 'w')
open_mode |= OPEN_ACCESS_READWRITE;
stat = DosOpen(drstr, /* filename to open */
&fh, /* address of file handle */
&usAction, /* address to store action taken */
0L, /* size of new file */
0, /* file's attribute */
FILE_OPEN, /* action to take if file exists */
open_mode, /* file's open mode */
0L); /* Reserved */
if(stat){
switch(stat){
case 15:
printf("Drive %s is invalid.\n", drstr);
break;
case 21:
printf("Drive %s is not ready.\n", drstr);
break;
case 32:
printf("Drive %s is currently locked by another
process.\n", drstr);
break;
case 65:
printf("Drive %s is a network drive.\n", drstr);
break;
default:
printf("error %d opening drive %s\n", stat, drstr);
}
exit(3);
}
#if 0
bCmd = 0;
stat = DosDevIOCtl(0L, &bCmd, DSK_LOCKDRIVE, IOCTL_DISK, fh);
if(stat){
printf("Error %d locking drive\n", stat);
exit(3);
}
#endif
return(fh);
}
void dump(char *buf, int b)
{
int i;
#if 1
for(i=0; i128 || isprint(buf[i]))
putchar(buf[i]);
else
putchar('.');
}
#endif
}
int main(void)
{
HFILE hf;
static char buf[6000];
APIRET rc;
struct ReadLong rl;
ULONG ulPinout, ulDinout;
memset(buf, 1, sizeof(buf));
hf = opendrive("J:", 'r');
ulPinout = sizeof(rl);
ulDinout = sizeof(buf);
rl.ID_code = 0x31304443L; // "CD01"
rl.address_mode = 0;
rl.transfer_count = 2;
rl.start_sector = 1000;
rl.reserved = 0;
rl.interleave_size = 0;
rl.interleave_skip_factor = 0;
rc = DosDevIOCtl(hf,
IOCTL_CDROMDISK,
CDROMDISK_READLONG,
&rl, sizeof(rl), &ulPinout, /* parms */
buf, sizeof(buf), &ulDinout); /* data */
if(rc)
printf("sys%04u: IOCD_READ_LONG error\n", rc);
else
dump(buf, 3000);
exit(0);
}
--- Maximus/2 3.00
* Origin: Sol 3 * Toronto * V.32 * (905)858-8488 (1:259/414)SEEN-BY: 270/101 620/243 711/401 409 410 413 430 808 809 934 955 712/407 515 SEEN-BY: 712/517 628 713/888 800/1 7877/2809 @PATH: 259/414 400 99 250/99 3615/50 396/1 270/101 712/515 711/808 809 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.