- diff -u B25Decoder/BonProject/BcasCardReader.cpp B1Decoder/BonProject/BcasCardReader.cpp
- --- B25Decoder/BonProject/BcasCardReader.cpp Fri Sep 25 05:59:12 2009
- +++ B1Decoder/BonProject/BcasCardReader.cpp Mon Mar 30 17:49:33 2015
- @@ -150,7 +150,7 @@
- const BYTE * CBcasCardReader::GetKsFromEcm(const BYTE *pEcmData, const DWORD dwEcmSize)
- {
- - static const BYTE abyEcmReceiveCmd[] = {0x90U, 0x34U, 0x00U, 0x00U};
- + static const BYTE abyEcmReceiveCmd[] = {0x80U, 0x34U, 0x00U, 0x00U};
- // 「ECM Receive Command」を処理する
- if(!m_hBcasCard){
- @@ -179,19 +179,41 @@
- // コマンド送信
- if(!TransmitCommand(m_hBcasCard, SendData, sizeof(abyEcmReceiveCmd) + dwEcmSize + 2UL, RecvData, sizeof(RecvData), &dwRecvSize)){
- ::ZeroMemory(&m_EcmStatus, sizeof(m_EcmStatus));
- - m_dwEcmError = EC_TRANSMIT_ERROR;
- + m_dwEcmError = EC_NO_ERROR;//EC_TRANSMIT_ERROR;
- return NULL;
- }
- // サイズチェック
- - if(dwRecvSize != 25UL){
- + if(dwRecvSize != 22UL){
- ::ZeroMemory(&m_EcmStatus, sizeof(m_EcmStatus));
- - m_dwEcmError = EC_TRANSMIT_ERROR;
- + m_dwEcmError = EC_NO_ERROR;//EC_TRANSMIT_ERROR;
- return NULL;
- }
- + else {
- // レスポンス解析
- - ::CopyMemory(m_EcmStatus.KsData, &RecvData[6], sizeof(m_EcmStatus.KsData));
- + ::CopyMemory(m_EcmStatus.KsData, &RecvData[0], sizeof(m_EcmStatus.KsData));
- + m_dwEcmError = EC_NO_ERROR;
- + return m_EcmStatus.KsData;
- + }
- +
- + //const static uint8_t ffff[16] = {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
- +/* memcpy(dst->scramble_key, prv->rbuf, 16);
- + switch ( load_be_uint16(prv->rbuf+18) ) {
- + case 0xc001 :
- + dst->return_code = 0x0800 ;
- + break ;
- + case 0xc000 :
- + dst->return_code = 0xa901 ;
- + break ;
- + // 他にどんなコードがあるか不明なのでとりあえずff..ffかどうかでチェック
- + default :
- + if ( !memcmp( dst->scramble_key, ffff, 16 ) ) {
- + dst->return_code = 0xa902 ;
- + }
- + else {
- + //dst->return_code = 0x0800 ;
- + }
- // リターンコード解析
- switch(((WORD)RecvData[4] << 8) | (WORD)RecvData[5]){
- @@ -210,7 +232,7 @@
- default :
- m_dwEcmError = EC_NOT_CONTRACTED;
- return NULL;
- - }
- + }*/
- }
- const DWORD CBcasCardReader::GetEcmError(void)
- @@ -221,7 +243,7 @@
- const bool CBcasCardReader::SendEmmSection(const BYTE *pEmmData, const DWORD dwEmmSize)
- {
- - static const BYTE abyEmmReceiveCmd[] = {0x90U, 0x36U, 0x00U, 0x00U};
- + static const BYTE abyEmmReceiveCmd[] = {0x80U, 0x36U, 0x00U, 0x00U};
- // 「EMM Receive Command」を処理する
- if(!m_hBcasCard)return false;
- @@ -249,7 +271,7 @@
- // リターンコード解析
- switch(((WORD)RecvData[4] << 8) | (WORD)RecvData[5]){
- - case 0x2100U : // 正常終了
- + case 0x9000U : // 正常終了
- return true;
- case 0xA102U : // 非運用(運用外プロトコル番号)
- @@ -281,7 +303,7 @@
- if(dwRecvSize != 20UL)return 0U;
- // リターンコード解析
- - if((((WORD)RecvData[4] << 8) | (WORD)RecvData[5]) != 0x2100U)return 0U;
- + if((((WORD)RecvData[4] << 8) | (WORD)RecvData[5]) != 0x9000U)return 0U;
- // レスポンス解析
- const WORD wInfoNum = (WORD)RecvData[7] + 1U;
- @@ -300,7 +322,7 @@
- if(dwRecvSize != 20UL)return 0U;
- // リターンコード解析
- - if((((WORD)RecvData[4] << 8) | (WORD)RecvData[5]) != 0x2100U)return 0U;
- + if((((WORD)RecvData[4] << 8) | (WORD)RecvData[5]) != 0x9000U)return 0U;
- // レスポンス解析
- TsTime.ClearTime();
- @@ -387,7 +409,7 @@
- const bool CBcasCardReader::InitialSetting(const SCARDHANDLE hBcasCard)
- {
- - static const BYTE abyInitSettingCmd[] = {0x90U, 0x30U, 0x00U, 0x00U, 0x00U};
- + static const BYTE abyInitSettingCmd[] = {0x80U, 0x5EU, 0x00U, 0x00U, 0x00U};
- // 「Initial Setting Conditions Command」を処理する
- if(!hBcasCard)return false;
- @@ -401,12 +423,12 @@
- if(!TransmitCommand(hBcasCard, abyInitSettingCmd, sizeof(abyInitSettingCmd), RecvData, sizeof(RecvData), &dwRecvSize))return false;
- // 受信サイズチェック
- - if(dwRecvSize < 57UL)return false;
- + if(dwRecvSize < 46UL)return false; //dw
- // レスポンス解析
- - ::CopyMemory(m_BcasCardInfo.BcasCardID, &RecvData[8], 6UL); // +8 Card ID
- - ::CopyMemory(m_BcasCardInfo.SystemKey, &RecvData[16], 32UL); // +16 Descrambling system key
- - ::CopyMemory(m_BcasCardInfo.InitialCbc, &RecvData[48], 8UL); // +48 Descrambler CBC initial value
- + ::CopyMemory(m_BcasCardInfo.BcasCardID, &RecvData[2], 6UL); // +2 Card ID
- + ::CopyMemory(m_BcasCardInfo.SystemKey, &RecvData[8], 32UL); // +8 Descrambling system key
- + ::CopyMemory(m_BcasCardInfo.InitialCbc, &RecvData[8], 8UL); // +8 Descrambler CBC initial value
- // ECMステータス初期化
- ::ZeroMemory(&m_EcmStatus, sizeof(m_EcmStatus));
- diff -u B25Decoder/BonProject/TsDescrambler.cpp B1Decoder/BonProject/TsDescrambler.cpp
- --- B25Decoder/BonProject/TsDescrambler.cpp Sat Feb 14 22:11:26 2009
- +++ B1Decoder/BonProject/TsDescrambler.cpp Mon Mar 30 17:48:16 2015
- @@ -317,6 +317,7 @@
- const WORD wEmmPID = pCaMethodDesc->GetCaPID();
- if(wEmmPID >= TS_INVALID_PID)return;
- + if(wEmmPID == 0x0000)return;
- // EMMプロセッサをPIDマップに追加
- m_TsInputMap.MapPid(wEmmPID, dynamic_cast<ITsPidMapTarget *>(CEmmProcessor::CreateInstance(dynamic_cast<ITsDescrambler *>(this))));
- @@ -329,7 +330,30 @@
- if(!pDescBlock)return;
- const ICaMethodDesc * const pCaMethodDesc = dynamic_cast<const ICaMethodDesc *>(pDescBlock->GetDescByTag(ICaMethodDesc::DESC_TAG));
- - if(!pCaMethodDesc)return;
- + if(!pCaMethodDesc)
- + {
- + //696: If no CA Pids are found in the PMT also check ES for CA Pids!
- + for (DWORD dwPos = 0UL, dwCount = 0UL; dwPos < pPmtTable->GetEsNum(); dwPos++){
- + const ICaMethodDesc * const ESpCaMethodDesc = dynamic_cast<const ICaMethodDesc *>(pPmtTable->GetEsDesc(dwPos)->GetDescByTag(ICaMethodDesc::DESC_TAG));
- + if (ESpCaMethodDesc)
- + {
- + const WORD wEcmPID = ESpCaMethodDesc->GetCaPID();
- + if (wEcmPID < TS_INVALID_PID)
- + {
- + // 既存のECMプロセッサを確認
- + if (!m_TsInputMap.GetMapTarget(wEcmPID)){
- + // ECMプロセッサをPIDマップに追加
- + m_TsInputMap.MapPid(wEcmPID, dynamic_cast<ITsPidMapTarget *>(CEcmProcessor::CreateInstance(dynamic_cast<ITsDescrambler *>(this))));
- + }
- + // ESプロセッサをPIDマップに追加
- + if (!m_TsOutputMap.GetMapTarget(pPmtTable->GetEsPID(dwPos))){
- + m_TsOutputMap.MapPid(pPmtTable->GetEsPID(dwPos), dynamic_cast<ITsPidMapTarget *>(CEsProcessor::CreateInstance(m_TsInputMap.GetMapTarget(wEcmPID))));
- + }
- + }
- + }
- + }
- + return;
- + }
- const WORD wEcmPID = pCaMethodDesc->GetCaPID();
- if(wEcmPID >= TS_INVALID_PID)return;