| 1 | // SoftEther UT-VPN SourceCode |
|---|
| 2 | // |
|---|
| 3 | // Copyright (C) 2004-2010 SoftEther Corporation. |
|---|
| 4 | // Copyright (C) 2004-2010 University of Tsukuba, Japan. |
|---|
| 5 | // Copyright (C) 2003-2010 Daiyuu Nobori. |
|---|
| 6 | // All Rights Reserved. |
|---|
| 7 | // |
|---|
| 8 | // http://utvpn.tsukuba.ac.jp/ |
|---|
| 9 | // |
|---|
| 10 | // This program is free software; you can redistribute it and/or |
|---|
| 11 | // modify it under the terms of the GNU General Public License |
|---|
| 12 | // version 2 as published by the Free Software Foundation. |
|---|
| 13 | // |
|---|
| 14 | // This program is distributed in the hope that it will be useful, |
|---|
| 15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 17 | // GNU General Public License for more details. |
|---|
| 18 | // |
|---|
| 19 | // You should have received a copy of the GNU General Public License version 2 |
|---|
| 20 | // along with this program; if not, write to the Free Software |
|---|
| 21 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|---|
| 22 | // |
|---|
| 23 | // このファイルは GPL バージョン 2 ライセンスで公開されています。 |
|---|
| 24 | // 誰でもこのファイルの内容を複製、改変したり、改変したバージョンを再配布 |
|---|
| 25 | // することができます。ただし、原著作物を改変した場合は、原著作物の著作権表示 |
|---|
| 26 | // を除去することはできません。改変した著作物を配布する場合は、改変実施者の |
|---|
| 27 | // 著作権表示を原著作物の著作権表示に付随して記載するようにしてください。 |
|---|
| 28 | // |
|---|
| 29 | // この SoftEther UT-VPN オープンソース・プロジェクトは、日本国の |
|---|
| 30 | // ソフトイーサ株式会社 (SoftEther Corporation, http://www.softether.co.jp/ ) |
|---|
| 31 | // および筑波大学 (University of Tsukuba, http://www.tsukuba.ac.jp/ ) によって |
|---|
| 32 | // ホストされています。 |
|---|
| 33 | // 本プログラムの配布者は、本プログラムを、業としての利用以外のため、 |
|---|
| 34 | // および、試験または研究のために利用が行われることを想定して配布 |
|---|
| 35 | // しています。 |
|---|
| 36 | // SoftEther UT-VPN プロジェクトの Web サイトは http://utvpn.tsukuba.ac.jp/ に |
|---|
| 37 | // あります。 |
|---|
| 38 | // 本ソフトウェアの不具合の修正、機能改良、セキュリティホールの修復などのコード |
|---|
| 39 | // の改変を行った場合で、その成果物を SoftEther UT-VPN プロジェクトに提出して |
|---|
| 40 | // いただける場合は、 http://utvpn.tsukuba.ac.jp/ までソースコードを送付して |
|---|
| 41 | // ください。SoftEther UT-VPN プロジェクトの本体リリースまたはブランチリリース |
|---|
| 42 | // に組み込みさせていただきます。 |
|---|
| 43 | // |
|---|
| 44 | // GPL に基づいて原著作物が提供される本ソフトウェアの改良版を配布、販売する |
|---|
| 45 | // 場合は、そのソースコードを GPL に基づいて誰にでも開示する義務が生じます。 |
|---|
| 46 | // |
|---|
| 47 | // 本ソフトウェアに関連する著作権、特許権、商標権はソフトイーサ株式会社 |
|---|
| 48 | // (SoftEther Corporation) およびその他の著作権保持者が保有しています。 |
|---|
| 49 | // ソフトイーサ株式会社等はこれらの権利を放棄していません。本ソフトウェアの |
|---|
| 50 | // 二次著作物を配布、販売する場合は、これらの権利を侵害しないようにご注意 |
|---|
| 51 | // ください。 |
|---|
| 52 | // |
|---|
| 53 | // お願い: どのような通信ソフトウェアにも通常は必ず未発見の |
|---|
| 54 | // セキュリティホールが潜んでいます。本ソースコードをご覧いただいた結果、 |
|---|
| 55 | // UT-VPN にセキュリティホールを発見された場合は、当該セキュリティホールの |
|---|
| 56 | // 情報を不特定多数に開示される前に、必ず、ソフトイーサ株式会社 |
|---|
| 57 | // および脆弱性情報の届出を受け付ける公的機関まで通報いただき、 |
|---|
| 58 | // 公益保護にご協力いただきますようお願い申し上げます。 |
|---|
| 59 | // |
|---|
| 60 | // ソフトイーサ株式会社は、当該セキュリティホールについて迅速に対処を |
|---|
| 61 | // 行い、UT-VPN および UT-VPN に関連するソフトウェアのユーザー・顧客 |
|---|
| 62 | // を保護するための努力を行います。 |
|---|
| 63 | // |
|---|
| 64 | // ソフトイーサへの届出先: http://www.softether.co.jp/jp/contact/ |
|---|
| 65 | // 日本国内の脆弱性情報届出受付公的機関: |
|---|
| 66 | // 独立行政法人 情報処理推進機構 |
|---|
| 67 | // http://www.ipa.go.jp/security/vuln/report/ |
|---|
| 68 | // |
|---|
| 69 | // 上記各事項について不明な点は、ソフトイーサ株式会社までご連絡ください。 |
|---|
| 70 | // 連絡先: http://www.softether.co.jp/jp/contact/ |
|---|
| 71 | |
|---|
| 72 | // ----------------------------------------------- |
|---|
| 73 | // [ChangeLog] |
|---|
| 74 | // 2010.05.20 |
|---|
| 75 | // 新規リリース by SoftEther |
|---|
| 76 | // ----------------------------------------------- |
|---|
| 77 | |
|---|
| 78 | // WinJumpList.cpp |
|---|
| 79 | // Windows7用 ジャンプリスト ソースコード |
|---|
| 80 | |
|---|
| 81 | // Q. このソースコードだけ他と違ってコメントが少ないように見える。 |
|---|
| 82 | // A. はい。 |
|---|
| 83 | |
|---|
| 84 | #ifdef WIN32 |
|---|
| 85 | |
|---|
| 86 | //#define NTDDI_WIN7 0x06010000 |
|---|
| 87 | //#define _WIN32_WINNT _WIN32_WINNT_VISTA |
|---|
| 88 | //#define NTDDI_VERSION NTDDI_VISTA // Specifies that the minimum required platform is Windows 7. |
|---|
| 89 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers |
|---|
| 90 | #define STRICT_TYPED_ITEMIDS // Utilize strictly typed IDLists |
|---|
| 91 | |
|---|
| 92 | //#include <objectarray.h> |
|---|
| 93 | #include <shobjidl.h> |
|---|
| 94 | #include <propkey.h> |
|---|
| 95 | #include <propvarutil.h> |
|---|
| 96 | //#include <knownfolders.h> |
|---|
| 97 | //#include <shlobj.h> |
|---|
| 98 | |
|---|
| 99 | |
|---|
| 100 | #ifdef StrCpy |
|---|
| 101 | #undef StrCpy |
|---|
| 102 | #endif |
|---|
| 103 | |
|---|
| 104 | #ifdef StrCat |
|---|
| 105 | #undef StrCat |
|---|
| 106 | #endif |
|---|
| 107 | |
|---|
| 108 | #ifdef StrCmp |
|---|
| 109 | #undef StrCmp |
|---|
| 110 | #endif |
|---|
| 111 | |
|---|
| 112 | |
|---|
| 113 | #define WIN32HTML_CPP |
|---|
| 114 | |
|---|
| 115 | //#define _WIN32_WINNT 0x0502 |
|---|
| 116 | //#define WINVER 0x0502 |
|---|
| 117 | #include <winsock2.h> |
|---|
| 118 | #include <windows.h> |
|---|
| 119 | #include <wincrypt.h> |
|---|
| 120 | #include <wininet.h> |
|---|
| 121 | #include <comdef.h> |
|---|
| 122 | #include <Mshtmhst.h> |
|---|
| 123 | //#include <shlobj.h> |
|---|
| 124 | #include <commctrl.h> |
|---|
| 125 | #include <Dbghelp.h> |
|---|
| 126 | #include <stdio.h> |
|---|
| 127 | #include <stdlib.h> |
|---|
| 128 | #include <string.h> |
|---|
| 129 | #include <wchar.h> |
|---|
| 130 | #include <stdarg.h> |
|---|
| 131 | #include <time.h> |
|---|
| 132 | #include <errno.h> |
|---|
| 133 | |
|---|
| 134 | extern "C" |
|---|
| 135 | { |
|---|
| 136 | #include <Mayaqua/Mayaqua.h> |
|---|
| 137 | #include <Cedar/Cedar.h> |
|---|
| 138 | } |
|---|
| 139 | #include "../PenCore/resource.h" |
|---|
| 140 | |
|---|
| 141 | extern "C" |
|---|
| 142 | { |
|---|
| 143 | |
|---|
| 144 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 145 | //JumpList |
|---|
| 146 | // 注意: このあたりのコードは Win32 ヘッダファイル等からコピーした部分がある。 |
|---|
| 147 | // ただしコピーしたのは単純な部分のみであり、創造的かつ複雑な部分ではないので |
|---|
| 148 | // GPL のコードの一部としてペーストしてあっても問題にはならないものと解釈 |
|---|
| 149 | // している。 |
|---|
| 150 | |
|---|
| 151 | #define CREATE_PROPERTYKEY(l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8, pid) { { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }, pid } |
|---|
| 152 | |
|---|
| 153 | |
|---|
| 154 | JL_HRESULT JL_CreateCustomDestinationList(JL_PCustomDestinationList* poc, wchar_t* appID) |
|---|
| 155 | { |
|---|
| 156 | ICustomDestinationList *pcdl; |
|---|
| 157 | |
|---|
| 158 | //CLSID_DestinationList = 6332DEBF-87B5-4670-90C0-5E57-B408-A49E |
|---|
| 159 | |
|---|
| 160 | GUID destList; |
|---|
| 161 | |
|---|
| 162 | destList.Data1 = 2012286192; |
|---|
| 163 | destList.Data2 = 15797; |
|---|
| 164 | destList.Data3 = 18790; |
|---|
| 165 | |
|---|
| 166 | destList.Data4[0] = 181; |
|---|
| 167 | destList.Data4[1] = 32; |
|---|
| 168 | destList.Data4[2] = 183; |
|---|
| 169 | destList.Data4[3] = 197; |
|---|
| 170 | destList.Data4[4] = 79; |
|---|
| 171 | destList.Data4[5] = 211; |
|---|
| 172 | destList.Data4[6] = 94; |
|---|
| 173 | destList.Data4[7] = 214; |
|---|
| 174 | |
|---|
| 175 | HRESULT hr = CoCreateInstance(destList, |
|---|
| 176 | NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pcdl)); |
|---|
| 177 | |
|---|
| 178 | if (SUCCEEDED(hr)) |
|---|
| 179 | { |
|---|
| 180 | pcdl->SetAppID(appID); |
|---|
| 181 | (*poc) = (void*)pcdl; |
|---|
| 182 | } |
|---|
| 183 | else |
|---|
| 184 | { |
|---|
| 185 | (*poc) = NULL; |
|---|
| 186 | } |
|---|
| 187 | |
|---|
| 188 | return hr; |
|---|
| 189 | } |
|---|
| 190 | |
|---|
| 191 | JL_HRESULT JL_ReleaseCustomDestinationList(JL_PCustomDestinationList poc) |
|---|
| 192 | { |
|---|
| 193 | ICustomDestinationList *pcdl = (ICustomDestinationList*)poc; |
|---|
| 194 | if(pcdl != NULL) |
|---|
| 195 | { |
|---|
| 196 | pcdl->Release(); |
|---|
| 197 | } |
|---|
| 198 | |
|---|
| 199 | return 0; |
|---|
| 200 | } |
|---|
| 201 | |
|---|
| 202 | JL_HRESULT JL_BeginList(JL_PCustomDestinationList poc, JL_PObjectArray* oaRemoved) |
|---|
| 203 | { |
|---|
| 204 | UINT cMinSlots; |
|---|
| 205 | IObjectArray *poaRemoved; |
|---|
| 206 | |
|---|
| 207 | ICustomDestinationList *pcdl = (ICustomDestinationList*)poc; |
|---|
| 208 | |
|---|
| 209 | HRESULT hr = pcdl->BeginList(&cMinSlots, IID_PPV_ARGS(&poaRemoved)); |
|---|
| 210 | |
|---|
| 211 | (*oaRemoved) = poaRemoved; |
|---|
| 212 | |
|---|
| 213 | return hr; |
|---|
| 214 | } |
|---|
| 215 | |
|---|
| 216 | JL_HRESULT JL_CommitList(JL_PCustomDestinationList cdl) |
|---|
| 217 | { |
|---|
| 218 | ICustomDestinationList *pcdl = (ICustomDestinationList*)cdl; |
|---|
| 219 | |
|---|
| 220 | return pcdl->CommitList(); |
|---|
| 221 | } |
|---|
| 222 | |
|---|
| 223 | JL_HRESULT JL_CreateObjectCollection(JL_PObjectCollection* jpoc) |
|---|
| 224 | { |
|---|
| 225 | |
|---|
| 226 | //CLSID_EnumerableObjectCollection = 2D3468C1-36A7-43B6-AC24-D3F0-2FD9-607A |
|---|
| 227 | |
|---|
| 228 | |
|---|
| 229 | GUID enumObjCol; |
|---|
| 230 | |
|---|
| 231 | enumObjCol.Data1 = 758409409; |
|---|
| 232 | enumObjCol.Data2 = 13991; |
|---|
| 233 | enumObjCol.Data3 = 17334; |
|---|
| 234 | |
|---|
| 235 | enumObjCol.Data4[0] = 172; |
|---|
| 236 | enumObjCol.Data4[1] = 36; |
|---|
| 237 | enumObjCol.Data4[2] = 211; |
|---|
| 238 | enumObjCol.Data4[3] = 240; |
|---|
| 239 | enumObjCol.Data4[4] = 47; |
|---|
| 240 | enumObjCol.Data4[5] = 217; |
|---|
| 241 | enumObjCol.Data4[6] = 96; |
|---|
| 242 | enumObjCol.Data4[7] = 122; |
|---|
| 243 | |
|---|
| 244 | IObjectCollection *poc; |
|---|
| 245 | HRESULT hr = CoCreateInstance(enumObjCol, |
|---|
| 246 | NULL, CLSCTX_INPROC, IID_PPV_ARGS(&poc)); |
|---|
| 247 | |
|---|
| 248 | if (SUCCEEDED(hr)) |
|---|
| 249 | { |
|---|
| 250 | (*jpoc) = poc; |
|---|
| 251 | } |
|---|
| 252 | else{ |
|---|
| 253 | (*jpoc) = NULL; |
|---|
| 254 | } |
|---|
| 255 | return hr; |
|---|
| 256 | } |
|---|
| 257 | |
|---|
| 258 | JL_HRESULT JL_ReleaseObjectCollection(JL_PObjectCollection jpoc) |
|---|
| 259 | { |
|---|
| 260 | IObjectCollection *poc = (IObjectCollection *)jpoc; |
|---|
| 261 | if(poc != NULL) |
|---|
| 262 | { |
|---|
| 263 | return poc->Release(); |
|---|
| 264 | } |
|---|
| 265 | |
|---|
| 266 | return 0; |
|---|
| 267 | } |
|---|
| 268 | |
|---|
| 269 | JL_HRESULT JL_ObjectCollectionAddShellLink(JL_PObjectCollection jpoc, JL_PShellLink jpsl) |
|---|
| 270 | { |
|---|
| 271 | IObjectCollection *poc = (IObjectCollection *)jpoc; |
|---|
| 272 | IShellLink *psl = (IShellLink *) jpsl; |
|---|
| 273 | |
|---|
| 274 | return poc->AddObject(psl); |
|---|
| 275 | |
|---|
| 276 | } |
|---|
| 277 | |
|---|
| 278 | |
|---|
| 279 | JL_HRESULT JL_AddCategoryToList(JL_PCustomDestinationList jpcdl, |
|---|
| 280 | JL_PObjectCollection jpoc, |
|---|
| 281 | wchar_t* categoryName, |
|---|
| 282 | JL_PObjectArray jpoaRemoved) |
|---|
| 283 | { |
|---|
| 284 | ICustomDestinationList *pcdl = (ICustomDestinationList*)jpcdl; |
|---|
| 285 | IObjectCollection *poc = (IObjectCollection *)jpoc; |
|---|
| 286 | IObjectArray *poaRemoved = (IObjectArray*)jpoaRemoved; |
|---|
| 287 | |
|---|
| 288 | IObjectArray *poa; |
|---|
| 289 | HRESULT hr = poc->QueryInterface(IID_PPV_ARGS(&poa)); |
|---|
| 290 | if (SUCCEEDED(hr)) |
|---|
| 291 | { |
|---|
| 292 | |
|---|
| 293 | hr = pcdl->AppendCategory(categoryName, poa); |
|---|
| 294 | poa->Release(); |
|---|
| 295 | |
|---|
| 296 | if (SUCCEEDED(hr)) |
|---|
| 297 | { |
|---|
| 298 | } |
|---|
| 299 | else |
|---|
| 300 | { |
|---|
| 301 | Print("Failed AppendCategory\n"); |
|---|
| 302 | } |
|---|
| 303 | } |
|---|
| 304 | else |
|---|
| 305 | { |
|---|
| 306 | Print("Failed QueryInterface\n"); |
|---|
| 307 | } |
|---|
| 308 | |
|---|
| 309 | |
|---|
| 310 | return hr; |
|---|
| 311 | } |
|---|
| 312 | |
|---|
| 313 | |
|---|
| 314 | |
|---|
| 315 | JL_HRESULT JL_CreateShellLink( |
|---|
| 316 | wchar_t* pszPath, |
|---|
| 317 | wchar_t* pszArguments, |
|---|
| 318 | wchar_t* pszTitle, |
|---|
| 319 | wchar_t* iconLocation, |
|---|
| 320 | int iconIndex, |
|---|
| 321 | wchar_t* description, JL_PShellLink *ppsl) |
|---|
| 322 | { |
|---|
| 323 | IShellLinkW *psl; |
|---|
| 324 | HRESULT hr = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&psl)); |
|---|
| 325 | if (SUCCEEDED(hr)) |
|---|
| 326 | { |
|---|
| 327 | psl->SetPath(pszPath); |
|---|
| 328 | psl->SetArguments(pszArguments); |
|---|
| 329 | if(iconLocation != NULL) |
|---|
| 330 | { |
|---|
| 331 | psl->SetIconLocation(iconLocation,iconIndex); |
|---|
| 332 | } |
|---|
| 333 | |
|---|
| 334 | if(description != NULL) |
|---|
| 335 | { |
|---|
| 336 | psl->SetDescription(description); |
|---|
| 337 | } |
|---|
| 338 | if (SUCCEEDED(hr)) |
|---|
| 339 | { |
|---|
| 340 | IPropertyStore *pps; |
|---|
| 341 | hr = psl->QueryInterface(IID_PPV_ARGS(&pps)); |
|---|
| 342 | if (SUCCEEDED(hr)) |
|---|
| 343 | { |
|---|
| 344 | PROPVARIANT propvar; |
|---|
| 345 | hr = InitPropVariantFromString(pszTitle, &propvar); |
|---|
| 346 | if (SUCCEEDED(hr)) |
|---|
| 347 | { |
|---|
| 348 | |
|---|
| 349 | PROPERTYKEY pkey_title = |
|---|
| 350 | CREATE_PROPERTYKEY(0xF29F85E0, 0x4FF9, 0x1068, 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9, 2); |
|---|
| 351 | |
|---|
| 352 | hr = pps->SetValue(pkey_title, propvar); |
|---|
| 353 | |
|---|
| 354 | |
|---|
| 355 | if (SUCCEEDED(hr)) |
|---|
| 356 | { |
|---|
| 357 | hr = pps->Commit(); |
|---|
| 358 | if (SUCCEEDED(hr)) |
|---|
| 359 | { |
|---|
| 360 | IShellLink *tpsl; |
|---|
| 361 | hr = psl->QueryInterface(IID_PPV_ARGS(&tpsl)); |
|---|
| 362 | (*ppsl) = tpsl; |
|---|
| 363 | } |
|---|
| 364 | } |
|---|
| 365 | PropVariantClear(&propvar); |
|---|
| 366 | } |
|---|
| 367 | pps->Release(); |
|---|
| 368 | } |
|---|
| 369 | } |
|---|
| 370 | psl->Release(); |
|---|
| 371 | } |
|---|
| 372 | return hr; |
|---|
| 373 | } |
|---|
| 374 | |
|---|
| 375 | JL_HRESULT JL_ReleaseShellLink(JL_PShellLink jpsl) |
|---|
| 376 | { |
|---|
| 377 | IShellLink *psl = (IShellLink *) jpsl; |
|---|
| 378 | |
|---|
| 379 | if(psl != NULL) |
|---|
| 380 | { |
|---|
| 381 | return psl->Release(); |
|---|
| 382 | } |
|---|
| 383 | |
|---|
| 384 | return 0; |
|---|
| 385 | } |
|---|
| 386 | |
|---|
| 387 | JL_HRESULT JL_DeleteJumpList(JL_PCustomDestinationList jpcdl,wchar_t* appID) |
|---|
| 388 | { |
|---|
| 389 | ICustomDestinationList *pcdl = (ICustomDestinationList *)jpcdl; |
|---|
| 390 | |
|---|
| 391 | HRESULT hr = pcdl->DeleteList(appID); |
|---|
| 392 | |
|---|
| 393 | |
|---|
| 394 | return hr; |
|---|
| 395 | } |
|---|
| 396 | |
|---|
| 397 | |
|---|
| 398 | |
|---|
| 399 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 400 | //SetApplicationID for Windows 7 |
|---|
| 401 | JL_HRESULT JL_SetCurrentProcessExplicitAppUserModelID(wchar_t* appID) |
|---|
| 402 | { |
|---|
| 403 | #ifdef UNICODE |
|---|
| 404 | HMODULE hModule = LoadLibraryW( L"shell32.dll"); |
|---|
| 405 | #else |
|---|
| 406 | HMODULE hModule = LoadLibraryA( "shell32.dll"); |
|---|
| 407 | #endif |
|---|
| 408 | HRESULT (__stdcall *SetAppID) (PCWSTR); |
|---|
| 409 | |
|---|
| 410 | if( hModule == NULL ) |
|---|
| 411 | { |
|---|
| 412 | Print("Not Found shell32.dll"); |
|---|
| 413 | } |
|---|
| 414 | else |
|---|
| 415 | { |
|---|
| 416 | SetAppID = (HRESULT (__stdcall *)(PCWSTR)) |
|---|
| 417 | GetProcAddress( hModule, "SetCurrentProcessExplicitAppUserModelID" ); |
|---|
| 418 | if( SetAppID != NULL ) |
|---|
| 419 | { |
|---|
| 420 | FreeLibrary( hModule ); |
|---|
| 421 | return SetAppID(appID); |
|---|
| 422 | } |
|---|
| 423 | else |
|---|
| 424 | { |
|---|
| 425 | Print("Not Found SetCurrentProcessExplicitAppUserModelID"); |
|---|
| 426 | |
|---|
| 427 | } |
|---|
| 428 | |
|---|
| 429 | FreeLibrary( hModule ); |
|---|
| 430 | } |
|---|
| 431 | return 0; |
|---|
| 432 | |
|---|
| 433 | |
|---|
| 434 | } |
|---|
| 435 | |
|---|
| 436 | |
|---|
| 437 | |
|---|
| 438 | } |
|---|
| 439 | |
|---|
| 440 | #endif |
|---|