123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- /****************************************************************************
- Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
-
- http://www.cocos2d-x.org
-
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
- ****************************************************************************/
- //#define USE_WIN32_CONSOLE 1 //是否创建命令行窗口
- #include "main.h"
- #include "SimulatorWin.h"
- #include <shellapi.h>
- #include "LuaExd/aes/aes_ex.hpp"
- int WINAPI _tWinMain(HINSTANCE hInstance,
- HINSTANCE hPrevInstance,
- LPTSTR lpCmdLine,
- int nCmdShow)
- {
- #ifdef USE_WIN32_CONSOLE
- AllocConsole();
- freopen("CONIN$", "r", stdin);
- freopen("CONOUT$", "w", stdout);
- freopen("CONOUT$", "w", stderr);
- #endif
- UNREFERENCED_PARAMETER(hPrevInstance);
- UNREFERENCED_PARAMETER(lpCmdLine);
- //
- // HANDLE hMutex = NULL;
- // if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
- // {
- // //创建互斥对象
- // hMutex = CreateMutex(NULL, FALSE, _T("OnlyOneThis"));
- // if (hMutex != NULL) {
- // if (GetLastError() == ERROR_ALREADY_EXISTS)
- // {
- // //不是第一次运行这个程序
- // //关闭互斥对象,退出程序
- // CloseHandle(hMutex);
- // return 0;
- // }
- // else {
- // //第一次运行这个程序
- // }
- // }
- // }
- auto simulator = SimulatorWin::getInstance();
- /*LPTSTR p = lpCmdLine;
- int iLen = WideCharToMultiByte(CP_ACP, 0, p, -1, NULL, 0, NULL, NULL);
- char* chRtn = new char[iLen * sizeof(char)];
- WideCharToMultiByte(CP_ACP, 0, p, -1, chRtn, iLen, NULL, NULL);
- string str(chRtn);
- if (str.length() > 0)
- {
- std::string strAll = str.substr(1, str.length());
- int _a_pos = strAll.find('=');
- if (_a_pos >= 0)
- {
- string _account = strAll.substr(0, _a_pos);
- string _pwd = strAll.substr(_a_pos + 1, str.length());
- simulator->setArgsFromPlaza(_account, _pwd);
- }
- }*/
-
- LPTSTR p = lpCmdLine;
- int iLen = WideCharToMultiByte(CP_ACP, 0, p, -1, NULL, 0, NULL, NULL);
- char* chRtn = new char[iLen * sizeof(char)];
- WideCharToMultiByte(CP_ACP, 0, p, -1, chRtn, iLen, NULL, NULL);
- string str1(chRtn);
- bool is_has = false;
- if (str1.length() > 0)
- {
- //解密
- unsigned char* outbuf1 = nullptr;
- int dlen1 = cocos2d::base64Decode((unsigned char*)str1.c_str(), str1.size(), &outbuf1);
- AES_ECB_Cipher aes((unsigned char*)"njPjVS/jmJUESwZH");
- char out2[1024] = { 0 };
- uint32_t dlen = 1024;
- aes.decode((unsigned char*)outbuf1, dlen1, (unsigned char*)out2, dlen);
- std::string str;
- str.append(out2);
- if (str.length() > 0)
- {
- std::string strAll = str.substr(0, str.length());
- int _a_pos = strAll.find('|~|');
- if (_a_pos >= 0)
- {
- string _token = strAll.substr(0, _a_pos);
- string _other_str = strAll.substr(_a_pos + 3, strAll.length());
- int _b_pos = _other_str.find('|~|');
- if (_b_pos >= 0)
- {
- string _refreshtoken = _other_str.substr(0, _b_pos);
- string _pc_id = _other_str.substr(_b_pos + 3, _other_str.length());
- simulator->setArgsFromPlaza(_token, _refreshtoken, _pc_id);
- is_has = true;
- }
- }
- }
- }
- if (!is_has) {
- simulator->clear_pc_param();
- }
- int res = simulator->run();
- #ifdef USE_WIN32_CONSOLE
- FreeConsole();
- #endif
- return res;
- }
|