@@ -118,6 +118,19 @@ const SCARD_IO_REQUEST g_rgSCardT0Pci, g_rgSCardT1Pci, g_rgSCardRawPci;
118118
119119/* ******************************************************************************* */
120120
121+ int compareWithNoCase (const char * str1, const char * str2) {
122+ char *str1_2 = new char [strlen (str1)];
123+ char *str2_2 = new char [strlen (str2)];
124+ strcpy (str1_2, str1);
125+ strcpy (str2_2, str2);
126+ toupper (*str1_2);
127+ toupper (*str2_2);
128+ int result = strcmp (str1_2, str2_2);
129+ delete[] str1_2;
130+ delete[] str2_2;
131+ return result;
132+ }
133+
121134void DumpMemory ( LPCBYTE location, DWORD length ) {
122135/*
123136 DWORD i, written;
@@ -144,9 +157,6 @@ void DumpMemory( LPCBYTE location, DWORD length ) {
144157
145158}
146159
147-
148-
149-
150160static WINSCARDAPI LONG (WINAPI *Original_SCardEstablishContext)(
151161 IN DWORD dwScope,
152162 IN LPCVOID pvReserved1,
@@ -2808,7 +2818,7 @@ int CWinscardApp::LoadRule(string ruleName, string filePath) {
28082818 APDU_RULE rule;
28092819 APDU_SINGLE_RULE singleRule;
28102820
2811- if (compareNoCase (ruleName.c_str (), " WINSCARD" ) == 0 ) {
2821+ if (compareWithNoCase (ruleName.c_str (), " WINSCARD" ) == 0 ) {
28122822 if ((GetPrivateProfileString ((LPCTSTR) ruleName.c_str (), " AUTO_REQUEST_DATA" , " " , buffer, cBuffer, filePath.c_str ())) > 0 ) {
28132823 m_winscardConfig.bAUTO_REQUEST_DATA = (atoi (buffer) == 0 ) ? FALSE : TRUE ;
28142824 }
@@ -2836,7 +2846,7 @@ int CWinscardApp::LoadRule(string ruleName, string filePath) {
28362846
28372847 }
28382848
2839- if (compareNoCase (ruleName.c_str (), " SCSAT04" ) == 0 ) {
2849+ if (compareWithNoCase (ruleName.c_str (), " SCSAT04" ) == 0 ) {
28402850 // SCSAT04 CONFIGURATION RULE
28412851 if ((GetPrivateProfileString ((LPCTSTR) ruleName.c_str (), " REDIRECT" , " " , buffer, cBuffer, filePath.c_str ())) > 0 ) {
28422852 m_scsat04Config.bRedirect = (atoi (buffer) == 0 ) ? FALSE : TRUE ;
@@ -2867,7 +2877,7 @@ int CWinscardApp::LoadRule(string ruleName, string filePath) {
28672877
28682878
28692879 }
2870- if (compareNoCase (ruleName.substr (0 , (int )strlen (" RULE" )).c_str (), " RULE" ) == 0 ) {
2880+ if (compareWithNoCase (ruleName.substr (0 , (int )strlen (" RULE" )).c_str (), " RULE" ) == 0 ) {
28712881 // COMMON RULE
28722882
28732883 if ((GetPrivateProfileString ((LPCTSTR) ruleName.c_str (), " USAGE" , " " , buffer, cBuffer, filePath.c_str ())) > 0 ) {
@@ -2911,32 +2921,32 @@ int CWinscardApp::LoadRule(string ruleName, string filePath) {
29112921 // elemName = rulePart.Left(rulePart.Find("="));
29122922 elemName = rulePart.substr (0 , rulePart.find (" =" ));
29132923
2914- if (compareNoCase (elemName.c_str (), " CLA" ) == 0 ) {
2924+ if (compareWithNoCase (elemName.c_str (), " CLA" ) == 0 ) {
29152925 singleRule.element = CLA_ELEM;
29162926 CCommonFnc::BYTE_ConvertFromHexNumToByte (rulePart.substr (rulePart.find (" =" )+1 , 2 ), &(singleRule.value ));
29172927 singleRule.valid = TRUE ;rule.matchRules .push_back (singleRule);
29182928 }
2919- if (compareNoCase (elemName.c_str (), " INS" ) == 0 ) {
2929+ if (compareWithNoCase (elemName.c_str (), " INS" ) == 0 ) {
29202930 singleRule.element = INS_ELEM;
29212931 CCommonFnc::BYTE_ConvertFromHexNumToByte (rulePart.substr (rulePart.find (" =" )+1 , 2 ), &(singleRule.value ));
29222932 singleRule.valid = TRUE ;rule.matchRules .push_back (singleRule);
29232933 }
2924- if (compareNoCase (elemName.c_str (), " P1" ) == 0 ) {
2934+ if (compareWithNoCase (elemName.c_str (), " P1" ) == 0 ) {
29252935 singleRule.element = P1_ELEM;
29262936 CCommonFnc::BYTE_ConvertFromHexNumToByte (rulePart.substr (rulePart.find (" =" )+1 , 2 ), &(singleRule.value ));
29272937 singleRule.valid = TRUE ;rule.matchRules .push_back (singleRule);
29282938 }
2929- if (compareNoCase (elemName.c_str (), " P2" ) == 0 ) {
2939+ if (compareWithNoCase (elemName.c_str (), " P2" ) == 0 ) {
29302940 singleRule.element = P2_ELEM;
29312941 CCommonFnc::BYTE_ConvertFromHexNumToByte (rulePart.substr (rulePart.find (" =" )+1 , 2 ), &(singleRule.value ));
29322942 singleRule.valid = TRUE ;rule.matchRules .push_back (singleRule);
29332943 }
2934- if (compareNoCase (elemName.c_str (), " LC" ) == 0 ) {
2944+ if (compareWithNoCase (elemName.c_str (), " LC" ) == 0 ) {
29352945 singleRule.element = LC_ELEM;
29362946 CCommonFnc::BYTE_ConvertFromHexNumToByte (rulePart.substr (rulePart.find (" =" )+1 , 2 ), &(singleRule.value ));
29372947 singleRule.valid = TRUE ;rule.matchRules .push_back (singleRule);
29382948 }
2939- if (compareNoCase (elemName.substr (0 , (int ) strlen (" DATA" )).c_str (), " DATA" ) == 0 ) {
2949+ if (compareWithNoCase (elemName.substr (0 , (int ) strlen (" DATA" )).c_str (), " DATA" ) == 0 ) {
29402950 // DATA CAN BE WRITTEN IN MORE VALUES AT ONCE, STARTING ON POSITION DATAx
29412951 // CREATE SEPARATE ELEMENT FOR EACH
29422952 int offset = atoi (elemName.substr (ruleName.find_first_of (" 0123456789" ), 0 ).c_str ());
@@ -2983,37 +2993,37 @@ int CWinscardApp::LoadRule(string ruleName, string filePath) {
29832993
29842994 elemName = rulePart.substr (0 , rulePart.find (" =" ));
29852995
2986- if (compareNoCase (elemName.c_str (), " CLA" ) == 0 ) {
2996+ if (compareWithNoCase (elemName.c_str (), " CLA" ) == 0 ) {
29872997 singleRule.element = CLA_ELEM;
29882998 CCommonFnc::BYTE_ConvertFromHexNumToByte (rulePart.substr (rulePart.find (" =" )+1 , 2 ), &(singleRule.value ));
29892999 singleRule.valid = TRUE ;rule.actionRules .push_back (singleRule);
29903000 }
2991- if (compareNoCase (elemName.c_str (), " INS" ) == 0 ) {
3001+ if (compareWithNoCase (elemName.c_str (), " INS" ) == 0 ) {
29923002 singleRule.element = INS_ELEM;
29933003 CCommonFnc::BYTE_ConvertFromHexNumToByte (rulePart.substr (rulePart.find (" =" )+1 , 2 ), &(singleRule.value ));
29943004 singleRule.valid = TRUE ;rule.actionRules .push_back (singleRule);
29953005 }
2996- if (compareNoCase (elemName.c_str (), " P1" ) == 0 ) {
3006+ if (compareWithNoCase (elemName.c_str (), " P1" ) == 0 ) {
29973007 singleRule.element = P1_ELEM;
29983008 CCommonFnc::BYTE_ConvertFromHexNumToByte (rulePart.substr (rulePart.find (" =" )+1 , 2 ), &(singleRule.value ));
29993009 singleRule.valid = TRUE ;rule.actionRules .push_back (singleRule);
30003010 }
3001- if (compareNoCase (elemName.c_str (), " P2" ) == 0 ) {
3011+ if (compareWithNoCase (elemName.c_str (), " P2" ) == 0 ) {
30023012 singleRule.element = P2_ELEM;
30033013 CCommonFnc::BYTE_ConvertFromHexNumToByte (rulePart.substr (rulePart.find (" =" )+1 , 2 ), &(singleRule.value ));
30043014 singleRule.valid = TRUE ;rule.actionRules .push_back (singleRule);
30053015 }
3006- if (compareNoCase (elemName.c_str (), " LC" ) == 0 ) {
3016+ if (compareWithNoCase (elemName.c_str (), " LC" ) == 0 ) {
30073017 singleRule.element = LC_ELEM;
30083018 CCommonFnc::BYTE_ConvertFromHexNumToByte (rulePart.substr (rulePart.find (" =" )+1 , 2 ), &(singleRule.value ));
30093019 singleRule.valid = TRUE ;rule.actionRules .push_back (singleRule);
30103020 }
3011- if (compareNoCase (elemName.c_str (), " LE" ) == 0 ) {
3021+ if (compareWithNoCase (elemName.c_str (), " LE" ) == 0 ) {
30123022 singleRule.element = LE_ELEM;
30133023 CCommonFnc::BYTE_ConvertFromHexNumToByte (rulePart.substr (rulePart.find (" =" )+1 , 2 ), &(singleRule.value ));
30143024 singleRule.valid = TRUE ;rule.actionRules .push_back (singleRule);
30153025 }
3016- if (compareNoCase (elemName.substr (0 , (int ) strlen (" DATA" )).c_str (), " DATA" ) == 0 ) {
3026+ if (compareWithNoCase (elemName.substr (0 , (int ) strlen (" DATA" )).c_str (), " DATA" ) == 0 ) {
30173027 // DATA CAN BE WRITTEN IN MORE VALUES AT ONCE, STARTING ON POSITION DATAx
30183028 // CREATE SEPARATE ELEMENT FOR EACH
30193029 int offset = atoi (elemName.substr (ruleName.find_first_of (" 0123456789" )).c_str ());
0 commit comments