daily pastebin goal
45%
SHARE
TWEET

winscard.cpp

a guest May 17th, 2012 26,990 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //  Put the following files in the same folder:
  2. //      Crypto.cpp, Crypto.h, Decoder-ECM.cpp, Decoder.h, Global.h
  3. //      Keys.cpp, Keys.h, Keyset.cpp, Keyset.h
  4. //  You should modify "Size" in Decoder-ECM.cpp l42 to "Size-3"
  5.  
  6. #include <Windows.h>
  7. #define htons htons_
  8. #define ntohs ntohs_
  9. #include "Crypto.cpp"
  10. #include "Decoder-ECM.cpp"
  11. #include "Keys.cpp"
  12. #include "Keyset.cpp"
  13. #pragma comment(linker,"/EXPORT:SCardEstablishContext=_SCardEstablishContext_@16")
  14. #pragma comment(linker,"/EXPORT:SCardListReadersA=_SCardListReadersA_@16")
  15. #pragma comment(linker,"/EXPORT:SCardListReadersW=_SCardListReadersW_@16")
  16. #pragma comment(linker,"/EXPORT:SCardConnectA=_SCardConnectA_@24")
  17. #pragma comment(linker,"/EXPORT:SCardConnectW=_SCardConnectW_@24")
  18. #pragma comment(linker,"/EXPORT:SCardTransmit=_SCardTransmit_@28")
  19. #pragma comment(linker,"/EXPORT:SCardDisconnect=_SCardDisconnect_@8")
  20. #pragma comment(linker,"/EXPORT:SCardFreeMemory=_SCardFreeMemory_@8")
  21. #pragma comment(linker,"/EXPORT:SCardReleaseContext=_SCardReleaseContext_@4")
  22. #pragma comment(linker,"/EXPORT:g_rgSCardT1Pci=_g_rgSCardT1Pci_")
  23. BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)
  24. {
  25.     if(fdwReason==DLL_PROCESS_ATTACH)BCAS::Keys::RegisterAll();
  26.     return TRUE;
  27. }
  28. extern"C"{
  29. LONG WINAPI SCardEstablishContext_(DWORD,LPCVOID,LPCVOID,LPSCARDCONTEXT phContext)
  30. {
  31.     *phContext=(SCARDCONTEXT)0x35313239;
  32.     return SCARD_S_SUCCESS;
  33. }
  34. LONG WINAPI SCardListReadersA_(SCARDCONTEXT,LPCTSTR,LPSTR mszReaders,LPDWORD pcchReaders)
  35. {
  36.     CHAR r[]="@OishiiSlurper\0";
  37.     if(mszReaders)memcpy(mszReaders,r,sizeof r);
  38.     *pcchReaders=sizeof r/sizeof r[0];
  39.     return SCARD_S_SUCCESS;
  40. }
  41. LONG WINAPI SCardListReadersW_(SCARDCONTEXT,LPCTSTR,LPWSTR mszReaders,LPDWORD pcchReaders)
  42. {
  43.     WCHAR r[]=L"@OishiiSlurper\0";
  44.     if(mszReaders)memcpy(mszReaders,r,sizeof r);
  45.     *pcchReaders=sizeof r/sizeof r[0];
  46.     return SCARD_S_SUCCESS;
  47. }
  48. LONG WINAPI SCardConnectA_(SCARDCONTEXT,LPCTSTR,DWORD,DWORD,LPSCARDHANDLE phCard,LPDWORD pdwActiveProtocol)
  49. {
  50.     *phCard=(SCARDHANDLE)0x35313239;
  51.     *pdwActiveProtocol=SCARD_PROTOCOL_T1;
  52.     return SCARD_S_SUCCESS;
  53. }
  54. LONG WINAPI SCardConnectW_(SCARDCONTEXT,LPCTSTR,DWORD,DWORD,LPSCARDHANDLE phCard,LPDWORD pdwActiveProtocol)
  55. {
  56.     *phCard=(SCARDHANDLE)0x35313239;
  57.     *pdwActiveProtocol=SCARD_PROTOCOL_T1;
  58.     return SCARD_S_SUCCESS;
  59. }
  60. LONG WINAPI SCardTransmit_(SCARDHANDLE,LPCSCARD_IO_REQUEST,LPCBYTE pbSendBuffer,DWORD cbSendLength,LPSCARD_IO_REQUEST,LPBYTE pbRecvBuffer,LPDWORD pcbRecvLength)
  61. {
  62.     switch(pbSendBuffer[1])
  63.     {
  64.     case 0x30:{
  65.         BYTE r[]={
  66.             0x00,0x39,0x00,0x00,0x21,0x00,0x00,0x05, 0xc0,0xff,0xee,0xc0,0xff,0xee,0x01,0x50,
  67.             0x36,0x31,0x04,0x66,0x4b,0x17,0xea,0x5c, 0x32,0xdf,0x9c,0xf5,0xc4,0xc3,0x6c,0x1b,
  68.             0xec,0x99,0x39,0x21,0x68,0x9d,0x4b,0xb7, 0xb7,0x4e,0x40,0x84,0x0d,0x2e,0x7d,0x98,
  69.             0xfe,0x27,0x19,0x99,0x19,0x69,0x09,0x11, 0x01,0x02,0x01,0x90,0x00};
  70.         memcpy(pbRecvBuffer,r,sizeof r);
  71.         *pcbRecvLength=sizeof r;
  72.         break;}
  73.     case 0x32:{
  74.         BYTE r[]={
  75.             0x00,0x0f,0x00,0x00,0x21,0x00,0x01,0x54, 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  76.             0x00,0x90,0x00};
  77.         memcpy(pbRecvBuffer,r,sizeof r);
  78.         *pcbRecvLength=sizeof r;
  79.         break;}
  80.     case 0x34:{
  81.         BYTE r[]={
  82.             0x00,0x15,0x00,0x00,0x08,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  83.             0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x90, 0x00};
  84.         BCAS::Decoder::DecodeECM(pbSendBuffer+5,pbSendBuffer[4],r+6,NULL);
  85.         memcpy(pbRecvBuffer,r,sizeof r);
  86.         *pcbRecvLength=sizeof r;
  87.         break;}
  88.     default:{
  89.         BYTE r[]={
  90.             0x00,0x04,0x00,0x00,0xa1,0xfe,0x90,0x00};
  91.         memcpy(pbRecvBuffer,r,sizeof r);
  92.         *pcbRecvLength=sizeof r;
  93.         break;}
  94.     }
  95.     return SCARD_S_SUCCESS;
  96. }
  97. LONG WINAPI SCardDisconnect_(SCARDHANDLE,DWORD){return SCARD_S_SUCCESS;}
  98. LONG WINAPI SCardFreeMemory_(SCARDCONTEXT,LPCVOID){return SCARD_S_SUCCESS;}
  99. LONG WINAPI SCardReleaseContext_(SCARDCONTEXT){return SCARD_S_SUCCESS;}
  100. SCARD_IO_REQUEST g_rgSCardT1Pci_;
  101. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top