SSブログ

この広告は前回の更新から一定期間経過したブログに表示されています。更新すると自動で解除されます。

LinuxでMirakurun (2) [PC関連]

先のエントリーの続き

その後,Mirakurunは,recdvbでハマりましたが,なんとか無事動作しています。
試しにBonDriver_MirakurunでTvmaidを使ってみましたが,BSがダメっぽい…
設定などを詰めていないので,『当たり』が有るかもしれませんが,まぁその内に…


『動いたらラッキー?』なパッチ
* 以下,ご利用は自己責任で… (質問などは無しで,特にiniの中身とか(笑)

”patch.patch”
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
diff -uprN a/Makefile b/Makefile
--- a/Makefile  2000-01-01 00:00:00.000000000 +0900
+++ b/Makefile  2020-02-01 13:14:15.000000000 +0900
@@ -1,6 +1,6 @@
 PROGRAM = libpcsclite.so.1.0.0
-SRCS = winscard.cpp Crypto.cpp  Decoder-ECM.cpp  Keys.cpp  Keyset.cpp
-OBJS = $(subst .cpp,.o,$(SRCS))
+SRCS = winscard.cpp Crypto.cpp  Decoder-ECM.cpp  Keyset.cpp  cpp/INIReader.cpp
+OBJS = $(subst .cpp,.o,$(SRCS))  ini.o
  
 RM := rm
 CXX := g++
diff -uprN -Xexclude.lst a/winscard.cpp b/winscard.cpp
--- a/winscard.cpp  2000-01-01 00:00:00.000000000 +0900
+++ b/winscard.cpp  2020-02-01 13:14:15.000000000 +0900
@@ -3,21 +3,76 @@
 //      Keys.cpp, Keys.h, Keyset.cpp, Keyset.h
 //  You should modify "Size" in Decoder-ECM.cpp l42 to "Size-3"
  
+#include <stdio.h>  //readlink
+#include <unistd.h> //readlink
+
 #include <string.h>
 #include <PCSC/winscard.h>
 #define htons htons_
 #define ntohs ntohs_
  
 #include "Global.h"
-#include "Keys.h"
+//#include "Keys.h"
+#include "Keyset.h"
 #include "Decoder.h"
  
+#include "cpp/INIReader.h" // https://github.com/benhoyt/inih/
+
 #define CHAR   char
  
+static void ProfileKeyset0(const char* ss, const char* ns, Key_t &k, INIReader reader)
+{
+    char szBuff[64];
+    u8 v[9]; //u8 = unsigned char
+
+    strcpy(szBuff, reader.Get(ss, ns, "").c_str());
+    sscanf(szBuff, "%hhx %hhx %hhx %hhx %hhx %hhx %hhx %hhx %hhx",&v[0],&v[1],&v[2],&v[3],&v[4],&v[5],&v[6],&v[7],&v[8]);
+    k.WorkKeyID = v[0];
+    memcpy(&k.Key[0], &v[1], 8);
+}
+
+static void ProfileKeyset(const char* ss, INIReader reader)
+{
+
+    Keyset_t Keyset;
+    char szBuff[64];
+    u8 v[1];
+   
+    //Keyset.BroadcastGroupID = reader.GetInteger(ss, "BID", 0);
+    strcpy(szBuff, reader.Get(ss, "BID", "").c_str() );
+    sscanf(szBuff, "%hhx", &v[0]);
+    Keyset.BroadcastGroupID = v[0];
+   
+    ProfileKeyset0(ss, "KW0", Keyset.Keys[0], reader);
+    ProfileKeyset0(ss, "KW1", Keyset.Keys[1], reader);
+
+    BCAS::Keyset::Register (&Keyset);
+}
+
+static void GetPrivateProfile()
+{
+    char p[4096] = ""; //PATH_MAX
+    int v = readlink("/proc/self/exe", p, sizeof(p));
+    if(v == 0)
+        return;
+
+    INIReader reader("/usr/local/lib/winscard.ini");
+    //INIReader reader("/usr/lib/x86_64-linux-gnu/winscard.ini");
+   
+    ProfileKeyset("WOWOW",                  reader);
+    ProfileKeyset("Star Channel HD",        reader);
+    ProfileKeyset("SkyPerfecTV E2 / 110CS", reader);
+    ProfileKeyset("Safenet",                reader);
+    ProfileKeyset("NHK",                    reader);
+    ProfileKeyset("Email",                  reader);
+    ProfileKeyset("NHK_Email",              reader);
+}
+
 extern"C"{
  
 void __attribute__ ((constructor)) SCardVCasInit(void) {
-    BCAS::Keys::RegisterAll();
+    //BCAS::Keys::RegisterAll();
+    ::GetPrivateProfile();
 }
  
 LONG SCardEstablishContext(DWORD dwScope, LPCVOID pvReserved1,LPCVOID pvReserved2, LPSCARDCONTEXT phContext)
@@ -93,9 +148,9 @@ LONG SCardFreeMemory(SCARDCONTEXT,LPCVOI
  
 LONG SCardReleaseContext(SCARDCONTEXT){return SCARD_S_SUCCESS;}
  
-LONG SCardGetStatusChange(SCARDCONTEXT hContext, DWORD dwTimeout,LPSCARD_READERSTATE_A rgReaderStates, DWORD cReaders){return SCARD_S_SUCCESS; }
+LONG SCardGetStatusChange(SCARDCONTEXT hContext, DWORD dwTimeout,LPSCARD_READERSTATE rgReaderStates, DWORD cReaders){return SCARD_S_SUCCESS; }
  
 SCARD_IO_REQUEST g_rgSCardT1Pci_;
-SCARD_IO_REQUEST g_rgSCardT1Pci;
+const SCARD_IO_REQUEST g_rgSCardT1Pci = { SCARD_PROTOCOL_T1, sizeof(SCARD_IO_REQUEST) };
  
 }


タグ:linux Mirakurun
コメント(0) 
共通テーマ:趣味・カルチャー

コメント 0

コメントを書く

お名前:[必須]
URL:
コメント:
画像認証:
下の画像に表示されている文字を入力してください。

※ブログオーナーが承認したコメントのみ表示されます。
LinuxでMirakurunLinuxでMirakurun (3) .. ブログトップ