summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MSVC/Tools/master.mak4
-rw-r--r--cd-tool.cpp21
-rw-r--r--lib/cdabstract.cpp21
-rw-r--r--lib/cdreader.cpp6
4 files changed, 49 insertions, 3 deletions
diff --git a/MSVC/Tools/master.mak b/MSVC/Tools/master.mak
index 11ee305..4243a99 100644
--- a/MSVC/Tools/master.mak
+++ b/MSVC/Tools/master.mak
@@ -48,9 +48,9 @@ _XSD=xsd.exe
#define our basic link line for managed code
!IFDEF DEBUG
-_LINK=link.exe /INCREMENTAL /NOLOGO /DEBUG /MACHINE:I386 /NODEFAULTLIB:LIBC USER32.LIB
+_LINK=link.exe /INCREMENTAL /NOLOGO /DEBUG /MACHINE:I386 /NODEFAULTLIB:LIBC
!ELSE
-_LINK=link.exe /INCREMENTAL /NOLOGO /MACHINE:I386 /NODEFAULTLIB:LIBCD USER32.LIB
+_LINK=link.exe /INCREMENTAL /NOLOGO /MACHINE:I386 /NODEFAULTLIB:LIBCD
!ENDIF
#this is used for compiling C# samples
diff --git a/cd-tool.cpp b/cd-tool.cpp
index d5d766b..e828233 100644
--- a/cd-tool.cpp
+++ b/cd-tool.cpp
@@ -74,6 +74,22 @@ void showhelp(void) {
"\n", argv[0]);
}
+void probe(void) {
+ std::vector<String> p;
+
+ if (!cdabstract::canprobe()) {
+ printm(M_ERROR, "Can't probe on this platform.\n");
+ exit(-1);
+ }
+
+ p = cdabstract::probe();
+
+ printm(M_BARE, "Alvaible devices:\n");
+ for (std::vector<String>::iterator i = p.begin(); i != p.end(); i++) {
+ printm(M_BARE, *i + "\n");
+ }
+}
+
virtual int startup() throw (GeneralException) {
int type = GUESS, c, size, force = 0, sector;
char * ppf = 0, * iso_name = 0, * arg1 = 0, * arg2 = 0, * f;
@@ -106,6 +122,11 @@ virtual int startup() throw (GeneralException) {
}
iso_name = argv[optind++];
+
+ if (!strcmp(iso_name, "probe")) {
+ probe();
+ exit(-1);
+ }
if (argc == optind) {
showhelp();
diff --git a/lib/cdabstract.cpp b/lib/cdabstract.cpp
index f5f0d08..ce22fad 100644
--- a/lib/cdabstract.cpp
+++ b/lib/cdabstract.cpp
@@ -38,6 +38,7 @@ bool cdabstract::canprobe() {
}
std::vector<String> cdabstract::probe() throw (GeneralException) {
+ int i;
std::vector<String> r;
String probed;
@@ -45,9 +46,27 @@ std::vector<String> cdabstract::probe() throw (GeneralException) {
throw GeneralException("Can't probe CD devices on this platform.");
#ifdef __linux__
+ if (subprobe(probed = "/dev/cdrom"))
+ r.push_back(probed);
+
+ for (i = 0; i < 63; i++) {
+ probed.set("/dev/cdroms/cdrom%i", i);
+ if (subprobe(probed))
+ r.push_back(probed);
+ }
+ for (i = 'a'; i <= 'z'; i++) {
+ probed.set("/dev/hd%c", i);
+ if (subprobe(probed))
+ r.push_back(probed);
+ }
#endif
#if defined (_MSC_VER) || defined (__MINGW32__)
+ for (i = 'A'; i <= 'Z'; i++) {
+ probed.set("%c:\\", i);
+ if (subprobe(probed))
+ r.push_back(probed);
+ }
#endif
return r;
@@ -69,7 +88,7 @@ HANDLE cdabstract::OpenIOCTLFile(char cLetter) {
dwFlags = GENERIC_READ | GENERIC_WRITE; // add gen write on W2k/XP
else dwFlags = GENERIC_READ;
- wsprintf(szFName, "\\\\.\\%c:", cLetter);
+ sprintf(szFName, "\\\\.\\%c:", cLetter);
hF = CreateFile(szFName, dwFlags, FILE_SHARE_READ, // open drive
NULL, OPEN_EXISTING, dwIOCTLAttr, NULL);
diff --git a/lib/cdreader.cpp b/lib/cdreader.cpp
index 5e88e98..bb785cf 100644
--- a/lib/cdreader.cpp
+++ b/lib/cdreader.cpp
@@ -168,6 +168,12 @@ void cdreader::getsector(void *buf, int sec) throw (GeneralException) {
buf, 2352, &dwRet, NULL);
if (!bStat) {
DWORD dwErrCode = GetLastError();
+ if (dwErrCode == ERROR_INVALID_FUNCTION) {
+ if (rawIOCTL.TrackMode == YellowMode2) {
+ rawIOCTL.TrackMode = XAForm2;
+ continue;
+ }
+ }
if (dwErrCode != ERROR_IO_PENDING) {
throw GeneralException("Gave up on reading CD");
}