00001 #pragma once
00002
00003 #pragma warning(disable : 4200)
00004
00005 #include <atlbase.h>
00006 #include <afxtempl.h>
00007
00008 #include "..\..\include\winddk\ntddcdvd.h"
00009
00010 class CDVDSession
00011 {
00012 protected:
00013 HANDLE m_hDrive;
00014
00015 DVD_SESSION_ID m_session;
00016 bool BeginSession();
00017 void EndSession();
00018
00019 BYTE m_SessionKey[5];
00020 bool Authenticate();
00021
00022 BYTE m_DiscKey[6], m_TitleKey[6];
00023 bool GetDiscKey();
00024 bool GetTitleKey(int lba, BYTE* pKey);
00025
00026 public:
00027 CDVDSession();
00028 virtual ~CDVDSession();
00029
00030 bool Open(LPCTSTR path);
00031 void Close();
00032
00033 operator HANDLE() {return m_hDrive;}
00034 operator DVD_SESSION_ID() {return m_session;}
00035
00036 bool SendKey(DVD_KEY_TYPE KeyType, BYTE* pKeyData);
00037 bool ReadKey(DVD_KEY_TYPE KeyType, BYTE* pKeyData, int lba = 0);
00038 };
00039
00040 class CLBAFile : private CFile
00041 {
00042 public:
00043 CLBAFile();
00044 virtual ~CLBAFile();
00045
00046 bool IsOpen();
00047
00048 bool Open(LPCTSTR path);
00049 void Close();
00050
00051 int GetLength();
00052 int GetPosition();
00053 int Seek(int lba);
00054 bool Read(BYTE* buff);
00055 };
00056
00057 class CVobFile : public CDVDSession
00058 {
00059
00060 typedef struct {CString fn; int size;} file_t;
00061 CArray<file_t> m_files;
00062 int m_iFile;
00063 int m_pos, m_size, m_offset;
00064
00065
00066 CLBAFile m_file;
00067
00068
00069 bool m_fDVD, m_fHasDiscKey, m_fHasTitleKey;
00070
00071 public:
00072 CVobFile();
00073 virtual ~CVobFile();
00074
00075 bool IsDVD();
00076 bool HasDiscKey(BYTE* key);
00077 bool HasTitleKey(BYTE* key);
00078
00079 bool Open(CString fn, CList<CString>& files );
00080 bool Open(CList<CString>& files, int offset = -1);
00081 void Close();
00082
00083 int GetLength();
00084 int GetPosition();
00085 int Seek(int pos);
00086 bool Read(BYTE* buff);
00087 };