OSDN Git Service

operaクッキー対応
authorqwerty2501 <riot313@gmail.com>
Wed, 22 Feb 2012 15:47:38 +0000 (00:47 +0900)
committerqwerty2501 <riot313@gmail.com>
Wed, 22 Feb 2012 15:47:38 +0000 (00:47 +0900)
nlite.suo
shareCookie/shareCookie.c

index d436ab8..bc22af6 100644 (file)
Binary files a/nlite.suo and b/nlite.suo differ
index a177c42..988750e 100644 (file)
@@ -1,6 +1,6 @@
 
 #include "shareCookie.h"
-
+#define WINDEBUGER_NOPRINTING
 
 #include <shlobj.h>
 #include <Wininet.h>
@@ -24,8 +24,8 @@ static sqlite3_stmt *googleChromeCookieStmt;          //
 static CRITICAL_SECTION googleChromeCs;                                //\83O\81[\83O\83\8b\83N\83\8d\81[\83\80\82Ì\83N\83b\83L\81[\8eæ\93¾\97p\83N\83\8a\83e\83B\83J\83\8b\83Z\83N\83V\83\87\83\93
 
 
-static WCHAR safariCookiePath[_MAX_PATH];                      //\83T\83t\83@\83\8a\82Ì\83N\83b\83L\81[\83p\83X
-
+static WCHAR safariCookiePath[_MAX_PATH];                      //Safari\82Ì\83N\83b\83L\81[\83p\83X
+static WCHAR operaCookiePath[_MAX_PATH];                       //Opera\82Ì\83N\83b\83L\81[\83p\83X
 
 typedef COOKIE_RESULT (*SelfParseCookieCallBack)(LPCSTR targetString,LPCSTR targetEndPointer,LPWSTR cookie,SIZE_T bufSize,LPCWSTR key,LPCWSTR domein);
 
@@ -169,6 +169,11 @@ VOID InitializeShareCookie(LPCWSTR appDataPath,LPCWSTR localAppDataPath){
        wcscpy(safariCookiePath,appDataPath);
        wcscat(safariCookiePath,L"Apple Computer\\Safari\\Cookies\\Cookies.binarycookies");
 
+       //Opera\82Ì\90Ý\92è
+       //
+       wcscpy(operaCookiePath,appDataPath);
+       wcscat(operaCookiePath,L"Opera\\Opera\\cookies4.dat");
+
        return;
 }
 
@@ -215,7 +220,7 @@ COOKIE_RESULT GetCookie(BROWSERTYPE browserType,LPWSTR cookie,SIZE_T bufSize, LP
                //\83I\83y\83\89\82Ì\8fê\8d\87
        case BT_OPERA:
 
-               return SelfParseCookie(NULL,cookie,bufSize,key,domein,GetCookieOpera);
+               return SelfParseCookie(operaCookiePath,cookie,bufSize,key,domein,GetCookieOpera);
                
 
                //\83T\83t\83@\83\8a\82Ì\8fê\8d\87
@@ -648,9 +653,81 @@ end:
 ///
 static INLINE COOKIE_RESULT GetCookieOpera(LPCSTR targetString,LPCSTR targetEndPointer,LPWSTR cookies,SIZE_T bufSize, LPCWSTR key,LPCWSTR domein){
 
-       
+       COOKIE_RESULT result = COOKIE_ERR_UNKNOWN;
+       CHAR mb_key[_MAX_PATH];
+       CHAR mb_domein[_MAX_PATH];
+       LPCSTR cookiePointer;
+       LPCSTR keyPointer;
+       SIZE_T mb_keyLen;
+
+       if(ARRAY_LENGTH(mb_key) < GetLenToMB(CP_THREAD_ACP,key)){
+               
+               goto keybuffbigerr;
+
+       } else if(ARRAY_LENGTH(mb_domein) < GetLenToMB(CP_THREAD_ACP,domein) ){
+
+               goto domeinbuffbigerr;
+
+       }
+
+
+       WideToMB(CP_THREAD_ACP,key,mb_key,ARRAY_LENGTH(mb_key));
+       WideToMB(CP_THREAD_ACP,domein,mb_domein,ARRAY_LENGTH(mb_domein));
+       strstr(mb_domein,".jp")[0] = '\0';
+
+       for(;targetString < targetEndPointer;targetString += strlen(targetString) + 1){
+
+               
+               if(strncmp(targetString + 1,mb_domein,strlen(mb_domein)) == 0){
+                       
+                       
+                       
+                       
+                       
+                       for(keyPointer = (targetString + strlen(targetString) + 1);keyPointer < targetEndPointer;keyPointer = (keyPointer + strlen(keyPointer) + 1)){
+                               if(strstr(keyPointer,mb_key) !=NULL){
+                                       CHAR cookie_mbBuff[_MAX_PATH];
+                                       UINT_PTR length;
+                                       cookiePointer = keyPointer+ strlen(keyPointer) + 1;
+                                       length = strlen(cookiePointer) -2;
+                                       strncpy(cookie_mbBuff,cookiePointer+1,length);
+                                       cookie_mbBuff[length] = '\0';
+                                       if(((INT_PTR)bufSize) < GetLenToWide(CP_THREAD_ACP,cookie_mbBuff) + wcslen(key) + 1){
+
+                                               goto cookiebuffbigerr;
+                                       }
+                                       wcscpy(cookies,key);
+                                       cookies += wcslen(cookies);
+                                       cookies[0] = L'=';
+                                       cookies++;
+
+                                       MBToWide(CP_THREAD_ACP,cookie_mbBuff,cookies,bufSize);
+                                       result = COOKIE_ERR_OK;
+                                       goto end;
+                               }
+                       }
+                       
+               }
+
+       }
+
+end:
+
+
+       return result;
+
 
-       return COOKIE_ERR_DETAIL_NOTFOUND;
+keybuffbigerr:
+       result = COOKIE_ERR_DETAIL_URL_TOOBIG;
+       goto end;
+
+domeinbuffbigerr:
+       result = COOKIE_ERR_DETAIL_DOMEIN_TOOBIG;
+       goto end;
+
+cookiebuffbigerr:
+       result = COOKIEERR_DETAIL_RESULT_TOOBIG;
+       goto end;
 }
 
 ///
@@ -664,7 +741,7 @@ static INLINE COOKIE_RESULT GetCookieSafari(LPCSTR targetString,LPCSTR targetEnd
        LPCSTR domeinPointer;
        SIZE_T mb_keyLen;
 
-       if(ARRAY_LENGTH(mb_key) < GetLenToMB(CP_THREAD_ACP,key) - 1){
+       if(ARRAY_LENGTH(mb_key)-1 < GetLenToMB(CP_THREAD_ACP,key)){
                
                goto keybuffbigerr;
 
@@ -698,6 +775,7 @@ static INLINE COOKIE_RESULT GetCookieSafari(LPCSTR targetString,LPCSTR targetEnd
 
                                MBToWide(CP_THREAD_ACP,cookiePointer,cookies,bufSize);
                                result = COOKIE_ERR_OK;
+                               break;
                        }
                }