Exemplo n.º 1
0
s32 CALLBACK CDVDreadTrack(u32 lsn, int mode)
{
	int retval;
	if (isofile == NULL)  return (-1);
	if (deviceopencount > 0) {
		deviceopencount--;
		return (-1);
	} // ENDIF- Simulate a temporarily open device?
#ifdef VERBOSE_FUNCTION_INTERFACE
	PrintLog("CDVDiso interface: CDVDreadTrack(%u)", lsn);
#endif /* VERBOSE_FUNCTION_INTERFACE */
	retval = IsoFileSeek(isofile, (off64_t) lsn);
	if (retval != 0) {
#ifdef VERBOSE_FUNCTION_INTERFACE
		PrintLog("CDVDiso interface:   Trouble finding the sector!");
#endif /* VERBOSE_FUNCTION_INTERFACE */
		return (-1);
	} // ENDIF- Trouble finding the sector?
	retval = IsoFileRead(isofile, isobuffer);
	if (retval != 0) {
#ifdef VERBOSE_FUNCTION_INTERFACE
		PrintLog("CDVDiso interface:   Trouble reading the sector!");
#endif /* VERBOSE_FUNCTION_INTERFACE */
		return (-1);
	} // ENDIF- Trouble finding the sector?
	isomode = mode;
	return (0);
} // END CDVDreadTrack()
Exemplo n.º 2
0
s32 CALLBACK CDVDctrlTrayOpen() {
  HWND lastwindow;
  int i;
  int retval;

#ifdef VERBOSE_FUNCTION_INTERFACE
  PrintLog("CDVDiso interface: CDVDctrlTrayOpen()");
#endif /* VERBOSE_FUNCTION_INTERFACE */
  // CDVDclose();
  isofile = IsoFileClose(isofile);
  deviceopencount = 50;

  // CDVDopen();
  lastwindow = GetActiveWindow();
  LoadConf();
  if((conf.isoname[0] == 0) || (conf.isoname[0] == '[') ||
     ((conf.restartconfigure == 1) && (deviceopencount > 0))) {
    DialogBox(progmodule,
              MAKEINTRESOURCE(DLG_0200),
              lastwindow,
              (DLGPROC)MainBoxCallback);
    SetActiveWindow(lastwindow);
    LoadConf();
    // Blank out the name in config file afterwards? Seems excessive.
  } // ENDIF- Haven't initialized the configure program yet? Do so now.
  lastwindow = NULL;
  deviceopencount = 0; // Temp line!
  // NOTE: What happened to repetitive polling when disc not in drive?

  isofile = IsoFileOpenForRead(conf.isoname);
  if(isofile == NULL) {
#ifdef VERBOSE_FUNCTION_INTERFACE
    PrintLog("CDVDiso interface:   Failed to open ISO file!");
#endif /* VERBOSE_FUNCTION_INTERFACE */
    // return(-1); // Removed to simulate disc not in drive.
    for(i = 0; i < 2048; i++)  isocdcheck[i] = 0;
    return(0);
  } // ENDIF- Trouble opening file? Abort.

  retval = IsoFileSeek(isofile, 16);
  if(retval != 0)  return(-1);
  retval = IsoFileRead(isofile, isobuffer);
  if(retval != 0)  return(-1);

  if(deviceopencount > 0) {
    i = 0;
    while((i < 2048) && (isocdcheck[i] == isobuffer[i]))  i++;
    if(i == 2048)  deviceopencount = 0; // Same CD/DVD? No delay.
  } // ENDIF- Is this a restart? Check for disc change.

  for(i = 0; i < 2048; i++)  isocdcheck[i] = isobuffer[i];

  return(0);
} // END CDVDctrlTrayOpen()
Exemplo n.º 3
0
s32 CALLBACK CDVDopen(const char* pTitleFilename)
{
	int retval;
	int i;
#ifdef VERBOSE_FUNCTION_INTERFACE
	PrintLog("CDVDiso interface: CDVDopen()");
#endif /* VERBOSE_FUNCTION_INTERFACE */
	LoadConf();
	if (pTitleFilename != NULL) strcpy(conf.isoname, pTitleFilename);
	if ((conf.isoname[0] == 0) ||
	    ((conf.startconfigure != 0) && (deviceopencount == 0)) ||
	    ((conf.restartconfigure != 0) && (deviceopencount > 0))) {
		ExecCfg("configure");
		LoadConf();
	} // ENDIF- Haven't initialized the configure program yet? Do so now.
	isofile = IsoFileOpenForRead(conf.isoname);
	if (isofile == NULL) {
#ifdef VERBOSE_FUNCTION_INTERFACE
		PrintLog("CDVDiso interface:   Failed to open ISO file!");
#endif /* VERBOSE_FUNCTION_INTERFACE */
		// return(-1); // Taken out for "NULL" device simulation
		for (i = 0; i < 2048; i++)  isocdcheck[i] = 0;
		return (0);
	} // ENDIF- Trouble opening file? Abort.
	retval = IsoFileSeek(isofile, 16);
	if (retval != 0)  return (-1);
	retval = IsoFileRead(isofile, isobuffer);
	if (retval != 0)  return (-1);
	if (deviceopencount > 0) {
		i = 0;
		while ((i < 2048) && (isocdcheck[i] == isobuffer[i]))  i++;
		if (i == 2048)  deviceopencount = 0; // Same CD/DVD? No delay.
	} // ENDIF- Is this a restart? Check for disc change.
	for (i = 0; i < 2048; i++)  isocdcheck[i] = isobuffer[i];
	return (0);
} // END CDVDopen()
Exemplo n.º 4
0
// External functions
struct IsoFile *IsoFileOpenForRead(const char *filename)
{
	struct IsoFile *newfile;
	int retval;
	int i;
	char tempblock[2448];
	struct tocTN toctn;
	struct tocTD toctd;
//   union {
//     struct ECMA119PrimaryVolume vol;
//     char ch[sizeof(struct ECMA119PrimaryVolume)];
//   } *volcheck;
	union
	{
		struct ECMA119PrimaryVolume *vol;
		char *ch;
	} volcheck;
	newfile = NULL;
	if (filename == NULL)  return(NULL);
#ifdef VERBOSE_FUNCTION_ISOFILE
	PrintLog("CDVD isofile: IsoFileOpenForRead(%s)", filename);
#endif /* VERBOSE_FUNCTION_ISOFILE */
	newfile = (struct IsoFile *) malloc(sizeof(struct IsoFile));
	if (newfile == NULL)  return(NULL);

	newfile->sectorpos = 0;
	newfile->openforread = 1; // Read-only ISO
	newfile->filebytepos = 0;
	newfile->filesectorpos = 0;
	newfile->blocksize = 0; // Flags as non-detected yet (Compress vs. Image)
	newfile->tabledata = NULL;
	newfile->namepos = 0;
	while ((newfile->namepos < 255) &&
	        (*(filename + newfile->namepos) != 0))
	{
		newfile->name[newfile->namepos] = *(filename + newfile->namepos);
		newfile->namepos++;
	} // ENDWHILE- copying the file name in...
	newfile->name[newfile->namepos] = 0; // And 0-terminate.
	IsoNameStripExt(newfile); // Ex: -I00.Z[.bin]
	// File Compression name detection
	newfile->compress = IsoNameStripCompress(newfile); // Ex: -I00.bin[.Z]
	newfile->compresspos = newfile->namepos;
	// Test File name compression
	retval = -1;
	if (newfile->compress > 0)
	{
		retval = CompressOpenForRead(newfile);
		if (retval == -1)  CompressClose(newfile);
	} // ENDIF- Have a compression type hint? Test it out

	if (retval == -1)
	{
		newfile->compress = 5;
		while ((newfile->compress > 0) && (retval == -1))
		{
			retval = CompressOpenForRead(newfile);
			if (retval == -1)
			{
				CompressClose(newfile);
				newfile->compress--;
			} // ENDIF- Failed to open? Close it... and try the next one.
		} // ENDWHILE- Trying to find a compression scheme that will work...

		if (newfile->compress == 0)
		{
			newfile->handle = ActualFileOpenForRead(newfile->name);
			if (newfile->handle == ACTUALHANDLENULL)
			{
				free(newfile);
				newfile = NULL;
				return(NULL);
			} // ENDIF- Failed to open? Abort.
			newfile->filebytesize = ActualFileSize(newfile->handle);
		} // ENDIF- No compression? Open it uncompressed.
	} // ENDIF- Temp- failed to open? Abort...
	// Compressed data file with no table? Return prematurely...
	// Condition detection: compress > 0, tablehandle == ACTUALHANDLENULL
	if (retval == -2)
	{
#ifdef VERBOSE_FUNCTION_ISOFILE
		PrintLog("CDVD isofile:   Data file with no table!");
#endif /* VERBOSE_FUNCTION_ISOFILE */
		return(newfile);
	} // ENDIF-

	newfile->imagetype = DetectImageType(newfile);

	if (newfile->compress == 0)
	{
		newfile->filesectorsize = newfile->filebytesize / newfile->blocksize;
	} // ENDIF- Now that blocksize is known, raw file sectors can be figured out

	IsoNameStripExt(newfile); // Ex: -I00[.bin].Z

	IsoNameStripMulti(newfile); // Ex: [-I00].bin.Z

#ifdef VERBOSE_DISC_INFO
	PrintLog("CDVD isofile:   Filename: %s", filename);
	if (newfile->multi > 0)  PrintLog("CDVD isofile:   Multiple <2GB files.");
	PrintLog("CDVD isofile:   Compression Method: %s",
	         compressdesc[newfile->compress]);
	PrintLog("CDVD isofile:   Image Type: %s",
	         newfile->imagename);
	PrintLog("CDVD isofile:   Block Size: %lli", newfile->blocksize);
	PrintLog("CDVD isofile:   Total Sectors (of first file): %lli",
	         newfile->filesectorsize);
#endif /* VERBOSE_DISC_INFO */

	// Load a TOC from a .toc file (is there is one)
	retval = IsoLoadTOC(newfile);
	if (retval == 0)  return(newfile);

	// Get the volume sector for disc type test
	retval = IsoFileSeek(newfile, 16);
	if (retval < 0)
	{
		newfile = IsoFileClose(newfile);
		return(NULL);
	} // ENDIF- Could not find the directory sector? Abort.
	retval = IsoFileRead(newfile, tempblock);
	if (retval < 0)
	{
		newfile = IsoFileClose(newfile);
		return(NULL);
	} // ENDIF- Could not read the directory sector? Abort.

	volcheck.ch = tempblock;
	volcheck.ch += newfile->blockoffset;
	if (ValidateECMA119PrimaryVolume(volcheck.vol) != 0)
	{
#ifdef VERBOSE_DISC_INFO
		PrintLog("CDVD isofile:   Not an ISO9660 disc! Music CD perhaps?");
#endif /* VERBOSE_DISC_INFO */
		newfile->cdvdtype = CDVD_TYPE_CDDA;

	}
	else
	{
		// Is this a playstation image?
		i = 0;
		while ((*(playstationid + i) != 0) &&
		        (*(playstationid + i) == tempblock[newfile->blockoffset + 8 + i]))  i++;
		if (*(playstationid + i) != 0)
		{
#ifdef VERBOSE_DISC_INFO
			PrintLog("CDVD isofile:   Not a Playstation Disc!");
#endif /* VERBOSE_DISC_INFO */
			newfile->cdvdtype = CDVD_TYPE_DVDV;
		}
		else
		{
			newfile->cdvdtype = CDVD_TYPE_PS2DVD;
		} // ENDIF- Is this not a Playstation 1 image?
		// Sidenote: if the emulator is just playing Playstation 2 images, we could
		// just invalidate the image file right here.
	} // ENDIF- Not an ISO9660 disc? Assume Music CD.
	if (newfile->cdvdtype == CDVD_TYPE_PS2DVD)
	{
		// Is this a Playstation CD image?
		i = 0;
		while ((*(cdname + i) != 0) &&
		        (*(cdname + i) == tempblock[newfile->blockoffset + 1024 + i]))  i++;
		if (*(cdname + i) == 0)
		{
			newfile->cdvdtype = CDVD_TYPE_PSCD;
#ifdef VERBOSE_DISC_INFO
			PrintLog("CDVD isofile:   Image is a Playstation 1 CD.");
#endif /* VERBOSE_DISC_INFO */
		}
		else
		{
			if (newfile->blocksize != 2048)
			{
				newfile->cdvdtype = CDVD_TYPE_PS2CD;
#ifdef VERBOSE_DISC_INFO
				PrintLog("CDVD isofile:   Image is a Playstation 2 CD.");
#endif /* VERBOSE_DISC_INFO */
			}
			else
			{
#ifdef VERBOSE_DISC_INFO
				PrintLog("CDVD isofile:   Image is a DVD.");
#endif /* VERBOSE_DISC_INFO */
			} // ENDIF- Is the blocksize not 2048? CD image then.
		} // ENDIF- Is this a PS1 CD image?
	} // ENDIF- Is this a Playstation image?
	volcheck.ch = NULL;

	if ((newfile->cdvdtype == CDVD_TYPE_DVDV) &&
	        (newfile->blocksize == 2352))  newfile->cdvdtype = CDVD_TYPE_CDDA;
	// Slap together a TOC based on the above guesswork.
	IsoInitTOC(newfile);
	if ((newfile->cdvdtype != CDVD_TYPE_PS2DVD) &&
	        (newfile->cdvdtype != CDVD_TYPE_DVDV))
	{
		toctn.strack = 1;
		toctn.etrack = 1;
		IsoAddTNToTOC(newfile, toctn);
		toctd.type = 0;
		toctd.lsn = newfile->filesectorsize;
		IsoAddTDToTOC(newfile, 0xAA, toctd);
		toctd.type = 0; // ?
		if (newfile->cdvdtype == CDVD_TYPE_CDDA)
		{
			toctd.type = CDVD_AUDIO_TRACK; // Music track assumed
		}
		else
		{
			toctd.type = CDVD_MODE1_TRACK; // Data track assumed
		} // ENDIF- Is this track a music or data track?
		toctd.lsn = 0;
		IsoAddTDToTOC(newfile, 1, toctd);
	} // ENDIF- Is this a CD? Single track for all sectors
	return(newfile);
} // END IsoFileOpenForRead()
Exemplo n.º 5
0
gint ConversionBoxOKEvent(GtkWidget *widget, GdkEvent event, gpointer data)
{
	char templine[256];
	char tempblock[2352];
	const char *filename;
	int compressmethod;
	int multi;
	struct IsoFile *fromfile;
	struct IsoFile *tofile;
	int i;
	off64_t endsector;
	int stop;
	int retval;

	ConversionBoxUnfocus();

	filename = gtk_entry_get_text(GTK_ENTRY(conversionbox.file));
	if (IsIsoFile(filename) < 0)
	{
		filename = NULL;
		MessageBoxShow("Not a valid file", 3);
		return(TRUE);
	} // ENDIF- Not an Iso File? Stop early.

	compressmethod = gtk_combo_box_get_active(GTK_COMBO_BOX(conversionbox.compress));
	if (compressmethod > 0)  compressmethod += 2;
	multi = 0;
	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(conversionbox.multi)) == TRUE)
		multi = 1;

	fromfile = NULL;
	fromfile = IsoFileOpenForRead(filename);
	if (fromfile == NULL)
	{
		filename = NULL;
		MessageBoxShow("Cannot opening the source file", 3);
		return(TRUE);
	} // ENDIF- Not an Iso File? Stop early.

	if ((compressmethod == fromfile->compress) &&
	        (multi == fromfile->multi))
	{
		fromfile = IsoFileClose(fromfile);
		filename = NULL;
		MessageBoxShow("Compress/Multifile methods match - no need to convert", 3);
		return(TRUE);
	} // ENDIF- Not an Iso File? Stop early.

	tofile = IsoFileOpenForWrite(filename,
	                             GetImageTypeConvertTo(fromfile->imagetype),
	                             multi,
	                             compressmethod);
	if (tofile == NULL)
	{
		fromfile = IsoFileClose(fromfile);
		filename = NULL;
		MessageBoxShow("Cannot create the new file", 3);
		return(TRUE);
	} // ENDIF- Not an Iso File? Stop early.

	if (fromfile->multi == 1)
	{
		i = 0;
		while ((i < 10) &&
		        (IsoFileSeek(fromfile, fromfile->multisectorend[i] + 1) == 0))  i++;
		endsector = fromfile->multisectorend[fromfile->multiend];
	}
	else
	{
		endsector = fromfile->filesectorsize;
	} // ENDIF- Get ending sector from multifile? (Or single file?)
	IsoFileSeek(fromfile, 0);

	// Open Progress Bar
	sprintf(templine, "%s: %s%s -> %s%s",
	        filename,
	        multinames[fromfile->multi],
	        compressdesc[fromfile->compress],
	        multinames[tofile->multi],
	        compressdesc[tofile->compress]);
	ProgressBoxStart(templine, endsector);

	tofile->cdvdtype = fromfile->cdvdtype;
	for (i = 0; i < 2048; i++)  tofile->toc[i] = fromfile->toc[i];

	stop = 0;
	mainbox.stop = 0;
	progressbox.stop = 0;
	while ((stop == 0) && (tofile->sectorpos < endsector))
	{
		retval = IsoFileRead(fromfile, tempblock);
		if (retval < 0)
		{
			MessageBoxShow("Trouble reading source file", 3);
			stop = 1;
		}
		else
		{
			retval = IsoFileWrite(tofile, tempblock);
			if (retval < 0)
			{
				MessageBoxShow("Trouble writing new file", 3);
				stop = 1;
			} // ENDIF- Trouble writing out the next block?
		} // ENDIF- Trouble reading in the next block?

		ProgressBoxTick(tofile->sectorpos);
		while (gtk_events_pending())  gtk_main_iteration();

		if (mainbox.stop != 0)  stop = 2;
		if (progressbox.stop != 0)  stop = 2;
	} // ENDWHILE- Not stopped for some reason...

	ProgressBoxStop();

	if (stop == 0)
	{
		if (tofile->multi == 1)  tofile->name[tofile->multipos] = '0'; // First file
		strcpy(templine, tofile->name);

		// fromfile = IsoFileCloseAndDelete(fromfile);
		fromfile = IsoFileClose(fromfile);

		IsoSaveTOC(tofile);
		tofile = IsoFileClose(tofile);
		gtk_entry_set_text(GTK_ENTRY(mainbox.file), templine);

	}
	else
	{
		fromfile = IsoFileClose(fromfile);
		tofile = IsoFileCloseAndDelete(tofile);
	} // ENDIF- Did we succeed in the transfer?

	if (stop != 1)  ConversionBoxRefocus();
	if (stop == 0)  ConversionBoxCancelEvent(widget, event, data);
	return(TRUE);
} // END ConversionBoxOKEvent()
Exemplo n.º 6
0
gint MainBoxOKEvent(GtkWidget *widget, GdkEvent event, gpointer data)
{
	const char *tempisoname1;
	const char *tempisoname2;
	struct IsoFile *tempiso1;
	struct IsoFile *tempiso2;
	int stop;
	off64_t endsector;
	off64_t sector;
	int retval;
	char tempblock1[2448];
	char tempblock2[2448];
	int i;

	MainBoxUnfocus();

	tempisoname1 = gtk_entry_get_text(GTK_ENTRY(mainbox.file1));
	tempisoname2 = gtk_entry_get_text(GTK_ENTRY(mainbox.file2));
	tempiso1 = NULL;
	tempiso2 = NULL;

	tempiso1 = IsoFileOpenForRead(tempisoname1);
	if (tempiso1 == NULL)
	{
		MainBoxRefocus();
		MessageBoxShow("First file is not a Valid Image File.", 0);
		tempisoname1 = NULL;
		tempisoname2 = NULL;
		return(TRUE);
	} // ENDIF- Not an ISO file? Message and Stop here.

	tempiso2 = IsoFileOpenForRead(tempisoname2);
	if (tempiso2 == NULL)
	{
		MainBoxRefocus();
		MessageBoxShow("Second file is not a Valid Image File.", 0);
		tempiso1 = IsoFileClose(tempiso1);
		tempisoname1 = NULL;
		tempisoname2 = NULL;
		return(TRUE);
	} // ENDIF- Not an ISO file? Message and Stop here.

	if (tempiso1->blocksize != tempiso2->blocksize)
	{
		MainBoxRefocus();
		MessageBoxShow("Block sizes in Image files do not match.", 0);
		tempiso1 = IsoFileClose(tempiso1);
		tempiso2 = IsoFileClose(tempiso2);
		tempisoname1 = NULL;
		tempisoname2 = NULL;
		return(TRUE);
	} // ENDIF- Not an ISO file? Message and Stop here.

	if (tempiso1->multi == 1)
	{
		i = 0;
		while ((i < 10) &&
		        (IsoFileSeek(tempiso1, tempiso1->multisectorend[i] + 1) == 0))  i++;
		endsector = tempiso1->multisectorend[tempiso1->multiend];
	}
	else
	{
		endsector = tempiso1->filesectorsize;
	} // ENDIF- Get ending sector from multifile? (Or single file?)
	IsoFileSeek(tempiso1, 0);

	if (tempiso2->multi == 1)
	{
		i = 0;
		while ((i < 10) &&
		        (IsoFileSeek(tempiso2, tempiso2->multisectorend[i] + 1) == 0))  i++;
		sector = tempiso2->multisectorend[tempiso2->multiend];
	}
	else
	{
		sector = tempiso2->filesectorsize;
	} // ENDIF- Get ending sector from multifile? (Or single file?)
	IsoFileSeek(tempiso2, 0);
	if (sector != endsector)
	{
		MainBoxRefocus();
		MessageBoxShow("Number of blocks in Image files do not match.", 0);
		tempiso1 = IsoFileClose(tempiso1);
		tempiso2 = IsoFileClose(tempiso2);
		tempisoname1 = NULL;
		tempisoname2 = NULL;
		return(TRUE);
	} // ENDIF- Number of blocks don't match? Say so.

	sprintf(tempblock1, "%s == %s ?", tempisoname1, tempisoname2);
	ProgressBoxStart(tempblock1, endsector);

	stop = 0;
	mainbox.stop = 0;
	progressbox.stop = 0;
	while ((stop == 0) && (tempiso1->sectorpos < endsector))
	{
		retval = IsoFileRead(tempiso1, tempblock1);
		if (retval < 0)
		{
			MainBoxRefocus();
			MessageBoxShow("Trouble reading first file.", 0);
			stop = 1;
		}
		else
		{
			retval = IsoFileRead(tempiso2, tempblock2);
			if (retval < 0)
			{
				MainBoxRefocus();
				MessageBoxShow("Trouble reading second file.", 0);
				stop = 1;
			}
			else
			{
				i = 0;
				while ((i < tempiso1->blocksize) && (tempblock1[i] == tempblock2[i])) i++;
				if (i < tempiso1->blocksize)
				{
					MainBoxRefocus();
					MessageBoxShow("Trouble reading second file.", 0);
					stop = 1;
				} // ENDIF- Sectors don't match? Say so.
			} // ENDIF- Trouble reading second file?
		} // ENDIF- Trouble reading first file?

		ProgressBoxTick(tempiso1->sectorpos);
		while (gtk_events_pending())  gtk_main_iteration();

		if (mainbox.stop != 0)  stop = 2;
		if (progressbox.stop != 0)  stop = 2;
	} // ENDWHILE- Comparing two files... sector by sector

	if (stop == 0)
	{
		MainBoxRefocus();
		MessageBoxShow("Images Match.", 0);
	} // ENDIF- Everything checked out? Say so.
	tempiso1 = IsoFileClose(tempiso1);
	tempiso2 = IsoFileClose(tempiso2);
	tempisoname1 = NULL;
	tempisoname2 = NULL;
	return(TRUE);
} // END MainBoxOKEvent()
Exemplo n.º 7
0
int DetectImageType(struct IsoFile *isofile) {

    char comparestr[] = "CD001";

    int newtype;

    off64_t targetpos;

    char teststr[2448];

    int dataoffset;

    int i;

    int retval;



    newtype = 0;

    if(isofile->compress > 0) {

        IsoFileSeek(isofile, 16);

        IsoFileRead(isofile, teststr);



        while(imagedata[newtype].name != NULL) {

            if((isofile->blocksize == imagedata[newtype].blocksize) &&

                    (isofile->imageheader == imagedata[newtype].fileoffset)) {

                dataoffset = imagedata[newtype].dataoffset + 1;

                i = 0;

                while((i < 5) && (teststr[dataoffset + i] == comparestr[i])) i++;

                if(i == 5) {

                    GetImageType(isofile, newtype);

                    return(newtype);

                } // ENDIF- Did we find a match?

            } // ENDIF- Do these pieces match the compression storage pieces?

            newtype++;

        } // ENDWHILE- looking for the image type that fits the stats



    } else {

        while(imagedata[newtype].name != NULL) {

            targetpos = (16 * imagedata[newtype].blocksize)

                        + imagedata[newtype].fileoffset

                        + imagedata[newtype].dataoffset

                        + 1; // Moves to start of string

            retval = ActualFileSeek(isofile->handle, targetpos);

            if(retval == 0) {

                retval = ActualFileRead(isofile->handle, 5, teststr);

                if(retval == 5) {

                    i = 0;

                    while((i < 5) && (teststr[i] == comparestr[i]))  i++;

                    if(i == 5) {

                        ActualFileSeek(isofile->handle, isofile->imageheader);

                        GetImageType(isofile, newtype);

                        return(newtype);

                    } // ENDIF- Did we find a match?

                } // ENDIF- Could we read in the test string? Cool! Test it.

            } // ENDIF- Could actually get to this point?

            newtype++;

        } // ENDWHILE- looking for the directory header string "CD001"

        ActualFileSeek(isofile->handle, isofile->imageheader);

    } // ENDIF- Do we match type to compression stats? (Or search against raw data?)



    GetImageType(isofile, REDBOOK2352);

    return(REDBOOK2352); // Couldn't find it? Guess it's RAW 2352, then. (Audio CD?)

} // END ImageDetect()