cdvdgigaherz: Fix sector address endian issue

The sector addresses returned when reading the layer information from a
DVD are big-endian. Convert the addresses to little endian.
This commit is contained in:
Jonathan Li 2016-03-15 00:10:41 +00:00
parent 5db0d682b8
commit 7292955600
1 changed files with 7 additions and 8 deletions

View File

@ -24,6 +24,7 @@
#include "rosddk/ntddscsi.h" #include "rosddk/ntddscsi.h"
#pragma warning(default:4200) #pragma warning(default:4200)
#include <stddef.h> #include <stddef.h>
#include <intrin.h>
template<class T> template<class T>
bool ApiErrorCheck(T t,T okValue,bool cmpEq) bool ApiErrorCheck(T t,T okValue,bool cmpEq)
@ -404,11 +405,11 @@ s32 IOCtlSrc::GetSectorCount()
{ {
if(dld.ld.EndLayerZeroSector>0) // OTP? if(dld.ld.EndLayerZeroSector>0) // OTP?
{ {
sectors1 = dld.ld.EndLayerZeroSector - dld.ld.StartingDataSector; sectors1 = _byteswap_ulong(dld.ld.EndLayerZeroSector) - _byteswap_ulong(dld.ld.StartingDataSector);
} }
else //PTP or single layer else //PTP or single layer
{ {
sectors1 = dld.ld.EndDataSector - dld.ld.StartingDataSector; sectors1 = _byteswap_ulong(dld.ld.EndDataSector) - _byteswap_ulong(dld.ld.StartingDataSector);
} }
dvdrs.BlockByteOffset.QuadPart=0; dvdrs.BlockByteOffset.QuadPart=0;
dvdrs.Format=DvdPhysicalDescriptor; dvdrs.Format=DvdPhysicalDescriptor;
@ -420,11 +421,11 @@ s32 IOCtlSrc::GetSectorCount()
//sectors1 += dld.ld.EndDataSector - dld.ld.StartingDataSector; //sectors1 += dld.ld.EndDataSector - dld.ld.StartingDataSector;
if(dld.ld.EndLayerZeroSector>0) // OTP? if(dld.ld.EndLayerZeroSector>0) // OTP?
{ {
sectors1 += dld.ld.EndLayerZeroSector - dld.ld.StartingDataSector; sectors1 += _byteswap_ulong(dld.ld.EndLayerZeroSector) - _byteswap_ulong(dld.ld.StartingDataSector);
} }
else //PTP else //PTP
{ {
sectors1 += dld.ld.EndDataSector - dld.ld.StartingDataSector; sectors1 += _byteswap_ulong(dld.ld.EndDataSector) - _byteswap_ulong(dld.ld.StartingDataSector);
} }
} }
@ -456,12 +457,12 @@ s32 IOCtlSrc::GetLayerBreakAddress()
if(dld.ld.EndLayerZeroSector>0) // OTP? if(dld.ld.EndLayerZeroSector>0) // OTP?
{ {
layerBreakCached = true; layerBreakCached = true;
layerBreak = dld.ld.EndLayerZeroSector - dld.ld.StartingDataSector; layerBreak = _byteswap_ulong(dld.ld.EndLayerZeroSector) - _byteswap_ulong(dld.ld.StartingDataSector);
return layerBreak; return layerBreak;
} }
else //PTP or single layer else //PTP or single layer
{ {
u32 s1 = dld.ld.EndDataSector - dld.ld.StartingDataSector; u32 s1 = _byteswap_ulong(dld.ld.EndDataSector) - _byteswap_ulong(dld.ld.StartingDataSector);
dvdrs.BlockByteOffset.QuadPart=0; dvdrs.BlockByteOffset.QuadPart=0;
dvdrs.Format=DvdPhysicalDescriptor; dvdrs.Format=DvdPhysicalDescriptor;
@ -568,8 +569,6 @@ s32 IOCtlSrc::GetMediaType()
} }
else //PTP or single layer else //PTP or single layer
{ {
u32 s1 = dld.ld.EndDataSector - dld.ld.StartingDataSector;
dvdrs.BlockByteOffset.QuadPart=0; dvdrs.BlockByteOffset.QuadPart=0;
dvdrs.Format=DvdPhysicalDescriptor; dvdrs.Format=DvdPhysicalDescriptor;
dvdrs.SessionId=sessID; dvdrs.SessionId=sessID;