This commit is contained in:
Li 2023-03-28 04:57:30 +13:00
parent c62b2e6ac2
commit 8c558e493b
26 changed files with 312 additions and 86 deletions

View File

@ -9,6 +9,6 @@
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup>
<ShowAllFiles>false</ShowAllFiles>
<ShowAllFiles>true</ShowAllFiles>
</PropertyGroup>
</Project>

View File

@ -69,9 +69,10 @@ namespace Li::Dvd {
int nmRd = 0;
int numRetry = 5;
for (int i = 0; i < toRead; i++) {
for (int retry = 0; retry < numRetry; retry++) {
for (int retry = 0; retry < numRetry; retry++)
{
int dataRd = dvdcss_read(driveIoCtl->GetDvdCssHandle(), this->tmpBuffer, 1, (this->decrypt ? DVDCSS_READ_DECRYPT : DVDCSS_NOFLAGS));
if (dataRd < 0) {
if (dataRd < 0 || dvdcss_was_error(driveIoCtl->GetDvdCssHandle())) {
// if the last read was an error, and this read is an error, give up trying as were still in
// the section of bad sectors,
@ -81,7 +82,7 @@ namespace Li::Dvd {
this->errorMsg = "one or more sectors failed to be read.";
// try seek forward 1 sector
if (dvdcss_seek(driveIoCtl->GetDvdCssHandle(), this->sectorsReadSoFar + 1, DVDCSS_NOFLAGS) < 0) break;
dvdcss_seek(driveIoCtl->GetDvdCssHandle(), this->sectorsReadSoFar + 1, DVDCSS_NOFLAGS);
// set the last read was error flag,
// increment the number of failed reads
@ -95,16 +96,15 @@ namespace Li::Dvd {
// write null sector to the ISO ...
this->iso->write((const char*)this->tmpBuffer, DVDCSS_BLOCK_SIZE);
continue;
break;
}
else {
// if we have not reached max retry count, then set the position back to the current sector
// and attempt a read again ..
if (dvdcss_seek(driveIoCtl->GetDvdCssHandle(), this->sectorsReadSoFar, DVDCSS_NOFLAGS) < 0) break;
dvdcss_seek(driveIoCtl->GetDvdCssHandle(), this->sectorsReadSoFar, DVDCSS_NOFLAGS);
}
this->retriedReads++;
continue; // retry
}
else {
// if there was a successful read,
@ -137,11 +137,8 @@ namespace Li::Dvd {
int numRead = dvdcss_read(driveIoCtl->GetDvdCssHandle(), this->tmpBuffer, toRead, DVDCSS_READ_DECRYPT);
if (dvdcss_was_error(driveIoCtl->GetDvdCssHandle())) {
this->errorMsg = std::string(dvdcss_error(driveIoCtl->GetDvdCssHandle()));
}
if (numRead < 0) {
dvdcss_seek(driveIoCtl->GetDvdCssHandle(), this->sectorsReadSoFar, DVDCSS_SEEK_KEY);
if (numRead < 0 || dvdcss_was_error(driveIoCtl->GetDvdCssHandle())) {
dvdcss_seek(driveIoCtl->GetDvdCssHandle(), this->sectorsReadSoFar, DVDCSS_NOFLAGS);
read1SectorATimeSkippingBadSectors(toRead);
}
else {
@ -151,7 +148,7 @@ namespace Li::Dvd {
}
} while ( (this->fileReadSoFar < this->fileRemain) &&
(this->sectorsReadSoFar < this->drive->Sectors()) &&
this->keepRunning);
this->keepRunning );
this->inFile = Li::Dvd::TitleKey::IsSectorInFile(this->sectorsReadSoFar);
this->fileReadSoFar = 0;
@ -161,18 +158,18 @@ namespace Li::Dvd {
dvdcss_title(this->driveIoCtl->GetDvdCssHandle(), this->sectorsReadSoFar);
this->fileRemain = Li::Dvd::TitleKey::GetDistanceToNextFile(this->sectorsReadSoFar);
if ((this->sectorsReadSoFar + this->fileRemain) > this->drive->Sectors()) {
if (this->fileRemain == 0 || (this->sectorsReadSoFar + this->fileRemain) > this->drive->Sectors()) {
this->fileRemain = (this->drive->Sectors() - this->sectorsReadSoFar);
}
this->fileReadSoFar = 0;
this->readCssSectors();
}
void DvdRipper::readFileSectors() {
dvdcss_title(this->driveIoCtl->GetDvdCssHandle(), this->sectorsReadSoFar);
this->titleKey = (std::byte*)dvdcss_get_cur_titlekey(this->driveIoCtl->GetDvdCssHandle());
sectorInfo* sectorInf = Li::Dvd::TitleKey::GetSectorInfo(this->sectorsReadSoFar);
this->fileRemain = (sectorInf->endSector - sectorInf->startSector);

View File

@ -31,7 +31,7 @@ namespace Li::Dvd {
uint32_t TitleKey::GetDistanceToNextFile(uint32_t currentSector) {
uint32_t lowestDistance = 0xFFFFFFFF;
uint64_t lowestDistance = 0xffffffffffffffff;
for (sectorInfo* inf : sectorsList) {
if (currentSector >= inf->startSector && currentSector < inf->endSector)
return 0;
@ -44,7 +44,10 @@ namespace Li::Dvd {
}
}
return lowestDistance;
if (lowestDistance == 0xffffffffffffffff)
return 0;
return (uint32_t)lowestDistance;
}
@ -59,6 +62,31 @@ namespace Li::Dvd {
return nullptr;
}
sectorInfo* TitleKey::getFile(uint32_t start, uint32_t sz) {
sectorInfo* file = new sectorInfo();
file->startSector = start;
if ((sz % DVDCSS_BLOCK_SIZE) != 0) {
sz += (DVDCSS_BLOCK_SIZE - (sz % DVDCSS_BLOCK_SIZE));
}
file->endSector = (file->startSector + (sz / DVDCSS_BLOCK_SIZE));
return file;
}
void TitleKey::addFileIfExist(sectorInfo* file) {
dvdcss_title(drv, file->startSector);
char* titleKey = dvdcss_get_cur_titlekey(drv);
// check title is encrypted ...
if (memcmp(titleKey, "\0\0\0\0\0", 5) && GetSectorInfo(file->startSector) == nullptr) {
sectorsList.push_back(file);
}
else {
delete file;
}
}
bool TitleKey::readDir(l9660_dir* dir, int depth=0) {
@ -77,33 +105,15 @@ namespace Li::Dvd {
if (dent->name_len < 2)
continue;
uint32_t cSector = *(uint32_t*)dent->sector.le;
if ((dent->flags & DENT_ISDIR) != 0) {
l9660_dir ndir;
if (l9660_opendirat(&ndir, dir, dent->name) != L9660_OK) return false;
success = readDir(&ndir, depth + 1);
}
else if (TitleKey::GetSectorInfo(cSector) == nullptr) {
sectorInfo* file = new sectorInfo();
file->startSector = cSector;
dvdcss_title(drv, file->startSector);
char* titleKey = dvdcss_get_cur_titlekey(drv);
// check title is encrypted ...
if (memcmp(titleKey, "\0\0\0\0\0", 5)) {
// Round to sector boundary
uint32_t sz = (*(uint32_t*)dent->size.le);
if((sz % DVDCSS_BLOCK_SIZE) != 0)
sz += (DVDCSS_BLOCK_SIZE - (sz % DVDCSS_BLOCK_SIZE));
file->endSector = (file->startSector + (sz / DVDCSS_BLOCK_SIZE));
sectorsList.push_back(file);
}
else {
delete file;
}
else {
addFileIfExist(getFile(*(uint32_t*)dent->sector.le, *(uint32_t*)dent->size.le));
addFileIfExist(getFile(_byteswap_ulong(*(uint32_t*)dent->sector.be), _byteswap_ulong(*(uint32_t*)dent->size.be)));
}
}

View File

@ -14,6 +14,8 @@ namespace Li::Dvd {
private:
static bool readSector(l9660_fs* fs, void* buf, uint32_t sector);
static bool readDir(l9660_dir* dir, int depth);
static sectorInfo* getFile(uint32_t start, uint32_t sz);
static void addFileIfExist(sectorInfo* file);
public:
static bool FindTitleKeys(dvdcss_t drive);
static uint32_t GetDistanceToNextFile(uint32_t currentSector);

View File

@ -7,7 +7,7 @@
#include <filesystem>
#include "Renderer.hpp"
#include "../Utils.hpp"
#include "../Scsi/IoCtl.hpp"
#include "../Scsi/OpticalDrive.hpp"
@ -17,20 +17,21 @@
namespace Li::Gui {
DumpDVD::DumpDVD() {
DumpDVD::DumpDVD(Renderer* renderer) {
this->discInserted = false;
this->keepPolling = true;
this->showDemoWindow = true;
this->imRippinIt = false;
this->selectedDrive = 0;
this->selectedDriveSpeed = 0;
this->dvdSpin = DvdSpin::RenderDvdSpin::CreateDvdSpinner(renderer);
this->drivesList = Li::Scsi::OpticalDrive::ListOpticalDrives();
this->pollDrives = new std::thread(&DumpDVD::pollDrivesThread, this);
this->sectorsAtOnce = 0x400;
this->lock = new std::mutex();
this->reset();
}
@ -41,10 +42,13 @@ namespace Li::Gui {
}
else {
this->keepPolling = false;
this->lock->lock();
this->pollDrives->detach();
delete this->pollDrives;
this->lock->unlock();
}
DvdSpin::RenderDvdSpin::DeleteDvdSpinner(this->dvdSpin);
delete this->lock;
freeOldDriveList();
}
@ -56,6 +60,17 @@ namespace Li::Gui {
}
}
void DumpDVD::updateSpinTexture() {
if (this->dvdSpin != nullptr) {
if (this->drivesList->size() >= 0) {
this->dvdSpin->UpdateTexture(this->GetCurrentSelectedDrive()->MediaType());
}
else {
this->dvdSpin->UpdateTexture(DvdSpin::CdType::UNKNOWN_DISC);
}
}
}
void DumpDVD::refreshDriveList() {
std::vector<Li::Scsi::OpticalDrive*>* pollDrives = Li::Scsi::OpticalDrive::ListOpticalDrives();
this->lock->lock();
@ -65,6 +80,8 @@ namespace Li::Gui {
if (this->selectedDrive >= this->drivesList->size())
this->reset();
this->updateSpinTexture();
this->lock->unlock();
}
@ -105,9 +122,12 @@ namespace Li::Gui {
this->selectedDriveSpeed = 0;
memset(this->outputFile, 0, sizeof(DumpDVD::outputFile));
}
this->updateSpinTexture();
}
Li::Scsi::OpticalDrive* DumpDVD::GetCurrentSelectedDrive() {
if (this->drivesList->size() <= 0) return nullptr;
return this->drivesList->at(this->selectedDrive);
}
@ -317,13 +337,14 @@ namespace Li::Gui {
void DumpDVD::RenderUI() {
this->dvdSpin->RenderDVD();
if (this->drivesList == nullptr) return;
const ImGuiViewport* mainViewport = ImGui::GetMainViewport();
ImGui::SetNextWindowPos(ImVec2(0, 0), ImGuiCond_Always);
ImGui::SetNextWindowSize(ImGui::GetIO().DisplaySize, ImGuiCond_Always);
ImGui::Begin("DVD Dumper", NULL, /* ImGuiWindowFlags_NoCollapse | */ ImGuiWindowFlags_NoMove |
ImGui::Begin("Disc Dumper", NULL, /* ImGuiWindowFlags_NoCollapse | */ ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize |
ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoFocusOnAppearing);
if (this->imRippinIt)

View File

@ -6,6 +6,9 @@
#include <thread>
#include <mutex>
#include "Renderer.hpp"
#include "DvdSpin/RenderDvdSpin.hpp"
#include "../Scsi/OpticalDrive.hpp"
#include "../Dvd/DvdRipper.hpp"
@ -30,8 +33,10 @@ namespace Li::Gui {
std::thread* pollDrives;
Li::Dvd::DvdRipper* dvdRipper;
DvdSpin::RenderDvdSpin* dvdSpin;
void pollDrivesThread();
void updateSpinTexture();
void freeOldDriveList();
void refreshDriveList();
@ -48,7 +53,7 @@ namespace Li::Gui {
public:
Li::Scsi::OpticalDrive* GetCurrentSelectedDrive();
DumpDVD();
DumpDVD(Renderer* renderer);
~DumpDVD();
void RenderUI();
};

View File

@ -9,6 +9,7 @@
namespace Li::Gui::DvdSpin {
CdTex::CdTex() {
this->uncompressedTextureSz = ceedeeImgUncompressedSz;
this->uncompressedTexture = new std::byte[this->uncompressedTextureSz];
this->SetUnknownTexture();
}
@ -21,25 +22,33 @@ namespace Li::Gui::DvdSpin {
}
void CdTex::SetCdTexture() {
if (this->currentCdType == CdType::COMPACT_DISC) return;
if (this->currentCdType != CdType::UNKNOWN_DISC) this->SetUnknownTexture();
this->applyDiff(ceedeeCdDiffSz, ceedeeCdDiff);
this->currentCdType = CdType::COMPACT_DISC;
}
void CdTex::SetDvdTexture() {
if (this->currentCdType == CdType::DIGITAL_VERSITLE_DISC) return;
if (this->currentCdType != CdType::UNKNOWN_DISC) this->SetUnknownTexture();
this->applyDiff(ceedeeDvdDiffSz, ceedeeDvdDiff);
this->currentCdType = CdType::DIGITAL_VERSITLE_DISC;
}
void CdTex::SetHdDvdTexture() {
if (this->currentCdType == CdType::HIGH_DEFINITION_DIGITAL_VERSITLE_DISC) return;
if (this->currentCdType != CdType::UNKNOWN_DISC) this->SetUnknownTexture();
this->applyDiff(ceedeeHdDvdDiffSz, ceedeeHdDvdDiff);
this->currentCdType = CdType::HIGH_DEFINITION_DIGITAL_VERSITLE_DISC;
}
void CdTex::SetBdTexture() {
if (this->currentCdType == CdType::BLU_RAY) return;
if (this->currentCdType != CdType::UNKNOWN_DISC) this->SetUnknownTexture();
this->applyDiff(ceedeeBluRayDiffSz, ceedeeBluRayDiff);
this->currentCdType = CdType::BLU_RAY;
}
void CdTex::SetUnknownTexture() {
this->uncompressedTexture = new std::byte[this->uncompressedTextureSz];
uint32_t compressedSize = ceedeeImgCompressedDataSz;
lzma2decompress((unsigned char*)&ceedeeImgCompressedData, &compressedSize, (unsigned char*)this->uncompressedTexture, &this->uncompressedTextureSz);
this->currentCdType = CdType::UNKNOWN_DISC;
@ -57,11 +66,15 @@ namespace Li::Gui::DvdSpin {
return ceedeeImgChannels;
}
uint32_t CdTex::Stride() {
uint32_t CdTex::Pitch() {
return (this->Width() * this->Channels());
}
std::byte* CdTex::GetCurrentTexture() {
CdType CdTex::CurrentCdType() {
return this->currentCdType;
}
std::byte* CdTex::CurrentTexture() {
return this->uncompressedTexture;
}

View File

@ -17,13 +17,15 @@ namespace Li::Gui::DvdSpin {
void SetUnknownTexture();
void SetBdTexture();
void SetDvdTexture();
void SetHdDvdTexture();
void SetCdTexture();
uint32_t Width();
uint32_t Height();
uint32_t Channels();
uint32_t Stride();
std::byte* GetCurrentTexture();
uint32_t Pitch();
CdType CurrentCdType();
std::byte* CurrentTexture();
};
};

View File

@ -6,6 +6,7 @@ namespace Li::Gui::DvdSpin {
UNKNOWN_DISC,
COMPACT_DISC,
DIGITAL_VERSITLE_DISC,
HIGH_DEFINITION_DIGITAL_VERSITLE_DISC,
BLU_RAY
};
}

View File

@ -127,15 +127,15 @@ namespace Li::Gui::DvdSpin {
this->d3d->D3dDeviceContext()->UpdateSubresource(this->cdTexture,
NULL,
nullptr,
this->TextureProvider()->GetCurrentTexture(),
this->TextureProvider()->Stride(),
this->cdTextureProvider->CurrentTexture(),
this->cdTextureProvider->Pitch(),
NULL);
}
HRESULT D3DSpin::createCdTexture() {
D3D11_TEXTURE2D_DESC tdesc;
tdesc.Width = this->TextureProvider()->Width();
tdesc.Height = this->TextureProvider()->Height();
tdesc.Width = this->cdTextureProvider->Width();
tdesc.Height = this->cdTextureProvider->Height();
tdesc.MipLevels = 1;
tdesc.ArraySize = 1;
tdesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
@ -149,8 +149,8 @@ namespace Li::Gui::DvdSpin {
D3D11_SUBRESOURCE_DATA tres = {};
tres.pSysMem = this->TextureProvider()->GetCurrentTexture();
tres.SysMemPitch = this->TextureProvider()->Stride();
tres.pSysMem = this->cdTextureProvider->CurrentTexture();
tres.SysMemPitch = this->cdTextureProvider->Pitch();
tres.SysMemSlicePitch = 0;
return d3d->D3dDevice()->CreateTexture2D(&tdesc, &tres, &this->cdTexture);
@ -208,21 +208,20 @@ namespace Li::Gui::DvdSpin {
ImGui::End();
ImGui::Begin("Change Tex");
if (ImGui::Button("Unknown Texture")) {
this->TextureProvider()->SetUnknownTexture();
this->updateCdTexture();
if (ImGui::Button("Unknown Disc")) {
this->UpdateTexture(CdType::UNKNOWN_DISC);
}
if(ImGui::Button("Blu-Ray")){
this->TextureProvider()->SetBdTexture();
this->updateCdTexture();
this->UpdateTexture(CdType::BLU_RAY);
}
if (ImGui::Button("Hd Dvd")) {
this->UpdateTexture(CdType::HIGH_DEFINITION_DIGITAL_VERSITLE_DISC);
}
if (ImGui::Button("Dvd")) {
this->TextureProvider()->SetDvdTexture();
this->updateCdTexture();
this->UpdateTexture(CdType::DIGITAL_VERSITLE_DISC);
}
if (ImGui::Button("Cd")) {
this->TextureProvider()->SetCdTexture();
this->updateCdTexture();
this->UpdateTexture(CdType::COMPACT_DISC);
}
ImGui::End();
@ -230,8 +229,28 @@ namespace Li::Gui::DvdSpin {
}
CdTex* D3DSpin::TextureProvider() {
return this->cdTextureProvider;
void D3DSpin::UpdateTexture(CdType type) {
if (this->cdTextureProvider->CurrentCdType() == type) return;
switch (type) {
case CdType::COMPACT_DISC:
this->cdTextureProvider->SetCdTexture();
break;
case CdType::DIGITAL_VERSITLE_DISC:
this->cdTextureProvider->SetDvdTexture();
break;
case CdType::HIGH_DEFINITION_DIGITAL_VERSITLE_DISC:
this->cdTextureProvider->SetHdDvdTexture();
break;
case CdType::BLU_RAY:
this->cdTextureProvider->SetBdTexture();
break;
case CdType::UNKNOWN_DISC:
default:
this->cdTextureProvider->SetUnknownTexture();
break;
}
this->updateCdTexture();
}
D3DSpin::D3DSpin(D3D* d3d) {

View File

@ -4,6 +4,7 @@
#include <DirectXMath.h>
#include "RenderDvdSpin.hpp"
#include "CdTex.hpp"
#include "CdType.hpp"
#include "../D3D.hpp"
namespace Li::Gui::DvdSpin {
@ -62,7 +63,7 @@ namespace Li::Gui::DvdSpin {
HRESULT createCdResourceView();
public:
void RenderDVD();
CdTex* TextureProvider();
void UpdateTexture(CdType type);
D3DSpin(D3D* d3d);
~D3DSpin();
};

View File

@ -1,13 +1,14 @@
#ifndef _LI_RENDER_DVD_SPIN
#define _LI_RENDER_DVD_SPIN 1
#include "CdTex.hpp"
#include "CdType.hpp"
#include "../Renderer.hpp"
namespace Li::Gui::DvdSpin {
class RenderDvdSpin {
public:
virtual void RenderDVD() {};
virtual CdTex* TextureProvider() { return nullptr; };
virtual void UpdateTexture(CdType type) {};
static RenderDvdSpin* CreateDvdSpinner(Renderer* renderer);
static void DeleteDvdSpinner(RenderDvdSpin* spinner);
};

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 MiB

File diff suppressed because one or more lines are too long

View File

@ -69,6 +69,7 @@ hdr += "/* Texture */\n"
img = readImg(imgName)
imgCd = readImg(imgName+"Cd")
imgDvd = readImg(imgName+"Dvd")
imgHdDvd = readImg(imgName+"HdDvd")
imgBd = readImg(imgName+"BluRay")
readTexture(img)
@ -76,6 +77,7 @@ readTexture(img)
hdr += "/* Diff */\n"
diffTexture(img, imgCd)
diffTexture(img, imgDvd)
diffTexture(img, imgHdDvd)
diffTexture(img, imgBd)
hdr += "#endif"
print(hdr)

View File

@ -3,6 +3,7 @@
#include "DumpDVD.hpp"
#include "D3D.hpp"
#include "../Scsi/OpticalDrive.hpp"
#include "DvdSpin/D3DSpin.hpp"
#include <iostream>
@ -15,20 +16,18 @@ namespace Li::Gui {
this->sdl = new SDL("DumpDVD", 800, 400);
this->sdl->SetMaxFPS(24.0);
// Create dvd spinner
Li::Gui::DvdSpin::RenderDvdSpin* spin = Li::Gui::DvdSpin::RenderDvdSpin::CreateDvdSpinner(sdl->Renderer());
// Create menu
DumpDVD* dumpDvdMenu = new DumpDVD();
DumpDVD* dumpDvdMenu = new DumpDVD(sdl->Renderer());
while (!this->sdl->IsExiting()) {
this->sdl->PollEvent();
this->sdl->NewFrame();
spin->RenderDVD();
dumpDvdMenu->RenderUI();
this->sdl->Render();
}
Li::Gui::DvdSpin::RenderDvdSpin::DeleteDvdSpinner(spin);
delete dumpDvdMenu;
}

View File

@ -14,7 +14,6 @@
#include <scsi.h>
#endif
#include <dvdcss.h>
#include <iostream>
#include <string>
@ -91,7 +90,7 @@ namespace Li::Scsi {
return speeds;
}
uint64_t IoCtl::GetTotalSectors() {
uint32_t IoCtl::GetTotalSectors() {
#ifdef _WIN32
DISK_GEOMETRY_EX geometry;
memset(&geometry, 0x00, sizeof(DISK_GEOMETRY_EX));
@ -101,7 +100,13 @@ namespace Li::Scsi {
if (!success) {
Utils::ShowErrorMessage("Error getting geometry: " + std::to_string(GetLastError()));
}
return (uint64_t)(geometry.DiskSize.QuadPart / DVDCSS_BLOCK_SIZE);
uint64_t totalSz = geometry.DiskSize.QuadPart;
if ((totalSz % DVDCSS_BLOCK_SIZE) != 0)
totalSz += (DVDCSS_BLOCK_SIZE - (totalSz % DVDCSS_BLOCK_SIZE));
return (uint32_t)(totalSz / DVDCSS_BLOCK_SIZE);
#else
#error no way to get total sector count of disc on this platform ..
#endif
@ -121,6 +126,69 @@ namespace Li::Scsi {
#endif
}
Li::Gui::DvdSpin::CdType IoCtl::GetMediaType() {
#ifdef _WIN32
DWORD unused;
GET_CONFIGURATION_IOCTL_INPUT configInput;
memset(&configInput, 0, sizeof(GET_CONFIGURATION_IOCTL_INPUT));
configInput.Feature = FeatureProfileList;
configInput.RequestType = SCSI_GET_CONFIGURATION_REQUEST_TYPE_CURRENT;
GET_CONFIGURATION_HEADER hdr;
memset(&hdr, 0, sizeof(GET_CONFIGURATION_HEADER));
BOOL success = DeviceIoControl((HANDLE)this->osFileHandle, IOCTL_CDROM_GET_CONFIGURATION, &configInput, sizeof(GET_CONFIGURATION_IOCTL_INPUT), &hdr, sizeof(GET_CONFIGURATION_HEADER), &unused, nullptr);
if (!success) {
Utils::ShowErrorMessage("Error getting configuration: " + std::to_string(GetLastError()));
}
else {
FEATURE_PROFILE_TYPE currentProfile = (FEATURE_PROFILE_TYPE)(_byteswap_ushort(*(uint16_t*)hdr.CurrentProfile));
if (currentProfile == ProfileDvdRom ||
currentProfile == ProfileDvdRecordable ||
currentProfile == ProfileDvdRam ||
currentProfile == ProfileDvdRewritable ||
currentProfile == ProfileDvdRWSequential ||
currentProfile == ProfileDvdDashRDualLayer ||
currentProfile == ProfileDvdDashRLayerJump ||
currentProfile == ProfileDvdPlusRW ||
currentProfile == ProfileDvdPlusR ||
currentProfile == ProfileDvdPlusRWDualLayer ||
currentProfile == ProfileDvdPlusRDualLayer ) {
return Li::Gui::DvdSpin::CdType::DIGITAL_VERSITLE_DISC;
}
else if (
currentProfile == ProfileCdrom ||
currentProfile == ProfileCdRecordable ||
currentProfile == ProfileCdRewritable ||
currentProfile == ProfileDDCdrom ||
currentProfile == ProfileDDCdRecordable ||
currentProfile == ProfileDDCdRewritable) {
return Li::Gui::DvdSpin::CdType::COMPACT_DISC;
}
else if (
currentProfile == ProfileBDRom ||
currentProfile == ProfileBDRSequentialWritable ||
currentProfile == ProfileBDRRandomWritable ||
currentProfile == ProfileBDRewritable) {
return Li::Gui::DvdSpin::CdType::BLU_RAY;
}
else if (
currentProfile == ProfileHDDVDRom ||
currentProfile == ProfileHDDVDRecordable ||
currentProfile == ProfileHDDVDRam ||
currentProfile == ProfileHDDVDRewritable ||
currentProfile == ProfileHDDVDRDualLayer ||
currentProfile == ProfileHDDVDRWDualLayer) {
return Li::Gui::DvdSpin::CdType::HIGH_DEFINITION_DIGITAL_VERSITLE_DISC;
}
}
return Li::Gui::DvdSpin::CdType::UNKNOWN_DISC;
#else
#error no way to check media type
#endif
}
/*bool IoCtl::UnmountVolume() {
#ifdef _WIN32
DWORD unused;

View File

@ -4,6 +4,7 @@
#include <vector>
#include <string>
#include <dvdcss.h>
#include "../DumpDVD/Gui/DvdSpin/CdType.hpp"
namespace Li::Scsi {
class IoCtl {
@ -15,9 +16,10 @@ namespace Li::Scsi {
~IoCtl();
dvdcss_t GetDvdCssHandle();
uint64_t GetTotalSectors();
uint32_t GetTotalSectors();
bool SetDriveSpeed(int readSpeed, int writeSpeed);
bool AllowReadingPastDisc();
Li::Gui::DvdSpin::CdType GetMediaType();
/*bool ExclusiveLockDrive();
bool ExclusiveUnlockDrive();
bool UnmountVolume();

View File

@ -1,5 +1,6 @@
#include "OpticalDrive.hpp"
#include "IoCtl.hpp"
#include "../Gui/DvdSpin/CdType.hpp"
#include "SDL.h"
#ifdef _WIN32
@ -38,11 +39,13 @@ namespace Li::Scsi {
OpticalDrive::OpticalDrive(std::string drv) {
this->getDriveInformation(drv);
if (this->discInDrive) {
IoCtl* ctl = new IoCtl(this->drivePath);
this->supportedSpeeds = ctl->GetSupportedReadSpeeds();
this->sectors = ctl->GetTotalSectors();
this->mediaType = ctl->GetMediaType();
this->hasCss = dvdcss_is_scrambled(ctl->GetDvdCssHandle());
if (this->hasCss) {
@ -55,6 +58,9 @@ namespace Li::Scsi {
delete ctl;
}
else {
this->mediaType = Li::Gui::DvdSpin::CdType::UNKNOWN_DISC;
}
}
OpticalDrive::~OpticalDrive() {
if(this->discInDrive)
@ -76,7 +82,9 @@ namespace Li::Scsi {
bool OpticalDrive::HasCss() {
return this->hasCss;
}
Li::Gui::DvdSpin::CdType OpticalDrive::MediaType() {
return this->mediaType;
}
std::byte* OpticalDrive::DiscKey() {
return this->discKey;
}

View File

@ -2,6 +2,7 @@
#define _LI_OPTICAL_DRIVE_H 1
#include <vector>
#include <iostream>
#include "../Gui/DvdSpin/CdType.hpp"
namespace Li::Scsi {
class OpticalDrive {
private:
@ -10,7 +11,7 @@ namespace Li::Scsi {
bool hasCss;
std::byte discKey[5];
Li::Gui::DvdSpin::CdType mediaType;
bool discInDrive;
std::vector<uint32_t>* supportedSpeeds;
uint32_t sectors;
@ -25,6 +26,7 @@ namespace Li::Scsi {
std::string VolumeName();
uint32_t Sectors();
std::byte* DiscKey();
Li::Gui::DvdSpin::CdType MediaType();
bool HasCss();
bool DiscInDrive();

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.