mirror of https://github.com/PCSX2/pcsx2.git
Undo my little mess. Fix it next commit
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1940 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
b6a19e6b2c
commit
c440e41859
|
@ -1,517 +0,0 @@
|
|||
#define _CRT_SECURE_NO_WARNINGS
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "CDVD.h"
|
||||
#include "resource.h"
|
||||
#include "Shlwapi.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
void (*newDiscCB)();
|
||||
|
||||
#define STRFY(x) #x
|
||||
#define TOSTR(x) STRFY(x)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// State Information //
|
||||
|
||||
int strack;
|
||||
int etrack;
|
||||
track tracks[100];
|
||||
|
||||
int curDiskType;
|
||||
int curTrayStatus;
|
||||
|
||||
int csector;
|
||||
int cmode;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Plugin Interface //
|
||||
|
||||
char *LibName = "Gigaherz's CDVD Plugin";
|
||||
|
||||
const unsigned char version = PS2E_CDVD_VERSION;
|
||||
const unsigned char revision = 0;
|
||||
const unsigned char build = 8;
|
||||
|
||||
HINSTANCE hinst;
|
||||
|
||||
BOOL WINAPI DllMain(
|
||||
HINSTANCE hinstDLL, // handle to DLL module
|
||||
DWORD fdwReason, // reason for calling function
|
||||
LPVOID lpvReserved // reserved
|
||||
)
|
||||
{
|
||||
if(fdwReason==DLL_PROCESS_ATTACH) {
|
||||
hinst=hinstDLL;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
char* CALLBACK PS2EgetLibName() {
|
||||
return LibName;
|
||||
}
|
||||
|
||||
u32 CALLBACK PS2EgetLibType() {
|
||||
return PS2E_LT_CDVD;
|
||||
}
|
||||
|
||||
u32 CALLBACK PS2EgetLibVersion2(u32 type) {
|
||||
return (version << 16) | (revision << 8) | build;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Utility Functions //
|
||||
|
||||
void SysMessage(char *fmt, ...) {
|
||||
va_list list;
|
||||
char tmp[512];
|
||||
|
||||
va_start(list,fmt);
|
||||
vsprintf(tmp,fmt,list);
|
||||
va_end(list);
|
||||
MessageBox(0, tmp, "cdvdGigaherz Msg", 0);
|
||||
}
|
||||
|
||||
u8 __inline dec_to_bcd(u8 dec)
|
||||
{
|
||||
return ((dec/10)<<4)|(dec%10);
|
||||
}
|
||||
|
||||
void __inline lsn_to_msf(u8* minute, u8* second, u8* frame, u32 lsn)
|
||||
{
|
||||
*frame = dec_to_bcd(lsn%75);
|
||||
lsn/=75;
|
||||
*second= dec_to_bcd(lsn%60);
|
||||
lsn/=60;
|
||||
*minute= dec_to_bcd(lsn%100);
|
||||
}
|
||||
|
||||
void __inline lba_to_msf(s32 lba, u8* m, u8* s, u8* f) {
|
||||
lba += 150;
|
||||
*m = (u8)(lba / (60*75));
|
||||
*s = (u8)((lba / 75) % 60);
|
||||
*f = (u8)(lba % 75);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// CDVD processing functions //
|
||||
|
||||
char csrc[20];
|
||||
|
||||
BOOL cdvd_is_open=FALSE;
|
||||
|
||||
Source *src;
|
||||
|
||||
s32 disc_has_changed=0;
|
||||
|
||||
int weAreInNewDiskCB=0;
|
||||
|
||||
char bfr[2352];
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// CDVD Pluin Interface //
|
||||
|
||||
s32 CALLBACK CDVDinit()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 CALLBACK CDVDopen(const char* pTitleFilename)
|
||||
{
|
||||
ReadSettings();
|
||||
|
||||
if(source_drive=='-')
|
||||
{
|
||||
char temp[3]="A:";
|
||||
|
||||
for(char d='A';d<='Z';d++)
|
||||
{
|
||||
temp[0]=d;
|
||||
if(GetDriveType(temp)==DRIVE_CDROM)
|
||||
{
|
||||
source_drive=d;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(source_drive=='@')
|
||||
{
|
||||
curDiskType=CDVD_TYPE_NODISC;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(source_drive='$')
|
||||
{
|
||||
printf(" * CDVD: Opening image '%s'...\n",source_file);
|
||||
|
||||
//open device file
|
||||
src=new FileSrc(source_file);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(csrc,"\\\\.\\%c:",source_drive);
|
||||
|
||||
printf(" * CDVD: Opening drive '%s'...\n",csrc);
|
||||
|
||||
//open device file
|
||||
src=new IOCtlSrc(csrc);
|
||||
}
|
||||
|
||||
if(!src->IsOK())
|
||||
{
|
||||
printf(" * CDVD: Error opening source.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
//setup threading manager
|
||||
cdvdStartThread();
|
||||
|
||||
return cdvdRefreshData();
|
||||
}
|
||||
|
||||
void CALLBACK CDVDclose()
|
||||
{
|
||||
cdvdStopThread();
|
||||
|
||||
//close device
|
||||
delete src;
|
||||
src=NULL;
|
||||
}
|
||||
|
||||
void CALLBACK CDVDshutdown()
|
||||
{
|
||||
//nothing to do here
|
||||
}
|
||||
|
||||
s32 CALLBACK CDVDgetDualInfo(s32* dualType, u32* _layer1start)
|
||||
{
|
||||
switch(src->GetMediaType())
|
||||
{
|
||||
case 1:
|
||||
*dualType = 1;
|
||||
*_layer1start = src->GetLayerBreakAddress();
|
||||
return 1;
|
||||
case 2:
|
||||
*dualType = 2;
|
||||
*_layer1start = src->GetLayerBreakAddress();
|
||||
return 1;
|
||||
case 0:
|
||||
*dualType = 0;
|
||||
*_layer1start = 0;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int lastReadInNewDiskCB=0;
|
||||
char fuckThisSector[2352];
|
||||
|
||||
s32 CALLBACK CDVDreadSector(u8* buffer, s32 lsn, int mode)
|
||||
{
|
||||
return cdvdDirectReadSector(lsn,mode,(char*)buffer);
|
||||
}
|
||||
|
||||
s32 CALLBACK CDVDreadTrack(u32 lsn, int mode)
|
||||
{
|
||||
csector=lsn;
|
||||
cmode=mode;
|
||||
|
||||
if(weAreInNewDiskCB)
|
||||
{
|
||||
int ret = cdvdDirectReadSector(lsn,mode,fuckThisSector);
|
||||
if(ret==0) lastReadInNewDiskCB=1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
if(lsn>tracks[0].length) // track 0 is total disc.
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return cdvdRequestSector(lsn,mode);
|
||||
}
|
||||
|
||||
// return can be NULL (for async modes)
|
||||
u8* CALLBACK CDVDgetBuffer()
|
||||
{
|
||||
if(lastReadInNewDiskCB)
|
||||
{
|
||||
lastReadInNewDiskCB=0;
|
||||
return (u8*)fuckThisSector;
|
||||
}
|
||||
|
||||
u8 *s = (u8*)cdvdGetSector(csector,cmode);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
// return can be NULL (for async modes)
|
||||
int CALLBACK CDVDgetBuffer2(u8* dest)
|
||||
{
|
||||
int csize = 2352;
|
||||
switch(cmode)
|
||||
{
|
||||
case CDVD_MODE_2048: csize = 2048; break;
|
||||
case CDVD_MODE_2328: csize = 2328; break;
|
||||
case CDVD_MODE_2340: csize = 2340; break;
|
||||
}
|
||||
|
||||
if(lastReadInNewDiskCB)
|
||||
{
|
||||
lastReadInNewDiskCB=0;
|
||||
|
||||
memcpy(dest, fuckThisSector, csize);
|
||||
return 0;
|
||||
}
|
||||
|
||||
memcpy(dest, cdvdGetSector(csector,cmode), csize);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 CALLBACK CDVDreadSubQ(u32 lsn, cdvdSubQ* subq)
|
||||
{
|
||||
int i;
|
||||
// the formatted subq command returns: control/adr, track, index, trk min, trk sec, trk frm, 0x00, abs min, abs sec, abs frm
|
||||
|
||||
if(lsn>tracks[0].length) // track 0 is total disc.
|
||||
return -1;
|
||||
|
||||
memset(subq,0,sizeof(cdvdSubQ));
|
||||
|
||||
lsn_to_msf(&subq->discM,&subq->discS,&subq->discF,lsn+150);
|
||||
|
||||
i=strack;
|
||||
while(i<=etrack)
|
||||
{
|
||||
if(lsn<=tracks[i].length)
|
||||
break;
|
||||
lsn-=tracks[i].length;
|
||||
i++;
|
||||
}
|
||||
|
||||
if(i>etrack)
|
||||
i=etrack;
|
||||
|
||||
lsn_to_msf(&subq->trackM,&subq->trackS,&subq->trackF,lsn);
|
||||
|
||||
subq->mode=1;
|
||||
subq->ctrl=tracks[i].type;
|
||||
subq->trackNum=i;
|
||||
subq->trackIndex=1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 CALLBACK CDVDgetTN(cdvdTN *Buffer)
|
||||
{
|
||||
Buffer->strack=strack;
|
||||
Buffer->etrack=etrack;
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 CALLBACK CDVDgetTD(u8 Track, cdvdTD *Buffer)
|
||||
{
|
||||
if(Track==0)
|
||||
{
|
||||
Buffer->lsn = tracks[0].length;
|
||||
Buffer->type= 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(Track<strack) return -1;
|
||||
if(Track>etrack) return -1;
|
||||
|
||||
Buffer->lsn = tracks[Track].start_lba;
|
||||
Buffer->type= tracks[Track].type;
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 layer1start=-1;
|
||||
|
||||
s32 CALLBACK CDVDgetTOC(u8* tocBuff)
|
||||
{
|
||||
//return src->ReadTOC((char*)toc,2048);
|
||||
//that didn't work too well...
|
||||
|
||||
if(curDiskType==CDVD_TYPE_NODISC)
|
||||
return -1;
|
||||
|
||||
if((curDiskType == CDVD_TYPE_DVDV) ||
|
||||
(curDiskType == CDVD_TYPE_PS2DVD))
|
||||
{
|
||||
memset(tocBuff, 0, 2048);
|
||||
|
||||
s32 mt=src->GetMediaType();
|
||||
|
||||
if(mt<0)
|
||||
return -1;
|
||||
|
||||
if(mt==0) //single layer
|
||||
{
|
||||
// fake it
|
||||
tocBuff[ 0] = 0x04;
|
||||
tocBuff[ 1] = 0x02;
|
||||
tocBuff[ 2] = 0xF2;
|
||||
tocBuff[ 3] = 0x00;
|
||||
tocBuff[ 4] = 0x86;
|
||||
tocBuff[ 5] = 0x72;
|
||||
|
||||
tocBuff[16] = 0x00; // first sector for layer 0
|
||||
tocBuff[17] = 0x03;
|
||||
tocBuff[18] = 0x00;
|
||||
tocBuff[19] = 0x00;
|
||||
}
|
||||
else if(mt==1) //PTP
|
||||
{
|
||||
layer1start = src->GetLayerBreakAddress() + 0x30000;
|
||||
|
||||
// dual sided
|
||||
tocBuff[ 0] = 0x24;
|
||||
tocBuff[ 1] = 0x02;
|
||||
tocBuff[ 2] = 0xF2;
|
||||
tocBuff[ 3] = 0x00;
|
||||
tocBuff[ 4] = 0x41;
|
||||
tocBuff[ 5] = 0x95;
|
||||
|
||||
tocBuff[14] = 0x61; // PTP
|
||||
|
||||
tocBuff[16] = 0x00;
|
||||
tocBuff[17] = 0x03;
|
||||
tocBuff[18] = 0x00;
|
||||
tocBuff[19] = 0x00;
|
||||
|
||||
tocBuff[20] = (layer1start>>24);
|
||||
tocBuff[21] = (layer1start>>16)&0xff;
|
||||
tocBuff[22] = (layer1start>> 8)&0xff;
|
||||
tocBuff[23] = (layer1start>> 0)&0xff;
|
||||
}
|
||||
else //OTP
|
||||
{
|
||||
layer1start = src->GetLayerBreakAddress() + 0x30000;
|
||||
|
||||
// dual sided
|
||||
tocBuff[ 0] = 0x24;
|
||||
tocBuff[ 1] = 0x02;
|
||||
tocBuff[ 2] = 0xF2;
|
||||
tocBuff[ 3] = 0x00;
|
||||
tocBuff[ 4] = 0x41;
|
||||
tocBuff[ 5] = 0x95;
|
||||
|
||||
tocBuff[14] = 0x71; // OTP
|
||||
|
||||
tocBuff[16] = 0x00;
|
||||
tocBuff[17] = 0x03;
|
||||
tocBuff[18] = 0x00;
|
||||
tocBuff[19] = 0x00;
|
||||
|
||||
tocBuff[24] = (layer1start>>24);
|
||||
tocBuff[25] = (layer1start>>16)&0xff;
|
||||
tocBuff[26] = (layer1start>> 8)&0xff;
|
||||
tocBuff[27] = (layer1start>> 0)&0xff;
|
||||
}
|
||||
}
|
||||
else if(curDiskType == CDVD_TYPE_CDDA ||
|
||||
curDiskType == CDVD_TYPE_PS2CDDA ||
|
||||
curDiskType == CDVD_TYPE_PS2CD ||
|
||||
curDiskType == CDVD_TYPE_PSCDDA ||
|
||||
curDiskType == CDVD_TYPE_PSCD)
|
||||
{
|
||||
// cd toc
|
||||
// (could be replaced by 1 command that reads the full toc)
|
||||
u8 min, sec, frm,i;
|
||||
s32 err;
|
||||
cdvdTN diskInfo;
|
||||
cdvdTD trackInfo;
|
||||
memset(tocBuff, 0, 1024);
|
||||
if (CDVDgetTN(&diskInfo) == -1) { diskInfo.etrack = 0;diskInfo.strack = 1; }
|
||||
if (CDVDgetTD(0, &trackInfo) == -1) trackInfo.lsn = 0;
|
||||
|
||||
tocBuff[0] = 0x41;
|
||||
tocBuff[1] = 0x00;
|
||||
|
||||
#define itob(n) ((((n)/10)<<4)+((n)%10))
|
||||
|
||||
//Number of FirstTrack
|
||||
tocBuff[2] = 0xA0;
|
||||
tocBuff[7] = itob(diskInfo.strack);
|
||||
|
||||
//Number of LastTrack
|
||||
tocBuff[12] = 0xA1;
|
||||
tocBuff[17] = itob(diskInfo.etrack);
|
||||
|
||||
//DiskLength
|
||||
lba_to_msf(trackInfo.lsn, &min, &sec, &frm);
|
||||
tocBuff[22] = 0xA2;
|
||||
tocBuff[27] = itob(min);
|
||||
tocBuff[28] = itob(sec);
|
||||
tocBuff[29] = itob(frm);
|
||||
|
||||
fprintf(stderr,"Track 0: %d mins %d secs %d frames\n",min,sec,frm);
|
||||
|
||||
for (i=diskInfo.strack; i<=diskInfo.etrack; i++)
|
||||
{
|
||||
err = CDVDgetTD(i, &trackInfo);
|
||||
lba_to_msf(trackInfo.lsn, &min, &sec, &frm);
|
||||
tocBuff[i*10+30] = trackInfo.type;
|
||||
tocBuff[i*10+32] = err == -1 ? 0 : itob(i); //number
|
||||
tocBuff[i*10+37] = itob(min);
|
||||
tocBuff[i*10+38] = itob(sec);
|
||||
tocBuff[i*10+39] = itob(frm);
|
||||
fprintf(stderr,"Track %d: %d mins %d secs %d frames\n",i,min,sec,frm);
|
||||
}
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 CALLBACK CDVDgetDiskType()
|
||||
{
|
||||
return curDiskType;
|
||||
}
|
||||
|
||||
s32 CALLBACK CDVDgetTrayStatus()
|
||||
{
|
||||
return curTrayStatus;
|
||||
}
|
||||
|
||||
s32 CALLBACK CDVDctrlTrayOpen()
|
||||
{
|
||||
curTrayStatus=CDVD_TRAY_OPEN;
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 CALLBACK CDVDctrlTrayClose()
|
||||
{
|
||||
curTrayStatus=CDVD_TRAY_CLOSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CALLBACK CDVDnewDiskCB(void (*callback)())
|
||||
{
|
||||
newDiscCB=callback;
|
||||
}
|
||||
|
||||
void configure();
|
||||
void CALLBACK CDVDconfigure()
|
||||
{
|
||||
configure();
|
||||
}
|
||||
|
||||
void CALLBACK CDVDabout() {
|
||||
SysMessage("%s %d.%d", LibName, revision, build);
|
||||
}
|
||||
|
||||
s32 CALLBACK CDVDtest() {
|
||||
return 0;
|
||||
}
|
|
@ -1,206 +0,0 @@
|
|||
#ifndef __CDVD_H__
|
||||
#define __CDVD_H__
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define CDVDdefs
|
||||
#include <PS2Edefs.h>
|
||||
|
||||
typedef struct _track
|
||||
{
|
||||
u32 start_lba;
|
||||
u32 length;
|
||||
u32 type;
|
||||
} track;
|
||||
|
||||
extern int strack;
|
||||
extern int etrack;
|
||||
extern track tracks[100];
|
||||
|
||||
extern int curDiskType;
|
||||
extern int curTrayStatus;
|
||||
|
||||
typedef struct _toc_entry {
|
||||
UCHAR SessionNumber;
|
||||
UCHAR Control : 4;
|
||||
UCHAR Adr : 4;
|
||||
UCHAR Reserved1;
|
||||
UCHAR Point;
|
||||
UCHAR MsfExtra[3];
|
||||
UCHAR Zero;
|
||||
UCHAR Msf[3];
|
||||
} toc_entry;
|
||||
|
||||
typedef struct _toc_data
|
||||
{
|
||||
UCHAR Length[2];
|
||||
UCHAR FirstCompleteSession;
|
||||
UCHAR LastCompleteSession;
|
||||
|
||||
toc_entry Descriptors[255];
|
||||
} toc_data;
|
||||
|
||||
extern toc_data cdtoc;
|
||||
|
||||
|
||||
class Source //abstract class as base for source modules
|
||||
{
|
||||
public:
|
||||
//virtual destructor
|
||||
virtual ~Source()
|
||||
{
|
||||
}
|
||||
|
||||
//virtual members
|
||||
virtual s32 GetSectorCount()=0;
|
||||
virtual s32 ReadTOC(char *toc,int size)=0;
|
||||
virtual s32 ReadSectors2048(u32 sector, u32 count, char *buffer)=0;
|
||||
virtual s32 ReadSectors2352(u32 sector, u32 count, char *buffer)=0;
|
||||
virtual s32 GetLayerBreakAddress()=0;
|
||||
|
||||
virtual s32 GetMediaType()=0;
|
||||
|
||||
virtual s32 IsOK()=0;
|
||||
virtual s32 Reopen()=0;
|
||||
|
||||
virtual s32 DiscChanged()=0;
|
||||
};
|
||||
|
||||
class IOCtlSrc: public Source
|
||||
{
|
||||
private:
|
||||
HANDLE device;
|
||||
|
||||
bool OpenOK;
|
||||
|
||||
s32 last_read_mode;
|
||||
|
||||
s32 last_sector_count;
|
||||
|
||||
char sectorbuffer[32*2048];
|
||||
|
||||
char fName[256];
|
||||
|
||||
DWORD sessID;
|
||||
|
||||
bool tocCached;
|
||||
char tocCacheData[2048];
|
||||
|
||||
bool mediaTypeCached;
|
||||
int mediaType;
|
||||
|
||||
bool discSizeCached;
|
||||
s32 discSize;
|
||||
|
||||
bool layerBreakCached;
|
||||
s32 layerBreak;
|
||||
|
||||
public:
|
||||
IOCtlSrc(const char* fileName);
|
||||
|
||||
//virtual destructor
|
||||
virtual ~IOCtlSrc();
|
||||
|
||||
//virtual members
|
||||
virtual s32 GetSectorCount();
|
||||
virtual s32 ReadTOC(char *toc,int size);
|
||||
virtual s32 ReadSectors2048(u32 sector, u32 count, char *buffer);
|
||||
virtual s32 ReadSectors2352(u32 sector, u32 count, char *buffer);
|
||||
virtual s32 GetLayerBreakAddress();
|
||||
|
||||
virtual s32 GetMediaType();
|
||||
|
||||
virtual s32 IsOK();
|
||||
virtual s32 Reopen();
|
||||
|
||||
virtual s32 DiscChanged();
|
||||
};
|
||||
|
||||
class FileSrc: public Source
|
||||
{
|
||||
private:
|
||||
HANDLE fileSource;
|
||||
|
||||
bool OpenOK;
|
||||
|
||||
s32 sector_count;
|
||||
|
||||
char sectorbuffer[32*2048];
|
||||
|
||||
char fName[256];
|
||||
|
||||
DWORD sessID;
|
||||
|
||||
bool tocCached;
|
||||
char tocCacheData[2048];
|
||||
|
||||
bool mediaTypeCached;
|
||||
int mediaType;
|
||||
|
||||
bool discSizeCached;
|
||||
s32 discSize;
|
||||
|
||||
bool layerBreakCached;
|
||||
s32 layerBreak;
|
||||
|
||||
public:
|
||||
FileSrc(const char* fileName);
|
||||
|
||||
//virtual destructor
|
||||
virtual ~FileSrc();
|
||||
|
||||
//virtual members
|
||||
virtual s32 GetSectorCount();
|
||||
virtual s32 ReadTOC(char *toc,int size);
|
||||
virtual s32 ReadSectors2048(u32 sector, u32 count, char *buffer);
|
||||
virtual s32 ReadSectors2352(u32 sector, u32 count, char *buffer);
|
||||
virtual s32 GetLayerBreakAddress();
|
||||
|
||||
virtual s32 GetMediaType();
|
||||
|
||||
virtual s32 IsOK();
|
||||
virtual s32 Reopen();
|
||||
|
||||
virtual s32 DiscChanged();
|
||||
};
|
||||
|
||||
extern Source *src;
|
||||
|
||||
int FindDiskType();
|
||||
|
||||
void configure();
|
||||
|
||||
extern char source_drive;
|
||||
extern char source_file[];
|
||||
|
||||
extern HINSTANCE hinst;
|
||||
|
||||
#define MSF_TO_LBA(m,s,f) ((m*60+s)*75+f-150)
|
||||
|
||||
s32 cdvdDirectReadSector(s32 first, s32 mode, char *buffer);
|
||||
|
||||
s32 cdvdGetMediaType();
|
||||
|
||||
void ReadSettings();
|
||||
void WriteSettings();
|
||||
|
||||
extern char csrc[];
|
||||
extern BOOL cdvd_is_open;
|
||||
extern int weAreInNewDiskCB;
|
||||
|
||||
extern void (*newDiscCB)();
|
||||
|
||||
extern s32 disc_has_changed;
|
||||
|
||||
s32 cdvdStartThread();
|
||||
void cdvdStopThread();
|
||||
s32 cdvdRequestSector(u32 sector, s32 mode);
|
||||
s32 cdvdRequestComplete();
|
||||
char* cdvdGetSector(s32 sector, s32 mode);
|
||||
s32 cdvdDirectReadSector(s32 first, s32 mode, char *buffer);
|
||||
s32 cdvdGetMediaType();
|
||||
s32 cdvdRefreshData();
|
||||
s32 cdvdParseTOC();
|
||||
|
||||
#endif /* __CDVD_H__ */
|
|
@ -1,119 +0,0 @@
|
|||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "CDVD.h"
|
||||
#include "isofs/CDVDlib.h"
|
||||
#include "isofs/CDVDiso.h"
|
||||
#include "isofs/CDVDisodrv.h"
|
||||
|
||||
char buffer[2048]; //if the file is longer...it should be shorter :D
|
||||
|
||||
int CheckDiskType(int baseType)
|
||||
{
|
||||
int f;
|
||||
char *pos;
|
||||
static struct TocEntry tocEntry;
|
||||
|
||||
CDVDFS_init();
|
||||
|
||||
// check if the file exists
|
||||
if (CDVD_findfile("SYSTEM.CNF;1", &tocEntry) == TRUE)
|
||||
{
|
||||
f=CDVDFS_open("SYSTEM.CNF;1", 1);
|
||||
CDVDFS_read(f, buffer, 2047);
|
||||
CDVDFS_close(f);
|
||||
|
||||
buffer[tocEntry.fileSize]='\0';
|
||||
|
||||
pos=strstr(buffer, "BOOT2");
|
||||
if (pos==NULL){
|
||||
pos=strstr(buffer, "BOOT");
|
||||
if (pos==NULL) {
|
||||
return CDVD_TYPE_ILLEGAL;
|
||||
}
|
||||
return CDVD_TYPE_PSCD;
|
||||
}
|
||||
return (baseType==CDVD_TYPE_DETCTCD)?CDVD_TYPE_PS2CD:CDVD_TYPE_PS2DVD;
|
||||
}
|
||||
|
||||
if (CDVD_findfile("PSX.EXE;1", &tocEntry) == TRUE)
|
||||
{
|
||||
return CDVD_TYPE_PSCD;
|
||||
}
|
||||
|
||||
if (CDVD_findfile("VIDEO_TS/VIDEO_TS.IFO;1", &tocEntry) == TRUE)
|
||||
{
|
||||
return CDVD_TYPE_DVDV;
|
||||
}
|
||||
|
||||
return CDVD_TYPE_ILLEGAL;
|
||||
}
|
||||
|
||||
char bleh[2352];
|
||||
|
||||
int FindDiskType()
|
||||
{
|
||||
int dataTracks=0;
|
||||
int audioTracks=0;
|
||||
|
||||
int iCDType = CDVD_TYPE_DETCTDVDS;
|
||||
|
||||
s32 mt=cdvdGetMediaType();
|
||||
|
||||
if(mt<0)
|
||||
{
|
||||
if(tracks[0].length>452849)
|
||||
{
|
||||
iCDType = CDVD_TYPE_DETCTDVDS;
|
||||
}
|
||||
else if(cdvdDirectReadSector(16,CDVD_MODE_2048,bleh)==0)
|
||||
{
|
||||
struct cdVolDesc* volDesc=(struct cdVolDesc *)bleh;
|
||||
if(volDesc)
|
||||
{
|
||||
if(volDesc->rootToc.tocSize==2048) iCDType = CDVD_TYPE_DETCTCD;
|
||||
else iCDType = CDVD_TYPE_DETCTDVDS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr," * CDVD Disk Open: %d tracks (%d to %d):\n",etrack-strack+1,strack,etrack);
|
||||
|
||||
audioTracks=dataTracks=0;
|
||||
for(int i=strack;i<=etrack;i++)
|
||||
{
|
||||
if(tracks[i].type==CDVD_AUDIO_TRACK)
|
||||
{
|
||||
audioTracks++;
|
||||
fprintf(stderr," * * Track %d: Audio (%d sectors)\n",i,tracks[i].length);
|
||||
}
|
||||
else
|
||||
{
|
||||
dataTracks++;
|
||||
fprintf(stderr," * * Track %d: Data (Mode %d) (%d sectors)\n",i,((tracks[i].type==CDVD_MODE1_TRACK)?1:2),tracks[i].length);
|
||||
}
|
||||
}
|
||||
|
||||
if(dataTracks>0)
|
||||
{
|
||||
iCDType=CheckDiskType(iCDType);
|
||||
}
|
||||
|
||||
if(audioTracks>0)
|
||||
{
|
||||
if(iCDType==CDVD_TYPE_PS2CD)
|
||||
{
|
||||
iCDType=CDVD_TYPE_PS2CDDA;
|
||||
}
|
||||
else if(iCDType==CDVD_TYPE_PSCD)
|
||||
{
|
||||
iCDType=CDVD_TYPE_PSCDDA;
|
||||
}
|
||||
else
|
||||
{
|
||||
iCDType=CDVD_TYPE_CDDA;
|
||||
}
|
||||
}
|
||||
|
||||
return iCDType;
|
||||
}
|
|
@ -1,243 +0,0 @@
|
|||
#undef _WIN32_WINNT
|
||||
#define _WIN32_WINNT 0x0600
|
||||
#include "CDVD.h"
|
||||
#pragma warning(disable:4200)
|
||||
#pragma pack(1)
|
||||
#include <winioctl.h>
|
||||
#include "rosddk/ntddcdvd.h"
|
||||
#include "rosddk/ntddcdrm.h"
|
||||
#include "rosddk/ntddscsi.h"
|
||||
#pragma warning(default:4200)
|
||||
#include <stddef.h>
|
||||
|
||||
#include "SectorConverters.h"
|
||||
template<class T>
|
||||
bool ApiErrorCheck(T t,T okValue,bool cmpEq)
|
||||
{
|
||||
bool cond=(t==okValue);
|
||||
|
||||
if(!cmpEq) cond=!cond;
|
||||
|
||||
if(!cond)
|
||||
{
|
||||
static char buff[1024];
|
||||
DWORD ec = GetLastError();
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,NULL,ec,0,buff,1023,NULL);
|
||||
MessageBoxEx(0,buff,"ERROR?!",MB_OK,0);
|
||||
}
|
||||
return cond;
|
||||
}
|
||||
|
||||
#define RETURN(v) {OpenOK=v; return;}
|
||||
|
||||
s32 FileSrc::Reopen()
|
||||
{
|
||||
if(fileSource!=INVALID_HANDLE_VALUE)
|
||||
{
|
||||
CloseHandle(fileSource);
|
||||
}
|
||||
|
||||
DWORD share = FILE_SHARE_READ;
|
||||
DWORD flags = FILE_ATTRIBUTE_READONLY | FILE_FLAG_SEQUENTIAL_SCAN;
|
||||
|
||||
OpenOK = false;
|
||||
|
||||
fileSource = CreateFile(fName, GENERIC_READ|FILE_READ_ATTRIBUTES, share, NULL, OPEN_EXISTING, flags, 0);
|
||||
|
||||
tocCached = false;
|
||||
mediaTypeCached = false;
|
||||
discSizeCached = false;
|
||||
layerBreakCached = false;
|
||||
|
||||
OpenOK=true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
FileSrc::FileSrc(const char* fileName)
|
||||
{
|
||||
fileSource=INVALID_HANDLE_VALUE;
|
||||
|
||||
strcpy_s(fName,256,fileName);
|
||||
|
||||
Reopen();
|
||||
}
|
||||
|
||||
FileSrc::~FileSrc()
|
||||
{
|
||||
if(OpenOK)
|
||||
{
|
||||
CloseHandle(fileSource);
|
||||
}
|
||||
}
|
||||
|
||||
s32 FileSrc::GetSectorCount()
|
||||
{
|
||||
LARGE_INTEGER li;
|
||||
int plain_sectors = 0;
|
||||
|
||||
if(discSizeCached)
|
||||
return discSize;
|
||||
|
||||
if(GetFileSizeEx(fileSource,&li))
|
||||
{
|
||||
discSizeCached = true;
|
||||
discSize = (s32)(li.QuadPart / 2048);
|
||||
return discSize;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
s32 FileSrc::GetLayerBreakAddress()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 FileSrc::GetMediaType()
|
||||
{
|
||||
if(mediaTypeCached)
|
||||
return mediaType;
|
||||
|
||||
// assume single layer DVD, for now
|
||||
mediaTypeCached = true;
|
||||
mediaType = 0;
|
||||
return mediaType;
|
||||
}
|
||||
|
||||
#define MKDESCRIPTOR(n,ses,ctr,adr,pt,me,se,fe,tm,ts,tf) \
|
||||
ftd->Descriptors[n].SessionNumber = ses; \
|
||||
ftd->Descriptors[n].Control = ctr; \
|
||||
ftd->Descriptors[n].Adr = adr; \
|
||||
ftd->Descriptors[n].Reserved1 = 0; \
|
||||
ftd->Descriptors[n].Point = pt; \
|
||||
ftd->Descriptors[n].MsfExtra[0] = me; \
|
||||
ftd->Descriptors[n].MsfExtra[1] = se; \
|
||||
ftd->Descriptors[n].MsfExtra[2] = fe; \
|
||||
ftd->Descriptors[n].Zero = 0; \
|
||||
ftd->Descriptors[n].Msf[0] = tm; \
|
||||
ftd->Descriptors[n].Msf[1] = ts; \
|
||||
ftd->Descriptors[n].Msf[2] = tf;
|
||||
|
||||
#define MSF_TO_LBA(m,s,f) ((m*60+s)*75+f-150)
|
||||
#define LBA_TO_MSF(m,s,f,l) \
|
||||
m = (l)/(75*60); \
|
||||
s = (((l)/75)%60); \
|
||||
f = ((l)%75);
|
||||
|
||||
|
||||
s32 FileSrc::ReadTOC(char *toc,int msize)
|
||||
{
|
||||
DWORD size=0;
|
||||
|
||||
if(GetMediaType()>=0)
|
||||
return -1;
|
||||
|
||||
if(!tocCached)
|
||||
{
|
||||
CDROM_TOC_FULL_TOC_DATA *ftd=(CDROM_TOC_FULL_TOC_DATA*)tocCacheData;
|
||||
|
||||
// Build basic TOC
|
||||
int length = 6 * sizeof(ftd->Descriptors[0]) + 2;
|
||||
ftd->Length[0] = length>>8;
|
||||
ftd->Length[1] = length;
|
||||
ftd->FirstCompleteSession=1;
|
||||
ftd->LastCompleteSession=2;
|
||||
|
||||
int dm,ds,df;
|
||||
|
||||
LBA_TO_MSF(dm,ds,df,sector_count);
|
||||
|
||||
MKDESCRIPTOR(0,1,0x00,1,0xA0,0,0,0,1,0,0);
|
||||
MKDESCRIPTOR(1,1,0x00,1,0xA1,0,0,0,1,0,0);
|
||||
MKDESCRIPTOR(2,1,0x00,1,0xA2,0,0,0,dm,ds,df);
|
||||
MKDESCRIPTOR(3,1,0x00,5,0xB0,0,0,0,0,0,0);
|
||||
MKDESCRIPTOR(4,1,0x00,5,0xC0,0,0,0,0,0,0);
|
||||
MKDESCRIPTOR(5,1,0x04,1,0x01,0,0,0,0,2,0);
|
||||
|
||||
tocCached = true;
|
||||
}
|
||||
|
||||
memcpy(toc,tocCacheData,min(2048,msize));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 FileSrc::ReadSectors2048(u32 sector, u32 count, char *buffer)
|
||||
{
|
||||
DWORD size=0;
|
||||
LARGE_INTEGER Offset;
|
||||
|
||||
if(!OpenOK) return -1;
|
||||
|
||||
Offset.QuadPart=sector*(u64)2048;
|
||||
|
||||
//fall back to standard reading
|
||||
if(SetFilePointer(fileSource,Offset.LowPart,&Offset.HighPart,FILE_BEGIN)==-1)
|
||||
{
|
||||
if(GetLastError()!=0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(ReadFile(fileSource,buffer,2048*count,&size,NULL)==0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(size!=(2048*count))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
s32 FileSrc::ReadSectors2352(u32 sector, u32 count, char *buffer)
|
||||
{
|
||||
DWORD size=0;
|
||||
LARGE_INTEGER Offset;
|
||||
|
||||
if(!OpenOK) return -1;
|
||||
|
||||
assert(count <= 32);
|
||||
|
||||
Offset.QuadPart=sector*(u64)2048;
|
||||
|
||||
//fall back to standard reading
|
||||
if(SetFilePointer(fileSource,Offset.LowPart,&Offset.HighPart,FILE_BEGIN)==-1)
|
||||
{
|
||||
if(GetLastError()!=0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(ReadFile(fileSource,sectorbuffer,2048*count,&size,NULL)==0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(size!=(2048*count))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
for(uint i=0;i<count;i++)
|
||||
{
|
||||
Convert<2048,2352>(buffer+2352*i,sectorbuffer+2048*i,sector+i);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 FileSrc::DiscChanged()
|
||||
{
|
||||
DWORD size=0;
|
||||
|
||||
if(!OpenOK) return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 FileSrc::IsOK()
|
||||
{
|
||||
return OpenOK;
|
||||
}
|
|
@ -1,673 +0,0 @@
|
|||
#undef _WIN32_WINNT
|
||||
#define _WIN32_WINNT 0x0600
|
||||
#include "CDVD.h"
|
||||
#pragma warning(disable:4200)
|
||||
#pragma pack(1)
|
||||
#include <winioctl.h>
|
||||
#include "rosddk/ntddcdvd.h"
|
||||
#include "rosddk/ntddcdrm.h"
|
||||
#include "rosddk/ntddscsi.h"
|
||||
#pragma warning(default:4200)
|
||||
#include <stddef.h>
|
||||
|
||||
template<class T>
|
||||
bool ApiErrorCheck(T t,T okValue,bool cmpEq)
|
||||
{
|
||||
bool cond=(t==okValue);
|
||||
|
||||
if(!cmpEq) cond=!cond;
|
||||
|
||||
if(!cond)
|
||||
{
|
||||
static char buff[1024];
|
||||
DWORD ec = GetLastError();
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,NULL,ec,0,buff,1023,NULL);
|
||||
MessageBoxEx(0,buff,"ERROR?!",MB_OK,0);
|
||||
}
|
||||
return cond;
|
||||
}
|
||||
|
||||
#if FALSE
|
||||
typedef struct {
|
||||
SCSI_PASS_THROUGH_DIRECT spt;
|
||||
ULONG Filler;
|
||||
UCHAR ucSenseBuf[32];
|
||||
} SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER, *PSCSI_PASS_THROUGH_DIRECT_WITH_BUFFER;
|
||||
|
||||
SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER sptIOCTL; // global read bufs
|
||||
|
||||
char szBuf[1024];
|
||||
|
||||
PSCSI_ADDRESS pSA;
|
||||
|
||||
DWORD SendIoCtlScsiCommand(HANDLE hDevice, u8 direction,
|
||||
u8 cdbLength, u8* cdb,
|
||||
u32 dataLength, void* dataBuffer
|
||||
)
|
||||
{
|
||||
DWORD dwRet;
|
||||
|
||||
memset(szBuf,0,1024);
|
||||
|
||||
pSA=(PSCSI_ADDRESS)szBuf;
|
||||
pSA->Length=sizeof(SCSI_ADDRESS);
|
||||
|
||||
if(!DeviceIoControl(hDevice,IOCTL_SCSI_GET_ADDRESS,NULL,
|
||||
0,pSA,sizeof(SCSI_ADDRESS),
|
||||
&dwRet,NULL))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(&sptIOCTL,0,sizeof(sptIOCTL));
|
||||
|
||||
sptIOCTL.spt.Length = sizeof(SCSI_PASS_THROUGH_DIRECT);
|
||||
sptIOCTL.spt.TimeOutValue = 60;
|
||||
sptIOCTL.spt.SenseInfoLength = 14;
|
||||
sptIOCTL.spt.SenseInfoOffset = offsetof(SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER, ucSenseBuf);
|
||||
|
||||
sptIOCTL.spt.PathId = pSA->PortNumber;
|
||||
sptIOCTL.spt.TargetId = pSA->TargetId;
|
||||
sptIOCTL.spt.Lun = pSA->Lun;
|
||||
|
||||
sptIOCTL.spt.DataIn = (direction>0)?SCSI_IOCTL_DATA_IN:((direction<0)?SCSI_IOCTL_DATA_OUT:SCSI_IOCTL_DATA_UNSPECIFIED);
|
||||
sptIOCTL.spt.DataTransferLength = dataLength;
|
||||
sptIOCTL.spt.DataBuffer = dataBuffer;
|
||||
|
||||
sptIOCTL.spt.CdbLength = cdbLength;
|
||||
memcpy(sptIOCTL.spt.Cdb,cdb,cdbLength);
|
||||
|
||||
DWORD code = DeviceIoControl(hDevice,
|
||||
IOCTL_SCSI_PASS_THROUGH_DIRECT,
|
||||
&sptIOCTL,sizeof(sptIOCTL),
|
||||
&sptIOCTL,sizeof(sptIOCTL),
|
||||
&dwRet,NULL);
|
||||
ApiErrorCheck<DWORD>(code,0,false);
|
||||
return code;
|
||||
}
|
||||
|
||||
//0x00 = PHYSICAL STRUCTURE
|
||||
DWORD ScsiReadStructure(HANDLE hDevice, u32 layer, u32 format, u32 buffer_length, void* buffer)
|
||||
{
|
||||
u8 cdb[12]={0};
|
||||
|
||||
|
||||
cdb[0] = 0xAD;
|
||||
/*
|
||||
cdb[2] = (unsigned char)((addr >> 24) & 0xFF);
|
||||
cdb[3] = (unsigned char)((addr >> 16) & 0xFF);
|
||||
cdb[4] = (unsigned char)((addr >> 8) & 0xFF);
|
||||
cdb[5] = (unsigned char)(addr & 0xFF);
|
||||
*/
|
||||
cdb[6] = layer;
|
||||
cdb[7] = format;
|
||||
cdb[8] = (unsigned char)((buffer_length>>8) & 0xFF);
|
||||
cdb[9] = (unsigned char)((buffer_length) & 0xFF);
|
||||
|
||||
return SendIoCtlScsiCommand(hDevice, 1, 12, cdb, buffer_length, buffer);
|
||||
}
|
||||
|
||||
|
||||
DWORD ScsiReadBE_2(HANDLE hDevice, u32 addr, u32 count, u8* buffer)
|
||||
{
|
||||
u8 cdb[12]={0};
|
||||
|
||||
cdb[0] = 0xBE;
|
||||
cdb[2] = (unsigned char)((addr >> 24) & 0xFF);
|
||||
cdb[3] = (unsigned char)((addr >> 16) & 0xFF);
|
||||
cdb[4] = (unsigned char)((addr >> 8) & 0xFF);
|
||||
cdb[5] = (unsigned char)(addr & 0xFF);
|
||||
cdb[8] = count;
|
||||
cdb[9] = 0xF8;
|
||||
cdb[10] = 0x2;
|
||||
|
||||
return SendIoCtlScsiCommand(hDevice, 1, 12, cdb, 2352, buffer);
|
||||
}
|
||||
|
||||
DWORD ScsiRead10(HANDLE hDevice, u32 addr, u32 count, u8* buffer)
|
||||
{
|
||||
u8 cdb[10]={0};
|
||||
|
||||
cdb[0] = 0x28;
|
||||
//cdb[1] = lun<<5;
|
||||
cdb[2] = (unsigned char)((addr >> 24) & 0xFF);
|
||||
cdb[3] = (unsigned char)((addr >> 16) & 0xFF);
|
||||
cdb[4] = (unsigned char)((addr >> 8) & 0xFF);
|
||||
cdb[5] = (unsigned char)(addr & 0xFF);
|
||||
cdb[8] = count;
|
||||
|
||||
return SendIoCtlScsiCommand(hDevice, 1, 10, cdb, 2352, buffer);
|
||||
}
|
||||
|
||||
DWORD ScsiReadTOC(HANDLE hDevice, u32 addr, u8* buffer, bool use_msf)
|
||||
{
|
||||
u8 cdb[12]={0};
|
||||
|
||||
cdb[0] = 0x43;
|
||||
cdb[7] = 0x03;
|
||||
cdb[8] = 0x24;
|
||||
|
||||
if(use_msf) cdb[1]=2;
|
||||
|
||||
return SendIoCtlScsiCommand(hDevice, 1, 10, cdb, 2352, buffer);
|
||||
}
|
||||
|
||||
s32 IOCtlSrc::GetSectorCount()
|
||||
{
|
||||
DWORD size;
|
||||
|
||||
LARGE_INTEGER li;
|
||||
int plain_sectors = 0;
|
||||
|
||||
if(GetFileSizeEx(device,&li))
|
||||
{
|
||||
return li.QuadPart / 2048;
|
||||
}
|
||||
|
||||
GET_LENGTH_INFORMATION info;
|
||||
if(DeviceIoControl(device, IOCTL_DISK_GET_LENGTH_INFO, NULL, 0, &info, sizeof(info), &size, NULL))
|
||||
{
|
||||
return info.Length.QuadPart / 2048;
|
||||
}
|
||||
|
||||
CDROM_READ_TOC_EX tocrq={0};
|
||||
|
||||
tocrq.Format = CDROM_READ_TOC_EX_FORMAT_FULL_TOC;
|
||||
tocrq.Msf=1;
|
||||
tocrq.SessionTrack=1;
|
||||
|
||||
CDROM_TOC_FULL_TOC_DATA *ftd=(CDROM_TOC_FULL_TOC_DATA*)sectorbuffer;
|
||||
|
||||
if(DeviceIoControl(device,IOCTL_CDROM_READ_TOC_EX,&tocrq,sizeof(tocrq),ftd, 2048, &size, NULL))
|
||||
{
|
||||
for(int i=0;i<101;i++)
|
||||
{
|
||||
if(ftd->Descriptors[i].Point==0xa2)
|
||||
{
|
||||
if(ftd->Descriptors[i].SessionNumber==ftd->LastCompleteSession)
|
||||
{
|
||||
int min=ftd->Descriptors[i].Msf[0];
|
||||
int sec=ftd->Descriptors[i].Msf[1];
|
||||
int frm=ftd->Descriptors[i].Msf[2];
|
||||
|
||||
return MSF_TO_LBA(min,sec,frm);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int sectors1=-1;
|
||||
|
||||
if(ScsiReadStructure(device,0,DvdPhysicalDescriptor, sizeof(dld), &dld)!=0)
|
||||
{
|
||||
if(dld.ld.EndLayerZeroSector>0) // OTP?
|
||||
{
|
||||
sectors1 = dld.ld.EndLayerZeroSector - dld.ld.StartingDataSector;
|
||||
}
|
||||
else //PTP or single layer
|
||||
{
|
||||
sectors1 = dld.ld.EndDataSector - dld.ld.StartingDataSector;
|
||||
}
|
||||
|
||||
if(ScsiReadStructure(device,1,DvdPhysicalDescriptor, sizeof(dld), &dld)!=0)
|
||||
{
|
||||
// PTP second layer
|
||||
//sectors1 += dld.ld.EndDataSector - dld.ld.StartingDataSector;
|
||||
if(dld.ld.EndLayerZeroSector>0) // OTP?
|
||||
{
|
||||
sectors1 += dld.ld.EndLayerZeroSector - dld.ld.StartingDataSector;
|
||||
}
|
||||
else //PTP
|
||||
{
|
||||
sectors1 += dld.ld.EndDataSector - dld.ld.StartingDataSector;
|
||||
}
|
||||
}
|
||||
|
||||
return sectors1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
s32 IOCtlSrc::GetLayerBreakAddress()
|
||||
{
|
||||
DWORD size;
|
||||
if(ScsiReadStructure(device,0,DvdPhysicalDescriptor, sizeof(dld), &dld)!=0)
|
||||
{
|
||||
if(dld.ld.EndLayerZeroSector>0) // OTP?
|
||||
{
|
||||
return dld.ld.EndLayerZeroSector - dld.ld.StartingDataSector;
|
||||
}
|
||||
else //PTP or single layer
|
||||
{
|
||||
u32 s1 = dld.ld.EndDataSector - dld.ld.StartingDataSector;
|
||||
|
||||
if(ScsiReadStructure(device,1,DvdPhysicalDescriptor, sizeof(dld), &dld)!=0)
|
||||
{
|
||||
//PTP
|
||||
return s1;
|
||||
}
|
||||
|
||||
// single layer
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define RETURN(v) {OpenOK=v; return;}
|
||||
|
||||
s32 IOCtlSrc::Reopen()
|
||||
{
|
||||
if(device!=INVALID_HANDLE_VALUE)
|
||||
{
|
||||
DWORD size;
|
||||
DeviceIoControl(device,IOCTL_DVD_END_SESSION,&sessID,sizeof(DVD_SESSION_ID),NULL,0,&size, NULL);
|
||||
CloseHandle(device);
|
||||
}
|
||||
|
||||
DWORD share = FILE_SHARE_READ;
|
||||
DWORD flags = FILE_ATTRIBUTE_READONLY | FILE_FLAG_SEQUENTIAL_SCAN;
|
||||
DWORD size;
|
||||
|
||||
OpenOK = false;
|
||||
|
||||
device = CreateFile(fName, GENERIC_READ|GENERIC_WRITE|FILE_READ_ATTRIBUTES, share, NULL, OPEN_EXISTING, flags, 0);
|
||||
if(device==INVALID_HANDLE_VALUE)
|
||||
{
|
||||
device = CreateFile(fName, GENERIC_READ|FILE_READ_ATTRIBUTES, share, NULL, OPEN_EXISTING, flags, 0);
|
||||
if(device==INVALID_HANDLE_VALUE)
|
||||
return -1;
|
||||
}
|
||||
|
||||
sessID=0;
|
||||
DeviceIoControl(device,IOCTL_DVD_START_SESSION,NULL,0,&sessID,sizeof(DVD_SESSION_ID), &size, NULL);
|
||||
|
||||
tocCached = false;
|
||||
mediaTypeCached = false;
|
||||
discSizeCached = false;
|
||||
layerBreakCached = false;
|
||||
|
||||
OpenOK=true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
IOCtlSrc::IOCtlSrc(const char* fileName)
|
||||
{
|
||||
device=INVALID_HANDLE_VALUE;
|
||||
|
||||
strcpy_s(fName,256,fileName);
|
||||
|
||||
Reopen();
|
||||
}
|
||||
|
||||
IOCtlSrc::~IOCtlSrc()
|
||||
{
|
||||
if(OpenOK)
|
||||
{
|
||||
DWORD size;
|
||||
DeviceIoControl(device,IOCTL_DVD_END_SESSION,&sessID,sizeof(DVD_SESSION_ID),NULL,0,&size, NULL);
|
||||
|
||||
CloseHandle(device);
|
||||
}
|
||||
}
|
||||
|
||||
struct mycrap
|
||||
{
|
||||
DWORD shit;
|
||||
DVD_LAYER_DESCRIPTOR ld;
|
||||
};
|
||||
|
||||
DVD_READ_STRUCTURE dvdrs;
|
||||
mycrap dld;
|
||||
DISK_GEOMETRY dg;
|
||||
CDROM_READ_TOC_EX tocrq={0};
|
||||
|
||||
s32 IOCtlSrc::GetSectorCount()
|
||||
{
|
||||
DWORD size;
|
||||
|
||||
LARGE_INTEGER li;
|
||||
int plain_sectors = 0;
|
||||
|
||||
if(discSizeCached)
|
||||
return discSize;
|
||||
|
||||
if(GetFileSizeEx(device,&li))
|
||||
{
|
||||
discSizeCached = true;
|
||||
discSize = (s32)(li.QuadPart / 2048);
|
||||
return discSize;
|
||||
}
|
||||
|
||||
GET_LENGTH_INFORMATION info;
|
||||
if(DeviceIoControl(device, IOCTL_DISK_GET_LENGTH_INFO, NULL, 0, &info, sizeof(info), &size, NULL))
|
||||
{
|
||||
discSizeCached = true;
|
||||
discSize = (s32)(info.Length.QuadPart / 2048);
|
||||
return discSize;
|
||||
}
|
||||
|
||||
memset(&tocrq,0,sizeof(CDROM_READ_TOC_EX));
|
||||
tocrq.Format = CDROM_READ_TOC_EX_FORMAT_FULL_TOC;
|
||||
tocrq.Msf=1;
|
||||
tocrq.SessionTrack=1;
|
||||
|
||||
CDROM_TOC_FULL_TOC_DATA *ftd=(CDROM_TOC_FULL_TOC_DATA*)sectorbuffer;
|
||||
|
||||
if(DeviceIoControl(device,IOCTL_CDROM_READ_TOC_EX,&tocrq,sizeof(tocrq),ftd, 2048, &size, NULL))
|
||||
{
|
||||
for(int i=0;i<101;i++)
|
||||
{
|
||||
if(ftd->Descriptors[i].Point==0xa2)
|
||||
{
|
||||
if(ftd->Descriptors[i].SessionNumber==ftd->LastCompleteSession)
|
||||
{
|
||||
int min=ftd->Descriptors[i].Msf[0];
|
||||
int sec=ftd->Descriptors[i].Msf[1];
|
||||
int frm=ftd->Descriptors[i].Msf[2];
|
||||
|
||||
discSizeCached = true;
|
||||
discSize = (s32)MSF_TO_LBA(min,sec,frm);
|
||||
return discSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int sectors1=-1;
|
||||
|
||||
dvdrs.BlockByteOffset.QuadPart=0;
|
||||
dvdrs.Format=DvdPhysicalDescriptor;
|
||||
dvdrs.SessionId=sessID;
|
||||
dvdrs.LayerNumber=0;
|
||||
if(DeviceIoControl(device,IOCTL_DVD_READ_STRUCTURE,&dvdrs,sizeof(dvdrs),&dld, sizeof(dld), &size, NULL)!=0)
|
||||
{
|
||||
if(dld.ld.EndLayerZeroSector>0) // OTP?
|
||||
{
|
||||
sectors1 = dld.ld.EndLayerZeroSector - dld.ld.StartingDataSector;
|
||||
}
|
||||
else //PTP or single layer
|
||||
{
|
||||
sectors1 = dld.ld.EndDataSector - dld.ld.StartingDataSector;
|
||||
}
|
||||
dvdrs.BlockByteOffset.QuadPart=0;
|
||||
dvdrs.Format=DvdPhysicalDescriptor;
|
||||
dvdrs.SessionId=sessID;
|
||||
dvdrs.LayerNumber=1;
|
||||
if(DeviceIoControl(device,IOCTL_DVD_READ_STRUCTURE,&dvdrs,sizeof(dvdrs),&dld, sizeof(dld), &size, NULL)!=0)
|
||||
{
|
||||
// PTP second layer
|
||||
//sectors1 += dld.ld.EndDataSector - dld.ld.StartingDataSector;
|
||||
if(dld.ld.EndLayerZeroSector>0) // OTP?
|
||||
{
|
||||
sectors1 += dld.ld.EndLayerZeroSector - dld.ld.StartingDataSector;
|
||||
}
|
||||
else //PTP
|
||||
{
|
||||
sectors1 += dld.ld.EndDataSector - dld.ld.StartingDataSector;
|
||||
}
|
||||
}
|
||||
|
||||
discSizeCached = true;
|
||||
discSize = sectors1;
|
||||
return discSize;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
s32 IOCtlSrc::GetLayerBreakAddress()
|
||||
{
|
||||
DWORD size;
|
||||
DWORD code;
|
||||
|
||||
if(GetMediaType()<0)
|
||||
return -1;
|
||||
|
||||
if(layerBreakCached)
|
||||
return layerBreak;
|
||||
|
||||
dvdrs.BlockByteOffset.QuadPart=0;
|
||||
dvdrs.Format=DvdPhysicalDescriptor;
|
||||
dvdrs.SessionId=sessID;
|
||||
dvdrs.LayerNumber=0;
|
||||
if(code=DeviceIoControl(device,IOCTL_DVD_READ_STRUCTURE,&dvdrs,sizeof(dvdrs),&dld, sizeof(dld), &size, NULL)!=0)
|
||||
{
|
||||
if(dld.ld.EndLayerZeroSector>0) // OTP?
|
||||
{
|
||||
layerBreakCached = true;
|
||||
layerBreak = dld.ld.EndLayerZeroSector - dld.ld.StartingDataSector;
|
||||
return layerBreak;
|
||||
}
|
||||
else //PTP or single layer
|
||||
{
|
||||
u32 s1 = dld.ld.EndDataSector - dld.ld.StartingDataSector;
|
||||
|
||||
dvdrs.BlockByteOffset.QuadPart=0;
|
||||
dvdrs.Format=DvdPhysicalDescriptor;
|
||||
dvdrs.SessionId=sessID;
|
||||
dvdrs.LayerNumber=1;
|
||||
|
||||
if(DeviceIoControl(device,IOCTL_DVD_READ_STRUCTURE,&dvdrs,sizeof(dvdrs),&dld, sizeof(dld), &size, NULL)!=0)
|
||||
{
|
||||
//PTP
|
||||
layerBreakCached = true;
|
||||
layerBreak = s1;
|
||||
return layerBreak;
|
||||
}
|
||||
|
||||
// single layer
|
||||
layerBreakCached = true;
|
||||
layerBreak = 0;
|
||||
return layerBreak;
|
||||
}
|
||||
}
|
||||
|
||||
//if not a cd, and fails, assume single layer
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 IOCtlSrc::GetMediaType()
|
||||
{
|
||||
DWORD size;
|
||||
DWORD code;
|
||||
|
||||
if(mediaTypeCached)
|
||||
return mediaType;
|
||||
|
||||
memset(&tocrq,0,sizeof(CDROM_READ_TOC_EX));
|
||||
tocrq.Format = CDROM_READ_TOC_EX_FORMAT_FULL_TOC;
|
||||
tocrq.Msf=1;
|
||||
tocrq.SessionTrack=1;
|
||||
|
||||
CDROM_TOC_FULL_TOC_DATA *ftd=(CDROM_TOC_FULL_TOC_DATA*)sectorbuffer;
|
||||
|
||||
if(DeviceIoControl(device,IOCTL_CDROM_READ_TOC_EX,&tocrq,sizeof(tocrq),ftd, 2048, &size, NULL))
|
||||
{
|
||||
mediaTypeCached = true;
|
||||
mediaType = -1;
|
||||
return mediaType;
|
||||
}
|
||||
|
||||
dvdrs.BlockByteOffset.QuadPart=0;
|
||||
dvdrs.Format=DvdPhysicalDescriptor;
|
||||
dvdrs.SessionId=sessID;
|
||||
dvdrs.LayerNumber=0;
|
||||
if(code=DeviceIoControl(device,IOCTL_DVD_READ_STRUCTURE,&dvdrs,sizeof(dvdrs),&dld, sizeof(dld), &size, NULL)!=0)
|
||||
{
|
||||
if(dld.ld.EndLayerZeroSector>0) // OTP?
|
||||
{
|
||||
mediaTypeCached = true;
|
||||
mediaType = 2;
|
||||
return mediaType;
|
||||
}
|
||||
else //PTP or single layer
|
||||
{
|
||||
u32 s1 = dld.ld.EndDataSector - dld.ld.StartingDataSector;
|
||||
|
||||
dvdrs.BlockByteOffset.QuadPart=0;
|
||||
dvdrs.Format=DvdPhysicalDescriptor;
|
||||
dvdrs.SessionId=sessID;
|
||||
dvdrs.LayerNumber=1;
|
||||
|
||||
if(DeviceIoControl(device,IOCTL_DVD_READ_STRUCTURE,&dvdrs,sizeof(dvdrs),&dld, sizeof(dld), &size, NULL)!=0)
|
||||
{
|
||||
//PTP
|
||||
mediaTypeCached = true;
|
||||
mediaType = 2;
|
||||
return mediaType;
|
||||
}
|
||||
|
||||
// single layer
|
||||
mediaTypeCached = true;
|
||||
mediaType = 0;
|
||||
return mediaType;
|
||||
}
|
||||
}
|
||||
|
||||
//if not a cd, and fails, assume single layer
|
||||
mediaTypeCached = true;
|
||||
mediaType = 0;
|
||||
return mediaType;
|
||||
}
|
||||
|
||||
s32 IOCtlSrc::ReadTOC(char *toc,int msize)
|
||||
{
|
||||
DWORD size=0;
|
||||
|
||||
if(GetMediaType()>=0)
|
||||
return -1;
|
||||
|
||||
if(!tocCached)
|
||||
{
|
||||
memset(&tocrq,0,sizeof(CDROM_READ_TOC_EX));
|
||||
tocrq.Format = CDROM_READ_TOC_EX_FORMAT_FULL_TOC;
|
||||
tocrq.Msf=1;
|
||||
tocrq.SessionTrack=1;
|
||||
|
||||
CDROM_TOC_FULL_TOC_DATA *ftd=(CDROM_TOC_FULL_TOC_DATA*)tocCacheData;
|
||||
|
||||
if(!OpenOK) return -1;
|
||||
|
||||
int code = DeviceIoControl(device,IOCTL_CDROM_READ_TOC_EX,&tocrq,sizeof(tocrq),tocCacheData, 2048, &size, NULL);
|
||||
|
||||
if(code==0)
|
||||
return -1;
|
||||
|
||||
tocCached = true;
|
||||
}
|
||||
|
||||
memcpy(toc,tocCacheData,min(2048,msize));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 IOCtlSrc::ReadSectors2048(u32 sector, u32 count, char *buffer)
|
||||
{
|
||||
RAW_READ_INFO rri;
|
||||
|
||||
DWORD size=0;
|
||||
|
||||
if(!OpenOK) return -1;
|
||||
|
||||
rri.DiskOffset.QuadPart=sector*(u64)2048;
|
||||
rri.SectorCount=count;
|
||||
|
||||
//fall back to standard reading
|
||||
if(SetFilePointer(device,rri.DiskOffset.LowPart,&rri.DiskOffset.HighPart,FILE_BEGIN)==-1)
|
||||
{
|
||||
if(GetLastError()!=0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(ReadFile(device,buffer,2048*count,&size,NULL)==0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(size!=(2048*count))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
s32 IOCtlSrc::ReadSectors2352(u32 sector, u32 count, char *buffer)
|
||||
{
|
||||
RAW_READ_INFO rri;
|
||||
|
||||
DWORD size=0;
|
||||
|
||||
if(!OpenOK) return -1;
|
||||
|
||||
rri.DiskOffset.QuadPart=sector*(u64)2048;
|
||||
rri.SectorCount=count;
|
||||
|
||||
rri.TrackMode=(TRACK_MODE_TYPE)last_read_mode;
|
||||
if(DeviceIoControl(device,IOCTL_CDROM_RAW_READ,&rri,sizeof(rri),buffer, 2352*count, &size, NULL)==0)
|
||||
{
|
||||
rri.TrackMode=CDDA;
|
||||
if(DeviceIoControl(device,IOCTL_CDROM_RAW_READ,&rri,sizeof(rri),buffer, 2352*count, &size, NULL)==0)
|
||||
{
|
||||
rri.TrackMode=XAForm2;
|
||||
if(DeviceIoControl(device,IOCTL_CDROM_RAW_READ,&rri,sizeof(rri),buffer, 2352*count, &size, NULL)==0)
|
||||
{
|
||||
rri.TrackMode=YellowMode2;
|
||||
if(DeviceIoControl(device,IOCTL_CDROM_RAW_READ,&rri,sizeof(rri),buffer, 2352*count, &size, NULL)==0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
last_read_mode=rri.TrackMode;
|
||||
|
||||
if(size!=(2352*count))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 IOCtlSrc::DiscChanged()
|
||||
{
|
||||
DWORD size=0;
|
||||
|
||||
if(!OpenOK) return -1;
|
||||
|
||||
int ret = DeviceIoControl(device,IOCTL_STORAGE_CHECK_VERIFY,NULL,0,NULL,0, &size, NULL);
|
||||
|
||||
if(ret==0)
|
||||
{
|
||||
tocCached = false;
|
||||
mediaTypeCached = false;
|
||||
discSizeCached = false;
|
||||
layerBreakCached = false;
|
||||
|
||||
if(sessID!=0)
|
||||
{
|
||||
DeviceIoControl(device,IOCTL_DVD_END_SESSION,&sessID,sizeof(DVD_SESSION_ID),NULL,0,&size, NULL);
|
||||
sessID=0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(sessID==0)
|
||||
{
|
||||
DeviceIoControl(device,IOCTL_DVD_START_SESSION,NULL,0,&sessID,sizeof(DVD_SESSION_ID), &size, NULL);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 IOCtlSrc::IsOK()
|
||||
{
|
||||
return OpenOK;
|
||||
}
|
|
@ -1,422 +0,0 @@
|
|||
#include "CDVD.h"
|
||||
|
||||
const s32 prefetch_max_blocks=16;
|
||||
s32 prefetch_mode=0;
|
||||
s32 prefetch_last_lba=0;
|
||||
s32 prefetch_last_mode=0;
|
||||
s32 prefetch_left=0;
|
||||
|
||||
HANDLE hNotify = INVALID_HANDLE_VALUE;
|
||||
HANDLE hThread = INVALID_HANDLE_VALUE;
|
||||
DWORD pidThread= 0;
|
||||
|
||||
enum loadStatus
|
||||
{
|
||||
LoadIdle,
|
||||
LoadPending,
|
||||
LoadSuccess,
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int lsn;
|
||||
int mode;
|
||||
char data[2352*16]; //we will read in blocks of 16 sectors
|
||||
} SectorInfo;
|
||||
|
||||
//bits: 8 would use 1<<8 entries, or 256*16 sectors
|
||||
#define CACHE_SIZE 10
|
||||
|
||||
const s32 CacheSize=(1<<CACHE_SIZE);
|
||||
SectorInfo Cache[CacheSize];
|
||||
|
||||
bool threadRequestPending;
|
||||
SectorInfo threadRequestInfo;
|
||||
|
||||
u32 cdvdSectorHash(int lsn, int mode)
|
||||
{
|
||||
u32 t = 0;
|
||||
|
||||
int i=32;
|
||||
int m=CacheSize-1;
|
||||
|
||||
while(i>=0)
|
||||
{
|
||||
t^=lsn&m;
|
||||
lsn>>=CACHE_SIZE;
|
||||
i-=CACHE_SIZE;
|
||||
}
|
||||
|
||||
return (t^mode)&m;
|
||||
}
|
||||
|
||||
void cdvdCacheUpdate(int lsn, int mode, char* data)
|
||||
{
|
||||
u32 entry = cdvdSectorHash(lsn,mode);
|
||||
|
||||
memcpy(Cache[entry].data,data,2352*16);
|
||||
Cache[entry].lsn = lsn;
|
||||
Cache[entry].mode = mode;
|
||||
}
|
||||
|
||||
bool cdvdCacheFetch(int lsn, int mode, char* data)
|
||||
{
|
||||
u32 entry = cdvdSectorHash(lsn,mode);
|
||||
|
||||
if((Cache[entry].lsn==lsn) &&
|
||||
(Cache[entry].mode==mode))
|
||||
{
|
||||
memcpy(data,Cache[entry].data,2352*16);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void cdvdCacheReset()
|
||||
{
|
||||
for(int i=0;i<CacheSize;i++)
|
||||
{
|
||||
Cache[i].lsn=-1;
|
||||
Cache[i].mode=-1;
|
||||
}
|
||||
}
|
||||
|
||||
void cdvdCallNewDiscCB()
|
||||
{
|
||||
weAreInNewDiskCB=1;
|
||||
newDiscCB();
|
||||
weAreInNewDiskCB=0;
|
||||
}
|
||||
|
||||
bool cdvdUpdateDiscStatus()
|
||||
{
|
||||
int change = src->DiscChanged();
|
||||
|
||||
if(change==-1) //error getting status (no disc in drive?)
|
||||
{
|
||||
//try to recreate the device
|
||||
src->Reopen();
|
||||
|
||||
if(src->IsOK())
|
||||
{
|
||||
change = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
curDiskType=CDVD_TYPE_NODISC;
|
||||
curTrayStatus=CDVD_TRAY_OPEN;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(change==1)
|
||||
{
|
||||
if(!disc_has_changed)
|
||||
{
|
||||
disc_has_changed=1;
|
||||
curDiskType=CDVD_TYPE_NODISC;
|
||||
curTrayStatus=CDVD_TRAY_OPEN;
|
||||
cdvdCallNewDiscCB();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(disc_has_changed)
|
||||
{
|
||||
curDiskType=CDVD_TYPE_NODISC;
|
||||
curTrayStatus=CDVD_TRAY_CLOSE;
|
||||
|
||||
// just a test
|
||||
src->Reopen();
|
||||
|
||||
disc_has_changed=0;
|
||||
cdvdRefreshData();
|
||||
cdvdCallNewDiscCB();
|
||||
}
|
||||
}
|
||||
return (change!=0);
|
||||
}
|
||||
|
||||
DWORD CALLBACK cdvdThread(PVOID param)
|
||||
{
|
||||
printf(" * CDVD: IO thread started...\n");
|
||||
while(cdvd_is_open)
|
||||
{
|
||||
DWORD f=0;
|
||||
|
||||
if(!src) break;
|
||||
|
||||
if(cdvdUpdateDiscStatus()) continue;
|
||||
|
||||
if(prefetch_left)
|
||||
WaitForSingleObject(hNotify,1);
|
||||
else
|
||||
WaitForSingleObject(hNotify,250);
|
||||
|
||||
if(cdvd_is_open)
|
||||
{
|
||||
static SectorInfo info;
|
||||
|
||||
bool handlingRequest = false;
|
||||
|
||||
if(threadRequestPending)
|
||||
{
|
||||
info=threadRequestInfo;
|
||||
handlingRequest = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
info.lsn = prefetch_last_lba;
|
||||
info.mode = prefetch_last_mode;
|
||||
}
|
||||
|
||||
if(threadRequestPending || prefetch_left)
|
||||
{
|
||||
s32 ret = -1;
|
||||
s32 tries=5;
|
||||
|
||||
s32 count = 16;
|
||||
|
||||
s32 left = tracks[0].length-info.lsn;
|
||||
|
||||
if(left<count) count=left;
|
||||
|
||||
do {
|
||||
if(info.mode==CDVD_MODE_2048)
|
||||
ret = src->ReadSectors2048(info.lsn,count,info.data);
|
||||
else
|
||||
ret = src->ReadSectors2352(info.lsn,count,info.data);
|
||||
|
||||
if(ret==0)
|
||||
break;
|
||||
|
||||
tries--;
|
||||
|
||||
} while((ret<0)&&(tries>0));
|
||||
|
||||
cdvdCacheUpdate(info.lsn,info.mode,info.data);
|
||||
|
||||
if(handlingRequest)
|
||||
{
|
||||
threadRequestInfo = info;
|
||||
|
||||
handlingRequest = false;
|
||||
threadRequestPending = false;
|
||||
|
||||
prefetch_last_lba=info.lsn;
|
||||
prefetch_last_mode=info.mode;
|
||||
|
||||
prefetch_left = prefetch_max_blocks;
|
||||
}
|
||||
else
|
||||
{
|
||||
prefetch_last_lba+=16;
|
||||
prefetch_left--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
printf(" * CDVD: IO thread finished.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 cdvdStartThread()
|
||||
{
|
||||
|
||||
hNotify = CreateEvent(NULL,FALSE,FALSE,NULL);
|
||||
if(hNotify==INVALID_HANDLE_VALUE)
|
||||
return -1;
|
||||
|
||||
cdvd_is_open=true;
|
||||
hThread = CreateThread(NULL,0,cdvdThread,NULL,0,&pidThread);
|
||||
|
||||
if(hThread==INVALID_HANDLE_VALUE)
|
||||
return -1;
|
||||
|
||||
SetThreadPriority(hThread,THREAD_PRIORITY_NORMAL);
|
||||
|
||||
cdvdCacheReset();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void cdvdStopThread()
|
||||
{
|
||||
cdvd_is_open=false;
|
||||
PulseEvent(hNotify);
|
||||
if(WaitForSingleObject(hThread,4000)==WAIT_TIMEOUT)
|
||||
{
|
||||
TerminateThread(hThread,0);
|
||||
}
|
||||
CloseHandle(hThread);
|
||||
CloseHandle(hNotify);
|
||||
}
|
||||
|
||||
s32 cdvdRequestSector(u32 sector, s32 mode)
|
||||
{
|
||||
if(sector>=tracks[0].length)
|
||||
return -1;
|
||||
|
||||
sector&=~15; //align to 16-sector block
|
||||
|
||||
threadRequestInfo.lsn = sector;
|
||||
threadRequestInfo.mode = mode;
|
||||
threadRequestPending = false;
|
||||
if(cdvdCacheFetch(sector,mode,threadRequestInfo.data))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
threadRequestPending = true;
|
||||
|
||||
PulseEvent(hNotify);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 cdvdRequestComplete()
|
||||
{
|
||||
return !threadRequestPending;
|
||||
}
|
||||
|
||||
s8* cdvdGetSector(s32 sector, s32 mode)
|
||||
{
|
||||
while(threadRequestPending)
|
||||
{
|
||||
Sleep(1);
|
||||
}
|
||||
|
||||
s32 offset;
|
||||
|
||||
if(mode==CDVD_MODE_2048)
|
||||
{
|
||||
offset = 2048*(sector-threadRequestInfo.lsn);
|
||||
return threadRequestInfo.data + offset;
|
||||
}
|
||||
|
||||
offset = 2352*(sector-threadRequestInfo.lsn);
|
||||
s8* data = threadRequestInfo.data + offset;
|
||||
|
||||
switch(mode)
|
||||
{
|
||||
case CDVD_MODE_2328:
|
||||
return data + 24;
|
||||
case CDVD_MODE_2340:
|
||||
return data + 12;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
s32 cdvdDirectReadSector(s32 first, s32 mode, char *buffer)
|
||||
{
|
||||
static char data[16*2352];
|
||||
|
||||
if((u32)first>=tracks[0].length)
|
||||
return -1;
|
||||
|
||||
s32 sector = first&(~15); //align to 16-sector block
|
||||
|
||||
if(!cdvdCacheFetch(sector,mode,data))
|
||||
{
|
||||
s32 ret = -1;
|
||||
s32 tries=5;
|
||||
|
||||
s32 count = 16;
|
||||
|
||||
s32 left = tracks[0].length-sector;
|
||||
|
||||
if(left<count) count=left;
|
||||
|
||||
do {
|
||||
if(mode==CDVD_MODE_2048)
|
||||
ret = src->ReadSectors2048(sector,count,data);
|
||||
else
|
||||
ret = src->ReadSectors2352(sector,count,data);
|
||||
|
||||
if(ret==0)
|
||||
break;
|
||||
|
||||
tries--;
|
||||
|
||||
} while((ret<0)&&(tries>0));
|
||||
|
||||
cdvdCacheUpdate(sector,mode,data);
|
||||
}
|
||||
|
||||
s32 offset;
|
||||
|
||||
if(mode==CDVD_MODE_2048)
|
||||
{
|
||||
offset = 2048*(first-sector);
|
||||
memcpy(buffer,data + offset,2048);
|
||||
return 0;
|
||||
}
|
||||
|
||||
offset = 2352*(first-sector);
|
||||
s8* bfr = data + offset;
|
||||
|
||||
switch(mode)
|
||||
{
|
||||
case CDVD_MODE_2328:
|
||||
memcpy(buffer,bfr+24,2328);
|
||||
return 0;
|
||||
case CDVD_MODE_2340:
|
||||
memcpy(buffer,bfr+12,2340);
|
||||
return 0;
|
||||
default:
|
||||
memcpy(buffer,bfr+12,2352);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 cdvdGetMediaType()
|
||||
{
|
||||
return src->GetMediaType();
|
||||
}
|
||||
|
||||
s32 refreshes=0;
|
||||
|
||||
s32 cdvdRefreshData()
|
||||
{
|
||||
char *diskTypeName="Unknown";
|
||||
|
||||
//read TOC from device
|
||||
cdvdParseTOC();
|
||||
|
||||
if((etrack==0)||(strack>etrack))
|
||||
{
|
||||
curDiskType=CDVD_TYPE_NODISC;
|
||||
}
|
||||
else
|
||||
{
|
||||
curDiskType = FindDiskType();
|
||||
}
|
||||
|
||||
curTrayStatus = CDVD_TRAY_CLOSE;
|
||||
|
||||
switch(curDiskType)
|
||||
{
|
||||
case CDVD_TYPE_ILLEGAL: diskTypeName="Illegal Disc"; break;
|
||||
case CDVD_TYPE_DVDV: diskTypeName="DVD-Video"; break;
|
||||
case CDVD_TYPE_CDDA: diskTypeName="CD-Audio"; break;
|
||||
case CDVD_TYPE_PS2DVD: diskTypeName="PS2 DVD"; break;
|
||||
case CDVD_TYPE_PS2CDDA: diskTypeName="PS2 CD+Audio"; break;
|
||||
case CDVD_TYPE_PS2CD: diskTypeName="PS2 CD"; break;
|
||||
case CDVD_TYPE_PSCDDA: diskTypeName="PS1 CD+Audio"; break;
|
||||
case CDVD_TYPE_PSCD: diskTypeName="PS1 CD"; break;
|
||||
case CDVD_TYPE_UNKNOWN: diskTypeName="Unknown"; break;
|
||||
case CDVD_TYPE_DETCTDVDD: diskTypeName="Detecting (Single-Layer DVD)"; break;
|
||||
case CDVD_TYPE_DETCTDVDS: diskTypeName="Detecting (Double-Layer DVD)"; break;
|
||||
case CDVD_TYPE_DETCTCD: diskTypeName="Detecting (CD)"; break;
|
||||
case CDVD_TYPE_DETCT: diskTypeName="Detecting"; break;
|
||||
case CDVD_TYPE_NODISC: diskTypeName="No Disc"; break;
|
||||
}
|
||||
|
||||
printf(" * CDVD: Disk Type: %s\n",diskTypeName);
|
||||
|
||||
cdvdCacheReset();
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
template<int from, int to>
|
||||
int Convert(char *dest, const char* psrc, int lsn);
|
||||
|
||||
template<>
|
||||
int Convert<2048,2048>(char *dest, const char* psrc, int lsn)
|
||||
{
|
||||
memcpy(dest,psrc,2048);
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<>
|
||||
int Convert<2352,2352>(char *dest, const char* psrc, int lsn)
|
||||
{
|
||||
memcpy(dest,psrc,2352);
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<>
|
||||
int Convert<2352,2048>(char *dest, const char* psrc, int lsn)
|
||||
{
|
||||
memcpy(dest,psrc+16,2048);
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<>
|
||||
int Convert<2048,2352>(char *dest, const char* psrc, int lsn)
|
||||
{
|
||||
int m = lsn / (75*60);
|
||||
int s = (lsn/75) % 60;
|
||||
int f = lsn%75;
|
||||
unsigned char header[16] = {
|
||||
0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00, m, s, f,0x02
|
||||
};
|
||||
|
||||
memcpy(dest,header,16);
|
||||
memcpy(dest+16,psrc,2048);
|
||||
return 0;
|
||||
}
|
|
@ -1,99 +0,0 @@
|
|||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "afxres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Spanish resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ESN)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_SPANISH, SUBLANG_SPANISH_MODERN
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#include ""afxres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_CONFIG DIALOGEX 0, 0, 184, 77
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "cdvdGigaherz"
|
||||
FONT 8, "MS Sans Serif", 0, 0, 0x0
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,75,59,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,129,59,50,14
|
||||
COMBOBOX IDC_DRIVE,15,20,160,64,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
GROUPBOX "Source drive...",IDC_STATIC,7,7,172,48
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO
|
||||
BEGIN
|
||||
IDD_CONFIG, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 179
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 73
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
#endif // Spanish resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||
# Visual Studio 2008
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cdvdGigaherz2008", "cdvdGigaherz2008.vcproj", "{5CF88D5F-64DD-4EDC-9F1A-436BD502940A}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{5CF88D5F-64DD-4EDC-9F1A-436BD502940A}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{5CF88D5F-64DD-4EDC-9F1A-436BD502940A}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{5CF88D5F-64DD-4EDC-9F1A-436BD502940A}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{5CF88D5F-64DD-4EDC-9F1A-436BD502940A}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -1,373 +0,0 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9,00"
|
||||
Name="cdvdGigaherz2008"
|
||||
ProjectGUID="{5CF88D5F-64DD-4EDC-9F1A-436BD502940A}"
|
||||
RootNamespace="cdvdGigaherz"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release"
|
||||
IntermediateDirectory=".\Release"
|
||||
ConfigurationType="2"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="true"
|
||||
SuppressStartupBanner="true"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\Release/cdvdGigaherz.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
AdditionalIncludeDirectories="H:\pcsx2-trunk\common\include"
|
||||
PreprocessorDefinitions="NDEBUG;WIN32;_WINDOWS;_USRDLL;__MSCW32__"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Release/cdvdGigaherz.pch"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
ObjectFile=".\Release/"
|
||||
ProgramDataBaseFileName=".\Release/"
|
||||
BrowseInformation="0"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="3082"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="odbc32.lib odbccp32.lib shlwapi.lib"
|
||||
OutputFile="$(OutDir)\cdvdGigaherz.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
ModuleDefinitionFile=".\plugin.def"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile="$(TargetDir)$(TargetName).pdb"
|
||||
RandomizedBaseAddress="0"
|
||||
DataExecutionPrevention="0"
|
||||
ImportLibrary="$(OutDir)\$(TargetName).lib"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="2"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
MkTypLibCompatible="true"
|
||||
SuppressStartupBanner="true"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\Debug/cdvdGigaherz.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="H:\pcsx2-trunk\common\include"
|
||||
PreprocessorDefinitions="_DEBUG;WIN32;_WINDOWS;_USRDLL;__MSCW32__;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Debug/cdvdGigaherz.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
BrowseInformation="0"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
DebugInformationFormat="4"
|
||||
EnablePREfast="false"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="3082"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="odbc32.lib odbccp32.lib shlwapi.lib"
|
||||
OutputFile="h:\pcsx2-trunk\bin\plugins\cdvdGigaherz.dll"
|
||||
LinkIncremental="2"
|
||||
SuppressStartupBanner="true"
|
||||
UACExecutionLevel="2"
|
||||
ModuleDefinitionFile=".\plugin.def"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile="$(TargetDir)$(TargetName).pdb"
|
||||
RandomizedBaseAddress="0"
|
||||
DataExecutionPrevention="0"
|
||||
ImportLibrary="$(OutDir)\$(TargetName).lib"
|
||||
TargetMachine="1"
|
||||
Profile="false"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\CDVD.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="NDEBUG;WIN32;_WINDOWS;_MBCS;_USRDLL;__MSCW32__;$(NoInherit)"
|
||||
BrowseInformation="1"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="_DEBUG;WIN32;_WINDOWS;_MBCS;_USRDLL;__MSCW32__;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"
|
||||
BrowseInformation="1"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\CheckDiskType.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\config.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\FileSrc.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\IOCtlSrc.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\mciTOC.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="plugin.def"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ReadThread.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\TestRun.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\TocStuff.cpp"
|
||||
>
|
||||
</File>
|
||||
<Filter
|
||||
Name="isofs"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\isofs\CDVDiso.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\isofs\CDVDisodrv.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl"
|
||||
>
|
||||
<File
|
||||
RelativePath="CDVD.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="resource.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\SectorConverters.h"
|
||||
>
|
||||
</File>
|
||||
<Filter
|
||||
Name="isofs"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\isofs\CDVDiso.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\isofs\CDVDisodrv.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\isofs\CDVDlib.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
>
|
||||
<File
|
||||
RelativePath="cdvd.rc"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -1,224 +0,0 @@
|
|||
//GiGaHeRz SPU2 Driver
|
||||
//Copyright (c) David Quintana <DavidQuintana@canal21.com>
|
||||
//
|
||||
//This library is free software; you can redistribute it and/or
|
||||
//modify it under the terms of the GNU Lesser General Public
|
||||
//License as published by the Free Software Foundation; either
|
||||
//version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
//This library is distributed in the hope that it will be useful,
|
||||
//but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
//Lesser General Public License for more details.
|
||||
//
|
||||
//You should have received a copy of the GNU Lesser General Public
|
||||
//License along with this library; if not, write to the Free Software
|
||||
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
//#include "spu2.h"
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
#include "resource.h"
|
||||
|
||||
#include "cdvd.h"
|
||||
|
||||
// Config Vars
|
||||
|
||||
// DEBUG
|
||||
|
||||
char source_drive;
|
||||
char source_file[256];
|
||||
|
||||
char CfgFile[]="inis\\cdvdGigaherz.ini";
|
||||
|
||||
|
||||
/*| Config File Format: |¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯*\
|
||||
+--+---------------------+------------------------+
|
||||
| |
|
||||
| Option=Value |
|
||||
| |
|
||||
| |
|
||||
| Boolean Values: TRUE,YES,1,T,Y mean 'true', |
|
||||
| everything else means 'false'. |
|
||||
| |
|
||||
| All Values are limited to 255 chars. |
|
||||
| |
|
||||
+-------------------------------------------------+
|
||||
\*_____________________________________________*/
|
||||
|
||||
|
||||
void CfgWriteBool(char *Section, char*Name, char Value) {
|
||||
char *Data=Value?"TRUE":"FALSE";
|
||||
|
||||
WritePrivateProfileString(Section,Name,Data,CfgFile);
|
||||
}
|
||||
|
||||
void CfgWriteInt(char *Section, char*Name, int Value) {
|
||||
char Data[255];
|
||||
_itoa(Value,Data,10);
|
||||
|
||||
WritePrivateProfileString(Section,Name,Data,CfgFile);
|
||||
}
|
||||
|
||||
void CfgWriteStr(char *Section, char*Name,char *Data) {
|
||||
WritePrivateProfileString(Section,Name,Data,CfgFile);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
char CfgReadBool(char *Section,char *Name,char Default) {
|
||||
char Data[255]="";
|
||||
GetPrivateProfileString(Section,Name,"",Data,255,CfgFile);
|
||||
Data[254]=0;
|
||||
if(strlen(Data)==0) {
|
||||
CfgWriteBool(Section,Name,Default);
|
||||
return Default;
|
||||
}
|
||||
|
||||
if(strcmp(Data,"1")==0) return -1;
|
||||
if(strcmp(Data,"Y")==0) return -1;
|
||||
if(strcmp(Data,"T")==0) return -1;
|
||||
if(strcmp(Data,"YES")==0) return -1;
|
||||
if(strcmp(Data,"TRUE")==0) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CfgReadInt(char *Section, char*Name,int Default) {
|
||||
char Data[255]="";
|
||||
GetPrivateProfileString(Section,Name,"",Data,255,CfgFile);
|
||||
Data[254]=0;
|
||||
|
||||
if(strlen(Data)==0) {
|
||||
CfgWriteInt(Section,Name,Default);
|
||||
return Default;
|
||||
}
|
||||
|
||||
return atoi(Data);
|
||||
}
|
||||
|
||||
void CfgReadStr(char *Section, char*Name,char *Data,int DataSize,char *Default) {
|
||||
int sl;
|
||||
GetPrivateProfileString(Section,Name,"",Data,DataSize,CfgFile);
|
||||
|
||||
if(strlen(Data)==0) {
|
||||
sl=(int)strlen(Default);
|
||||
strncpy(Data,Default,sl>255?255:sl);
|
||||
CfgWriteStr(Section,Name,Data);
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void ReadSettings()
|
||||
{
|
||||
char temp[512];
|
||||
|
||||
CfgReadStr("Config","Source",temp,511,"-");
|
||||
source_drive=temp[0];
|
||||
|
||||
if(source_drive=='$')
|
||||
strcpy_s(source_file,sizeof(source_file),temp+1);
|
||||
else
|
||||
source_file[0]=0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void WriteSettings()
|
||||
{
|
||||
char temp[511];
|
||||
|
||||
temp[0]=source_drive;
|
||||
temp[1]=0;
|
||||
|
||||
strcat(temp,source_file);
|
||||
|
||||
CfgWriteStr("Config","Source",temp);
|
||||
}
|
||||
|
||||
char* path[] = {
|
||||
"A:","B:","C:","D:","E:","F:","G:","H:","I:","J:","K:","L:","M:",
|
||||
"N:","O:","P:","Q:","R:","S:","T:","U:","V:","W:","X:","Y:","Z:",
|
||||
};
|
||||
|
||||
int n,s;
|
||||
|
||||
#define SET_CHECK(idc,value) SendMessage(GetDlgItem(hWnd,idc),BM_SETCHECK,((value)==0)?BST_UNCHECKED:BST_CHECKED,0)
|
||||
#define HANDLE_CHECK(idc,hvar) case idc: hvar=hvar?0:1; SendMessage(GetDlgItem(hWnd,idc),BM_SETCHECK,(hvar==1)?BST_CHECKED:BST_UNCHECKED,0); break
|
||||
#define HANDLE_CHECKNB(idc,hvar)case idc: hvar=hvar?0:1; SendMessage(GetDlgItem(hWnd,idc),BM_SETCHECK,(hvar==1)?BST_CHECKED:BST_UNCHECKED,0)
|
||||
#define ENABLE_CONTROL(idc,value) EnableWindow(GetDlgItem(hWnd,idc),value)
|
||||
|
||||
BOOL CALLBACK ConfigProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
|
||||
{
|
||||
int wmId,wmEvent;
|
||||
char temp[20]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
||||
|
||||
switch(uMsg)
|
||||
{
|
||||
|
||||
case WM_PAINT:
|
||||
return FALSE;
|
||||
case WM_INITDIALOG:
|
||||
|
||||
n=0;s=0;
|
||||
|
||||
SendMessage(GetDlgItem(hWnd,IDC_DRIVE),CB_RESETCONTENT,0,0);
|
||||
SendMessage(GetDlgItem(hWnd,IDC_DRIVE),CB_ADDSTRING,0,(LPARAM)"@ (No disc)");
|
||||
for(char d='A';d<='Z';d++)
|
||||
{
|
||||
if(GetDriveType(path[d-'A'])==DRIVE_CDROM)
|
||||
{
|
||||
n++;
|
||||
|
||||
SendMessage(GetDlgItem(hWnd,IDC_DRIVE),CB_ADDSTRING,0,(LPARAM)path[d-'A']);
|
||||
|
||||
if(source_drive==d)
|
||||
{
|
||||
s=n;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SendMessage(GetDlgItem(hWnd,IDC_DRIVE),CB_SETCURSEL,s,0);
|
||||
|
||||
break;
|
||||
case WM_COMMAND:
|
||||
wmId = LOWORD(wParam);
|
||||
wmEvent = HIWORD(wParam);
|
||||
// Parse the menu selections:
|
||||
switch (wmId)
|
||||
{
|
||||
case IDOK:
|
||||
GetDlgItemText(hWnd,IDC_DRIVE,temp,20);
|
||||
temp[19]=0;
|
||||
source_drive=temp[0];
|
||||
|
||||
WriteSettings();
|
||||
EndDialog(hWnd,0);
|
||||
break;
|
||||
case IDCANCEL:
|
||||
EndDialog(hWnd,0);
|
||||
break;
|
||||
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void configure()
|
||||
{
|
||||
INT_PTR ret;
|
||||
ReadSettings();
|
||||
ret=DialogBoxParam(hinst,MAKEINTRESOURCE(IDD_CONFIG),GetActiveWindow(),(DLGPROC)ConfigProc,1);
|
||||
if(ret==-1)
|
||||
{
|
||||
MessageBoxEx(GetActiveWindow(),"Error Opening the config dialog.","OMG ERROR!",MB_OK,0);
|
||||
return;
|
||||
}
|
||||
ReadSettings();
|
||||
}
|
|
@ -1,825 +0,0 @@
|
|||
/*
|
||||
* Original code from libcdvd by Hiryu & Sjeep (C) 2002
|
||||
* Modified by Florin for PCSX2 emu
|
||||
* Fixed CdRead by linuzappz
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#ifdef __LINUX__
|
||||
#define strnicmp strncasecmp
|
||||
#endif
|
||||
|
||||
#include "CDVDiso.h"
|
||||
#include "CDVDisodrv.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
|
||||
struct dir_toc_data{
|
||||
unsigned int start_LBA;
|
||||
unsigned int num_sectors;
|
||||
unsigned int num_entries;
|
||||
unsigned int current_entry;
|
||||
unsigned int current_sector;
|
||||
unsigned int current_sector_offset;
|
||||
unsigned int inc_dirs;
|
||||
unsigned char extension_list[128+1];
|
||||
};
|
||||
|
||||
//static u8 cdVolDescriptor[2048];
|
||||
static struct dir_toc_data getDirTocData;
|
||||
static struct cdVolDesc CDVolDesc;
|
||||
|
||||
extern s32 cdvdDirectReadSector(s32 first, s32 mode, char *buffer);
|
||||
|
||||
void _splitpath2(const char *constpath, char *dir, char *fname){
|
||||
// 255 char max path-length is an ISO9660 restriction
|
||||
// we must change this for Joliet or relaxed iso restriction support
|
||||
static char pathcopy[1024+1];
|
||||
|
||||
char* slash;
|
||||
|
||||
strncpy(pathcopy, constpath, 1024);
|
||||
pathcopy[1024]=0;
|
||||
|
||||
slash = strrchr (pathcopy, '/');
|
||||
|
||||
// if the path doesn't contain a '/' then look for a '\'
|
||||
if (!slash)
|
||||
slash = strrchr (pathcopy, (int)'\\');
|
||||
|
||||
// if a slash was found
|
||||
if (slash != NULL)
|
||||
{
|
||||
// null terminate the path
|
||||
slash[0] = 0;
|
||||
// and copy the path into 'dir'
|
||||
strncpy(dir, pathcopy, 1024);
|
||||
dir[255]=0;
|
||||
|
||||
// copy the filename into 'fname'
|
||||
strncpy(fname, slash+1, 128);
|
||||
fname[128]=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
dir[0] = 0;
|
||||
|
||||
strncpy(fname, pathcopy, 128);
|
||||
fname[128]=0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Used in findfile
|
||||
int strcasecmp(const char *s1, const char *s2){
|
||||
while (*s1 != '\0' && tolower(*s1) == tolower(*s2))
|
||||
{
|
||||
s1++;
|
||||
s2++;
|
||||
}
|
||||
|
||||
return tolower(*(unsigned char *) s1) - tolower(*(unsigned char *) s2);
|
||||
}
|
||||
|
||||
// Copy a TOC Entry from the CD native format to our tidier format
|
||||
void TocEntryCopy(struct TocEntry* tocEntry, struct dirTocEntry* internalTocEntry){
|
||||
int i;
|
||||
int filenamelen;
|
||||
|
||||
tocEntry->fileSize = internalTocEntry->fileSize;
|
||||
tocEntry->fileLBA = internalTocEntry->fileLBA;
|
||||
tocEntry->fileProperties = internalTocEntry->fileProperties;
|
||||
memcpy(tocEntry->date, internalTocEntry->dateStamp, 6);
|
||||
tocEntry->date[6]=0;
|
||||
|
||||
if (CDVolDesc.filesystemType == 2){
|
||||
// This is a Joliet Filesystem, so use Unicode to ISO string copy
|
||||
|
||||
filenamelen = internalTocEntry->filenameLength/2;
|
||||
|
||||
if (!(tocEntry->fileProperties & 0x02)){
|
||||
// strip the ;1 from the filename
|
||||
// filenamelen -= 2;//(Florin) nah, do not strip ;1
|
||||
}
|
||||
|
||||
for (i=0; i < filenamelen; i++)
|
||||
tocEntry->filename[i] = internalTocEntry->filename[(i<<1)+1];
|
||||
|
||||
tocEntry->filename[filenamelen] = 0;
|
||||
}
|
||||
else{
|
||||
filenamelen = internalTocEntry->filenameLength;
|
||||
|
||||
if (!(tocEntry->fileProperties & 0x02)){
|
||||
// strip the ;1 from the filename
|
||||
// filenamelen -= 2;//(Florin) nah, do not strip ;1
|
||||
}
|
||||
|
||||
// use normal string copy
|
||||
strncpy((char*)tocEntry->filename,(char*)internalTocEntry->filename,128);
|
||||
tocEntry->filename[filenamelen] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if a TOC Entry matches our extension list
|
||||
int TocEntryCompare(char* filename, char* extensions){
|
||||
static char ext_list[129];
|
||||
|
||||
char* token;
|
||||
|
||||
char* ext_point;
|
||||
|
||||
strncpy(ext_list,extensions,128);
|
||||
ext_list[128]=0;
|
||||
|
||||
token = strtok( ext_list, " ," );
|
||||
while( token != NULL )
|
||||
{
|
||||
// if 'token' matches extension of 'filename'
|
||||
// then return a match
|
||||
ext_point = strrchr(filename,'.');
|
||||
|
||||
if (_strnicmp(ext_point, token, strlen(token)) == 0)
|
||||
return (TRUE);
|
||||
|
||||
/* Get next token: */
|
||||
token = strtok( NULL, " ," );
|
||||
}
|
||||
|
||||
// If not match found then return FALSE
|
||||
return (FALSE);
|
||||
|
||||
}
|
||||
|
||||
#define CD_SECS 60 /* seconds per minute */
|
||||
#define CD_FRAMES 75 /* frames per second */
|
||||
#define CD_MSF_OFFSET 150 /* MSF numbering offset of first frame */
|
||||
|
||||
int CdRead(u32 lsn, u32 sectors, void *buf, CdRMode *mode){
|
||||
u32 i;
|
||||
int rmode;
|
||||
|
||||
switch (mode->datapattern) {
|
||||
case CdSecS2048:
|
||||
rmode = CDVD_MODE_2048; break;
|
||||
case CdSecS2328:
|
||||
rmode = CDVD_MODE_2328; break;
|
||||
case CdSecS2340:
|
||||
rmode = CDVD_MODE_2340; break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (i=0; i<sectors; i++)
|
||||
{
|
||||
switch (mode->datapattern)
|
||||
{
|
||||
case CdSecS2048:
|
||||
if(cdvdDirectReadSector(lsn+i, rmode, (char*)buf+2048*i))
|
||||
return 0;
|
||||
case CdSecS2328:
|
||||
if(cdvdDirectReadSector(lsn+i, rmode, (char*)buf+2328*i))
|
||||
return 0;
|
||||
case CdSecS2340:
|
||||
if(cdvdDirectReadSector(lsn+i, rmode, (char*)buf+2340*i))
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int DvdRead(u32 lsn, u32 sectors, void *buf, CdRMode *mode){
|
||||
u32 i;
|
||||
|
||||
for (i=lsn; i<(lsn+sectors); i++)
|
||||
{
|
||||
((u32*)buf)[0] = i + 0x30000;
|
||||
|
||||
if(cdvdDirectReadSector(lsn+i, CDVD_MODE_2048,(char*)buf+12))
|
||||
return 0;
|
||||
|
||||
buf=((u8*)buf)+2064; break;
|
||||
// default:
|
||||
// return 0;
|
||||
// }
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**************************************************************
|
||||
* The functions below are not exported for normal file-system *
|
||||
* operations, but are used by the file-system operations, and *
|
||||
* may also be exported for use via RPC *
|
||||
**************************************************************/
|
||||
|
||||
int CDVD_GetVolumeDescriptor(void){
|
||||
// Read until we find the last valid Volume Descriptor
|
||||
int volDescSector;
|
||||
|
||||
static struct cdVolDesc localVolDesc;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("CDVD_GetVolumeDescriptor called\n");
|
||||
#endif
|
||||
|
||||
for (volDescSector = 16; volDescSector<20; volDescSector++)
|
||||
{
|
||||
CdRead(volDescSector,1,&localVolDesc,&cdReadMode);
|
||||
// CdSync(0x00);
|
||||
|
||||
// If this is still a volume Descriptor
|
||||
if (strncmp((char*)localVolDesc.volID, "CD001", 5) == 0)
|
||||
{
|
||||
if ((localVolDesc.filesystemType == 1) ||
|
||||
(localVolDesc.filesystemType == 2))
|
||||
{
|
||||
memcpy(&CDVolDesc, &localVolDesc, sizeof(struct cdVolDesc));
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
if (CDVolDesc.filesystemType == 1)
|
||||
printf("CD FileSystem is ISO9660\n");
|
||||
else if (CDVolDesc.filesystemType == 2)
|
||||
printf("CD FileSystem is Joliet\n");
|
||||
else printf("Could not detect CD FileSystem type\n");
|
||||
#endif
|
||||
// CdStop();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int CDVD_findfile(char* fname, struct TocEntry* tocEntry){
|
||||
static char filename[128+1];
|
||||
static char pathname[1024+1];
|
||||
static char toc[2048];
|
||||
char* dirname;
|
||||
|
||||
|
||||
static struct TocEntry localTocEntry; // used for internal checking only
|
||||
|
||||
int found_dir;
|
||||
|
||||
int num_dir_sectors;
|
||||
int current_sector;
|
||||
|
||||
int dir_lba;
|
||||
|
||||
struct dirTocEntry* tocEntryPointer;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("CDVD_findfile called\n");
|
||||
#endif
|
||||
|
||||
//make sure we have good cdReadMode
|
||||
cdReadMode.trycount = 0;
|
||||
cdReadMode.spindlctrl = CdSpinStm;
|
||||
cdReadMode.datapattern = CdSecS2048;
|
||||
|
||||
_splitpath2(fname, pathname, filename);
|
||||
|
||||
// Find the TOC for a specific directory
|
||||
if (CDVD_GetVolumeDescriptor() != TRUE){
|
||||
#ifdef RPC_LOG
|
||||
RPC_LOG("Could not get CD Volume Descriptor\n");
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Read the TOC of the root directory
|
||||
if (CdRead(CDVolDesc.rootToc.tocLBA,1,toc,&cdReadMode) != TRUE){
|
||||
#ifdef RPC_LOG
|
||||
RPC_LOG("Couldn't Read from CD !\n");
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
//CdSync(0x00);
|
||||
|
||||
// point the tocEntryPointer at the first real toc entry
|
||||
tocEntryPointer = (dirTocEntry*)toc;
|
||||
|
||||
num_dir_sectors = (tocEntryPointer->fileSize+2047) >> 11; //round up fix
|
||||
current_sector = tocEntryPointer->fileLBA;
|
||||
|
||||
tocEntryPointer = (dirTocEntry*)(((char*)tocEntryPointer)+tocEntryPointer->length);
|
||||
tocEntryPointer = (dirTocEntry*)(((char*)tocEntryPointer)+tocEntryPointer->length);
|
||||
|
||||
|
||||
localTocEntry.fileLBA = CDVolDesc.rootToc.tocLBA;
|
||||
// while (there are more dir names in the path)
|
||||
dirname = strtok( pathname, "\\/" );
|
||||
|
||||
while( dirname != NULL )
|
||||
{
|
||||
found_dir = FALSE;
|
||||
/*
|
||||
while(tocEntryPointer->length > 0)
|
||||
{
|
||||
// while there are still more directory entries then search through
|
||||
// for the one we want
|
||||
|
||||
if (tocEntryPointer->fileProperties & 0x02)
|
||||
{
|
||||
// Copy the CD format TOC Entry to our format
|
||||
TocEntryCopy(&localTocEntry, tocEntryPointer);
|
||||
|
||||
// If this TOC Entry is a directory,
|
||||
// then see if it has the right name
|
||||
if (strcasecmp(dirname,localTocEntry.filename) == 0)
|
||||
{
|
||||
// if the name matches then we've found the directory
|
||||
found_dir = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// point to the next entry
|
||||
(char*)tocEntryPointer += tocEntryPointer->length;
|
||||
}
|
||||
*/
|
||||
while(1)
|
||||
{
|
||||
if ((tocEntryPointer->length == 0) || (((char*)tocEntryPointer-toc)>=2048))
|
||||
{
|
||||
num_dir_sectors--;
|
||||
|
||||
if (num_dir_sectors > 0)
|
||||
{
|
||||
// If we've run out of entries, but arent on the last sector
|
||||
// then load another sector
|
||||
|
||||
current_sector++;
|
||||
if (CdRead(current_sector,1,toc,&cdReadMode) != TRUE)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
// CdSync(0x00);
|
||||
|
||||
tocEntryPointer = (dirTocEntry*)toc;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Couldnt find the directory, and got to end of directory
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (tocEntryPointer->fileProperties & 0x02)
|
||||
{
|
||||
TocEntryCopy(&localTocEntry, tocEntryPointer);
|
||||
|
||||
// If this TOC Entry is a directory,
|
||||
// then see if it has the right name
|
||||
if (strcmp(dirname,(char*)localTocEntry.filename) == 0)
|
||||
{
|
||||
// if the name matches then we've found the directory
|
||||
found_dir = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// point to the next entry
|
||||
tocEntryPointer = (dirTocEntry*)(((char*)tocEntryPointer)+tocEntryPointer->length);
|
||||
}
|
||||
|
||||
// If we havent found the directory name we wanted then fail
|
||||
if (found_dir != TRUE)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Get next directory name
|
||||
dirname = strtok( NULL, "\\/" );
|
||||
|
||||
// Read the TOC of the found subdirectory
|
||||
if (CdRead(localTocEntry.fileLBA,1,toc,&cdReadMode) != TRUE)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
// CdSync(0x00);
|
||||
|
||||
num_dir_sectors = (localTocEntry.fileSize+2047) >> 11; //round up fix
|
||||
current_sector = localTocEntry.fileLBA;
|
||||
|
||||
// and point the tocEntryPointer at the first real toc entry
|
||||
tocEntryPointer = (dirTocEntry*)toc;
|
||||
tocEntryPointer = (dirTocEntry*)(((char*)tocEntryPointer)+tocEntryPointer->length);
|
||||
tocEntryPointer = (dirTocEntry*)(((char*)tocEntryPointer)+tocEntryPointer->length);
|
||||
}
|
||||
|
||||
tocEntryPointer = (dirTocEntry*)toc;
|
||||
|
||||
num_dir_sectors = (tocEntryPointer->fileSize+2047) >> 11; //round up fix
|
||||
dir_lba = tocEntryPointer->fileLBA;
|
||||
|
||||
tocEntryPointer = (dirTocEntry*)toc;
|
||||
tocEntryPointer = (dirTocEntry*)(((char*)tocEntryPointer)+tocEntryPointer->length);
|
||||
tocEntryPointer = (dirTocEntry*)(((char*)tocEntryPointer)+tocEntryPointer->length);
|
||||
|
||||
while (num_dir_sectors > 0)
|
||||
{
|
||||
while(tocEntryPointer->length != 0)
|
||||
{
|
||||
// Copy the CD format TOC Entry to our format
|
||||
TocEntryCopy(&localTocEntry, tocEntryPointer);
|
||||
|
||||
if ((_strnicmp((char*)localTocEntry.filename, filename, strlen(filename)) == 0) ||
|
||||
((filename[strlen(filename)-2] == ';') &&
|
||||
(localTocEntry.filename[strlen((char*)localTocEntry.filename)-2] == ';') &&
|
||||
(_strnicmp((char*)localTocEntry.filename, filename, strlen(filename)-2) == 0)))
|
||||
{
|
||||
// if the filename matches then copy the toc Entry
|
||||
tocEntry->fileLBA = localTocEntry.fileLBA;
|
||||
tocEntry->fileProperties = localTocEntry.fileProperties;
|
||||
tocEntry->fileSize = localTocEntry.fileSize;
|
||||
|
||||
strcpy((char*)tocEntry->filename, (char*)localTocEntry.filename);
|
||||
memcpy((char*)tocEntry->date, (char*)localTocEntry.date, 7);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("CDVD_findfile: found file\n");
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
tocEntryPointer = (dirTocEntry*)(((char*)tocEntryPointer)+tocEntryPointer->length);
|
||||
}
|
||||
|
||||
num_dir_sectors--;
|
||||
|
||||
if (num_dir_sectors > 0)
|
||||
{
|
||||
dir_lba++;
|
||||
|
||||
if (CdRead(dir_lba,1,toc,&cdReadMode) != TRUE){
|
||||
return -1;
|
||||
}
|
||||
// CdSync(0x00);
|
||||
|
||||
tocEntryPointer = (dirTocEntry*)toc;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// This is the RPC-ready function which takes the request to start the tocEntry retrieval
|
||||
int CDVD_GetDir_RPC_request(char* pathname, char* extensions, unsigned int inc_dirs){
|
||||
// int dir_depth = 1;
|
||||
static char toc[2048];
|
||||
char* dirname;
|
||||
int found_dir;
|
||||
int num_dir_sectors;
|
||||
unsigned int toc_entry_num;
|
||||
struct dirTocEntry* tocEntryPointer;
|
||||
static struct TocEntry localTocEntry;
|
||||
int current_sector;
|
||||
|
||||
// store the extension list statically for the retrieve function
|
||||
strncpy((char*)getDirTocData.extension_list, extensions, 128);
|
||||
getDirTocData.extension_list[128]=0;
|
||||
|
||||
getDirTocData.inc_dirs = inc_dirs;
|
||||
|
||||
// Find the TOC for a specific directory
|
||||
if (CDVD_GetVolumeDescriptor() != TRUE){
|
||||
#ifdef RPC_LOG
|
||||
RPC_LOG("[RPC:cdvd] Could not get CD Volume Descriptor\n");
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef RPC_LOG
|
||||
RPC_LOG("[RPC:cdvd] Getting Directory Listing for: \"%s\"\n", pathname);
|
||||
#endif
|
||||
|
||||
// Read the TOC of the root directory
|
||||
if (CdRead(CDVolDesc.rootToc.tocLBA,1,toc,&cdReadMode) != TRUE){
|
||||
#ifdef RPC_LOG
|
||||
RPC_LOG("[RPC: ] Couldn't Read from CD !\n");
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
//CdSync(0x00);
|
||||
|
||||
// point the tocEntryPointer at the first real toc entry
|
||||
tocEntryPointer = (dirTocEntry*)toc;
|
||||
|
||||
num_dir_sectors = (tocEntryPointer->fileSize+2047) >> 11;
|
||||
current_sector = tocEntryPointer->fileLBA;
|
||||
|
||||
tocEntryPointer = (dirTocEntry*)(((char*)tocEntryPointer)+tocEntryPointer->length);
|
||||
tocEntryPointer = (dirTocEntry*)(((char*)tocEntryPointer)+tocEntryPointer->length);
|
||||
|
||||
// use strtok to get the next dir name
|
||||
|
||||
// if there isnt one, then assume we want the LBA
|
||||
// for the current one, and exit the while loop
|
||||
|
||||
// if there is another dir name then increment dir_depth
|
||||
// and look through dir table entries until we find the right name
|
||||
// if we dont find the right name
|
||||
// before finding an entry at a higher level (lower num), then return nothing
|
||||
|
||||
localTocEntry.fileLBA = CDVolDesc.rootToc.tocLBA;
|
||||
|
||||
// while (there are more dir names in the path)
|
||||
dirname = strtok( pathname, "\\/" );
|
||||
while( dirname != NULL ){
|
||||
found_dir = FALSE;
|
||||
|
||||
while(1){
|
||||
if ((tocEntryPointer->length == 0) || (((char*)tocEntryPointer-toc)>=2048)) {
|
||||
num_dir_sectors--;
|
||||
|
||||
if (num_dir_sectors > 0){
|
||||
// If we've run out of entries, but arent on the last sector
|
||||
// then load another sector
|
||||
|
||||
current_sector++;
|
||||
if (CdRead(current_sector,1,toc,&cdReadMode) != TRUE){
|
||||
#ifdef RPC_LOG
|
||||
RPC_LOG("[RPC: ] Couldn't Read from CD !\n");
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
//CdSync(0x00);
|
||||
|
||||
tocEntryPointer = (dirTocEntry*)toc;
|
||||
}
|
||||
else{
|
||||
// Couldnt find the directory, and got to end of directory
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (tocEntryPointer->fileProperties & 0x02){
|
||||
TocEntryCopy(&localTocEntry, tocEntryPointer);
|
||||
|
||||
// If this TOC Entry is a directory,
|
||||
// then see if it has the right name
|
||||
if (strcmp(dirname,(char*)localTocEntry.filename) == 0){
|
||||
// if the name matches then we've found the directory
|
||||
found_dir = TRUE;
|
||||
#ifdef RPC_LOG
|
||||
RPC_LOG("[RPC: ] Found directory %s in subdir at sector %d\n",dirname,current_sector);
|
||||
RPC_LOG("[RPC: ] LBA of found subdirectory = %d\n",localTocEntry.fileLBA);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// point to the next entry
|
||||
tocEntryPointer = (dirTocEntry*)(((char*)tocEntryPointer)+tocEntryPointer->length);
|
||||
}
|
||||
|
||||
// If we havent found the directory name we wanted then fail
|
||||
if (found_dir != TRUE)
|
||||
return -1;
|
||||
|
||||
// Get next directory name
|
||||
dirname = strtok( NULL, "\\/" );
|
||||
|
||||
// Read the TOC of the found subdirectory
|
||||
if (CdRead(localTocEntry.fileLBA,1,toc,&cdReadMode) != TRUE){
|
||||
#ifdef RPC_LOG
|
||||
RPC_LOG("[RPC: ] Couldn't Read from CD !\n");
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
//CdSync(0x00);
|
||||
|
||||
num_dir_sectors = (localTocEntry.fileSize+2047) >> 11;
|
||||
current_sector = localTocEntry.fileLBA;
|
||||
|
||||
// and point the tocEntryPointer at the first real toc entry
|
||||
tocEntryPointer = (dirTocEntry*)toc;
|
||||
tocEntryPointer = (dirTocEntry*)(((char*)tocEntryPointer)+tocEntryPointer->length);
|
||||
tocEntryPointer = (dirTocEntry*)(((char*)tocEntryPointer)+tocEntryPointer->length);
|
||||
}
|
||||
|
||||
// We know how much data we need to read in from the DirTocHeader
|
||||
// but we need to read in at least 1 sector before we can get this value
|
||||
|
||||
// Now we need to COUNT the number of entries (dont do anything with info at this point)
|
||||
// so set the tocEntryPointer to point to the first actual file entry
|
||||
|
||||
// This is a bit of a waste of reads since we're not actually copying the data out yet,
|
||||
// but we dont know how big this TOC might be, so we cant allocate a specific size
|
||||
|
||||
tocEntryPointer = (dirTocEntry*)toc;
|
||||
|
||||
// Need to STORE the start LBA and number of Sectors, for use by the retrieve func.
|
||||
getDirTocData.start_LBA = localTocEntry.fileLBA;
|
||||
getDirTocData.num_sectors = (tocEntryPointer->fileSize+2047) >> 11;
|
||||
getDirTocData.num_entries = 0;
|
||||
getDirTocData.current_entry = 0;
|
||||
getDirTocData.current_sector = getDirTocData.start_LBA;
|
||||
getDirTocData.current_sector_offset = 0;
|
||||
|
||||
num_dir_sectors = getDirTocData.num_sectors;
|
||||
|
||||
tocEntryPointer = (dirTocEntry*)toc;
|
||||
tocEntryPointer = (dirTocEntry*)(((char*)tocEntryPointer)+tocEntryPointer->length);
|
||||
tocEntryPointer = (dirTocEntry*)(((char*)tocEntryPointer)+tocEntryPointer->length);
|
||||
|
||||
toc_entry_num=0;
|
||||
|
||||
while(1){
|
||||
if ((tocEntryPointer->length == 0) || (((char*)tocEntryPointer-toc)>=2048)){
|
||||
// decrease the number of dirs remaining
|
||||
num_dir_sectors--;
|
||||
|
||||
if (num_dir_sectors > 0){
|
||||
// If we've run out of entries, but arent on the last sector
|
||||
// then load another sector
|
||||
getDirTocData.current_sector++;
|
||||
|
||||
if (CdRead(getDirTocData.current_sector,1,toc,&cdReadMode) != TRUE){
|
||||
#ifdef RPC_LOG
|
||||
RPC_LOG("[RPC: ] Couldn't Read from CD !\n");
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
//CdSync(0x00);
|
||||
|
||||
tocEntryPointer = (dirTocEntry*)toc;
|
||||
|
||||
// continue;
|
||||
}
|
||||
else{
|
||||
getDirTocData.num_entries = toc_entry_num;
|
||||
getDirTocData.current_sector = getDirTocData.start_LBA;
|
||||
return (toc_entry_num);
|
||||
}
|
||||
}
|
||||
|
||||
// We've found a file/dir in this directory
|
||||
// now check if it matches our extension list (if there is one)
|
||||
TocEntryCopy(&localTocEntry, tocEntryPointer);
|
||||
|
||||
if (localTocEntry.fileProperties & 0x02){
|
||||
// If this is a subdir, then check if we want to include subdirs
|
||||
if (getDirTocData.inc_dirs){
|
||||
toc_entry_num++;
|
||||
}
|
||||
}
|
||||
else{
|
||||
if (strlen((char*)getDirTocData.extension_list) > 0){
|
||||
if (TocEntryCompare((char*)localTocEntry.filename, (char*)getDirTocData.extension_list) == TRUE){
|
||||
// increment the number of matching entries counter
|
||||
toc_entry_num++;
|
||||
}
|
||||
}
|
||||
else{
|
||||
toc_entry_num++;
|
||||
}
|
||||
}
|
||||
|
||||
tocEntryPointer = (dirTocEntry*)(((char*)tocEntryPointer)+tocEntryPointer->length);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// THIS SHOULD BE UNREACHABLE -
|
||||
// since we are trying to count ALL matching entries, rather than upto a limit
|
||||
|
||||
|
||||
// STORE total number of TOC entries
|
||||
getDirTocData.num_entries = toc_entry_num;
|
||||
getDirTocData.current_sector = getDirTocData.start_LBA;
|
||||
|
||||
|
||||
// we've reached the toc entry limit, so return how many we've done
|
||||
return (toc_entry_num);
|
||||
|
||||
}
|
||||
|
||||
// This function can be called repeatedly after CDVD_GetDir_RPC_request to get the actual entries
|
||||
// buffer (tocEntry) must be 18KB in size, and this will be filled with a maximum of 128 entries in one go
|
||||
int CDVD_GetDir_RPC_get_entries(struct TocEntry tocEntry[], int req_entries){
|
||||
static char toc[2048];
|
||||
int toc_entry_num;
|
||||
|
||||
struct dirTocEntry* tocEntryPointer;
|
||||
|
||||
if (CdRead(getDirTocData.current_sector,1,toc,&cdReadMode) != TRUE){
|
||||
#ifdef RPC_LOG
|
||||
RPC_LOG("[RPC:cdvd] Couldn't Read from CD !\n");
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
//CdSync(0x00);
|
||||
|
||||
if (getDirTocData.current_entry == 0){
|
||||
// if this is the first read then make sure we point to the first real entry
|
||||
tocEntryPointer = (dirTocEntry*)toc;
|
||||
tocEntryPointer = (dirTocEntry*)(((char*)tocEntryPointer)+tocEntryPointer->length);
|
||||
tocEntryPointer = (dirTocEntry*)(((char*)tocEntryPointer)+tocEntryPointer->length);
|
||||
|
||||
getDirTocData.current_sector_offset = (char*)tocEntryPointer - toc;
|
||||
}
|
||||
else{
|
||||
tocEntryPointer = (dirTocEntry*)(toc + getDirTocData.current_sector_offset);
|
||||
}
|
||||
|
||||
if (req_entries > 128)
|
||||
req_entries = 128;
|
||||
|
||||
for (toc_entry_num=0; toc_entry_num < req_entries;){
|
||||
if ((tocEntryPointer->length == 0) || (getDirTocData.current_sector_offset >= 2048)){
|
||||
// decrease the number of dirs remaining
|
||||
getDirTocData.num_sectors--;
|
||||
|
||||
if (getDirTocData.num_sectors > 0){
|
||||
// If we've run out of entries, but arent on the last sector
|
||||
// then load another sector
|
||||
getDirTocData.current_sector++;
|
||||
|
||||
if (CdRead(getDirTocData.current_sector,1,toc,&cdReadMode) != TRUE){
|
||||
#ifdef RPC_LOG
|
||||
RPC_LOG("[RPC:cdvd] Couldn't Read from CD !\n");
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
//CdSync(0x00);
|
||||
|
||||
getDirTocData.current_sector_offset = 0;
|
||||
tocEntryPointer = (dirTocEntry*)(toc + getDirTocData.current_sector_offset);
|
||||
|
||||
// continue;
|
||||
}
|
||||
else{
|
||||
return (toc_entry_num);
|
||||
}
|
||||
}
|
||||
|
||||
// This must be incremented even if the filename doesnt match extension list
|
||||
getDirTocData.current_entry++;
|
||||
|
||||
// We've found a file in this directory
|
||||
// now check if it matches our extension list (if there is one)
|
||||
|
||||
// Copy the entry regardless, as it makes the comparison easier
|
||||
// if it doesn't match then it will just be overwritten
|
||||
TocEntryCopy(&tocEntry[toc_entry_num], tocEntryPointer);
|
||||
|
||||
if (tocEntry[toc_entry_num].fileProperties & 0x02){
|
||||
// If this is a subdir, then check if we want to include subdirs
|
||||
if (getDirTocData.inc_dirs) {
|
||||
toc_entry_num++;
|
||||
}
|
||||
|
||||
getDirTocData.current_sector_offset += tocEntryPointer->length;
|
||||
tocEntryPointer = (dirTocEntry*)(toc + getDirTocData.current_sector_offset);
|
||||
}
|
||||
else{
|
||||
if (strlen((char*)getDirTocData.extension_list) > 0){
|
||||
if (TocEntryCompare((char*)tocEntry[toc_entry_num].filename, (char*)getDirTocData.extension_list) == TRUE){
|
||||
// increment the number of matching entries counter
|
||||
toc_entry_num++;
|
||||
}
|
||||
|
||||
getDirTocData.current_sector_offset += tocEntryPointer->length;
|
||||
tocEntryPointer = (dirTocEntry*)(toc + getDirTocData.current_sector_offset);
|
||||
|
||||
}
|
||||
else{
|
||||
toc_entry_num++;
|
||||
getDirTocData.current_sector_offset += tocEntryPointer->length;
|
||||
tocEntryPointer = (dirTocEntry*)(toc + getDirTocData.current_sector_offset);
|
||||
}
|
||||
}
|
||||
/*
|
||||
if (strlen(getDirTocData.extension_list) > 0)
|
||||
{
|
||||
if (TocEntryCompare(tocEntry[toc_entry_num].filename, getDirTocData.extension_list) == TRUE)
|
||||
{
|
||||
|
||||
// increment this here, rather than in the main for loop
|
||||
// since this should count the number of matching entries
|
||||
toc_entry_num++;
|
||||
}
|
||||
|
||||
getDirTocData.current_sector_offset += tocEntryPointer->length;
|
||||
(char*)tocEntryPointer = toc + getDirTocData.current_sector_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
toc_entry_num++;
|
||||
getDirTocData.current_sector_offset += tocEntryPointer->length;
|
||||
(char*)tocEntryPointer = toc + getDirTocData.current_sector_offset;
|
||||
}
|
||||
*/
|
||||
}
|
||||
return (toc_entry_num);
|
||||
}
|
|
@ -1,131 +0,0 @@
|
|||
/*
|
||||
* Original code from libcdvd by Hiryu & Sjeep (C) 2002
|
||||
* Modified by Florin for PCSX2 emu
|
||||
*/
|
||||
|
||||
#ifndef __CDVDISO_H__
|
||||
#define __CDVDISO_H__
|
||||
|
||||
#include "CDVDlib.h"
|
||||
|
||||
int CDVD_findfile(char* fname, struct TocEntry* tocEntry);
|
||||
int CDVD_GetDir_RPC_request(char* pathname, char* extensions, unsigned int inc_dirs);
|
||||
int CDVD_GetDir_RPC_get_entries(struct TocEntry tocEntry[], int req_entries);
|
||||
|
||||
#if defined(__WIN32__)
|
||||
#pragma pack(1)
|
||||
#endif
|
||||
|
||||
struct rootDirTocHeader
|
||||
{
|
||||
u16 length; //+00
|
||||
u32 tocLBA; //+02
|
||||
u32 tocLBA_bigend; //+06
|
||||
u32 tocSize; //+0A
|
||||
u32 tocSize_bigend; //+0E
|
||||
u8 dateStamp[8]; //+12
|
||||
u8 reserved[6]; //+1A
|
||||
u8 reserved2; //+20
|
||||
u8 reserved3; //+21
|
||||
#if defined(__WIN32__)
|
||||
}; //+22
|
||||
#else
|
||||
} __attribute__((packed));
|
||||
#endif
|
||||
|
||||
struct asciiDate
|
||||
{
|
||||
char year[4];
|
||||
char month[2];
|
||||
char day[2];
|
||||
char hours[2];
|
||||
char minutes[2];
|
||||
char seconds[2];
|
||||
char hundreths[2];
|
||||
char terminator[1];
|
||||
#if defined(__WIN32__)
|
||||
};
|
||||
#else
|
||||
} __attribute__((packed));
|
||||
#endif
|
||||
|
||||
struct cdVolDesc
|
||||
{
|
||||
u8 filesystemType; // 0x01 = ISO9660, 0x02 = Joliet, 0xFF = NULL
|
||||
u8 volID[5]; // "CD001"
|
||||
u8 reserved2;
|
||||
u8 reserved3;
|
||||
u8 sysIdName[32];
|
||||
u8 volName[32]; // The ISO9660 Volume Name
|
||||
u8 reserved5[8];
|
||||
u32 volSize; // Volume Size
|
||||
u32 volSizeBig; // Volume Size Big-Endian
|
||||
u8 reserved6[32];
|
||||
u32 unknown1;
|
||||
u32 unknown1_bigend;
|
||||
u16 volDescSize; //+80
|
||||
u16 volDescSize_bigend; //+82
|
||||
u32 unknown3; //+84
|
||||
u32 unknown3_bigend; //+88
|
||||
u32 priDirTableLBA; // LBA of Primary Dir Table //+8C
|
||||
u32 reserved7; //+90
|
||||
u32 secDirTableLBA; // LBA of Secondary Dir Table //+94
|
||||
u32 reserved8; //+98
|
||||
struct rootDirTocHeader rootToc;
|
||||
u8 volSetName[128];
|
||||
u8 publisherName[128];
|
||||
u8 preparerName[128];
|
||||
u8 applicationName[128];
|
||||
u8 copyrightFileName[37];
|
||||
u8 abstractFileName[37];
|
||||
u8 bibliographyFileName[37];
|
||||
struct asciiDate creationDate;
|
||||
struct asciiDate modificationDate;
|
||||
struct asciiDate effectiveDate;
|
||||
struct asciiDate expirationDate;
|
||||
u8 reserved10;
|
||||
u8 reserved11[1166];
|
||||
#if defined(__WIN32__)
|
||||
};
|
||||
#else
|
||||
} __attribute__((packed));
|
||||
#endif
|
||||
|
||||
struct dirTableEntry
|
||||
{
|
||||
u8 dirNameLength;
|
||||
u8 reserved;
|
||||
u32 dirTOCLBA;
|
||||
u16 dirDepth;
|
||||
u8 dirName[32];
|
||||
#if defined(__WIN32__)
|
||||
};
|
||||
#else
|
||||
} __attribute__((packed));
|
||||
#endif
|
||||
|
||||
struct dirTocEntry
|
||||
{
|
||||
short length;
|
||||
unsigned int fileLBA;
|
||||
unsigned int fileLBA_bigend;
|
||||
unsigned int fileSize;
|
||||
unsigned int fileSize_bigend;
|
||||
unsigned char dateStamp[6];
|
||||
unsigned char reserved1;
|
||||
unsigned char fileProperties;
|
||||
unsigned char reserved2[6];
|
||||
unsigned char filenameLength;
|
||||
unsigned char filename[128];
|
||||
#if defined(__WIN32__)
|
||||
};
|
||||
#else
|
||||
} __attribute__((packed));
|
||||
#endif // This is the internal format on the CD
|
||||
// TocEntry structure contains only the important stuff needed for export
|
||||
|
||||
#if defined(__WIN32__)
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
#endif//__CDVDISO_H__
|
|
@ -1,269 +0,0 @@
|
|||
/*
|
||||
* Original code from libcdvd by Hiryu & Sjeep (C) 2002
|
||||
* Modified by Florin for PCSX2 emu
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "CDVDlib.h"
|
||||
#include "CDVDiso.h"
|
||||
#include "CDVDisodrv.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
|
||||
#define min(x,y) (((y)<(x))?(x):(y))
|
||||
|
||||
CdRMode cdReadMode;
|
||||
|
||||
struct fdtable{
|
||||
//int fd;
|
||||
int fileSize;
|
||||
int LBA;
|
||||
int filePos;
|
||||
};
|
||||
|
||||
static struct fdtable fd_table[16];
|
||||
static int fd_used[16];
|
||||
static int files_open=0;
|
||||
static int inited=FALSE;
|
||||
|
||||
/*************************************************************
|
||||
* The functions below are the normal file-system operations, *
|
||||
* used to provide a standard filesystem interface *
|
||||
*************************************************************/
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// CDVDFS_init
|
||||
// called by 80000592 sceCdInit()
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
void CDVDFS_init(){
|
||||
|
||||
#ifdef RPC_LOG
|
||||
RPC_LOG("[CDVDisodrv:init] CDVD Filesystem v1.00\n");
|
||||
RPC_LOG("[CDVDisodrv ] \tby A.Lee (aka Hiryu) & Nicholas Van Veen (aka Sjeep)\n");
|
||||
RPC_LOG("[CDVDisodrv ] Initializing '%s' file driver.\n", "cdfs");
|
||||
#endif
|
||||
|
||||
//CdInit(0); already called by plugin loading system ;)
|
||||
|
||||
cdReadMode.trycount = 0;
|
||||
cdReadMode.spindlctrl = CdSpinStm;
|
||||
cdReadMode.datapattern = CdSecS2048; //isofs driver only needs
|
||||
//2KB sectors
|
||||
|
||||
memset(fd_table, 0, sizeof(fd_table));
|
||||
memset(fd_used, 0, 16*sizeof(int));
|
||||
|
||||
inited = TRUE;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// CDVDFS_open
|
||||
// called by 80000001 fileio_open for devices: "cdrom:", "cdrom0:"
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
int CDVDFS_open(char *name, int mode){
|
||||
register int j;
|
||||
static struct TocEntry tocEntry;
|
||||
|
||||
// check if the file exists
|
||||
if (CDVD_findfile(name, &tocEntry) != TRUE)
|
||||
return -1;
|
||||
|
||||
if(mode != 1) return -2; //SCE_RDONLY
|
||||
|
||||
// set up a new file descriptor
|
||||
for(j=0; j < 16; j++) if(fd_used[j] == 0) break;
|
||||
if(j >= 16) return -3;
|
||||
|
||||
fd_used[j] = 1;
|
||||
files_open++;
|
||||
|
||||
#ifdef RPC_LOG
|
||||
RPC_LOG("[CDVDisodrv:open] internal fd=%d\n", j);
|
||||
#endif
|
||||
|
||||
fd_table[j].fileSize = tocEntry.fileSize;
|
||||
fd_table[j].LBA = tocEntry.fileLBA;
|
||||
fd_table[j].filePos = 0;
|
||||
|
||||
#ifdef RPC_LOG
|
||||
RPC_LOG("[CDVDisodrv ] tocEntry.fileSize = %d\n",tocEntry.fileSize);
|
||||
#endif
|
||||
|
||||
return j;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// CDVDFS_lseek
|
||||
// called by 80000001 fileio_lseek for devices: "cdrom:", "cdrom0:"
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
int CDVDFS_lseek(int fd, int offset, int whence){
|
||||
|
||||
if ((fd >= 16) || (fd_used[fd]==0)){
|
||||
#ifdef RPC_LOG
|
||||
RPC_LOG("[CDVDisodrv:lseek] ERROR: File does not appear to be open!\n");
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch(whence){
|
||||
case SEEK_SET:
|
||||
fd_table[fd].filePos = offset;
|
||||
break;
|
||||
|
||||
case SEEK_CUR:
|
||||
fd_table[fd].filePos += offset;
|
||||
break;
|
||||
|
||||
case SEEK_END:
|
||||
fd_table[fd].filePos = fd_table[fd].fileSize + offset;
|
||||
break;
|
||||
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (fd_table[fd].filePos < 0)
|
||||
fd_table[fd].filePos = 0;
|
||||
|
||||
if (fd_table[fd].filePos > fd_table[fd].fileSize)
|
||||
fd_table[fd].filePos = fd_table[fd].fileSize;
|
||||
|
||||
return fd_table[fd].filePos;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// CDVDFS_read
|
||||
// called by 80000001 fileio_read for devices: "cdrom:", "cdrom0:", "cdfs:"
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
int CDVDFS_read( int fd, char *buffer, int size ){
|
||||
// int start_sector;
|
||||
int off_sector;
|
||||
// int num_sectors;
|
||||
|
||||
//static char local_buffer[2024*2048]; //4MB
|
||||
static char lb[2048]; //2KB
|
||||
//Start, Aligned, End
|
||||
int ssector, asector, esector;
|
||||
int ssize=0, asize, esize;
|
||||
|
||||
if ((fd >= 16) || (fd_used[fd]==0)){
|
||||
#ifdef RPC_LOG
|
||||
RPC_LOG("[CDVDisodrv:read] ERROR: File does not appear to be open!\n");
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
// A few sanity checks
|
||||
if (fd_table[fd].filePos > fd_table[fd].fileSize){
|
||||
// We cant start reading from past the beginning of the file
|
||||
return 0; // File exists but we couldnt read anything from it
|
||||
}
|
||||
|
||||
if ((fd_table[fd].filePos + size) > fd_table[fd].fileSize)
|
||||
size = fd_table[fd].fileSize - fd_table[fd].filePos;
|
||||
|
||||
// Now work out where we want to start reading from
|
||||
asector = ssector = fd_table[fd].LBA + (fd_table[fd].filePos >> 11);
|
||||
off_sector = (fd_table[fd].filePos & 0x7FF);
|
||||
if (off_sector){
|
||||
ssize = min(2048 - off_sector, size);
|
||||
size -= ssize;
|
||||
asector++;
|
||||
}
|
||||
asize = size & 0xFFFFF800;
|
||||
esize = size & 0x000007FF;
|
||||
esector=asector + (asize >> 11);
|
||||
size += ssize;
|
||||
|
||||
#ifdef RPC_LOG
|
||||
RPC_LOG("[CDVDisodrv:read] read sectors 0x%08X to 0x%08X\n", ssector, esector-(esize==0));
|
||||
#endif
|
||||
|
||||
if (ssize){ if (CdRead(ssector, 1, lb, &cdReadMode) != TRUE){
|
||||
#ifdef RPC_LOG
|
||||
RPC_LOG("[CDVDisodrv: ] Couldn't Read from file for some reason\n");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
memcpy(buffer, lb + off_sector, ssize);
|
||||
}
|
||||
if (asize) if (CdRead(asector, asize >> 11, buffer+ssize, &cdReadMode) != TRUE){
|
||||
#ifdef RPC_LOG
|
||||
RPC_LOG("[CDVDisodrv: ] Couldn't Read from file for some reason\n");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
if (esize){ if (CdRead(esector, 1, lb, &cdReadMode) != TRUE){
|
||||
#ifdef RPC_LOG
|
||||
RPC_LOG("[CDVDisodrv: ] Couldn't Read from file for some reason\n");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
memcpy(buffer+ssize+asize, lb, esize);
|
||||
}
|
||||
/***********************
|
||||
// Now work out where we want to start reading from
|
||||
start_sector = fd_table[fd].LBA + (fd_table[fd].filePos >> 11);
|
||||
off_sector = (fd_table[fd].filePos & 0x7FF);
|
||||
num_sectors = ((off_sector + size) >> 11) + 1;
|
||||
|
||||
#ifdef RPC_LOG
|
||||
RPC_LOG("[CDVDisodrv:read] read sectors 0x%08X to 0x%08X\n",start_sector,start_sector+num_sectors);
|
||||
#endif
|
||||
|
||||
// Read the data (we only ever get 16KB max request at once)
|
||||
if (CdRead(start_sector, num_sectors, local_buffer, &cdReadMode) != TRUE){
|
||||
#ifdef RPC_LOG
|
||||
//RPC_LOG("sector = %d, start sector = %d\n",sector,start_sector);
|
||||
RPC_LOG("[CDVDisodrv: ] Couldn't Read from file for some reason\n");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
//CdSync(0); hm, a wait function maybe...
|
||||
|
||||
memcpy(buffer,local_buffer+off_sector,size);
|
||||
**************************/
|
||||
fd_table[fd].filePos += size;
|
||||
|
||||
return (size);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// CDVDFS_write
|
||||
// called by 80000001 fileio_write for devices: "cdrom:", "cdrom0:"
|
||||
// hehe, this ain't a CD writing option :D
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
int CDVDFS_write( int fd, char * buffer, int size ){
|
||||
if(size == 0) return 0;
|
||||
else return -1;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// CDVDFS_close
|
||||
// called by 80000001 fileio_close for devices: "cdrom:", "cdrom0:"
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
int CDVDFS_close( int fd){
|
||||
|
||||
if ((fd >= 16) || (fd_used[fd]==0)){
|
||||
#ifdef RPC_LOG
|
||||
RPC_LOG("[CDVDisodrv:close] ERROR: File does not appear to be open!\n");
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef RPC_LOG
|
||||
RPC_LOG("[CDVDisodrv:close] internal fd %d\n", fd);
|
||||
#endif
|
||||
|
||||
fd_used[fd] = 0;
|
||||
files_open--;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
/*
|
||||
* Original code from libcdvd by Hiryu & Sjeep (C) 2002
|
||||
* Modified by Florin for PCSX2 emu
|
||||
*/
|
||||
|
||||
#ifndef __CDVDISODRV_H__
|
||||
#define __CDVDISODRV_H__
|
||||
|
||||
//#include "Common.h"
|
||||
#include "CDVDlib.h"
|
||||
|
||||
extern CdRMode cdReadMode;
|
||||
|
||||
/* Filing-system exported functions */
|
||||
void CDVDFS_init();
|
||||
int CDVDFS_open(char *name, int mode);
|
||||
int CDVDFS_lseek(int fd, int offset, int whence);
|
||||
int CDVDFS_read( int fd, char * buffer, int size );
|
||||
int CDVDFS_write( int fd, char * buffer, int size );
|
||||
int CDVDFS_close( int fd);
|
||||
|
||||
#endif//__CDVDISODRV_H__
|
|
@ -1,187 +0,0 @@
|
|||
/*
|
||||
* Original code from libcdvd by Hiryu & Sjeep (C) 2002
|
||||
* Linux kernel headers
|
||||
* Modified by Florin for PCSX2 emu
|
||||
*/
|
||||
|
||||
#ifndef _CDVDLIB_H
|
||||
#define _CDVDLIB_H
|
||||
|
||||
#define __WIN32__
|
||||
#define CDVDdefs
|
||||
#include <PS2Edefs.h>
|
||||
|
||||
// Macros for READ Data pattan
|
||||
#define CdSecS2048 0 // sector size 2048
|
||||
#define CdSecS2328 1 // sector size 2328
|
||||
#define CdSecS2340 2 // sector size 2340
|
||||
|
||||
//#define CD_FRAMESIZE_RAW1 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE) /*2340*/
|
||||
//#define CD_FRAMESIZE_RAW0 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE-CD_HEAD_SIZE) /*2336*/
|
||||
//#define CD_HEAD_SIZE 4 /* header (address) bytes per raw data frame */
|
||||
//#define CD_SUBHEAD_SIZE 8 /* subheader bytes per raw XA data frame */
|
||||
//#define CD_XA_HEAD (CD_HEAD_SIZE+CD_SUBHEAD_SIZE) /* "before data" part of raw XA frame */
|
||||
|
||||
/*
|
||||
* A CD-ROM physical sector size is 2048, 2052, 2056, 2324, 2332, 2336,
|
||||
* 2340, or 2352 bytes long.
|
||||
* Sector types of the standard CD-ROM data formats:
|
||||
*
|
||||
* format sector type user data size (bytes)
|
||||
* -----------------------------------------------------------------------------
|
||||
* 1 (Red Book) CD-DA 2352 (CD_FRAMESIZE_RAW)
|
||||
* 2 (Yellow Book) Mode1 Form1 2048 (CD_FRAMESIZE)
|
||||
* 3 (Yellow Book) Mode1 Form2 2336 (CD_FRAMESIZE_RAW0)
|
||||
* 4 (Green Book) Mode2 Form1 2048 (CD_FRAMESIZE)
|
||||
* 5 (Green Book) Mode2 Form2 2328 (2324+4 spare bytes)
|
||||
*
|
||||
*
|
||||
* The layout of the standard CD-ROM data formats:
|
||||
* -----------------------------------------------------------------------------
|
||||
* - audio (red): | audio_sample_bytes |
|
||||
* | 2352 |
|
||||
*
|
||||
* - data (yellow, mode1): | sync - head - data - EDC - zero - ECC |
|
||||
* | 12 - 4 - 2048 - 4 - 8 - 276 |
|
||||
*
|
||||
* - data (yellow, mode2): | sync - head - data |
|
||||
* | 12 - 4 - 2336 |
|
||||
*
|
||||
* - XA data (green, mode2 form1): | sync - head - sub - data - EDC - ECC |
|
||||
* | 12 - 4 - 8 - 2048 - 4 - 276 |
|
||||
*
|
||||
* - XA data (green, mode2 form2): | sync - head - sub - data - Spare |
|
||||
* | 12 - 4 - 8 - 2324 - 4 |
|
||||
*
|
||||
*/
|
||||
|
||||
// Macros for Spindle control
|
||||
#define CdSpinMax 0
|
||||
#define CdSpinNom 1 // Starts reading data at maximum rotational velocity and if a read error occurs, the rotational velocity is reduced.
|
||||
#define CdSpinStm 0 // Recommended stream rotation speed.
|
||||
|
||||
// Macros for TrayReq
|
||||
#define CdTrayOpen 0
|
||||
#define CdTrayClose 1
|
||||
#define CdTrayCheck 2
|
||||
|
||||
/*
|
||||
* Macros for sceCdGetDiskType() //comments translated from japanese;)
|
||||
*/
|
||||
#define SCECdIllgalMedia 0xff
|
||||
/* ILIMEDIA (Illegal Media)
|
||||
A non-PS / non-PS2 Disc. */
|
||||
#define SCECdDVDV 0xfe
|
||||
/* DVDV (DVD Video)
|
||||
A non-PS / non-PS2 Disc, but a DVD Video Disc */
|
||||
#define SCECdCDDA 0xfd
|
||||
/* CDDA (CD DA)
|
||||
A non-PS / non-PS2 Disc that include a DA track */
|
||||
#define SCECdPS2DVD 0x14
|
||||
/* PS2DVD PS2 consumer DVD. */
|
||||
#define SCECdPS2CDDA 0x13
|
||||
/* PS2CDDA PS2 consumer CD that includes a DA track */
|
||||
#define SCECdPS2CD 0x12
|
||||
/* PS2CD PS2 consumer CD that does not include a DA track */
|
||||
#define SCECdPSCDDA 0x11
|
||||
/* PSCDDA PS CD that includes a DA track */
|
||||
#define SCECdPSCD 0x10
|
||||
/* PSCD PS CD that does not include a DA track */
|
||||
#define SCECdDETCT 0x01
|
||||
/* DETCT (Detecting) Disc distinction action */
|
||||
#define SCECdNODISC 0x00
|
||||
/* NODISC (No disc) No disc entered */
|
||||
|
||||
/*
|
||||
* Media mode
|
||||
*/
|
||||
#define SCECdCD 1
|
||||
#define SCECdDVD 2
|
||||
|
||||
typedef struct {
|
||||
u8 stat; // 0: normal. Any other: error
|
||||
u8 second; // second (BCD value)
|
||||
u8 minute; // minute (BCD value)
|
||||
u8 hour; // hour (BCD value)
|
||||
u8 week; // week (BCD value)
|
||||
u8 day; // day (BCD value)
|
||||
u8 month; // month (BCD value)
|
||||
u8 year; // year (BCD value)
|
||||
} CdCLOCK;
|
||||
|
||||
typedef struct {
|
||||
u32 lsn; // Logical sector number of file
|
||||
u32 size; // File size (in bytes)
|
||||
char name[16]; // Filename
|
||||
u8 date[8]; // 1th: Seconds
|
||||
// 2th: Minutes
|
||||
// 3th: Hours
|
||||
// 4th: Date
|
||||
// 5th: Month
|
||||
// 6th 7th: Year (4 digits)
|
||||
} CdlFILE;
|
||||
|
||||
typedef struct {
|
||||
u8 minute; // Minutes
|
||||
u8 second; // Seconds
|
||||
u8 sector; // Sector
|
||||
u8 track; // Track number
|
||||
} CdlLOCCD;
|
||||
|
||||
typedef struct {
|
||||
u8 trycount; // Read try count (No. of error retries + 1) (0 - 255)
|
||||
u8 spindlctrl; // SCECdSpinStm: Recommended stream rotation speed.
|
||||
// SCECdSpinNom: Starts reading data at maximum rotational velocity and if a read error occurs, the rotational velocity is reduced.
|
||||
u8 datapattern; // SCECdSecS2048: Data size 2048 bytes
|
||||
// SCECdSecS2328: 2328 bytes
|
||||
// SCECdSecS2340: 2340 bytes
|
||||
u8 pad; // Padding data produced by alignment.
|
||||
} CdRMode;
|
||||
|
||||
#if defined(__WIN32__)
|
||||
#pragma pack(1)
|
||||
#endif
|
||||
|
||||
struct TocEntry
|
||||
{
|
||||
u32 fileLBA;
|
||||
u32 fileSize;
|
||||
u8 fileProperties;
|
||||
u8 padding1[3];
|
||||
u8 filename[128+1];
|
||||
u8 date[7];
|
||||
#if defined(__WIN32__)
|
||||
};
|
||||
#else
|
||||
} __attribute__((packed));
|
||||
#endif
|
||||
|
||||
#if defined(__WIN32__)
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
int CDVD_findfile(char* fname, struct TocEntry* tocEntry);
|
||||
/*
|
||||
int CdBreak(void);
|
||||
int CdCallback( void (*func)() );
|
||||
int CdDiskReady(int mode);
|
||||
int CdGetDiskType(void);
|
||||
int CdGetError(void);
|
||||
u32 CdGetReadPos(void);
|
||||
int CdGetToc(u8 *toc);
|
||||
int CdInit(int init_mode);
|
||||
CdlLOCCD *CdIntToPos(int i, CdlLOCCD *p);
|
||||
int CdPause(void);
|
||||
int CdPosToInt(CdlLOCCD *p);*/
|
||||
int CdRead(u32 lsn, u32 sectors, void *buf, CdRMode *mode);
|
||||
int DvdRead(u32 lsn, u32 sectors, void *buf, CdRMode *mode);
|
||||
/*int CdReadClock(CdCLOCK *rtc);
|
||||
int CdSearchFile (CdlFILE *fp, const char *name);
|
||||
int CdSeek(u32 lsn);
|
||||
int CdStandby(void);
|
||||
int CdStatus(void);
|
||||
int CdStop(void);
|
||||
int CdSync(int mode);
|
||||
int CdTrayReq(int mode, u32 *traycnt);
|
||||
*/
|
||||
#endif // _CDVDLIB_H
|
|
@ -1,119 +0,0 @@
|
|||
/* General ioctl() CD-ROM command function */
|
||||
#include "CDVD.h"
|
||||
|
||||
#define MSF_TO_LBA(m,s,f) ((m*60+s)*75+f-150)
|
||||
|
||||
int MCI_CDioctl(int id, UINT msg, DWORD flags, void *arg)
|
||||
{
|
||||
MCIERROR mci_error;
|
||||
|
||||
mci_error = mciSendCommand(id, msg, flags, (DWORD)arg);
|
||||
if ( mci_error ) {
|
||||
char error[256];
|
||||
|
||||
mciGetErrorString(mci_error, error, 256);
|
||||
printf(" * CDVD mciTOC: mciSendCommand() error: %s", error);
|
||||
}
|
||||
return(!mci_error ? 0 : -1);
|
||||
}
|
||||
|
||||
int MCI_CDGetTOC(char driveLetter)
|
||||
{
|
||||
MCI_OPEN_PARMS mci_open;
|
||||
MCI_SET_PARMS mci_set;
|
||||
MCI_STATUS_PARMS mci_status;
|
||||
|
||||
char device[3];
|
||||
int i, okay;
|
||||
DWORD flags;
|
||||
|
||||
okay = 0;
|
||||
|
||||
int cdromId;
|
||||
|
||||
device[0] = driveLetter;
|
||||
device[1] = ':';
|
||||
device[2] = '\0';
|
||||
|
||||
/* Open the requested device */
|
||||
mci_open.lpstrDeviceType = (LPCSTR) MCI_DEVTYPE_CD_AUDIO;
|
||||
mci_open.lpstrElementName = device;
|
||||
flags = (MCI_OPEN_TYPE|MCI_OPEN_SHAREABLE|MCI_OPEN_TYPE_ID|MCI_OPEN_ELEMENT);
|
||||
if ( MCI_CDioctl(0, MCI_OPEN, flags, &mci_open) < 0 )
|
||||
{
|
||||
flags &= ~MCI_OPEN_SHAREABLE;
|
||||
if ( MCI_CDioctl(0, MCI_OPEN, flags, &mci_open) < 0 )
|
||||
{
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
cdromId = mci_open.wDeviceID;
|
||||
|
||||
/* Set the minute-second-frame time format */
|
||||
mci_set.dwTimeFormat = MCI_FORMAT_MSF;
|
||||
MCI_CDioctl(cdromId, MCI_SET, MCI_SET_TIME_FORMAT, &mci_set);
|
||||
|
||||
/* Request number of tracks */
|
||||
mci_status.dwItem = MCI_STATUS_NUMBER_OF_TRACKS;
|
||||
flags = MCI_STATUS_ITEM | MCI_WAIT;
|
||||
if ( MCI_CDioctl(cdromId, MCI_STATUS, flags, &mci_status) == 0 )
|
||||
{
|
||||
strack=1;
|
||||
etrack=mci_status.dwReturn;
|
||||
|
||||
/* Read all the track TOC entries */
|
||||
flags = MCI_STATUS_ITEM | MCI_TRACK | MCI_WAIT;
|
||||
|
||||
for ( i=strack; i<etrack; ++i )
|
||||
{
|
||||
mci_status.dwTrack = i+1;
|
||||
|
||||
mci_status.dwItem = MCI_CDA_STATUS_TYPE_TRACK;
|
||||
if ( MCI_CDioctl(cdromId, MCI_STATUS, flags, &mci_status) < 0 )
|
||||
{
|
||||
break;
|
||||
}
|
||||
if ( mci_status.dwReturn == MCI_CDA_TRACK_AUDIO )
|
||||
{
|
||||
tracks[i+1].type = CDVD_AUDIO_TRACK;
|
||||
} else {
|
||||
tracks[i+1].type = CDVD_MODE1_TRACK; //no way to detect between mode1 and mode2 yet
|
||||
}
|
||||
|
||||
mci_status.dwItem = MCI_STATUS_POSITION;
|
||||
if ( MCI_CDioctl(cdromId, MCI_STATUS, flags, &mci_status) < 0 )
|
||||
{
|
||||
break;
|
||||
}
|
||||
tracks[i+1].start_lba = MSF_TO_LBA(
|
||||
MCI_MSF_MINUTE(mci_status.dwReturn),
|
||||
MCI_MSF_SECOND(mci_status.dwReturn),
|
||||
MCI_MSF_FRAME(mci_status.dwReturn));
|
||||
tracks[i+1].length = 0;
|
||||
if ( i > 0 )
|
||||
{
|
||||
tracks[i].length = tracks[i+1].start_lba - tracks[i].start_lba;
|
||||
}
|
||||
}
|
||||
if ( i == etrack )
|
||||
{
|
||||
mci_status.dwTrack = i;
|
||||
mci_status.dwItem = MCI_STATUS_LENGTH;
|
||||
if ( MCI_CDioctl(cdromId, MCI_STATUS, flags, &mci_status) == 0 )
|
||||
{
|
||||
tracks[i].length = MSF_TO_LBA(
|
||||
MCI_MSF_MINUTE(mci_status.dwReturn),
|
||||
MCI_MSF_SECOND(mci_status.dwReturn),
|
||||
MCI_MSF_FRAME(mci_status.dwReturn)) + 1; /* +1 to fix MCI last track length bug */
|
||||
/* compute lead-out offset */
|
||||
tracks[i+1].start_lba = tracks[i].start_lba + tracks[i].length;
|
||||
tracks[i+1].length = 0;
|
||||
okay = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MCI_CDioctl(cdromId, MCI_CLOSE, MCI_WAIT, NULL);
|
||||
|
||||
return(okay ? 0 : -1);
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
EXPORTS
|
||||
PS2EgetLibType @2
|
||||
PS2EgetLibName @3
|
||||
PS2EgetLibVersion2 @4
|
||||
CDVDinit @5
|
||||
CDVDshutdown @6
|
||||
CDVDopen @7
|
||||
CDVDclose @8
|
||||
CDVDreadTrack @9
|
||||
CDVDgetBuffer @10
|
||||
CDVDreadSubQ @11
|
||||
CDVDgetTN @12
|
||||
CDVDgetTD @13
|
||||
CDVDgetTOC @14
|
||||
CDVDgetDiskType @15
|
||||
CDVDgetTrayStatus @16
|
||||
CDVDctrlTrayOpen @17
|
||||
CDVDctrlTrayClose @18
|
||||
CDVDconfigure @19
|
||||
CDVDtest @20
|
||||
CDVDabout @21
|
||||
CDVDnewDiskCB @22
|
||||
CDVDgetBuffer2 @23
|
||||
CDVDreadSector @24
|
||||
CDVDgetDualInfo @25
|
|
@ -1,37 +0,0 @@
|
|||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by cdvd.rc
|
||||
//
|
||||
#define IDD_CONFIG 101
|
||||
#define IDC_PLUGINS 1000
|
||||
#define IDC_CONFIGURE 1001
|
||||
#define IDC_TEST 1002
|
||||
#define IDC_ABOUT 1003
|
||||
#define IDC_IMAGE_BROWSE 1004
|
||||
#define IDC_USEISO 1005
|
||||
#define IDC_NOCD 1006
|
||||
#define IDC_PLUGIN 1007
|
||||
#define IDC_IMAGE 1008
|
||||
#define IDC_IMAGE_FILE 1009
|
||||
#define IDC_NOSUB 1010
|
||||
#define IDC_FAKE 1011
|
||||
#define IDC_SAME 1012
|
||||
#define IDC_DRIVE 1012
|
||||
#define IDC_SUB_FILE 1014
|
||||
#define IDC_ABOUT3 1015
|
||||
#define IDC_SUB_BROWSE 1015
|
||||
#define IDC_FILE 1016
|
||||
#define IDC_NODUMP 1020
|
||||
#define IDC_DUMP_ISO 1021
|
||||
#define IDC_DUMP_BDV2 1022
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 102
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1011
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
|
@ -1,348 +0,0 @@
|
|||
/*
|
||||
* ntddcdrm.h
|
||||
*
|
||||
* CDROM IOCTL interface.
|
||||
*
|
||||
* This file is part of the w32api package.
|
||||
*
|
||||
* Contributors:
|
||||
* Created by Casper S. Hornstrup <chorns@users.sourceforge.net>
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAIMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _NTDDCDRM_H_
|
||||
#define _NTDDCDRM_H_
|
||||
|
||||
#include "ntddstor.h"
|
||||
|
||||
#define _ANONYMOUS_UNION
|
||||
#define DUMMYUNIONNAME
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define IOCTL_CDROM_BASE FILE_DEVICE_CD_ROM
|
||||
|
||||
#define IOCTL_CDROM_CHECK_VERIFY \
|
||||
CTL_CODE(IOCTL_CDROM_BASE, 0x0200, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||||
|
||||
#define IOCTL_CDROM_FIND_NEW_DEVICES \
|
||||
CTL_CODE(IOCTL_CDROM_BASE, 0x0206, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||||
|
||||
#define IOCTL_CDROM_GET_CONTROL \
|
||||
CTL_CODE(IOCTL_CDROM_BASE, 0x000D, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||||
|
||||
#define IOCTL_CDROM_GET_DRIVE_GEOMETRY \
|
||||
CTL_CODE(IOCTL_CDROM_BASE, 0x0013, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||||
|
||||
#define IOCTL_CDROM_GET_LAST_SESSION \
|
||||
CTL_CODE(IOCTL_CDROM_BASE, 0x000E, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||||
|
||||
#define IOCTL_CDROM_GET_VOLUME \
|
||||
CTL_CODE(IOCTL_CDROM_BASE, 0x0005, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||||
|
||||
#define IOCTL_CDROM_PAUSE_AUDIO \
|
||||
CTL_CODE(IOCTL_CDROM_BASE, 0x0003, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||||
|
||||
#define IOCTL_CDROM_PLAY_AUDIO_MSF \
|
||||
CTL_CODE(IOCTL_CDROM_BASE, 0x0006, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||||
|
||||
#define IOCTL_CDROM_RAW_READ \
|
||||
CTL_CODE(IOCTL_CDROM_BASE, 0x000F, METHOD_OUT_DIRECT, FILE_READ_ACCESS)
|
||||
|
||||
#define IOCTL_CDROM_DISK_TYPE \
|
||||
CTL_CODE(IOCTL_CDROM_BASE, 0x0010, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
|
||||
#define IOCTL_CDROM_READ_Q_CHANNEL \
|
||||
CTL_CODE(IOCTL_CDROM_BASE, 0x000B, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||||
|
||||
#define IOCTL_CDROM_READ_TOC \
|
||||
CTL_CODE(IOCTL_CDROM_BASE, 0x0000, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||||
|
||||
#define IOCTL_CDROM_READ_TOC_EX \
|
||||
CTL_CODE(IOCTL_CDROM_BASE, 0x0015, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||||
|
||||
#define IOCTL_CDROM_RESUME_AUDIO \
|
||||
CTL_CODE(IOCTL_CDROM_BASE, 0x0004, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||||
|
||||
#define IOCTL_CDROM_SEEK_AUDIO_MSF \
|
||||
CTL_CODE(IOCTL_CDROM_BASE, 0x0001, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||||
|
||||
#define IOCTL_CDROM_SET_VOLUME \
|
||||
CTL_CODE(IOCTL_CDROM_BASE, 0x000A, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||||
|
||||
#define IOCTL_CDROM_SIMBAD \
|
||||
CTL_CODE(IOCTL_CDROM_BASE, 0x1003, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||||
|
||||
#define IOCTL_CDROM_STOP_AUDIO \
|
||||
CTL_CODE(IOCTL_CDROM_BASE, 0x0002, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||||
|
||||
|
||||
#define MAXIMUM_NUMBER_TRACKS 100
|
||||
#define MAXIMUM_CDROM_SIZE 804
|
||||
#define MINIMUM_CDROM_READ_TOC_EX_SIZE 2
|
||||
|
||||
typedef struct _TRACK_DATA {
|
||||
UCHAR Reserved;
|
||||
UCHAR Control : 4;
|
||||
UCHAR Adr : 4;
|
||||
UCHAR TrackNumber;
|
||||
UCHAR Reserved1;
|
||||
UCHAR Address[4];
|
||||
} TRACK_DATA, *PTRACK_DATA;
|
||||
|
||||
/* CDROM_DISK_DATA.DiskData flags */
|
||||
#define CDROM_DISK_AUDIO_TRACK 0x00000001
|
||||
#define CDROM_DISK_DATA_TRACK 0x00000002
|
||||
|
||||
typedef struct _CDROM_DISK_DATA {
|
||||
ULONG DiskData;
|
||||
} CDROM_DISK_DATA, *PCDROM_DISK_DATA;
|
||||
|
||||
typedef struct _CDROM_PLAY_AUDIO_MSF {
|
||||
UCHAR StartingM;
|
||||
UCHAR StartingS;
|
||||
UCHAR StartingF;
|
||||
UCHAR EndingM;
|
||||
UCHAR EndingS;
|
||||
UCHAR EndingF;
|
||||
} CDROM_PLAY_AUDIO_MSF, *PCDROM_PLAY_AUDIO_MSF;
|
||||
|
||||
/* CDROM_READ_TOC_EX.Format constants */
|
||||
#define CDROM_READ_TOC_EX_FORMAT_TOC 0x00
|
||||
#define CDROM_READ_TOC_EX_FORMAT_SESSION 0x01
|
||||
#define CDROM_READ_TOC_EX_FORMAT_FULL_TOC 0x02
|
||||
#define CDROM_READ_TOC_EX_FORMAT_PMA 0x03
|
||||
#define CDROM_READ_TOC_EX_FORMAT_ATIP 0x04
|
||||
#define CDROM_READ_TOC_EX_FORMAT_CDTEXT 0x05
|
||||
|
||||
typedef struct _CDROM_READ_TOC_EX {
|
||||
UCHAR Format : 4;
|
||||
UCHAR Reserved1 : 3;
|
||||
UCHAR Msf : 1;
|
||||
UCHAR SessionTrack;
|
||||
UCHAR Reserved2;
|
||||
UCHAR Reserved3;
|
||||
} CDROM_READ_TOC_EX, *PCDROM_READ_TOC_EX;
|
||||
|
||||
typedef struct _CDROM_SEEK_AUDIO_MSF {
|
||||
UCHAR M;
|
||||
UCHAR S;
|
||||
UCHAR F;
|
||||
} CDROM_SEEK_AUDIO_MSF, *PCDROM_SEEK_AUDIO_MSF;
|
||||
|
||||
/* CDROM_SUB_Q_DATA_FORMAT.Format constants */
|
||||
#define IOCTL_CDROM_SUB_Q_CHANNEL 0x00
|
||||
#define IOCTL_CDROM_CURRENT_POSITION 0x01
|
||||
#define IOCTL_CDROM_MEDIA_CATALOG 0x02
|
||||
#define IOCTL_CDROM_TRACK_ISRC 0x03
|
||||
|
||||
typedef struct _CDROM_SUB_Q_DATA_FORMAT {
|
||||
UCHAR Format;
|
||||
UCHAR Track;
|
||||
} CDROM_SUB_Q_DATA_FORMAT, *PCDROM_SUB_Q_DATA_FORMAT;
|
||||
|
||||
typedef struct _CDROM_TOC {
|
||||
UCHAR Length[2];
|
||||
UCHAR FirstTrack;
|
||||
UCHAR LastTrack;
|
||||
TRACK_DATA TrackData[MAXIMUM_NUMBER_TRACKS];
|
||||
} CDROM_TOC, *PCDROM_TOC;
|
||||
|
||||
#define CDROM_TOC_SIZE sizeof(CDROM_TOC)
|
||||
|
||||
typedef struct _CDROM_TOC_ATIP_DATA_BLOCK {
|
||||
UCHAR CdrwReferenceSpeed : 3;
|
||||
UCHAR Reserved3 : 1;
|
||||
UCHAR WritePower : 3;
|
||||
UCHAR True1 : 1;
|
||||
UCHAR Reserved4 : 6;
|
||||
UCHAR UnrestrictedUse : 1;
|
||||
UCHAR Reserved5 : 1;
|
||||
UCHAR A3Valid : 1;
|
||||
UCHAR A2Valid : 1;
|
||||
UCHAR A1Valid : 1;
|
||||
UCHAR Reserved6 : 3;
|
||||
UCHAR IsCdrw : 1;
|
||||
UCHAR True2 : 1;
|
||||
UCHAR Reserved7;
|
||||
UCHAR LeadInMsf[3];
|
||||
UCHAR Reserved8;
|
||||
UCHAR LeadOutMsf[3];
|
||||
UCHAR Reserved9;
|
||||
UCHAR A1Values[3];
|
||||
UCHAR Reserved10;
|
||||
UCHAR A2Values[3];
|
||||
UCHAR Reserved11;
|
||||
UCHAR A3Values[3];
|
||||
UCHAR Reserved12;
|
||||
} CDROM_TOC_ATIP_DATA_BLOCK, *PCDROM_TOC_ATIP_DATA_BLOCK;
|
||||
|
||||
typedef struct _CDROM_TOC_ATIP_DATA {
|
||||
UCHAR Length[2];
|
||||
UCHAR Reserved1;
|
||||
UCHAR Reserved2;
|
||||
CDROM_TOC_ATIP_DATA_BLOCK Descriptors[0];
|
||||
} CDROM_TOC_ATIP_DATA, *PCDROM_TOC_ATIP_DATA;
|
||||
|
||||
/* CDROM_TOC_CD_TEXT_DATA_BLOCK.PackType constants */
|
||||
#define CDROM_CD_TEXT_PACK_ALBUM_NAME 0x80
|
||||
#define CDROM_CD_TEXT_PACK_PERFORMER 0x81
|
||||
#define CDROM_CD_TEXT_PACK_SONGWRITER 0x82
|
||||
#define CDROM_CD_TEXT_PACK_COMPOSER 0x83
|
||||
#define CDROM_CD_TEXT_PACK_ARRANGER 0x84
|
||||
#define CDROM_CD_TEXT_PACK_MESSAGES 0x85
|
||||
#define CDROM_CD_TEXT_PACK_DISC_ID 0x86
|
||||
#define CDROM_CD_TEXT_PACK_GENRE 0x87
|
||||
#define CDROM_CD_TEXT_PACK_TOC_INFO 0x88
|
||||
#define CDROM_CD_TEXT_PACK_TOC_INFO2 0x89
|
||||
#define CDROM_CD_TEXT_PACK_UPC_EAN 0x8e
|
||||
#define CDROM_CD_TEXT_PACK_SIZE_INFO 0x8f
|
||||
|
||||
typedef struct _CDROM_TOC_CD_TEXT_DATA_BLOCK {
|
||||
UCHAR PackType;
|
||||
UCHAR TrackNumber : 7;
|
||||
UCHAR ExtensionFlag : 1;
|
||||
UCHAR SequenceNumber;
|
||||
UCHAR CharacterPosition : 4;
|
||||
UCHAR BlockNumber : 3;
|
||||
UCHAR Unicode : 1;
|
||||
_ANONYMOUS_UNION union {
|
||||
UCHAR Text[12];
|
||||
WCHAR WText[6];
|
||||
} DUMMYUNIONNAME;
|
||||
UCHAR CRC[2];
|
||||
} CDROM_TOC_CD_TEXT_DATA_BLOCK, *PCDROM_TOC_CD_TEXT_DATA_BLOCK;
|
||||
|
||||
typedef struct _CDROM_TOC_CD_TEXT_DATA {
|
||||
UCHAR Length[2];
|
||||
UCHAR Reserved1;
|
||||
UCHAR Reserved2;
|
||||
CDROM_TOC_CD_TEXT_DATA_BLOCK Descriptors[0];
|
||||
} CDROM_TOC_CD_TEXT_DATA, *PCDROM_TOC_CD_TEXT_DATA;
|
||||
|
||||
/* CDROM_TOC_FULL_TOC_DATA_BLOCK.Adr constants */
|
||||
#define ADR_NO_MODE_INFORMATION 0x0
|
||||
#define ADR_ENCODES_CURRENT_POSITION 0x1
|
||||
#define ADR_ENCODES_MEDIA_CATALOG 0x2
|
||||
#define ADR_ENCODES_ISRC 0x3
|
||||
|
||||
typedef struct _CDROM_TOC_FULL_TOC_DATA_BLOCK {
|
||||
UCHAR SessionNumber;
|
||||
UCHAR Control : 4;
|
||||
UCHAR Adr : 4;
|
||||
UCHAR Reserved1;
|
||||
UCHAR Point;
|
||||
UCHAR MsfExtra[3];
|
||||
UCHAR Zero;
|
||||
UCHAR Msf[3];
|
||||
} CDROM_TOC_FULL_TOC_DATA_BLOCK, *PCDROM_TOC_FULL_TOC_DATA_BLOCK;
|
||||
|
||||
typedef struct _CDROM_TOC_FULL_TOC_DATA {
|
||||
UCHAR Length[2];
|
||||
UCHAR FirstCompleteSession;
|
||||
UCHAR LastCompleteSession;
|
||||
CDROM_TOC_FULL_TOC_DATA_BLOCK Descriptors[0];
|
||||
} CDROM_TOC_FULL_TOC_DATA, *PCDROM_TOC_FULL_TOC_DATA;
|
||||
|
||||
typedef struct _CDROM_TOC_PMA_DATA {
|
||||
UCHAR Length[2];
|
||||
UCHAR Reserved1;
|
||||
UCHAR Reserved2;
|
||||
CDROM_TOC_FULL_TOC_DATA_BLOCK Descriptors[0];
|
||||
} CDROM_TOC_PMA_DATA, *PCDROM_TOC_PMA_DATA;
|
||||
|
||||
/* SUB_Q_HEADER.AudioStatus constants */
|
||||
#define AUDIO_STATUS_NOT_SUPPORTED 0x00
|
||||
#define AUDIO_STATUS_IN_PROGRESS 0x11
|
||||
#define AUDIO_STATUS_PAUSED 0x12
|
||||
#define AUDIO_STATUS_PLAY_COMPLETE 0x13
|
||||
#define AUDIO_STATUS_PLAY_ERROR 0x14
|
||||
#define AUDIO_STATUS_NO_STATUS 0x15
|
||||
|
||||
typedef struct _SUB_Q_HEADER {
|
||||
UCHAR Reserved;
|
||||
UCHAR AudioStatus;
|
||||
UCHAR DataLength[2];
|
||||
} SUB_Q_HEADER, *PSUB_Q_HEADER;
|
||||
|
||||
typedef struct _SUB_Q_MEDIA_CATALOG_NUMBER {
|
||||
SUB_Q_HEADER Header;
|
||||
UCHAR FormatCode;
|
||||
UCHAR Reserved[3];
|
||||
UCHAR Reserved1 : 7;
|
||||
UCHAR Mcval :1;
|
||||
UCHAR MediaCatalog[15];
|
||||
} SUB_Q_MEDIA_CATALOG_NUMBER, *PSUB_Q_MEDIA_CATALOG_NUMBER;
|
||||
|
||||
typedef struct _SUB_Q_TRACK_ISRC {
|
||||
SUB_Q_HEADER Header;
|
||||
UCHAR FormatCode;
|
||||
UCHAR Reserved0;
|
||||
UCHAR Track;
|
||||
UCHAR Reserved1;
|
||||
UCHAR Reserved2 : 7;
|
||||
UCHAR Tcval : 1;
|
||||
UCHAR TrackIsrc[15];
|
||||
} SUB_Q_TRACK_ISRC, *PSUB_Q_TRACK_ISRC;
|
||||
|
||||
typedef struct _SUB_Q_CURRENT_POSITION {
|
||||
SUB_Q_HEADER Header;
|
||||
UCHAR FormatCode;
|
||||
UCHAR Control : 4;
|
||||
UCHAR ADR : 4;
|
||||
UCHAR TrackNumber;
|
||||
UCHAR IndexNumber;
|
||||
UCHAR AbsoluteAddress[4];
|
||||
UCHAR TrackRelativeAddress[4];
|
||||
} SUB_Q_CURRENT_POSITION, *PSUB_Q_CURRENT_POSITION;
|
||||
|
||||
typedef union _SUB_Q_CHANNEL_DATA {
|
||||
SUB_Q_CURRENT_POSITION CurrentPosition;
|
||||
SUB_Q_MEDIA_CATALOG_NUMBER MediaCatalog;
|
||||
SUB_Q_TRACK_ISRC TrackIsrc;
|
||||
} SUB_Q_CHANNEL_DATA, *PSUB_Q_CHANNEL_DATA;
|
||||
|
||||
/* CDROM_AUDIO_CONTROL.LbaFormat constants */
|
||||
#define AUDIO_WITH_PREEMPHASIS 0x1
|
||||
#define DIGITAL_COPY_PERMITTED 0x2
|
||||
#define AUDIO_DATA_TRACK 0x4
|
||||
#define TWO_FOUR_CHANNEL_AUDIO 0x8
|
||||
|
||||
typedef struct _CDROM_AUDIO_CONTROL {
|
||||
UCHAR LbaFormat;
|
||||
USHORT LogicalBlocksPerSecond;
|
||||
} CDROM_AUDIO_CONTROL, *PCDROM_AUDIO_CONTROL;
|
||||
|
||||
typedef struct _VOLUME_CONTROL {
|
||||
UCHAR PortVolume[4];
|
||||
} VOLUME_CONTROL, *PVOLUME_CONTROL;
|
||||
|
||||
typedef enum _TRACK_MODE_TYPE {
|
||||
YellowMode2,
|
||||
XAForm2,
|
||||
CDDA
|
||||
} TRACK_MODE_TYPE, *PTRACK_MODE_TYPE;
|
||||
|
||||
typedef struct __RAW_READ_INFO {
|
||||
LARGE_INTEGER DiskOffset;
|
||||
ULONG SectorCount;
|
||||
TRACK_MODE_TYPE TrackMode;
|
||||
} RAW_READ_INFO, *PRAW_READ_INFO;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _NTDDCDRM_H_ */
|
|
@ -1,208 +0,0 @@
|
|||
/*
|
||||
* ntddcdvd.h
|
||||
*
|
||||
* DVD IOCTL interface.
|
||||
*
|
||||
* This file is part of the w32api package.
|
||||
*
|
||||
* Contributors:
|
||||
* Created by Casper S. Hornstrup <chorns@users.sourceforge.net>
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAIMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _NTDDCDVD_H_
|
||||
#define _NTDDCDVD_H_
|
||||
|
||||
#include "ntddstor.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define IOCTL_DVD_BASE FILE_DEVICE_DVD
|
||||
|
||||
#define IOCTL_DVD_END_SESSION \
|
||||
CTL_CODE(IOCTL_DVD_BASE, 0x0403, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||||
|
||||
#define IOCTL_DVD_GET_REGION \
|
||||
CTL_CODE(IOCTL_DVD_BASE, 0x0405, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||||
|
||||
#define IOCTL_DVD_READ_KEY \
|
||||
CTL_CODE(IOCTL_DVD_BASE, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||||
|
||||
#define IOCTL_DVD_READ_STRUCTURE \
|
||||
CTL_CODE(IOCTL_DVD_BASE, 0x0450, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||||
|
||||
#define IOCTL_DVD_SEND_KEY \
|
||||
CTL_CODE(IOCTL_DVD_BASE, 0x0402, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||||
|
||||
#define IOCTL_DVD_START_SESSION \
|
||||
CTL_CODE(IOCTL_DVD_BASE, 0x0400, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||||
|
||||
#define IOCTL_DVD_SET_READ_AHEAD \
|
||||
CTL_CODE(IOCTL_DVD_BASE, 0x0404, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||||
|
||||
|
||||
typedef ULONG DVD_SESSION_ID, *PDVD_SESSION_ID;
|
||||
|
||||
typedef struct _STORAGE_SET_READ_AHEAD {
|
||||
LARGE_INTEGER TriggerAddress;
|
||||
LARGE_INTEGER TargetAddress;
|
||||
} STORAGE_SET_READ_AHEAD, *PSTORAGE_SET_READ_AHEAD;
|
||||
|
||||
typedef enum DVD_STRUCTURE_FORMAT {
|
||||
DvdPhysicalDescriptor,
|
||||
DvdCopyrightDescriptor,
|
||||
DvdDiskKeyDescriptor,
|
||||
DvdBCADescriptor,
|
||||
DvdManufacturerDescriptor,
|
||||
DvdMaxDescriptor
|
||||
} DVD_STRUCTURE_FORMAT, *PDVD_STRUCTURE_FORMAT;
|
||||
|
||||
#include <pshpack1.h>
|
||||
typedef struct DVD_READ_STRUCTURE {
|
||||
LARGE_INTEGER BlockByteOffset;
|
||||
DVD_STRUCTURE_FORMAT Format;
|
||||
DVD_SESSION_ID SessionId;
|
||||
UCHAR LayerNumber;
|
||||
} DVD_READ_STRUCTURE, *PDVD_READ_STRUCTURE;
|
||||
#include <poppack.h>
|
||||
|
||||
typedef struct _DVD_DESCRIPTOR_HEADER {
|
||||
USHORT Length;
|
||||
UCHAR Reserved[2];
|
||||
UCHAR Data[0];
|
||||
} DVD_DESCRIPTOR_HEADER, *PDVD_DESCRIPTOR_HEADER;
|
||||
|
||||
#include <pshpack1.h>
|
||||
typedef struct _DVD_LAYER_DESCRIPTOR {
|
||||
UCHAR BookVersion : 4;
|
||||
UCHAR BookType : 4;
|
||||
UCHAR MinimumRate : 4;
|
||||
UCHAR DiskSize : 4;
|
||||
UCHAR LayerType : 4;
|
||||
UCHAR TrackPath : 1;
|
||||
UCHAR NumberOfLayers : 2;
|
||||
UCHAR Reserved1 : 1;
|
||||
UCHAR TrackDensity : 4;
|
||||
UCHAR LinearDensity : 4;
|
||||
ULONG StartingDataSector;
|
||||
ULONG EndDataSector;
|
||||
ULONG EndLayerZeroSector;
|
||||
UCHAR Reserved5 : 7;
|
||||
UCHAR BCAFlag : 1;
|
||||
UCHAR Reserved6;
|
||||
} DVD_LAYER_DESCRIPTOR, *PDVD_LAYER_DESCRIPTOR;
|
||||
#include <poppack.h>
|
||||
|
||||
typedef struct _DVD_COPYRIGHT_DESCRIPTOR {
|
||||
UCHAR CopyrightProtectionType;
|
||||
UCHAR RegionManagementInformation;
|
||||
USHORT Reserved;
|
||||
} DVD_COPYRIGHT_DESCRIPTOR, *PDVD_COPYRIGHT_DESCRIPTOR;
|
||||
|
||||
typedef struct _DVD_DISK_KEY_DESCRIPTOR {
|
||||
UCHAR DiskKeyData[2048];
|
||||
} DVD_DISK_KEY_DESCRIPTOR, *PDVD_DISK_KEY_DESCRIPTOR;
|
||||
|
||||
typedef enum _DVD_KEY_TYPE {
|
||||
DvdChallengeKey = 0x01,
|
||||
DvdBusKey1,
|
||||
DvdBusKey2,
|
||||
DvdTitleKey,
|
||||
DvdAsf,
|
||||
DvdSetRpcKey = 0x6,
|
||||
DvdGetRpcKey = 0x8,
|
||||
DvdDiskKey = 0x80,
|
||||
DvdInvalidateAGID = 0x3f
|
||||
} DVD_KEY_TYPE;
|
||||
|
||||
typedef struct _DVD_COPY_PROTECT_KEY {
|
||||
ULONG KeyLength;
|
||||
DVD_SESSION_ID SessionId;
|
||||
DVD_KEY_TYPE KeyType;
|
||||
ULONG KeyFlags;
|
||||
union {
|
||||
HANDLE FileHandle;
|
||||
LARGE_INTEGER TitleOffset;
|
||||
} Parameters;
|
||||
UCHAR KeyData[0];
|
||||
} DVD_COPY_PROTECT_KEY, *PDVD_COPY_PROTECT_KEY;
|
||||
|
||||
#define DVD_CHALLENGE_KEY_LENGTH (12 + sizeof(DVD_COPY_PROTECT_KEY))
|
||||
#define DVD_BUS_KEY_LENGTH (8 + sizeof(DVD_COPY_PROTECT_KEY))
|
||||
#define DVD_TITLE_KEY_LENGTH (8 + sizeof(DVD_COPY_PROTECT_KEY))
|
||||
#define DVD_DISK_KEY_LENGTH (2048 + sizeof(DVD_COPY_PROTECT_KEY))
|
||||
#define DVD_RPC_KEY_LENGTH (sizeof(DVD_RPC_KEY) + sizeof(DVD_COPY_PROTECT_KEY))
|
||||
#define DVD_SET_RPC_KEY_LENGTH (sizeof(DVD_SET_RPC_KEY) + sizeof(DVD_COPY_PROTECT_KEY))
|
||||
#define DVD_ASF_LENGTH (sizeof(DVD_ASF) + sizeof(DVD_COPY_PROTECT_KEY))
|
||||
|
||||
#define DVD_END_ALL_SESSIONS ((DVD_SESSION_ID) 0xffffffff)
|
||||
|
||||
|
||||
#define DVD_CGMS_RESERVED_MASK 0x00000078
|
||||
|
||||
#define DVD_CGMS_COPY_PROTECT_MASK 0x00000018
|
||||
#define DVD_CGMS_COPY_PERMITTED 0x00000000
|
||||
#define DVD_CGMS_COPY_ONCE 0x00000010
|
||||
#define DVD_CGMS_NO_COPY 0x00000018
|
||||
|
||||
#define DVD_COPYRIGHT_MASK 0x00000040
|
||||
#define DVD_NOT_COPYRIGHTED 0x00000000
|
||||
#define DVD_COPYRIGHTED 0x00000040
|
||||
|
||||
#define DVD_SECTOR_PROTECT_MASK 0x00000020
|
||||
#define DVD_SECTOR_NOT_PROTECTED 0x00000000
|
||||
#define DVD_SECTOR_PROTECTED 0x00000020
|
||||
|
||||
|
||||
typedef struct _DVD_BCA_DESCRIPTOR {
|
||||
UCHAR BCAInformation[0];
|
||||
} DVD_BCA_DESCRIPTOR, *PDVD_BCA_DESCRIPTOR;
|
||||
|
||||
typedef struct _DVD_MANUFACTURER_DESCRIPTOR {
|
||||
UCHAR ManufacturingInformation[2048];
|
||||
} DVD_MANUFACTURER_DESCRIPTOR, *PDVD_MANUFACTURER_DESCRIPTOR;
|
||||
|
||||
typedef struct _DVD_RPC_KEY {
|
||||
UCHAR UserResetsAvailable : 3;
|
||||
UCHAR ManufacturerResetsAvailable : 3;
|
||||
UCHAR TypeCode : 2;
|
||||
UCHAR RegionMask;
|
||||
UCHAR RpcScheme;
|
||||
UCHAR Reserved2[1];
|
||||
} DVD_RPC_KEY, *PDVD_RPC_KEY;
|
||||
|
||||
typedef struct _DVD_SET_RPC_KEY {
|
||||
UCHAR PreferredDriveRegionCode;
|
||||
UCHAR Reserved[3];
|
||||
} DVD_SET_RPC_KEY, *PDVD_SET_RPC_KEY;
|
||||
|
||||
typedef struct _DVD_ASF {
|
||||
UCHAR Reserved0[3];
|
||||
UCHAR SuccessFlag : 1;
|
||||
UCHAR Reserved1 : 7;
|
||||
} DVD_ASF, *PDVD_ASF;
|
||||
|
||||
typedef struct _DVD_REGION {
|
||||
UCHAR CopySystem;
|
||||
UCHAR RegionData;
|
||||
UCHAR SystemRegion;
|
||||
UCHAR ResetCount;
|
||||
} DVD_REGION, *PDVD_REGION;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _NTDDCDVD_H_ */
|
|
@ -1,171 +0,0 @@
|
|||
/*
|
||||
* ntddscsi.h
|
||||
*
|
||||
* SCSI port IOCTL interface.
|
||||
*
|
||||
* This file is part of the w32api package.
|
||||
*
|
||||
* Contributors:
|
||||
* Created by Casper S. Hornstrup <chorns@users.sourceforge.net>
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAIMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __NTDDSCSI_H
|
||||
#define __NTDDSCSI_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define DD_SCSI_DEVICE_NAME "\\Device\\ScsiPort"
|
||||
#define DD_SCSI_DEVICE_NAME_U L"\\Device\\ScsiPort"
|
||||
|
||||
#define IOCTL_SCSI_BASE FILE_DEVICE_CONTROLLER
|
||||
|
||||
#define IOCTL_SCSI_FREE_DUMP_POINTERS \
|
||||
CTL_CODE(IOCTL_SCSI_BASE, 0x0409, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
|
||||
#define IOCTL_SCSI_GET_INQUIRY_DATA \
|
||||
CTL_CODE(IOCTL_SCSI_BASE, 0x0403, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
|
||||
#define IOCTL_SCSI_GET_CAPABILITIES \
|
||||
CTL_CODE(IOCTL_SCSI_BASE, 0x0404, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
|
||||
#define IOCTL_SCSI_GET_ADDRESS \
|
||||
CTL_CODE(IOCTL_SCSI_BASE, 0x0406, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
|
||||
#define IOCTL_SCSI_GET_DUMP_POINTERS \
|
||||
CTL_CODE(IOCTL_SCSI_BASE, 0x0408, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
|
||||
#define IOCTL_SCSI_MINIPORT \
|
||||
CTL_CODE(IOCTL_SCSI_BASE, 0x0402, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
|
||||
|
||||
#define IOCTL_SCSI_PASS_THROUGH \
|
||||
CTL_CODE(IOCTL_SCSI_BASE, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
|
||||
|
||||
#define IOCTL_SCSI_PASS_THROUGH_DIRECT \
|
||||
CTL_CODE(IOCTL_SCSI_BASE, 0x0405, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
|
||||
|
||||
#define IOCTL_SCSI_RESCAN_BUS \
|
||||
CTL_CODE(IOCTL_SCSI_BASE, 0x0407, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
|
||||
|
||||
DEFINE_GUID(ScsiRawInterfaceGuid, \
|
||||
0x53f56309L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
|
||||
|
||||
DEFINE_GUID(WmiScsiAddressGuid, \
|
||||
0x53f5630fL, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
|
||||
|
||||
typedef struct _SCSI_PASS_THROUGH {
|
||||
USHORT Length;
|
||||
UCHAR ScsiStatus;
|
||||
UCHAR PathId;
|
||||
UCHAR TargetId;
|
||||
UCHAR Lun;
|
||||
UCHAR CdbLength;
|
||||
UCHAR SenseInfoLength;
|
||||
UCHAR DataIn;
|
||||
ULONG DataTransferLength;
|
||||
ULONG TimeOutValue;
|
||||
ULONG_PTR DataBufferOffset;
|
||||
ULONG SenseInfoOffset;
|
||||
UCHAR Cdb[16];
|
||||
} SCSI_PASS_THROUGH, *PSCSI_PASS_THROUGH;
|
||||
|
||||
typedef struct _SCSI_PASS_THROUGH_DIRECT {
|
||||
USHORT Length;
|
||||
UCHAR ScsiStatus;
|
||||
UCHAR PathId;
|
||||
UCHAR TargetId;
|
||||
UCHAR Lun;
|
||||
UCHAR CdbLength;
|
||||
UCHAR SenseInfoLength;
|
||||
UCHAR DataIn;
|
||||
ULONG DataTransferLength;
|
||||
ULONG TimeOutValue;
|
||||
PVOID DataBuffer;
|
||||
ULONG SenseInfoOffset;
|
||||
UCHAR Cdb[16];
|
||||
} SCSI_PASS_THROUGH_DIRECT, *PSCSI_PASS_THROUGH_DIRECT;
|
||||
|
||||
typedef struct _SRB_IO_CONTROL {
|
||||
ULONG HeaderLength;
|
||||
UCHAR Signature[8];
|
||||
ULONG Timeout;
|
||||
ULONG ControlCode;
|
||||
ULONG ReturnCode;
|
||||
ULONG Length;
|
||||
} SRB_IO_CONTROL, *PSRB_IO_CONTROL;
|
||||
|
||||
typedef struct _SCSI_ADDRESS {
|
||||
ULONG Length;
|
||||
UCHAR PortNumber;
|
||||
UCHAR PathId;
|
||||
UCHAR TargetId;
|
||||
UCHAR Lun;
|
||||
} SCSI_ADDRESS, *PSCSI_ADDRESS;
|
||||
|
||||
typedef struct _SCSI_BUS_DATA {
|
||||
UCHAR NumberOfLogicalUnits;
|
||||
UCHAR InitiatorBusId;
|
||||
ULONG InquiryDataOffset;
|
||||
}SCSI_BUS_DATA, *PSCSI_BUS_DATA;
|
||||
|
||||
typedef struct _SCSI_ADAPTER_BUS_INFO {
|
||||
UCHAR NumberOfBuses;
|
||||
SCSI_BUS_DATA BusData[1];
|
||||
} SCSI_ADAPTER_BUS_INFO, *PSCSI_ADAPTER_BUS_INFO;
|
||||
|
||||
typedef struct _IO_SCSI_CAPABILITIES {
|
||||
ULONG Length;
|
||||
ULONG MaximumTransferLength;
|
||||
ULONG MaximumPhysicalPages;
|
||||
ULONG SupportedAsynchronousEvents;
|
||||
ULONG AlignmentMask;
|
||||
BOOLEAN TaggedQueuing;
|
||||
BOOLEAN AdapterScansDown;
|
||||
BOOLEAN AdapterUsesPio;
|
||||
} IO_SCSI_CAPABILITIES, *PIO_SCSI_CAPABILITIES;
|
||||
|
||||
typedef struct _SCSI_INQUIRY_DATA {
|
||||
UCHAR PathId;
|
||||
UCHAR TargetId;
|
||||
UCHAR Lun;
|
||||
BOOLEAN DeviceClaimed;
|
||||
ULONG InquiryDataLength;
|
||||
ULONG NextInquiryDataOffset;
|
||||
UCHAR InquiryData[1];
|
||||
} SCSI_INQUIRY_DATA, *PSCSI_INQUIRY_DATA;
|
||||
|
||||
#define SCSI_IOCTL_DATA_OUT 0
|
||||
#define SCSI_IOCTL_DATA_IN 1
|
||||
#define SCSI_IOCTL_DATA_UNSPECIFIED 2
|
||||
|
||||
typedef struct _DUMP_POINTERS {
|
||||
struct _ADAPTER_OBJECT *AdapterObject;
|
||||
PVOID MappedRegisterBase;
|
||||
PVOID DumpData;
|
||||
PVOID CommonBufferVa;
|
||||
LARGE_INTEGER CommonBufferPa;
|
||||
ULONG CommonBufferSize;
|
||||
BOOLEAN AllocateCommonBuffers;
|
||||
BOOLEAN UseDiskDump;
|
||||
UCHAR Spare1[2];
|
||||
PVOID DeviceObject;
|
||||
} DUMP_POINTERS, *PDUMP_POINTERS;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __NTDDSCSI_H */
|
|
@ -1,356 +0,0 @@
|
|||
/*
|
||||
* ntddstor.h
|
||||
*
|
||||
* Storage class IOCTL interface.
|
||||
*
|
||||
* This file is part of the w32api package.
|
||||
*
|
||||
* Contributors:
|
||||
* Created by Casper S. Hornstrup <chorns@users.sourceforge.net>
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAIMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _NTDDSTOR_H_
|
||||
#define _NTDDSTOR_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define IOCTL_STORAGE_BASE FILE_DEVICE_MASS_STORAGE
|
||||
|
||||
#define IOCTL_STORAGE_CHECK_VERIFY \
|
||||
CTL_CODE(IOCTL_STORAGE_BASE, 0x0200, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||||
|
||||
#define IOCTL_STORAGE_CHECK_VERIFY2 \
|
||||
CTL_CODE(IOCTL_STORAGE_BASE, 0x0200, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
|
||||
#define IOCTL_STORAGE_EJECT_MEDIA \
|
||||
CTL_CODE(IOCTL_STORAGE_BASE, 0x0202, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||||
|
||||
#define IOCTL_STORAGE_EJECTION_CONTROL \
|
||||
CTL_CODE(IOCTL_STORAGE_BASE, 0x0250, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
|
||||
#define IOCTL_STORAGE_FIND_NEW_DEVICES \
|
||||
CTL_CODE(IOCTL_STORAGE_BASE, 0x0206, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||||
|
||||
#define IOCTL_STORAGE_GET_DEVICE_NUMBER \
|
||||
CTL_CODE(IOCTL_STORAGE_BASE, 0x0420, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
|
||||
#define IOCTL_STORAGE_GET_MEDIA_SERIAL_NUMBER \
|
||||
CTL_CODE(IOCTL_STORAGE_BASE, 0x0304, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
|
||||
#define IOCTL_STORAGE_GET_MEDIA_TYPES \
|
||||
CTL_CODE(IOCTL_STORAGE_BASE, 0x0300, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
|
||||
#define IOCTL_STORAGE_GET_MEDIA_TYPES_EX \
|
||||
CTL_CODE(IOCTL_STORAGE_BASE, 0x0301, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
|
||||
#define IOCTL_STORAGE_LOAD_MEDIA \
|
||||
CTL_CODE(IOCTL_STORAGE_BASE, 0x0203, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||||
|
||||
#define IOCTL_STORAGE_LOAD_MEDIA2 \
|
||||
CTL_CODE(IOCTL_STORAGE_BASE, 0x0203, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
|
||||
#define IOCTL_STORAGE_MCN_CONTROL \
|
||||
CTL_CODE(IOCTL_STORAGE_BASE, 0x0251, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
|
||||
#define IOCTL_STORAGE_MEDIA_REMOVAL \
|
||||
CTL_CODE(IOCTL_STORAGE_BASE, 0x0201, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||||
|
||||
#define IOCTL_STORAGE_PREDICT_FAILURE \
|
||||
CTL_CODE(IOCTL_STORAGE_BASE, 0x0440, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
|
||||
#define IOCTL_STORAGE_QUERY_PROPERTY \
|
||||
CTL_CODE(IOCTL_STORAGE_BASE, 0x0500, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
|
||||
#define IOCTL_STORAGE_RELEASE \
|
||||
CTL_CODE(IOCTL_STORAGE_BASE, 0x0205, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||||
|
||||
#define IOCTL_STORAGE_RESERVE \
|
||||
CTL_CODE(IOCTL_STORAGE_BASE, 0x0204, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||||
|
||||
#define IOCTL_STORAGE_GET_HOTPLUG_INFO \
|
||||
CTL_CODE(IOCTL_STORAGE_BASE, 0x0305, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
|
||||
#define IOCTL_STORAGE_SET_HOTPLUG_INFO \
|
||||
CTL_CODE(IOCTL_STORAGE_BASE, 0x0306, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
|
||||
|
||||
#define IOCTL_STORAGE_RESET_BUS \
|
||||
CTL_CODE(IOCTL_STORAGE_BASE, 0x0400, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
|
||||
|
||||
#define IOCTL_STORAGE_RESET_DEVICE \
|
||||
CTL_CODE(IOCTL_STORAGE_BASE, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
|
||||
|
||||
|
||||
DEFINE_GUID(GUID_DEVINTERFACE_DISK,
|
||||
0x53f56307L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
|
||||
|
||||
DEFINE_GUID(GUID_DEVINTERFACE_CDROM,
|
||||
0x53f56308L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
|
||||
|
||||
DEFINE_GUID(GUID_DEVINTERFACE_PARTITION,
|
||||
0x53f5630aL, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
|
||||
|
||||
DEFINE_GUID(GUID_DEVINTERFACE_TAPE,
|
||||
0x53f5630bL, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
|
||||
|
||||
DEFINE_GUID(GUID_DEVINTERFACE_WRITEONCEDISK,
|
||||
0x53f5630cL, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
|
||||
|
||||
DEFINE_GUID(GUID_DEVINTERFACE_VOLUME,
|
||||
0x53f5630dL, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
|
||||
|
||||
DEFINE_GUID(GUID_DEVINTERFACE_MEDIUMCHANGER,
|
||||
0x53f56310L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
|
||||
|
||||
DEFINE_GUID(GUID_DEVINTERFACE_FLOPPY,
|
||||
0x53f56311L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
|
||||
|
||||
DEFINE_GUID(GUID_DEVINTERFACE_CDCHANGER,
|
||||
0x53f56312L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
|
||||
|
||||
DEFINE_GUID(GUID_DEVINTERFACE_STORAGEPORT,
|
||||
0x2accfe60L, 0xc130, 0x11d2, 0xb0, 0x82, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
|
||||
|
||||
DEFINE_GUID(GUID_DEVINTERFACE_HIDDEN_VOLUME,
|
||||
0x7f108a28L, 0x9833, 0x4b3b, 0xb7, 0x80, 0x2c, 0x6b, 0x5f, 0xa5, 0xc0, 0x62);
|
||||
|
||||
/* Aliases for storage guids */
|
||||
#define DiskClassGuid GUID_DEVINTERFACE_DISK
|
||||
#define CdRomClassGuid GUID_DEVINTERFACE_CDROM
|
||||
#define PartitionClassGuid GUID_DEVINTERFACE_PARTITION
|
||||
#define TapeClassGuid GUID_DEVINTERFACE_TAPE
|
||||
#define WriteOnceDiskClassGuid GUID_DEVINTERFACE_WRITEONCEDISK
|
||||
#define VolumeClassGuid GUID_DEVINTERFACE_VOLUME
|
||||
#define MediumChangerClassGuid GUID_DEVINTERFACE_MEDIUMCHANGER
|
||||
#define FloppyClassGuid GUID_DEVINTERFACE_FLOPPY
|
||||
#define CdChangerClassGuid GUID_DEVINTERFACE_CDCHANGER
|
||||
#define StoragePortClassGuid GUID_DEVINTERFACE_STORAGEPORT
|
||||
#define HiddenVolumeClassGuid GUID_DEVINTERFACE_HIDDEN_VOLUME
|
||||
|
||||
typedef enum _STORAGE_MEDIA_TYPE {
|
||||
DDS_4mm = 0x20,
|
||||
MiniQic,
|
||||
Travan,
|
||||
QIC,
|
||||
MP_8mm,
|
||||
AME_8mm,
|
||||
AIT1_8mm,
|
||||
DLT,
|
||||
NCTP,
|
||||
IBM_3480,
|
||||
IBM_3490E,
|
||||
IBM_Magstar_3590,
|
||||
IBM_Magstar_MP,
|
||||
STK_DATA_D3,
|
||||
SONY_DTF,
|
||||
DV_6mm,
|
||||
DMI,
|
||||
SONY_D2,
|
||||
CLEANER_CARTRIDGE,
|
||||
CD_ROM,
|
||||
CD_R,
|
||||
CD_RW,
|
||||
DVD_ROM,
|
||||
DVD_R,
|
||||
DVD_RW,
|
||||
MO_3_RW,
|
||||
MO_5_WO,
|
||||
MO_5_RW,
|
||||
MO_5_LIMDOW,
|
||||
PC_5_WO,
|
||||
PC_5_RW,
|
||||
PD_5_RW,
|
||||
ABL_5_WO,
|
||||
PINNACLE_APEX_5_RW,
|
||||
SONY_12_WO,
|
||||
PHILIPS_12_WO,
|
||||
HITACHI_12_WO,
|
||||
CYGNET_12_WO,
|
||||
KODAK_14_WO,
|
||||
MO_NFR_525,
|
||||
NIKON_12_RW,
|
||||
IOMEGA_ZIP,
|
||||
IOMEGA_JAZ,
|
||||
SYQUEST_EZ135,
|
||||
SYQUEST_EZFLYER,
|
||||
SYQUEST_SYJET,
|
||||
AVATAR_F2,
|
||||
MP2_8mm,
|
||||
DST_S,
|
||||
DST_M,
|
||||
DST_L,
|
||||
VXATape_1,
|
||||
VXATape_2,
|
||||
STK_9840,
|
||||
LTO_Ultrium,
|
||||
LTO_Accelis,
|
||||
DVD_RAM,
|
||||
AIT_8mm,
|
||||
ADR_1,
|
||||
ADR_2
|
||||
} STORAGE_MEDIA_TYPE, *PSTORAGE_MEDIA_TYPE;
|
||||
|
||||
typedef enum _STORAGE_BUS_TYPE {
|
||||
BusTypeUnknown = 0x00,
|
||||
BusTypeScsi,
|
||||
BusTypeAtapi,
|
||||
BusTypeAta,
|
||||
BusType1394,
|
||||
BusTypeSsa,
|
||||
BusTypeFibre,
|
||||
BusTypeUsb,
|
||||
BusTypeRAID,
|
||||
BusTypeMaxReserved = 0x7F
|
||||
} STORAGE_BUS_TYPE, *PSTORAGE_BUS_TYPE;
|
||||
|
||||
/* DEVICE_MEDIA_INFO.DeviceSpecific.DiskInfo.MediaCharacteristics constants */
|
||||
#define MEDIA_ERASEABLE 0x00000001
|
||||
#define MEDIA_WRITE_ONCE 0x00000002
|
||||
#define MEDIA_READ_ONLY 0x00000004
|
||||
#define MEDIA_READ_WRITE 0x00000008
|
||||
#define MEDIA_WRITE_PROTECTED 0x00000100
|
||||
#define MEDIA_CURRENTLY_MOUNTED 0x80000000
|
||||
|
||||
typedef struct _DEVICE_MEDIA_INFO {
|
||||
union {
|
||||
struct {
|
||||
LARGE_INTEGER Cylinders;
|
||||
STORAGE_MEDIA_TYPE MediaType;
|
||||
ULONG TracksPerCylinder;
|
||||
ULONG SectorsPerTrack;
|
||||
ULONG BytesPerSector;
|
||||
ULONG NumberMediaSides;
|
||||
ULONG MediaCharacteristics;
|
||||
} DiskInfo;
|
||||
struct {
|
||||
LARGE_INTEGER Cylinders;
|
||||
STORAGE_MEDIA_TYPE MediaType;
|
||||
ULONG TracksPerCylinder;
|
||||
ULONG SectorsPerTrack;
|
||||
ULONG BytesPerSector;
|
||||
ULONG NumberMediaSides;
|
||||
ULONG MediaCharacteristics;
|
||||
} RemovableDiskInfo;
|
||||
struct {
|
||||
STORAGE_MEDIA_TYPE MediaType;
|
||||
ULONG MediaCharacteristics;
|
||||
ULONG CurrentBlockSize;
|
||||
STORAGE_BUS_TYPE BusType;
|
||||
union {
|
||||
struct {
|
||||
UCHAR MediumType;
|
||||
UCHAR DensityCode;
|
||||
} ScsiInformation;
|
||||
} BusSpecificData;
|
||||
} TapeInfo;
|
||||
} DeviceSpecific;
|
||||
} DEVICE_MEDIA_INFO, *PDEVICE_MEDIA_INFO;
|
||||
|
||||
typedef struct _GET_MEDIA_TYPES {
|
||||
ULONG DeviceType;
|
||||
ULONG MediaInfoCount;
|
||||
DEVICE_MEDIA_INFO MediaInfo[1];
|
||||
} GET_MEDIA_TYPES, *PGET_MEDIA_TYPES;
|
||||
|
||||
typedef struct _STORAGE_ADAPTER_DESCRIPTOR {
|
||||
ULONG Version;
|
||||
ULONG Size;
|
||||
ULONG MaximumTransferLength;
|
||||
ULONG MaximumPhysicalPages;
|
||||
ULONG AlignmentMask;
|
||||
BOOLEAN AdapterUsesPio;
|
||||
BOOLEAN AdapterScansDown;
|
||||
BOOLEAN CommandQueueing;
|
||||
BOOLEAN AcceleratedTransfer;
|
||||
STORAGE_BUS_TYPE BusType;
|
||||
USHORT BusMajorVersion;
|
||||
USHORT BusMinorVersion;
|
||||
} STORAGE_ADAPTER_DESCRIPTOR, *PSTORAGE_ADAPTER_DESCRIPTOR;
|
||||
|
||||
typedef struct _STORAGE_BUS_RESET_REQUEST {
|
||||
UCHAR PathId;
|
||||
} STORAGE_BUS_RESET_REQUEST, *PSTORAGE_BUS_RESET_REQUEST;
|
||||
|
||||
typedef struct _STORAGE_DESCRIPTOR_HEADER {
|
||||
ULONG Version;
|
||||
ULONG Size;
|
||||
} STORAGE_DESCRIPTOR_HEADER, *PSTORAGE_DESCRIPTOR_HEADER;
|
||||
|
||||
typedef struct _STORAGE_DEVICE_DESCRIPTOR {
|
||||
ULONG Version;
|
||||
ULONG Size;
|
||||
UCHAR DeviceType;
|
||||
UCHAR DeviceTypeModifier;
|
||||
BOOLEAN RemovableMedia;
|
||||
BOOLEAN CommandQueueing;
|
||||
ULONG VendorIdOffset;
|
||||
ULONG ProductIdOffset;
|
||||
ULONG ProductRevisionOffset;
|
||||
ULONG SerialNumberOffset;
|
||||
STORAGE_BUS_TYPE BusType;
|
||||
ULONG RawPropertiesLength;
|
||||
UCHAR RawDeviceProperties[1];
|
||||
} STORAGE_DEVICE_DESCRIPTOR, *PSTORAGE_DEVICE_DESCRIPTOR;
|
||||
|
||||
typedef struct _STORAGE_DEVICE_ID_DESCRIPTOR {
|
||||
ULONG Version;
|
||||
ULONG Size;
|
||||
ULONG NumberOfIdentifiers;
|
||||
UCHAR Identifiers[1];
|
||||
} STORAGE_DEVICE_ID_DESCRIPTOR, *PSTORAGE_DEVICE_ID_DESCRIPTOR;
|
||||
|
||||
typedef struct _STORAGE_DEVICE_NUMBER {
|
||||
DEVICE_TYPE DeviceType;
|
||||
ULONG DeviceNumber;
|
||||
ULONG PartitionNumber;
|
||||
} STORAGE_DEVICE_NUMBER, *PSTORAGE_DEVICE_NUMBER;
|
||||
|
||||
typedef struct _STORAGE_PREDICT_FAILURE {
|
||||
ULONG PredictFailure;
|
||||
UCHAR VendorSpecific[512];
|
||||
} STORAGE_PREDICT_FAILURE, *PSTORAGE_PREDICT_FAILURE;
|
||||
|
||||
typedef enum _STORAGE_PROPERTY_ID {
|
||||
StorageDeviceProperty = 0,
|
||||
StorageAdapterProperty,
|
||||
StorageDeviceIdProperty,
|
||||
StorageDeviceUniqueIdProperty,
|
||||
StorageDeviceWriteCacheProperty,
|
||||
StorageMiniportProperty,
|
||||
StorageAccessAlignmentProperty
|
||||
} STORAGE_PROPERTY_ID, *PSTORAGE_PROPERTY_ID;
|
||||
|
||||
typedef enum _STORAGE_QUERY_TYPE {
|
||||
PropertyStandardQuery = 0,
|
||||
PropertyExistsQuery,
|
||||
PropertyMaskQuery,
|
||||
PropertyQueryMaxDefined
|
||||
} STORAGE_QUERY_TYPE, *PSTORAGE_QUERY_TYPE;
|
||||
|
||||
typedef struct _STORAGE_PROPERTY_QUERY {
|
||||
STORAGE_PROPERTY_ID PropertyId;
|
||||
STORAGE_QUERY_TYPE QueryType;
|
||||
UCHAR AdditionalParameters[1];
|
||||
} STORAGE_PROPERTY_QUERY, *PSTORAGE_PROPERTY_QUERY;
|
||||
|
||||
typedef struct _PREVENT_MEDIA_REMOVAL {
|
||||
BOOLEAN PreventMediaRemoval;
|
||||
} PREVENT_MEDIA_REMOVAL, *PPREVENT_MEDIA_REMOVAL;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _NTDDSTOR_H_ */
|
Loading…
Reference in New Issue