| Revision | 84661a525afa126c40aae0a81519623a8ba3a1ae (tree) |
|---|---|
| Time | 2012-03-14 15:43:22 |
| Author | qwerty2501 <qwerty2501@user...> |
| Commiter | qwerty2501 |
クローム、ファイアフォックスのクッキー取得処理を修正
| @@ -424,7 +424,7 @@ namespace nlite{ | ||
| 424 | 424 | |
| 425 | 425 | GetTextExtentPoint32(hdc , columns[index] , _tcslen(columns[index]) , &size); |
| 426 | 426 | UINT_PTR holsize = holizenSize[index] + size.cx + 15; |
| 427 | - holizenSize[index] = viewproperty.GetHeaderHolSize()[index] >= 0 ? viewproperty.GetHeaderHolSize()[index] : holsize; | |
| 427 | + holizenSize[index] = viewproperty.GetHeaderHolSize()[index] > 0 ? viewproperty.GetHeaderHolSize()[index] : holsize; | |
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | SelectObject(hdc,hOld); |
| @@ -65,11 +65,11 @@ namespace nlite{ | ||
| 65 | 65 | { |
| 66 | 66 | for(INT_PTR orderIndex = 0;orderIndex < ARRAY_LENGTH(headerOrderArray);orderIndex++){ |
| 67 | 67 | |
| 68 | - new(&headerOrderArray[orderIndex]) INT_PTR(orderIndex); | |
| 68 | + headerOrderArray[orderIndex] = orderIndex; | |
| 69 | 69 | |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - memset(headerholSize,-1,sizeof(headerholSize)); | |
| 72 | + memset(headerholSize,0,sizeof(headerholSize)); | |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 |
| @@ -16,8 +16,8 @@ | ||
| 16 | 16 | #define _WTL_NO_CSTRING |
| 17 | 17 | |
| 18 | 18 | #ifndef NDEBUG |
| 19 | -#define NLITE_UNIT_TEST //単体テストモード | |
| 20 | -#define USE_STUB //スタブを使用する場合はコメントアウトを解除する | |
| 19 | +//#define NLITE_UNIT_TEST //単体テストモード | |
| 20 | +//#define USE_STUB //スタブを使用する場合はコメントアウトを解除する | |
| 21 | 21 | #endif |
| 22 | 22 | // Windows ヘッダー ファイル: |
| 23 | 23 | #include <windows.h> |
| @@ -4,6 +4,7 @@ | ||
| 4 | 4 | #define _CRT_SECURE_NO_WARNINGS 1 //vc++のおせっかいな警告を消す |
| 5 | 5 | #define _CRT_NON_CONFORMING_SWPRINTFS 1 //vc++のおせっかいな警告を消す |
| 6 | 6 | #include <shlobj.h> |
| 7 | +#include <time.h> | |
| 7 | 8 | #include <Wininet.h> |
| 8 | 9 | #include <Iepmapi.h> |
| 9 | 10 | #include <sqlite3\sqlite3.h> |
| @@ -14,16 +15,16 @@ | ||
| 14 | 15 | |
| 15 | 16 | static TCHAR ieCookiePath[_MAX_PATH]; //IEのクッキーパス |
| 16 | 17 | static TCHAR ieCookieSecPath[_MAX_PATH]; //IEセキュリティモードのパス |
| 17 | -static WCHAR fireFoxCookiePath[_MAX_PATH]; //ファイアフォックスのクッキーのパス | |
| 18 | -static sqlite3 *firefoxCookie; //ファイアフォックスのクッキーのDB | |
| 19 | -static sqlite3_stmt *firefoxCookieStmt; //ファイアフォックスのクッキー取得用ステートメント | |
| 20 | -static CRITICAL_SECTION firefoxCs; //ファイアフォックスのクッキー取得用クリティカルセクション | |
| 18 | +static WCHAR fireFoxCookiePath[_MAX_PATH]; //ファイアフォックスのクッキーのパス | |
| 19 | +//static sqlite3 *firefoxCookie; //ファイアフォックスのクッキーのDB | |
| 20 | +//static sqlite3_stmt *firefoxCookieStmt; //ファイアフォックスのクッキー取得用ステートメント | |
| 21 | +//static CRITICAL_SECTION firefoxCs; //ファイアフォックスのクッキー取得用クリティカルセクション | |
| 21 | 22 | |
| 22 | 23 | |
| 23 | 24 | static WCHAR googleChromeCookiePath[_MAX_PATH]; //グーグルクロームのクッキーのパス |
| 24 | -static sqlite3 *googleChromeCookie; //グーグルクロームのクッキーのDB | |
| 25 | -static sqlite3_stmt *googleChromeCookieStmt; //グーグルクロームのクッキー取得用ステートメント | |
| 26 | -static CRITICAL_SECTION googleChromeCs; //グーグルクロームのクッキー取得用クリティカルセクション | |
| 25 | +//static sqlite3 *googleChromeCookie; //グーグルクロームのクッキーのDB | |
| 26 | +//static sqlite3_stmt *googleChromeCookieStmt; //グーグルクロームのクッキー取得用ステートメント | |
| 27 | +//static CRITICAL_SECTION googleChromeCs; //グーグルクロームのクッキー取得用クリティカルセクション | |
| 27 | 28 | |
| 28 | 29 | |
| 29 | 30 | static WCHAR safariCookiePath[_MAX_PATH]; //Safariのクッキーパス |
| @@ -31,6 +32,8 @@ static WCHAR operaCookiePath[_MAX_PATH]; //Opera | ||
| 31 | 32 | |
| 32 | 33 | typedef COOKIE_RESULT (*SelfParseCookieCallBack)(LPCSTR targetString,LPCSTR targetEndPointer,LPWSTR cookie,SIZE_T bufSize,LPCWSTR key,LPCWSTR domein); |
| 33 | 34 | |
| 35 | +typedef COOKIE_RESULT (*ParseCookieCallBack)(sqlite3_stmt *stmt,LPWSTR cookie,SIZE_T bufSize, LPCWSTR key,LPCWSTR domein); | |
| 36 | + | |
| 34 | 37 | /// |
| 35 | 38 | ///クロームとファイアフォックスの共通処理 |
| 36 | 39 | /// |
| @@ -73,15 +76,29 @@ static INLINE COOKIE_RESULT GetCookieInternetExplorerSelfParse(LPCWSTR dir,LPWST | ||
| 73 | 76 | ///自力解析時のコールバック関数 |
| 74 | 77 | /// |
| 75 | 78 | static COOKIE_RESULT selfParseIECallBack(LPCSTR targetString,LPCSTR targetEndPointer,LPWSTR cookie,SIZE_T bufSize,LPCWSTR key,LPCWSTR domein); |
| 79 | + | |
| 80 | +static COOKIE_RESULT getCookieSQLite(LPCWSTR path,LPCWSTR sql,LPWSTR cookie,SIZE_T bufSize,LPCWSTR key,LPCWSTR domein,ParseCookieCallBack sqlCallBack,SelfParseCookieCallBack selfCallBack); | |
| 81 | + | |
| 76 | 82 | /// |
| 77 | 83 | ///ファイアフォックスのクッキーを取得 |
| 78 | 84 | /// |
| 79 | -static INLINE COOKIE_RESULT GetCookieFireFox(LPWSTR cookie,SIZE_T bufSize, LPCWSTR key,LPCWSTR domein); | |
| 85 | +static INLINE COOKIE_RESULT GetCookieFireFoxSQLite(sqlite3_stmt *stmt,LPWSTR cookie,SIZE_T bufSize, LPCWSTR key,LPCWSTR domein); | |
| 86 | + | |
| 87 | + | |
| 88 | +/// | |
| 89 | +///ファイアフォックスを自力で解析 | |
| 90 | +/// | |
| 91 | +static INLINE COOKIE_RESULT GetCookieFireFoxSelf(LPCSTR targetString,LPCSTR targetEndPointer,LPWSTR cookie,SIZE_T bufSize,LPCWSTR key,LPCWSTR domein); | |
| 80 | 92 | |
| 81 | 93 | /// |
| 82 | 94 | ///グーグルクロームのクッキーを取得 |
| 83 | 95 | /// |
| 84 | -static INLINE COOKIE_RESULT GetCookieGoogleChrome(LPWSTR cookie,SIZE_T bufSize, LPCWSTR key,LPCWSTR domein); | |
| 96 | +static INLINE COOKIE_RESULT GetCookieGoogleChromeSQLite(sqlite3_stmt *stmt,LPWSTR cookie,SIZE_T bufSize, LPCWSTR key,LPCWSTR domein); | |
| 97 | + | |
| 98 | +/// | |
| 99 | +///グーグルクロームを自力で解析 | |
| 100 | +/// | |
| 101 | +static INLINE COOKIE_RESULT GetCookieGoogleChromeSelf(LPCSTR targetString,LPCSTR targetEndPointer,LPWSTR cookie,SIZE_T bufSize,LPCWSTR key,LPCWSTR domein); | |
| 85 | 102 | |
| 86 | 103 | /// |
| 87 | 104 | ///オペラのクッキーを取得 |
| @@ -93,10 +110,16 @@ static INLINE COOKIE_RESULT GetCookieOpera(LPCSTR targetString,LPCSTR targetEndP | ||
| 93 | 110 | /// |
| 94 | 111 | static INLINE COOKIE_RESULT GetCookieSafari(LPCSTR targetString,LPCSTR targetEndPointer,LPWSTR cookie,SIZE_T bufSize, LPCWSTR key,LPCWSTR domein); |
| 95 | 112 | |
| 96 | -#define FIREFOX_GET_COOKIE_SQL "SELECT a.name, a.value FROM moz_cookies a WHERE a.name = ?1 AND a.baseDomain = ?2 " //ファイアフォックスクッキー取得用SQL | |
| 113 | + | |
| 114 | +/// | |
| 115 | +///クッキーコピー用のパスを取得 | |
| 116 | +/// | |
| 117 | +static INLINE BOOL CookieFileCopy(LPCWSTR sourceFileName,LPWSTR pathBuf,int bufSize); | |
| 118 | + | |
| 119 | +const LPCWSTR FIREFOX_GET_COOKIE_SQL = L"SELECT a.name, a.value FROM moz_cookies a WHERE a.name = ?1 AND a.baseDomain = ?2 "; //ファイアフォックスクッキー取得用SQL | |
| 97 | 120 | |
| 98 | 121 | |
| 99 | -#define GOOGLECHROME_GET_COOKIE_SQL "SELECT a.name,a.value FROM cookies a WHERE a.name = ?1 AND (a.host_key = ?2 OR a.host_key = ?3)" //グーグルクロームクッキー取得用SQL 頭に.付いてるのと付いてないのがあったのでとりえあえず両方拾うことにした。規則性がわかればもう少しスマートにいける | |
| 122 | +const LPCWSTR GOOGLECHROME_GET_COOKIE_SQL = L"SELECT a.name,a.value FROM cookies a WHERE a.name = ?1 AND (a.host_key = ?2 OR a.host_key = ?3)"; //グーグルクロームクッキー取得用SQL 頭に.付いてるのと付いてないのがあったのでとりえあえず両方拾うことにした。規則性がわかればもう少しスマートにいける | |
| 100 | 123 | |
| 101 | 124 | |
| 102 | 125 | VOID InitializeShareCookie(LPCWSTR appDataPath,LPCWSTR localAppDataPath){ |
| @@ -151,7 +174,7 @@ VOID InitializeShareCookie(LPCWSTR appDataPath,LPCWSTR localAppDataPath){ | ||
| 151 | 174 | break; |
| 152 | 175 | |
| 153 | 176 | default: |
| 154 | - //ZeroMemory(fireFoxCookiePath,sizeof(fireFoxCookiePath) / sizeof(fireFoxCookiePath[0])); | |
| 177 | + | |
| 155 | 178 | |
| 156 | 179 | break; |
| 157 | 180 |
| @@ -166,9 +189,9 @@ VOID InitializeShareCookie(LPCWSTR appDataPath,LPCWSTR localAppDataPath){ | ||
| 166 | 189 | dumpln(TEXT("firefoxのクッキーファイルを開いた")); |
| 167 | 190 | } |
| 168 | 191 | */ |
| 169 | - checkDBAndStmt(&firefoxCookie,&firefoxCookieStmt,fireFoxCookiePath,WTEXT(FIREFOX_GET_COOKIE_SQL)); | |
| 192 | + //checkDBAndStmt(&firefoxCookie,&firefoxCookieStmt,fireFoxCookiePath,WTEXT(FIREFOX_GET_COOKIE_SQL)); | |
| 170 | 193 | |
| 171 | - InitializeCriticalSection(&firefoxCs); | |
| 194 | + //InitializeCriticalSection(&firefoxCs); | |
| 172 | 195 | } |
| 173 | 196 | |
| 174 | 197 | //GoogleChromeの設定 |
| @@ -187,9 +210,9 @@ VOID InitializeShareCookie(LPCWSTR appDataPath,LPCWSTR localAppDataPath){ | ||
| 187 | 210 | dumpln(TEXT("chromeのクッキーファイルを開いた")); |
| 188 | 211 | } |
| 189 | 212 | */ |
| 190 | - checkDBAndStmt(&googleChromeCookie,&googleChromeCookieStmt,googleChromeCookiePath,WTEXT(GOOGLECHROME_GET_COOKIE_SQL)); | |
| 213 | + //checkDBAndStmt(&googleChromeCookie,&googleChromeCookieStmt,googleChromeCookiePath,WTEXT(GOOGLECHROME_GET_COOKIE_SQL)); | |
| 191 | 214 | |
| 192 | - InitializeCriticalSection(&googleChromeCs); | |
| 215 | + //InitializeCriticalSection(&googleChromeCs); | |
| 193 | 216 | |
| 194 | 217 | |
| 195 | 218 |
| @@ -215,13 +238,9 @@ VOID InitializeShareCookie(LPCWSTR appDataPath,LPCWSTR localAppDataPath){ | ||
| 215 | 238 | |
| 216 | 239 | VOID FinalizeShareCookie(){ |
| 217 | 240 | |
| 218 | - | |
| 219 | - DeleteCriticalSection(&firefoxCs); | |
| 220 | - DeleteCriticalSection(&googleChromeCs); | |
| 221 | - sqlite3_finalize(firefoxCookieStmt); | |
| 222 | - sqlite3_finalize(googleChromeCookieStmt); | |
| 223 | - SqliteManager_close(&firefoxCookie); | |
| 224 | - SqliteManager_close(&googleChromeCookie); | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 225 | 244 | |
| 226 | 245 | |
| 227 | 246 |
| @@ -230,6 +249,31 @@ VOID FinalizeShareCookie(){ | ||
| 230 | 249 | |
| 231 | 250 | |
| 232 | 251 | |
| 252 | +static INLINE BOOL CookieFileCopy(LPCWSTR sourceFileName,LPWSTR pathBuf,int bufSize){ | |
| 253 | + | |
| 254 | + WCHAR tempBuff[_MAX_PATH]; | |
| 255 | + LPWSTR timestartPtr = NULL; | |
| 256 | + BOOL result = FALSE; | |
| 257 | + int tmpnamesize = 0; | |
| 258 | + struct tm nowtm; | |
| 259 | + time_t nowtime = time(NULL); | |
| 260 | + SHGetFolderPathW(0,CSIDL_TEMPLATES,0,SHGFP_TYPE_CURRENT,tempBuff); | |
| 261 | + tmpnamesize = wcslen(tempBuff); | |
| 262 | + timestartPtr = tempBuff + tmpnamesize; | |
| 263 | + nowtm = *localtime(&nowtime); | |
| 264 | + if(_tcsftime(timestartPtr,bufSize - tmpnamesize,L"\\cookie_buff_%Y%m%d%H&M%S",&nowtm) > 0){ | |
| 265 | + | |
| 266 | + result = CopyFile(sourceFileName,tempBuff,TRUE); | |
| 267 | + | |
| 268 | + if(result != FALSE)wcscpy(pathBuf,tempBuff); | |
| 269 | + } | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + return result; | |
| 274 | +} | |
| 275 | + | |
| 276 | + | |
| 233 | 277 | COOKIE_RESULT GetCookie(BROWSERTYPE browserType,LPWSTR cookie,SIZE_T bufSize, LPCWSTR key,LPCWSTR domein){ |
| 234 | 278 | |
| 235 | 279 | //ブラウザタイプにより実行する関数を決定する |
| @@ -245,13 +289,13 @@ COOKIE_RESULT GetCookie(BROWSERTYPE browserType,LPWSTR cookie,SIZE_T bufSize, LP | ||
| 245 | 289 | //ファイアフォックスの場合 |
| 246 | 290 | case BT_FIRE_FOX: |
| 247 | 291 | |
| 248 | - return GetCookieFireFox(cookie,bufSize,key,domein); | |
| 292 | + return getCookieSQLite(fireFoxCookiePath,FIREFOX_GET_COOKIE_SQL,cookie,bufSize,key,domein,GetCookieFireFoxSQLite,GetCookieFireFoxSelf); | |
| 249 | 293 | |
| 250 | 294 | //グーグルクロームの場合 |
| 251 | 295 | case BT_GOOGLE_CHROME: |
| 252 | 296 | |
| 253 | 297 | |
| 254 | - return GetCookieGoogleChrome(cookie,bufSize,key,domein); | |
| 298 | + return getCookieSQLite(googleChromeCookiePath,GOOGLECHROME_GET_COOKIE_SQL,cookie,bufSize,key,domein,GetCookieGoogleChromeSQLite,GetCookieGoogleChromeSelf); | |
| 255 | 299 | |
| 256 | 300 | //オペラの場合 |
| 257 | 301 | case BT_OPERA: |
| @@ -310,7 +354,7 @@ static INLINE COOKIE_RESULT GetCookieInternetExplorer(LPWSTR cookie,SIZE_T bufSi | ||
| 310 | 354 | HRESULT cookieResult; //クッキー取得結果コード |
| 311 | 355 | BOOL isProtectedMode = FALSE; //保護モードフラグ |
| 312 | 356 | WCHAR url[GET_IE_COOKIE_URL_MAXLENGTH]; //urlバッファ |
| 313 | - | |
| 357 | + SIZE_T bufSizeTemp = bufSize; | |
| 314 | 358 | //IEかIEコンポーネントかを判定 |
| 315 | 359 | if(isIE){ |
| 316 | 360 |
| @@ -394,8 +438,7 @@ static INLINE COOKIE_RESULT GetCookieInternetExplorer(LPWSTR cookie,SIZE_T bufSi | ||
| 394 | 438 | |
| 395 | 439 | } |
| 396 | 440 | |
| 397 | - dumpln(TEXT("cookieResult:%d"),cookieResult); | |
| 398 | - dumpln(TEXT("cookie:%s"),cookie); | |
| 441 | + | |
| 399 | 442 | |
| 400 | 443 | |
| 401 | 444 | //結果コード判定 |
| @@ -407,9 +450,9 @@ static INLINE COOKIE_RESULT GetCookieInternetExplorer(LPWSTR cookie,SIZE_T bufSi | ||
| 407 | 450 | |
| 408 | 451 | result = COOKIE_ERR_OK; |
| 409 | 452 | |
| 410 | - //取得したクッキーのサイズが0の場合、notFoundErrorを設定 | |
| 453 | + //取得したクッキーのサイズが0の場合、自力で解析する | |
| 411 | 454 | } else { |
| 412 | - result = COOKIE_ERR_DETAIL_NOTFOUND; | |
| 455 | + result = GetCookieInternetExplorerSelfParse(isProtectedMode == TRUE ? ieCookieSecPath : ieCookiePath,cookie,bufSizeTemp,key,domein); | |
| 413 | 456 | |
| 414 | 457 | }//if(bufSize > 0) |
| 415 | 458 |
| @@ -571,49 +614,74 @@ cookiebuffbigerr: | ||
| 571 | 614 | } |
| 572 | 615 | |
| 573 | 616 | /// |
| 574 | -///ファイアフォックスのクッキーを取得 | |
| 617 | +///SQL系の解析用関数 | |
| 575 | 618 | /// |
| 576 | -static INLINE COOKIE_RESULT GetCookieFireFox(LPWSTR cookie,SIZE_T bufSize, LPCWSTR key,LPCWSTR domein){ | |
| 577 | 619 | |
| 578 | - COOKIE_RESULT result = COOKIE_ERR_OK; //結果コード | |
| 579 | - LPCWSTR pName = (LPCWSTR)NULL; //名前の値を確保する一時的なポインタ | |
| 580 | - LPCWSTR pValue = (LPCWSTR)NULL; //valueの値を確保する一時的なポインタ | |
| 581 | - | |
| 582 | - | |
| 620 | +static COOKIE_RESULT getCookieSQLite(LPCWSTR path,LPCWSTR sql,LPWSTR cookie,SIZE_T bufSize,LPCWSTR key,LPCWSTR domein,ParseCookieCallBack sqlCallBack,SelfParseCookieCallBack selfCallBack){ | |
| 583 | 621 | |
| 584 | - | |
| 622 | + COOKIE_RESULT result = COOKIE_ERR_UNKNOWN; | |
| 623 | + UINT dbchekresult = 0; | |
| 624 | + sqlite3 *db = NULL; | |
| 625 | + sqlite3_stmt *stmt = NULL; | |
| 626 | + BOOL copyFlag = FALSE; | |
| 627 | + WCHAR cookieFilePathBuff[_MAX_PATH] ={0}; | |
| 628 | + dbchekresult = checkDBAndStmt(&db,&stmt,path,sql); | |
| 629 | + | |
| 630 | + if(dbchekresult != 0){ | |
| 631 | + db = NULL; | |
| 632 | + stmt = NULL; | |
| 633 | + copyFlag = CookieFileCopy(path,cookieFilePathBuff,ARRAY_LENGTH(cookieFilePathBuff)); | |
| 634 | + dbchekresult = checkDBAndStmt(&db,&stmt,path,sql); | |
| 635 | + } | |
| 585 | 636 | |
| 586 | - //db,ステートメントが開かれているかチェック | |
| 587 | - switch(checkDBAndStmt(&firefoxCookie,&firefoxCookieStmt,fireFoxCookiePath, WTEXT(FIREFOX_GET_COOKIE_SQL))){ | |
| 637 | + if(dbchekresult == 0){ | |
| 588 | 638 | |
| 589 | - case 0: | |
| 590 | - break; | |
| 639 | + result = sqlCallBack(stmt,cookie,bufSize,key,domein); | |
| 591 | 640 | |
| 592 | - case 1: | |
| 593 | - result = COOKIE_ERR_DBOPEN_FAILED; | |
| 594 | - goto end; | |
| 641 | + } | |
| 595 | 642 | |
| 596 | - case 2: | |
| 597 | - result = COOKIE_ERR_CREATESTMT_FAILED; | |
| 598 | - goto end; | |
| 643 | + if(result != COOKIE_ERR_OK){ | |
| 599 | 644 | |
| 645 | + SelfParseCookie(path,cookie,bufSize,key,domein,selfCallBack); | |
| 600 | 646 | |
| 601 | 647 | } |
| 602 | 648 | |
| 603 | - EnterCriticalSection(&firefoxCs); | |
| 649 | + | |
| 650 | + sqlite3_finalize(stmt); | |
| 651 | + SqliteManager_close(&db); | |
| 652 | + | |
| 653 | + if(copyFlag != FALSE)DeleteFile(cookieFilePathBuff); | |
| 654 | + | |
| 655 | + return result; | |
| 656 | +} | |
| 657 | + | |
| 658 | +/// | |
| 659 | +///ファイアフォックスのクッキーを取得 | |
| 660 | +/// | |
| 661 | +static INLINE COOKIE_RESULT GetCookieFireFoxSQLite(sqlite3_stmt *stmt,LPWSTR cookie,SIZE_T bufSize, LPCWSTR key,LPCWSTR domein){ | |
| 662 | + | |
| 663 | + COOKIE_RESULT result = COOKIE_ERR_UNKNOWN; //結果コード | |
| 664 | + LPCWSTR pName = (LPCWSTR)NULL; //名前の値を確保する一時的なポインタ | |
| 665 | + LPCWSTR pValue = (LPCWSTR)NULL; //valueの値を確保する一時的なポインタ | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 604 | 672 | |
| 605 | 673 | |
| 606 | 674 | |
| 607 | - switch(sqlite3_bind_text16(firefoxCookieStmt,1,key,-1,SQLITE_STATIC)){ | |
| 675 | + switch(sqlite3_bind_text16(stmt,1,key,-1,SQLITE_STATIC)){ | |
| 608 | 676 | |
| 609 | 677 | case SQLITE_OK: |
| 610 | 678 | |
| 611 | 679 | |
| 612 | - switch(sqlite3_bind_text16(firefoxCookieStmt,2,domein,-1,SQLITE_STATIC)){ | |
| 680 | + switch(sqlite3_bind_text16(stmt,2,domein,-1,SQLITE_STATIC)){ | |
| 613 | 681 | |
| 614 | 682 | case SQLITE_OK: |
| 615 | 683 | |
| 616 | - cookieStepExec(firefoxCookieStmt,cookie,bufSize, &result); | |
| 684 | + cookieStepExec(stmt,cookie,bufSize, &result); | |
| 617 | 685 | |
| 618 | 686 | |
| 619 | 687 |
| @@ -656,28 +724,30 @@ static INLINE COOKIE_RESULT GetCookieFireFox(LPWSTR cookie,SIZE_T bufSize, LPCWS | ||
| 656 | 724 | |
| 657 | 725 | }//switch(sqlite3_bind_text16(firefoxCookieStmt,1,key[index],sizeof(WCHAR) * (wcslen(key[index]) + 1),SQLITE_STATIC)) |
| 658 | 726 | |
| 659 | - //パラメタのリセット(バインド解除) | |
| 660 | - sqlite3_reset(firefoxCookieStmt); | |
| 661 | 727 | |
| 662 | 728 | |
| 663 | - | |
| 664 | - LeaveCriticalSection(&firefoxCs); | |
| 665 | 729 | |
| 666 | -end: | |
| 730 | + | |
| 731 | + | |
| 667 | 732 | |
| 668 | 733 | |
| 669 | 734 | return result; |
| 670 | 735 | } |
| 671 | 736 | |
| 672 | 737 | |
| 738 | +static INLINE COOKIE_RESULT GetCookieFireFoxSelf(LPCSTR targetString,LPCSTR targetEndPointer,LPWSTR cookie,SIZE_T bufSize,LPCWSTR key,LPCWSTR domein){ | |
| 739 | + COOKIE_RESULT result = COOKIE_ERR_UNKNOWN; | |
| 673 | 740 | |
| 741 | + result = COOKIE_ERR_DETAIL_NOTFOUND; | |
| 742 | + return result; | |
| 743 | +} | |
| 674 | 744 | |
| 675 | 745 | |
| 676 | 746 | |
| 677 | 747 | /// |
| 678 | 748 | ///グーグルクロームのクッキーを取得 |
| 679 | 749 | /// |
| 680 | -static INLINE COOKIE_RESULT GetCookieGoogleChrome(LPWSTR cookie,SIZE_T bufSize, LPCWSTR key,LPCWSTR domein){ | |
| 750 | +static INLINE COOKIE_RESULT GetCookieGoogleChromeSQLite(sqlite3_stmt *stmt,LPWSTR cookie,SIZE_T bufSize, LPCWSTR key,LPCWSTR domein){ | |
| 681 | 751 | |
| 682 | 752 | |
| 683 | 753 |
| @@ -691,35 +761,18 @@ static INLINE COOKIE_RESULT GetCookieGoogleChrome(LPWSTR cookie,SIZE_T bufSize, | ||
| 691 | 761 | |
| 692 | 762 | |
| 693 | 763 | |
| 694 | - //db,ステートメントが開かれているかチェック | |
| 695 | - switch(checkDBAndStmt(&googleChromeCookie,&googleChromeCookieStmt,googleChromeCookiePath, WTEXT(GOOGLECHROME_GET_COOKIE_SQL))){ | |
| 696 | - | |
| 697 | - case 0: | |
| 698 | - break; | |
| 699 | - | |
| 700 | - case 1: | |
| 701 | - result = COOKIE_ERR_DBOPEN_FAILED; | |
| 702 | - goto end; | |
| 703 | - | |
| 704 | - case 2: | |
| 705 | - result = COOKIE_ERR_CREATESTMT_FAILED; | |
| 706 | - goto end; | |
| 707 | - | |
| 708 | - | |
| 709 | - } | |
| 710 | - | |
| 711 | - EnterCriticalSection(&googleChromeCs); | |
| 764 | + | |
| 712 | 765 | |
| 713 | 766 | |
| 714 | 767 | |
| 715 | 768 | |
| 716 | 769 | //ステートメントにパラメタを設定1 |
| 717 | - switch(sqlite3_bind_text16(googleChromeCookieStmt,1,key,-1,SQLITE_STATIC)){ | |
| 770 | + switch(sqlite3_bind_text16(stmt,1,key,-1,SQLITE_STATIC)){ | |
| 718 | 771 | |
| 719 | 772 | case SQLITE_OK: |
| 720 | 773 | |
| 721 | 774 | //ステートメントにパラメタを設定2 |
| 722 | - switch(sqlite3_bind_text16(googleChromeCookieStmt,2,domein,-1,SQLITE_STATIC)){ | |
| 775 | + switch(sqlite3_bind_text16(stmt,2,domein,-1,SQLITE_STATIC)){ | |
| 723 | 776 | |
| 724 | 777 | case SQLITE_OK: |
| 725 | 778 |
| @@ -735,13 +788,13 @@ static INLINE COOKIE_RESULT GetCookieGoogleChrome(LPWSTR cookie,SIZE_T bufSize, | ||
| 735 | 788 | wcscpy(pHostKey,domein); //このあたりはもう少し効率化できる? |
| 736 | 789 | |
| 737 | 790 | //ステートメントにパラメタを設定3 |
| 738 | - switch(sqlite3_bind_text16(googleChromeCookieStmt,3,host_key2Buf,-1,SQLITE_STATIC)){ | |
| 791 | + switch(sqlite3_bind_text16(stmt,3,host_key2Buf,-1,SQLITE_STATIC)){ | |
| 739 | 792 | |
| 740 | 793 | case SQLITE_OK: |
| 741 | 794 | |
| 742 | 795 | |
| 743 | 796 | //クッキー取得SQL実行 |
| 744 | - cookieStepExec(googleChromeCookieStmt,cookie,bufSize,&result); | |
| 797 | + cookieStepExec(stmt,cookie,bufSize,&result); | |
| 745 | 798 | |
| 746 | 799 | |
| 747 | 800 |
| @@ -804,17 +857,17 @@ static INLINE COOKIE_RESULT GetCookieGoogleChrome(LPWSTR cookie,SIZE_T bufSize, | ||
| 804 | 857 | |
| 805 | 858 | }//switch(sqlite3_bind_text16(googleChromeCookieStmt,1,key[index],sizeof(WCHAR) * (wcslen(key[index]) + 1),SQLITE_STATIC)) |
| 806 | 859 | |
| 807 | - //パラメタのリセット(バインド解除) | |
| 808 | - sqlite3_reset(googleChromeCookieStmt); | |
| 809 | 860 | |
| 810 | 861 | |
| 811 | - | |
| 812 | - LeaveCriticalSection(&googleChromeCs); | |
| 813 | 862 | |
| 814 | -end: | |
| 863 | + return result; | |
| 864 | +} | |
| 815 | 865 | |
| 866 | +static INLINE COOKIE_RESULT GetCookieGoogleChromeSelf(LPCSTR targetString,LPCSTR targetEndPointer,LPWSTR cookie,SIZE_T bufSize,LPCWSTR key,LPCWSTR domein){ | |
| 816 | 867 | |
| 868 | + COOKIE_RESULT result = COOKIE_ERR_UNKNOWN; | |
| 817 | 869 | |
| 870 | + result = COOKIE_ERR_DETAIL_NOTFOUND; | |
| 818 | 871 | return result; |
| 819 | 872 | } |
| 820 | 873 |
| @@ -1036,7 +1089,7 @@ static INLINE VOID cookieStepExec(sqlite3_stmt *stmt,LPWSTR cookie,SIZE_T bufSiz | ||
| 1036 | 1089 | wcscat(cookie,L"="); |
| 1037 | 1090 | wcscat(cookie,pValue); |
| 1038 | 1091 | |
| 1039 | - | |
| 1092 | + *result = COOKIE_ERR_OK; | |
| 1040 | 1093 | |
| 1041 | 1094 | |
| 1042 | 1095 |