void CrashRptAPITests::Test_crInstallToCurrentThread_concurrent() { // Install crash handler for the main thread CR_INSTALL_INFO info; memset(&info, 0, sizeof(CR_INSTALL_INFO)); info.cb = sizeof(CR_INSTALL_INFO); info.pszAppVersion = _T("1.0.0"); // Specify app version, otherwise it will fail. int nInstResult = crInstall(&info); TEST_ASSERT(nInstResult==0); // Run a worker thread HANDLE hThread = CreateThread(NULL, 0, ThreadProc3, NULL, 0, NULL); // Run another worker thread HANDLE hThread2 = CreateThread(NULL, 0, ThreadProc3, NULL, 0, NULL); // Run the third worker thread HANDLE hThread3 = CreateThread(NULL, 0, ThreadProc3, NULL, 0, NULL); // Wait until threads exit WaitForSingleObject(hThread, INFINITE); WaitForSingleObject(hThread2, INFINITE); WaitForSingleObject(hThread3, INFINITE); __TEST_CLEANUP__; // Uninstall crUninstall(); }
int CVS2010MFCDemoApp::Run() { // Call your crInstall code here ... CR_INSTALL_INFO info; // Install crash handlers int nInstResult = crInstall(&info); assert(nInstResult==0); nInstResult = crAddScreenshot(CR_AS_MAIN_WINDOW); assert(nInstResult==0); // Check result if(nInstResult!=0) { TCHAR buff[256]; crGetLastErrorMsg(buff, 256); // Get last error _tprintf(_T("%s\n"), buff); // and output it to the screen return FALSE; } BOOL bRun; BOOL bExit=FALSE; while(!bExit) { bRun= CWinApp::Run(); bExit=TRUE; } // Uninstall crash reporting //crUninstall(); return bRun; }
void CrashRptAPITests::Test_crInstallToCurrentThread() { // Call before install - must fail int nResult = crInstallToCurrentThread(); TEST_ASSERT(nResult!=0); // Call before install - must fail int nResult2 = crInstallToCurrentThread2(0); TEST_ASSERT(nResult2!=0); // Install crash handler for the main thread CR_INSTALL_INFO info; memset(&info, 0, sizeof(CR_INSTALL_INFO)); info.cb = sizeof(CR_INSTALL_INFO); info.pszAppVersion = _T("1.0.0"); // Specify app version, otherwise it will fail. int nInstResult = crInstall(&info); TEST_ASSERT(nInstResult==0); // Call in the main thread - must fail int nResult3 = crInstallToCurrentThread2(0); TEST_ASSERT(nResult3!=0); // Run a worker thread HANDLE hThread = CreateThread(NULL, 0, ThreadProc2, NULL, 0, NULL); // Wait until thread exits WaitForSingleObject(hThread, INFINITE); __TEST_CLEANUP__; // Uninstall should succeed crUninstall(); }
void CrashRptHead() { // Define CrashRpt configuration parameters CR_INSTALL_INFO info; memset(&info, 0, sizeof(CR_INSTALL_INFO)); info.cb = sizeof(CR_INSTALL_INFO); info.pszAppName = _T("gkLauncher"); info.pszAppVersion = _T("1.0.0"); info.pszEmailSubject = _T("gkLauncher 1.0.0 Error Report"); info.pszEmailTo = _T("*****@*****.**"); info.pszUrl = _T("http://myapp.com/tools/crashrpt.php"); info.pfnCrashCallback = CrashCallback; info.uPriorities[CR_HTTP] = 3; // First try send report over HTTP info.uPriorities[CR_SMTP] = 2; // Second try send report over SMTP info.uPriorities[CR_SMAPI] = 1; // Third try send report over Simple MAPI // Install all available exception handlers, use HTTP binary transfer encoding (recommended). info.dwFlags |= CR_INST_ALL_EXCEPTION_HANDLERS; info.dwFlags |= CR_INST_HTTP_BINARY_ENCODING; info.dwFlags |= CR_INST_APP_RESTART; info.pszRestartCmdLine = _T("/restart"); // Define the Privacy Policy URL info.pszPrivacyPolicyURL = _T("http://myapp.com/privacypolicy.html"); // Install exception handlers int nResult = crInstall(&info); if(nResult!=0) { // Something goes wrong. Get error message. TCHAR szErrorMsg[512]; szErrorMsg[0]=0; crGetLastErrorMsg(szErrorMsg, 512); printf("%s\n", szErrorMsg); return; } }
// This test tries to send report in silent mode over SMAPI. // Since SMAPI is not available in silent mode, test passes when delivery fails. void DeliveryTests::Test_SMAPI_Delivery() { CString sAppDataFolder; CString sExeFolder; CString sTmpFolder; // Create a temporary folder Utility::GetSpecialFolder(CSIDL_APPDATA, sAppDataFolder); sTmpFolder = sAppDataFolder+_T("\\CrashRpt"); BOOL bCreate = Utility::CreateFolder(sTmpFolder); TEST_ASSERT(bCreate); // Install crash handler for the main thread CR_INSTALL_INFO info; memset(&info, 0, sizeof(CR_INSTALL_INFO)); info.cb = sizeof(CR_INSTALL_INFO); info.pszAppVersion = _T("1.0.0"); // Specify app version, otherwise it will fail. info.dwFlags = CR_INST_NO_GUI; info.pszEmailTo = _T("*****@*****.**"); info.pszEmailSubject = _T("Crash Report Whooaaa!!!"); info.pszEmailText = _T("And some text in the email body..."); info.uPriorities[CR_HTTP] = CR_NEGATIVE_PRIORITY; info.uPriorities[CR_SMTP] = CR_NEGATIVE_PRIORITY; info.uPriorities[CR_SMAPI] = 0; info.pszErrorReportSaveDir = sTmpFolder; int nInstResult = crInstall(&info); TEST_ASSERT(nInstResult==0); // Generate and send error report CR_EXCEPTION_INFO exc; memset(&exc, 0, sizeof(CR_EXCEPTION_INFO)); exc.cb = sizeof(CR_EXCEPTION_INFO); int nResult2 = crGenerateErrorReport(&exc); TEST_ASSERT(nResult2==0); // Wait until CrashSender exits and check exit code WaitForSingleObject(exc.hSenderProcess, INFINITE); DWORD dwExitCode = 1; GetExitCodeProcess(exc.hSenderProcess, &dwExitCode); // Since SMAPI is not available in silent mode, test passes when delivery fails. TEST_ASSERT(dwExitCode!=0); // Exit code should be non-zero __TEST_CLEANUP__; // Uninstall crUninstall(); // Delete tmp folder Utility::RecycleFile(sTmpFolder, TRUE); }
void CrashRptAPITests::Test_crInstall_wrong_cb() { // Test crInstall with wrong cb parameter - should fail CR_INSTALL_INFO info; memset(&info, 0, sizeof(CR_INSTALL_INFO)); info.cb = 1000; int nInstallResult = crInstall(&info); TEST_ASSERT(nInstallResult!=0); __TEST_CLEANUP__; }
void DeliveryTests::Test_HttpDelivery() { CString sAppDataFolder; CString sExeFolder; CString sTmpFolder; // Create a temporary folder Utility::GetSpecialFolder(CSIDL_APPDATA, sAppDataFolder); sTmpFolder = sAppDataFolder+_T("\\CrashRpt"); BOOL bCreate = Utility::CreateFolder(sTmpFolder); TEST_ASSERT(bCreate); // Install crash handler for the main thread CR_INSTALL_INFO info; memset(&info, 0, sizeof(CR_INSTALL_INFO)); info.cb = sizeof(CR_INSTALL_INFO); info.pszAppVersion = _T("1.0.0"); // Specify app version, otherwise it will fail. info.dwFlags = CR_INST_NO_GUI; info.pszUrl = _T("localhost/crashrpt.php"); // Use HTTP address for delivery info.uPriorities[CR_HTTP] = 0; info.uPriorities[CR_SMTP] = CR_NEGATIVE_PRIORITY; info.uPriorities[CR_SMAPI] = CR_NEGATIVE_PRIORITY; info.pszErrorReportSaveDir = sTmpFolder; int nInstResult = crInstall(&info); TEST_ASSERT(nInstResult==0); // Generate and send error report CR_EXCEPTION_INFO exc; memset(&exc, 0, sizeof(CR_EXCEPTION_INFO)); exc.cb = sizeof(CR_EXCEPTION_INFO); int nResult2 = crGenerateErrorReport(&exc); TEST_ASSERT(nResult2==0); // Wait until CrashSender exits and check exit code WaitForSingleObject(exc.hSenderProcess, INFINITE); DWORD dwExitCode = 1; GetExitCodeProcess(exc.hSenderProcess, &dwExitCode); TEST_ASSERT(dwExitCode==0); // Exit code should be zero __TEST_CLEANUP__; // Uninstall crUninstall(); // Delete tmp folder Utility::RecycleFile(sTmpFolder, TRUE); }
void CrashRptAPITests::Test_crInstall_missing_app_ver() { // Test crInstall with with missing app version // As this console app has missing EXE product version - should fail CR_INSTALL_INFO info; memset(&info, 0, sizeof(CR_INSTALL_INFO)); info.cb = sizeof(CR_INSTALL_INFO); int nInstallResult = crInstall(&info); TEST_ASSERT(nInstallResult!=0); __TEST_CLEANUP__; }
void CrashRptAPITests::Test_crGenerateErrorReport() { CString sAppDataFolder; CString sExeFolder; CString sTmpFolder; // Create a temporary folder Utility::GetSpecialFolder(CSIDL_APPDATA, sAppDataFolder); sTmpFolder = sAppDataFolder+_T("\\CrashRpt"); BOOL bCreate = Utility::CreateFolder(sTmpFolder); TEST_ASSERT(bCreate); // Install crash handler for the main thread CR_INSTALL_INFO info; memset(&info, 0, sizeof(CR_INSTALL_INFO)); info.cb = sizeof(CR_INSTALL_INFO); info.pszAppVersion = _T("1.0.0"); // Specify app version, otherwise it will fail. info.dwFlags = CR_INST_NO_GUI|CR_INST_DONT_SEND_REPORT; info.pszErrorReportSaveDir = sTmpFolder; int nInstResult = crInstall(&info); TEST_ASSERT(nInstResult==0); // Call with NULL parameter - should fail int nResult = crGenerateErrorReport(NULL); TEST_ASSERT(nResult!=0); // Call with valid parameter - should succeed CR_EXCEPTION_INFO exc; memset(&exc, 0, sizeof(CR_EXCEPTION_INFO)); exc.cb = sizeof(CR_EXCEPTION_INFO); int nResult2 = crGenerateErrorReport(&exc); TEST_ASSERT(nResult2==0); // Check that a folder with crash report files exists WIN32_FIND_DATA fd; HANDLE hFind = FindFirstFile(sTmpFolder+_T("\\*"), &fd); FindClose(hFind); TEST_ASSERT(hFind!=INVALID_HANDLE_VALUE && hFind!=NULL); __TEST_CLEANUP__; // Uninstall crUninstall(); // Delete tmp folder Utility::RecycleFile(sTmpFolder, TRUE); }
void Test_HttpDelivery_binary_encoding() { CString sAppDataFolder; CString sExeFolder; CString sTmpFolder; // Create a temporary folder Utility::GetSpecialFolder(CSIDL_APPDATA, sAppDataFolder); sTmpFolder = sAppDataFolder+_T("\\CrashRpt"); BOOL bCreate = Utility::CreateFolder(sTmpFolder); TEST_ASSERT(bCreate); // Install crash handler for the main thread CR_INSTALL_INFO info; memset(&info, 0, sizeof(CR_INSTALL_INFO)); info.size = sizeof(CR_INSTALL_INFO); info.application_version = _T("1.0.0"); // Specify app version, otherwise it will fail. info.flags = CR_INST_NO_GUI; info.crash_server_url = _T("localhost/crashrpt.php"); // Use HTTP address for delivery info.send_method = CR_HTTP_MutilPart; info.save_dir = sTmpFolder; int nInstResult = crInstall(&info); TEST_ASSERT(nInstResult==0); // Generate and send error report CR_EXCEPTION_INFO exc; memset(&exc, 0, sizeof(CR_EXCEPTION_INFO)); exc.cb = sizeof(CR_EXCEPTION_INFO); int nResult2 = crGenerateErrorReport(&exc); TEST_ASSERT(nResult2==0); // Wait until CrashSender exits and check exit code WaitForSingleObject(exc.hSenderProcess, INFINITE); DWORD dwExitCode = 1; GetExitCodeProcess(exc.hSenderProcess, &dwExitCode); TEST_ASSERT(dwExitCode==0); // Exit code should be zero __TEST_CLEANUP__; // Uninstall crUninstall(); // Delete tmp folder Utility::RecycleFile(sTmpFolder, TRUE); }
int main(int argc, char* argv[]) { argc; // this is to avoid C4100 unreferenced formal parameter warning argv; // this is to avoid C4100 unreferenced formal parameter warning // Install crash reporting CR_INSTALL_INFO info; memset(&info, 0, sizeof(CR_INSTALL_INFO)); info.cb = sizeof(CR_INSTALL_INFO); // Size of the structure info.pszAppName = _T("CrashRpt Console Test"); // App name info.pszAppVersion = _T("1.0.0"); // App version info.pszEmailSubject = _T("CrashRpt Console Test 1.0.0 Error Report"); // Email subject info.pszEmailTo = _T("*****@*****.**"); // Email recipient address // Install crash handlers int nInstResult = crInstall(&info); assert(nInstResult==0); // Check result if(nInstResult!=0) { TCHAR buff[256]; crGetLastErrorMsg(buff, 256); // Get last error _tprintf(_T("%s\n"), buff); // and output it to the screen return FALSE; } printf("Press Enter to simulate a null pointer exception or any other key to exit...\n"); int n = _getch(); if(n==13) { int *p = 0; *p = 0; // Access violation } #ifdef TEST_DEPRECATED_FUNCS Uninstall(lpvState); // Uninstall exception handlers #else int nUninstRes = crUninstall(); // Uninstall exception handlers assert(nUninstRes==0); nUninstRes; #endif //TEST_DEPRECATED_FUNCS // Exit return 0; }
int CMFCDemoApp::Run() { // Install crash reporting CR_INSTALL_INFO info; memset(&info, 0, sizeof(CR_INSTALL_INFO)); info.cb = sizeof(CR_INSTALL_INFO); info.pszAppName = _T("MFCDemo"); // Define application name. //info.pszAppVersion = _T("1.0.0"); // Define application version. // URL for sending error reports over HTTP. info.pszUrl = _T("http://someserver.com/crashrpt.php"); // Install all available exception handlers. info.dwFlags |= CR_INST_ALL_POSSIBLE_HANDLERS; // Provide privacy policy URL info.pszPrivacyPolicyURL = _T("http://someserver.com/privacy.html"); int nResult = crInstall(&info); if(nResult!=0) { TCHAR buff[256]; crGetLastErrorMsg(buff, 256); MessageBox(NULL, buff, _T("crInstall error"), MB_OK); return 1; } // Take screenshot of the app window at the moment of crash crAddScreenshot2(CR_AS_MAIN_WINDOW|CR_AS_USE_JPEG_FORMAT, 95); BOOL bRun = TRUE; BOOL bExit=FALSE; while(!bExit) { bRun= CWinApp::Run(); bExit=TRUE; } // Uninstall crash reporting crUninstall(); return bRun; }
// WinMain parses the command line and either calls the main App // routine or, under NT, the main service routine. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) { if (VNCOS.OS_NOTSUPPORTED==true) { MessageBoxSecure(NULL, "Error OS not supported","Unsupported OS", MB_ICONERROR); return true; } // make vnc last service to stop SetProcessShutdownParameters(0x100,false); // handle dpi on aero /*HMODULE hUser32 = LoadLibrary(_T("user32.dll")); typedef BOOL (*SetProcessDPIAwareFunc)(); SetProcessDPIAwareFunc setDPIAware=NULL; if (hUser32) setDPIAware = (SetProcessDPIAwareFunc)GetProcAddress(hUser32, "SetProcessDPIAware"); if (setDPIAware) setDPIAware(); if (hUser32) FreeLibrary(hUser32);*/ #ifdef IPP InitIpp(); #endif #ifdef CRASHRPT CR_INSTALL_INFO info; memset(&info, 0, sizeof(CR_INSTALL_INFO)); info.cb = sizeof(CR_INSTALL_INFO); info.pszAppName = _T("UVNC"); info.pszAppVersion = _T("1.2.0.9"); info.pszEmailSubject = _T("UVNC server 1.2.0.9 Error Report"); info.pszEmailTo = _T("*****@*****.**"); info.uPriorities[CR_SMAPI] = 1; // Third try send report over Simple MAPI // Install all available exception handlers info.dwFlags |= CR_INST_ALL_POSSIBLE_HANDLERS; // Restart the app on crash info.dwFlags |= CR_INST_APP_RESTART; info.dwFlags |= CR_INST_SEND_QUEUED_REPORTS; info.dwFlags |= CR_INST_AUTO_THREAD_HANDLERS; info.pszRestartCmdLine = _T("/restart"); // Define the Privacy Policy URL // Install crash reporting int nResult = crInstall(&info); if (nResult != 0) { // Something goes wrong. Get error message. TCHAR szErrorMsg[512] = _T(""); crGetLastErrorMsg(szErrorMsg, 512); _tprintf_s(_T("%s\n"), szErrorMsg); return 1; } #endif bool Injected_autoreconnect=false; SPECIAL_SC_EXIT=false; SPECIAL_SC_PROMPT=false; setbuf(stderr, 0); // [v1.0.2-jp1 fix] Load resouce from dll hInstResDLL = NULL; //limit the vnclang.dll searchpath to avoid char szCurrentDir[MAX_PATH]; char szCurrentDir_vnclangdll[MAX_PATH]; if (GetModuleFileName(NULL, szCurrentDir, MAX_PATH)) { char* p = strrchr(szCurrentDir, '\\'); *p = '\0'; } strcpy (szCurrentDir_vnclangdll,szCurrentDir); strcat (szCurrentDir_vnclangdll,"\\"); strcat (szCurrentDir_vnclangdll,"vnclang_server.dll"); hInstResDLL = LoadLibrary(szCurrentDir_vnclangdll); if (hInstResDLL == NULL) { hInstResDLL = hInstance; } // RegisterLinkLabel(hInstResDLL); //Load all messages from ressource file Load_Localization(hInstResDLL) ; char WORKDIR[MAX_PATH]; if (GetModuleFileName(NULL, WORKDIR, MAX_PATH)) { char* p = strrchr(WORKDIR, '\\'); if (p == NULL) return 0; *p = '\0'; } char progname[MAX_PATH]; strncpy(progname, WORKDIR, sizeof progname); progname[MAX_PATH - 1] = 0; //strcat(WORKDIR,"\\"); //strcat(WORKDIR,"WinVNC.log"); vnclog.SetFile(); //vnclog.SetMode(4); //vnclog.SetLevel(10); #ifdef _DEBUG { // Get current flag int tmpFlag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ); // Turn on leak-checking bit tmpFlag |= _CRTDBG_LEAK_CHECK_DF; // Set flag to the new value _CrtSetDbgFlag( tmpFlag ); } #endif // Save the application instance and main thread id hAppInstance = hInstance; mainthreadId = GetCurrentThreadId(); // Initialise the VSocket system VSocketSystem socksys; if (!socksys.Initialised()) { MessageBoxSecure(NULL, sz_ID_FAILED_INIT, szAppName, MB_OK); #ifdef CRASHRPT crUninstall(); #endif return 0; } // look up the current service name in the registry. GetServiceName(progname, service_name); // Make the command-line lowercase and parse it size_t i; for (i = 0; i < strlen(szCmdLine); i++) { szCmdLine[i] = tolower(szCmdLine[i]); } BOOL argfound = FALSE; for (i = 0; i < strlen(szCmdLine); i++) { if (szCmdLine[i] <= ' ') continue; argfound = TRUE; if (strncmp(&szCmdLine[i], winvncSettingshelper, strlen(winvncSettingshelper)) == 0) { Sleep(3000); char mycommand[MAX_PATH]; i+=strlen(winvncSettingshelper); strcpy( mycommand, &(szCmdLine[i+1])); Set_settings_as_admin(mycommand); #ifdef CRASHRPT crUninstall(); #endif return 0; } if (strncmp(&szCmdLine[i], winvncStopserviceHelper, strlen(winvncStopserviceHelper)) == 0) { Sleep(3000); Set_stop_service_as_admin(); #ifdef CRASHRPT crUninstall(); #endif return 0; } if (strncmp(&szCmdLine[i], winvncKill, strlen(winvncKill)) == 0) { static HANDLE hShutdownEventTmp; hShutdownEventTmp = OpenEvent(EVENT_ALL_ACCESS, FALSE, "Global\\SessionEventUltra"); SetEvent(hShutdownEventTmp); CloseHandle(hShutdownEventTmp); //adzm 2010-02-10 - Finds the appropriate VNC window for any process. Sends this message to all of them! // do removed, loops forever with cpu 100 HWND hservwnd = NULL; hservwnd = FindWinVNCWindow(false); if (hservwnd!=NULL) { PostMessage(hservwnd, WM_COMMAND, 40002, 0); PostMessage(hservwnd, WM_CLOSE, 0, 0); } #ifdef CRASHRPT crUninstall(); #endif return 0; } if (strncmp(&szCmdLine[i], winvncopenhomepage, strlen(winvncopenhomepage)) == 0) { Open_homepage(); #ifdef CRASHRPT crUninstall(); #endif return 0; } if (strncmp(&szCmdLine[i], winvncopenforum, strlen(winvncopenforum)) == 0) { Open_forum(); #ifdef CRASHRPT crUninstall(); #endif return 0; } if (strncmp(&szCmdLine[i], winvncStartserviceHelper, strlen(winvncStartserviceHelper)) == 0) { Sleep(3000); Set_start_service_as_admin(); #ifdef CRASHRPT crUninstall(); #endif return 0; } if (strncmp(&szCmdLine[i], winvncInstallServiceHelper, strlen(winvncInstallServiceHelper)) == 0) { //Sleeps are realy needed, else runas fails... Sleep(3000); Set_install_service_as_admin(); #ifdef CRASHRPT crUninstall(); #endif return 0; } if (strncmp(&szCmdLine[i], winvncUnInstallServiceHelper, strlen(winvncUnInstallServiceHelper)) == 0) { Sleep(3000); Set_uninstall_service_as_admin(); #ifdef CRASHRPT crUninstall(); #endif return 0; } if (strncmp(&szCmdLine[i], winvncSoftwarecadHelper, strlen(winvncSoftwarecadHelper)) == 0) { Sleep(3000); Enable_softwareCAD_elevated(); #ifdef CRASHRPT crUninstall(); #endif return 0; } if (strncmp(&szCmdLine[i], winvncdelSoftwarecadHelper, strlen(winvncdelSoftwarecadHelper)) == 0) { Sleep(3000); delete_softwareCAD_elevated(); #ifdef CRASHRPT crUninstall(); #endif return 0; } if (strncmp(&szCmdLine[i], winvncRebootSafeHelper, strlen(winvncRebootSafeHelper)) == 0) { Sleep(3000); Reboot_in_safemode_elevated(); #ifdef CRASHRPT crUninstall(); #endif return 0; } if (strncmp(&szCmdLine[i], winvncRebootForceHelper, strlen(winvncRebootForceHelper)) == 0) { Sleep(3000); Reboot_with_force_reboot_elevated(); #ifdef CRASHRPT crUninstall(); #endif return 0; } if (strncmp(&szCmdLine[i], winvncSecurityEditorHelper, strlen(winvncSecurityEditorHelper)) == 0) { Sleep(3000); winvncSecurityEditorHelper_as_admin(); #ifdef CRASHRPT crUninstall(); #endif return 0; } if (strncmp(&szCmdLine[i], winvncSecurityEditor, strlen(winvncSecurityEditor)) == 0) { typedef void (*vncEditSecurityFn) (HWND hwnd, HINSTANCE hInstance); vncEditSecurityFn vncEditSecurity = 0; char szCurrentDirl[MAX_PATH]; if (GetModuleFileName(NULL, szCurrentDirl, MAX_PATH)) { char* p = strrchr(szCurrentDirl, '\\'); *p = '\0'; strcat (szCurrentDirl,"\\authSSP.dll"); } HMODULE hModule = LoadLibrary(szCurrentDirl); if (hModule) { vncEditSecurity = (vncEditSecurityFn) GetProcAddress(hModule, "vncEditSecurity"); HRESULT hr = CoInitialize(NULL); vncEditSecurity(NULL, hAppInstance); CoUninitialize(); FreeLibrary(hModule); } #ifdef CRASHRPT crUninstall(); #endif return 0; } if (strncmp(&szCmdLine[i], winvncSettings, strlen(winvncSettings)) == 0) { char mycommand[MAX_PATH]; i+=strlen(winvncSettings); strcpy( mycommand, &(szCmdLine[i+1])); Real_settings(mycommand); #ifdef CRASHRPT crUninstall(); #endif return 0; } if (strncmp(&szCmdLine[i], dsmpluginhelper, strlen(dsmpluginhelper)) == 0) { char mycommand[MAX_PATH]; i += strlen(dsmpluginhelper); strcpy(mycommand, &(szCmdLine[i + 1])); Secure_Plugin_elevated(mycommand); #ifdef CRASHRPT crUninstall(); #endif return 0; } if (strncmp(&szCmdLine[i], dsmplugininstance, strlen(dsmplugininstance)) == 0) { char mycommand[MAX_PATH]; i += strlen(dsmplugininstance); strcpy(mycommand, &(szCmdLine[i + 1])); Secure_Plugin(mycommand); #ifdef CRASHRPT crUninstall(); #endif return 0; } if (strncmp(&szCmdLine[i], winvncSoftwarecad, strlen(winvncSoftwarecad)) == 0) { Enable_softwareCAD(); #ifdef CRASHRPT crUninstall(); #endif return 0; } if (strncmp(&szCmdLine[i], winvncdelSoftwarecad, strlen(winvncdelSoftwarecad)) == 0) { delete_softwareCAD(); #ifdef CRASHRPT crUninstall(); #endif return 0; } if (strncmp(&szCmdLine[i], winvncRebootSafe, strlen(winvncRebootSafe)) == 0) { Reboot_in_safemode(); #ifdef CRASHRPT crUninstall(); #endif return 0; } if (strncmp(&szCmdLine[i], winvncRebootForce, strlen(winvncRebootForce)) == 0) { Reboot_with_force_reboot(); #ifdef CRASHRPT crUninstall(); #endif return 0; } if (strncmp(&szCmdLine[i], winvncStopservice, strlen(winvncStopservice)) == 0) { Real_stop_service(); #ifdef CRASHRPT crUninstall(); #endif return 0; } if (strncmp(&szCmdLine[i], winvncStartservice, strlen(winvncStartservice)) == 0) { Real_start_service(); #ifdef CRASHRPT crUninstall(); #endif return 0; } if (strncmp(&szCmdLine[i], winvncInstallService, strlen(winvncInstallService)) == 0) { // rest of command line service name, if provided. char *pServiceName = &szCmdLine[i]; // skip over command switch, find next whitepace while (*pServiceName && !isspace(*(unsigned char*)pServiceName)) ++pServiceName; // skip past whitespace to service name while (*pServiceName && isspace(*(unsigned char*)pServiceName)) ++pServiceName; // strip off any quotes if (*pServiceName && *pServiceName == '\"') ++pServiceName; if (*pServiceName) { // look for trailing quote, if found, terminate the string there. char *pQuote = pServiceName; pQuote = strrchr(pServiceName, '\"'); if (pQuote) *pQuote = 0; } // if a service name is supplied, and it differs except in case from // the default, use the supplied service name instead if (*pServiceName && (_strcmpi(pServiceName, service_name) != 0)) { strncpy(service_name, pServiceName, 256); service_name[255] = 0; } install_service(); Sleep(2000); char command[MAX_PATH + 32]; // 29 January 2008 jdp _snprintf(command, sizeof command, "net start \"%s\"", service_name); WinExec(command,SW_HIDE); #ifdef CRASHRPT crUninstall(); #endif return 0; } if (strncmp(&szCmdLine[i], winvncUnInstallService, strlen(winvncUnInstallService)) == 0) { char command[MAX_PATH + 32]; // 29 January 2008 jdp // rest of command line service name, if provided. char *pServiceName = &szCmdLine[i]; // skip over command switch, find next whitepace while (*pServiceName && !isspace(*(unsigned char*)pServiceName)) ++pServiceName; // skip past whitespace to service name while (*pServiceName && isspace(*(unsigned char*)pServiceName)) ++pServiceName; // strip off any quotes if (*pServiceName && *pServiceName == '\"') ++pServiceName; if (*pServiceName) { // look for trailing quote, if found, terminate the string there. char *pQuote = pServiceName; pQuote = strrchr(pServiceName, '\"'); if (pQuote) *pQuote = 0; } if (*pServiceName && (_strcmpi(pServiceName, service_name) != 0)) { strncpy(service_name, pServiceName, 256); service_name[255] = 0; } _snprintf(command, sizeof command, "net stop \"%s\"", service_name); WinExec(command,SW_HIDE); uninstall_service(); #ifdef CRASHRPT crUninstall(); #endif return 0; } if (strncmp(&szCmdLine[i], winvncRunService, strlen(winvncRunService)) == 0) { //Run as service if (!Myinit(hInstance)) return 0; fRunningFromExternalService = true; vncService::RunningFromExternalService(true); int returnvalue = WinVNCAppMain(); #ifdef CRASHRPT crUninstall(); #endif return returnvalue; } if (strncmp(&szCmdLine[i], winvncStartService, strlen(winvncStartService)) == 0) { start_service(szCmdLine); #ifdef CRASHRPT crUninstall(); #endif return 0; } if (strncmp(&szCmdLine[i], winvncRunAsUserApp, strlen(winvncRunAsUserApp)) == 0) { // WinVNC is being run as a user-level program if (!Myinit(hInstance)) return 0; int returnvalue = WinVNCAppMain(); #ifdef CRASHRPT crUninstall(); #endif return returnvalue; } if (strncmp(&szCmdLine[i], winvncSCexit, strlen(winvncSCexit)) == 0) { SPECIAL_SC_EXIT=true; i+=strlen(winvncSCexit); continue; } if (strncmp(&szCmdLine[i], winvncSCprompt, strlen(winvncSCprompt)) == 0) { SPECIAL_SC_PROMPT=true; i+=strlen(winvncSCprompt); continue; } if (strncmp(&szCmdLine[i], winvncmulti, strlen(winvncmulti)) == 0) { multi=true; i+=strlen(winvncmulti); continue; } if (strncmp(&szCmdLine[i], winvnchttp, strlen(winvnchttp)) == 0) { G_HTTP=true; i+=strlen(winvnchttp); continue; } if (strncmp(&szCmdLine[i], winvncStopReconnect, strlen(winvncStopReconnect)) == 0) { i+=strlen(winvncStopReconnect); vncService::PostAddStopConnectClientAll(); continue; } if (strncmp(&szCmdLine[i], winvncAutoReconnect, strlen(winvncAutoReconnect)) == 0) { // Note that this "autoreconnect" param MUST be BEFORE the "connect" one // on the command line ! // wa@2005 -- added support for the AutoReconnectId i+=strlen(winvncAutoReconnect); Injected_autoreconnect=true; int start, end; char* pszId = NULL; start = i; // skip any spaces and grab the parameter while (szCmdLine[start] <= ' ' && szCmdLine[start] != 0) start++; if ( strncmp( &szCmdLine[start], winvncAutoReconnectId, strlen(winvncAutoReconnectId) ) == 0 ) { end = start; while (szCmdLine[end] > ' ') end++; if (end - start > 0) { pszId = new char[end - start + 1]; strncpy(pszId, &(szCmdLine[start]), end - start); pszId[end - start] = 0; pszId = _strupr(pszId); } //multiple spaces between autoreconnect and id i = end; }// end of condition we found the ID: parameter // NOTE: id must be NULL or the ID:???? (pointer will get deleted when message is processed) // We can not contact a runnning service, permissions, so we must store the settings // and process until the vncmenu has been started if (!vncService::PostAddAutoConnectClient( pszId )) { PostAddAutoConnectClient_bool=true; if (pszId==NULL) { PostAddAutoConnectClient_bool_null=true; PostAddAutoConnectClient_bool=false; } else { strcpy(pszId_char,pszId); //memory leak fix delete[] pszId; pszId = NULL; } } if (pszId != NULL) delete[] pszId; pszId = NULL; continue; } if ( strncmp( &szCmdLine[i], winvncReconnectId, strlen(winvncReconnectId) ) == 0 ) { i+=strlen("-"); int start, end; char* pszId = NULL; start = i; end = start; while (szCmdLine[end] > ' ') end++; if (end - start > 0) { pszId = new char[end - start + 1]; if (pszId != 0) { strncpy(pszId, &(szCmdLine[start]), end - start); pszId[end - start] = 0; pszId = _strupr(pszId); } } i = end; if (!vncService::PostAddConnectClient( pszId )) { PostAddConnectClient_bool=true; if (pszId==NULL) { PostAddConnectClient_bool_null=true; PostAddConnectClient_bool=false; } else { strcpy(pszId_char,pszId); //memory leak fix delete[] pszId; pszId = NULL; } } if (pszId != NULL) delete[] pszId; pszId = NULL; continue; } if (strncmp(&szCmdLine[i], winvncConnect, strlen(winvncConnect)) == 0) { if (!Injected_autoreconnect) { vncService::PostAddStopConnectClient(); } // Add a new client to an existing copy of winvnc i+=strlen(winvncConnect); // First, we have to parse the command line to get the filename to use int start, end; start=i; while (szCmdLine[start] <= ' ' && szCmdLine[start] != 0) start++; end = start; while (szCmdLine[end] > ' ') end++; // Was there a hostname (and optionally a port number) given? if (end-start > 0) { char *name = new char[end-start+1]; if (name != 0) { strncpy(name, &(szCmdLine[start]), end-start); name[end-start] = 0; int port = INCOMING_PORT_OFFSET; char *portp = strchr(name, ':'); if (portp) { *portp++ = '\0'; if (*portp == ':') { port = atoi(++portp); // Port number after "::" } else { port = atoi(portp); // Display number after ":" } } vnclog.Print(LL_STATE, VNCLOG("test... %s %d\n"),name,port); strcpy_s(dnsname,name); VCard32 address = VSocket::Resolve(name); delete [] name; if (address != 0) { // Post the IP address to the server // We can not contact a runnning service, permissions, so we must store the settings // and process until the vncmenu has been started vnclog.Print(LL_INTERR, VNCLOG("PostAddNewClient III \n")); if (!vncService::PostAddNewClientInit(address, port)) { PostAddNewClient_bool=true; port_int=port; address_vcard=address; } } else { //ask for host,port PostAddNewClient_bool=true; port_int=0; address_vcard=0; Sleep(2000); //Beep(200,1000); return 0; } } i=end; continue; } else { // Tell the server to show the Add New Client dialog // We can not contact a runnning service, permissions, so we must store the settings // and process until the vncmenu has been started vnclog.Print(LL_INTERR, VNCLOG("PostAddNewClient IIII\n")); if (!vncService::PostAddNewClient(0, 0)) { PostAddNewClient_bool=true; port_int=0; address_vcard=0; } } continue; } //adzm 2009-06-20 if (strncmp(&szCmdLine[i], winvncRepeater, strlen(winvncRepeater)) == 0) { // set the default repeater host i+=strlen(winvncRepeater); // First, we have to parse the command line to get the host to use int start, end; start=i; while (szCmdLine[start] <= ' ' && szCmdLine[start] != 0) start++; end = start; while (szCmdLine[end] > ' ') end++; // Was there a hostname (and optionally a port number) given? if (end-start > 0) { if (g_szRepeaterHost) { delete[] g_szRepeaterHost; g_szRepeaterHost = NULL; } g_szRepeaterHost = new char[end-start+1]; if (g_szRepeaterHost != 0) { strncpy(g_szRepeaterHost, &(szCmdLine[start]), end-start); g_szRepeaterHost[end-start] = 0; // We can not contact a runnning service, permissions, so we must store the settings // and process until the vncmenu has been started vnclog.Print(LL_INTERR, VNCLOG("PostAddNewRepeaterClient I\n")); if (!vncService::PostAddNewRepeaterClient()) { PostAddNewRepeaterClient_bool=true; port_int=0; address_vcard=0; } } i=end; continue; } else { /* // Tell the server to show the Add New Client dialog // We can not contact a runnning service, permissions, so we must store the settings // and process until the vncmenu has been started vnclog.Print(LL_INTERR, VNCLOG("PostAddNewClient IIII\n")); if (!vncService::PostAddNewClient(0, 0)) { PostAddNewClient_bool=true; port_int=0; address_vcard=0; } */ } continue; } // Either the user gave the -help option or there is something odd on the cmd-line! // Show the usage dialog MessageBoxSecure(NULL, winvncUsageText, sz_ID_WINVNC_USAGE, MB_OK | MB_ICONINFORMATION); break; }; // If no arguments were given then just run if (!argfound) { if (!Myinit(hInstance)) { #ifdef CRASHRPT crUninstall(); #endif return 0; } int returnvalue= WinVNCAppMain(); #ifdef CRASHRPT crUninstall(); #endif return returnvalue; } #ifdef CRASHRPT crUninstall(); #endif return 0; }
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow) { // Define CrashRpt configuration parameters CR_INSTALL_INFO info; memset(&info, 0, sizeof(CR_INSTALL_INFO)); info.cb = sizeof(CR_INSTALL_INFO); info.pszAppName = _T("crashtestdummy"); info.pszAppVersion = _T("1.0.0"); info.pszEmailSubject = _T("Error Report"); info.pszEmailTo = _T("*****@*****.**"); info.uPriorities[CR_HTTP] = 3; // First try send report over HTTP info.uPriorities[CR_SMTP] = 2; // Second try send report over SMTP info.uPriorities[CR_SMAPI] = 1; // Third try send report over Simple MAPI // Install all available exception handlers info.dwFlags |= CR_INST_ALL_POSSIBLE_HANDLERS; // Restart the app on crash info.dwFlags |= CR_INST_APP_RESTART; info.dwFlags |= CR_INST_SEND_QUEUED_REPORTS; info.pszRestartCmdLine = _T("/restart"); // Define the Privacy Policy URL info.pszPrivacyPolicyURL = _T("http://myapp.com/privacypolicy.html"); // Install crash reporting int nResult = crInstall(&info); if(nResult!=0) { // Something goes wrong. Get error message. TCHAR szErrorMsg[512] = _T(""); crGetLastErrorMsg(szErrorMsg, 512); _tprintf_s(_T("%s\n"), szErrorMsg); return 1; } // Set crash callback function crSetCrashCallback(CrashCallback, NULL); // Add our log file to the error report crAddFile2(_T("log.txt"), NULL, _T("Log File"), CR_AF_MAKE_FILE_COPY); // We want the screenshot of the entire desktop is to be added on crash crAddScreenshot2(CR_AS_VIRTUAL_SCREEN, 0); // Add a named property that means what graphics adapter is // installed on user's machine crAddProperty(_T("VideoCard"), _T("nVidia GeForce 8600 GTS")); HRESULT hRes = ::CoInitialize(NULL); // If you are running on NT 4.0 or higher you can use the following call instead to // make the EXE free threaded. This means that calls come in on a random RPC thread. // HRESULT hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED); ATLASSERT(SUCCEEDED(hRes)); // this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used ::DefWindowProc(NULL, 0, 0, 0L); AtlInitCommonControls(ICC_BAR_CLASSES); // add flags to support other controls hRes = _Module.Init(NULL, hInstance); ATLASSERT(SUCCEEDED(hRes)); int nRet = Run(lpstrCmdLine, nCmdShow); _Module.Term(); ::CoUninitialize(); errno_t err = _tfopen_s(&g_hLog, _T("log.txt"), _T("wt")); if(err!=0 || g_hLog==NULL) { _tprintf_s(_T("Error opening log.txt\n")); return 1; // Couldn't open log file } log_write(_T("Started successfully\n")); // There is a hidden error in the main() function // Call of _tprintf_s with NULL parameter TCHAR* szFormatString = NULL; _tprintf_s(szFormatString); // Close the log file if(g_hLog!=NULL) { fclose(g_hLog); g_hLog = NULL;// Clean up handle } // Uninitialize CrashRpt before exiting the main function crUninstall(); return nRet; }
BOOL CAlarmCenterApp::InitInstance() { /*{ bool connect_by_sse_or_ip_ = true; std::string cloud_sse_id_ = ""; std::string device_ipv4_ = ""; int device_port_ = 0; std::wstring user_name_ = L""; int user_id = 0; std::wstring _device_note = L""; int _id = 0; CString sql; sql.Format(L"update table_device_info_jovision set \ connect_by_sse_or_ip=%d,\ cloud_sse_id='%s',\ device_ipv4='%s',\ device_port=%d,\ user_name='%s',\ user_passwd='%s',\ user_info_id=%d,\ device_note='%s' where id=%d", connect_by_sse_or_ip_ ? 1 : 0, utf8::a2w(cloud_sse_id_).c_str(), utf8::a2w(device_ipv4_).c_str(), device_port_, user_name_.c_str(), user_id, _device_note.c_str(), _id); JLOG(sql); }*/ do { if (IfProcessRunning()) break; auto log = log::get_instance(); log->set_output_to_dbg_view(); log->set_line_prifix("HB"); log->set_log_file_foler(get_exe_path_a() + "\\Log"); log->set_log_file_prefix("AlarmCenter"); log->set_output_to_file(); JLOG(L"AlarmCenter startup.\n"); AUTO_LOG_FUNCTION; int nRet; WSAData wsData; nRet = WSAStartup(MAKEWORD(2, 2), &wsData); if (nRet < 0) { JLOG(L"Can't load winsock.dll.\n"); break; } #pragma region init crashrpt // Place all significant initialization in InitInstance // Define CrashRpt configuration parameters CR_INSTALL_INFO info; memset(&info, 0, sizeof(CR_INSTALL_INFO)); info.cb = sizeof(CR_INSTALL_INFO); info.pszAppName = _T("AlarmCenter"); static CString version; detail::GetProductVersion(version); info.pszAppVersion = version; info.pszEmailSubject = _T("AlarmCenter Error Report"); info.pszEmailTo = _T("*****@*****.**"); info.pszUrl = _T("http://113.140.30.118/crashrpt.php"); info.uPriorities[CR_HTTP] = 3; // First try send report over HTTP info.uPriorities[CR_SMTP] = 2; // Second try send report over SMTP info.uPriorities[CR_SMAPI] = 1; // Third try send report over Simple MAPI // Install all available exception handlers info.dwFlags |= CR_INST_ALL_POSSIBLE_HANDLERS; // Restart the app on crash info.dwFlags |= CR_INST_APP_RESTART; info.dwFlags |= CR_INST_SEND_QUEUED_REPORTS; //info.pszRestartCmdLine = _T("/restart"); // Define the Privacy Policy URL //info.pszPrivacyPolicyURL = _T("http://myapp.com/privacypolicy.html"); // Install crash reporting int nResult = crInstall(&info); if (nResult != 0) { // Something goes wrong. Get error message. TCHAR szErrorMsg[512] = _T(""); crGetLastErrorMsg(szErrorMsg, 512); _tprintf_s(_T("%s\n"), szErrorMsg); MessageBox(nullptr, szErrorMsg, L"Error", MB_ICONERROR); break; } // Set crash callback function //crSetCrashCallback(CrashCallback, nullptr); // Add our log file to the error report crAddFile2(utf8::a2w(log::get_instance()->get_log_file_path()).c_str(), nullptr, _T("Log File"), CR_AF_MAKE_FILE_COPY); // We want the screenshot of the entire desktop is to be added on crash crAddScreenshot2(CR_AS_VIRTUAL_SCREEN, 0); // Add a named property that means what graphics adapter is // installed on user's machine //crAddProperty(_T("VideoCard"), _T("nVidia GeForce 8600 GTS")); #pragma endregion auto res = res::get_instance(); auto cfg = util::CConfigHelper::get_instance(); auto lang = cfg->get_language(); auto path = get_exe_path(); #ifdef _DEBUG path = path.substr(0, path.find_last_of(L'\\')); path += L"\\installer"; #endif switch (lang) { case util::AL_TAIWANESE: res->parse_file(path + L"\\lang\\zh-tw.txt"); SetThreadUILanguage(MAKELCID(MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL), SORT_DEFAULT)); break; case util::AL_ENGLISH: res->parse_file(path + L"\\lang\\en-us.txt"); SetThreadUILanguage(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT)); break; case util::AL_CHINESE: default: res->parse_file(path + L"\\lang\\zh-cn.txt"); SetThreadUILanguage(MAKELCID(MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED), SORT_DEFAULT)); break; } CAppResource::get_instance(); // InitCommonControlsEx() is required on Windows XP if an application // manifest specifies use of ComCtl32.dll version 6 or later to enable // visual styles. Otherwise, any window creation will fail. INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // Set this to include all the common control classes you want to use // in your application. InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinApp::InitInstance(); AfxEnableControlContainer(); // Create the shell manager, in case the dialog contains // any shell tree view or shell list view controls. auto pShellManager = std::make_unique<CShellManager>(); // Activate "Windows Native" visual manager for enabling themes in MFC controls //CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows)); // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need // Change the registry key under which our settings are stored // You should modify this string to be something appropriate // such as the name of your company or organization SetRegistryKey(_T("Local AppWizard-Generated Applications")); CLoginDlg loginDlg; if (loginDlg.DoModal() != IDOK) { JLOG(L"user canceled login.\n"); break; } CSetupNetworkDlg setupDlg; if (setupDlg.DoModal() != IDOK) { JLOG(L"user canceled setup network.\n"); break; } CAlarmCenterDlg dlg; m_pMainWnd = &dlg; INT_PTR nResponse = dlg.DoModal(); if (nResponse == IDOK) { } else if (nResponse == IDCANCEL) { } else if (nResponse == -1) { TRACE(L"Warning: dialog creation failed, so application is terminating unexpectedly.\n"); TRACE(L"Warning: if you are using MFC controls on the dialog, you cannot #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS.\n"); } } while (false); //video::ezviz::sdk_mgr_ezviz::release_singleton(); // Since the dialog has been closed, return FALSE so that we exit the // application, rather than start the application's message pump. return FALSE; }
// Called from MyApp() immediately upon entry to MyApp::OnInit() void OCPNPlatform::Initialize_1( void ) { #ifdef OCPN_USE_CRASHRPT #ifndef _DEBUG // Install Windows crash reporting CR_INSTALL_INFO info; memset(&info, 0, sizeof(CR_INSTALL_INFO)); info.cb = sizeof(CR_INSTALL_INFO); info.pszAppName = _T("OpenCPN"); wxString version_crash = str_version_major + _T(".") + str_version_minor + _T(".") + str_version_patch; info.pszAppVersion = version_crash.c_str(); int type = MiniDumpWithDataSegs; // Include the data sections from all loaded modules. // This results in the inclusion of global variables type |= MiniDumpNormal;// | MiniDumpWithPrivateReadWriteMemory | MiniDumpWithIndirectlyReferencedMemory; info.uMiniDumpType = (MINIDUMP_TYPE)type; // Install all available exception handlers.... info.dwFlags = CR_INST_ALL_POSSIBLE_HANDLERS; // Except memory allocation failures info.dwFlags &= ~CR_INST_NEW_OPERATOR_ERROR_HANDLER; // Allow user to attach files info.dwFlags |= CR_INST_ALLOW_ATTACH_MORE_FILES; // Allow user to add more info info.dwFlags |= CR_INST_SHOW_ADDITIONAL_INFO_FIELDS; // URL for sending error reports over HTTP. if(g_bEmailCrashReport){ info.pszEmailTo = _T("*****@*****.**"); info.pszSmtpProxy = _T("mail.bigdumboat.com:587"); info.pszUrl = _T("http://bigdumboat.com/crashrpt/ocpn_crashrpt.php"); info.uPriorities[CR_HTTP] = 1; // First try send report over HTTP } else{ info.dwFlags |= CR_INST_DONT_SEND_REPORT; info.uPriorities[CR_HTTP] = CR_NEGATIVE_PRIORITY; // don't send at all } info.uPriorities[CR_SMTP] = CR_NEGATIVE_PRIORITY; // Second try send report over SMTP info.uPriorities[CR_SMAPI] = CR_NEGATIVE_PRIORITY; //1; // Third try send report over Simple MAPI wxStandardPaths& crash_std_path = g_Platform->GetStdPaths(); wxString crash_rpt_save_locn = crash_std_path.GetConfigDir(); if( g_bportable ) { wxFileName exec_path_crash( crash_std_path.GetExecutablePath() ); crash_rpt_save_locn = exec_path_crash.GetPath( wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR ); } wxString locn = crash_rpt_save_locn + _T("\\CrashReports"); if(!wxDirExists( locn ) ) wxMkdir( locn ); if(wxDirExists( locn ) ){ wxCharBuffer buf = locn.ToUTF8(); wchar_t wlocn[256]; if(buf && (locn.Length() < sizeof(wlocn)) ){ MultiByteToWideChar( 0, 0, buf.data(), -1, wlocn, sizeof(wlocn)-1); info.pszErrorReportSaveDir = (LPCWSTR)wlocn; } } // Provide privacy policy URL wxFileName exec_path_crash( crash_std_path.GetExecutablePath() ); wxString policy_file = exec_path_crash.GetPath( wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR ); policy_file += _T("PrivacyPolicy.txt"); policy_file.Prepend(_T("file:")); info.pszPrivacyPolicyURL = policy_file.c_str();; int nResult = crInstall(&info); if(nResult!=0) { TCHAR buff[256]; crGetLastErrorMsg(buff, 256); MessageBox(NULL, buff, _T("crInstall error, Crash Reporting disabled."), MB_OK); } // Establish the crash callback function crSetCrashCallback( CrashCallback, NULL ); // Take screenshot of the app window at the moment of crash crAddScreenshot2(CR_AS_PROCESS_WINDOWS|CR_AS_USE_JPEG_FORMAT, 95); // Mark some files to add to the crash report wxString home_data_crash = crash_std_path.GetConfigDir(); if( g_bportable ) { wxFileName f( crash_std_path.GetExecutablePath() ); home_data_crash = f.GetPath(); } appendOSDirSlash( &home_data_crash ); wxString config_crash = _T("opencpn.ini"); config_crash.Prepend( home_data_crash ); crAddFile2( config_crash.c_str(), NULL, NULL, CR_AF_MISSING_FILE_OK | CR_AF_ALLOW_DELETE ); wxString log_crash = _T("opencpn.log"); log_crash.Prepend( home_data_crash ); crAddFile2( log_crash.c_str(), NULL, NULL, CR_AF_MISSING_FILE_OK | CR_AF_ALLOW_DELETE ); #endif #endif #ifdef LINUX_CRASHRPT #if wxUSE_ON_FATAL_EXCEPTION // fatal exceptions handling wxHandleFatalExceptions (true); #endif #endif #ifdef __WXMSW__ // Invoke my own handler for failures of malloc/new _set_new_handler( MyNewHandler ); // configure malloc to call the New failure handler on failure _set_new_mode(1); #endif // On MSW, force the entire process to run on one CPU core only // This resolves some difficulty with wxThread syncronization #if 0 #ifdef __WXMSW__ //Gets the current process handle HANDLE hProc = GetCurrentProcess(); DWORD procMask; DWORD sysMask; HANDLE hDup; DuplicateHandle( hProc, hProc, hProc, &hDup, 0, FALSE, DUPLICATE_SAME_ACCESS ); //Gets the current process affinity mask GetProcessAffinityMask( hDup, &procMask, &sysMask ); // Take a simple approach, and assume up to 4 processors DWORD newMask; if( ( procMask & 1 ) == 1 ) newMask = 1; else if( ( procMask & 2 ) == 2 ) newMask = 2; else if( ( procMask & 4 ) == 4 ) newMask = 4; else if( ( procMask & 8 ) == 8 ) newMask = 8; //Set te affinity mask for the process BOOL res = SetProcessAffinityMask( hDup, (DWORD_PTR) newMask ); if( res == 0 ) { //Error setting affinity mask!! } #endif #endif #ifdef __WXMSW__ // Handle any Floating Point Exceptions which may leak thru from other // processes. The exception filter is in cutil.c // Seems to only happen for W98 wxPlatformInfo Platform; if( Platform.GetOperatingSystemId() == wxOS_WINDOWS_9X ) SetUnhandledExceptionFilter (&MyUnhandledExceptionFilter); #endif #ifdef __WXMSW__ // _CrtSetBreakAlloc(25503); #endif #ifndef __WXMSW__ // Setup Linux SIGNAL handling, for external program control // Build the sigaction structure sa_all.sa_handler = catch_signals;// point to my handler sigemptyset(&sa_all.sa_mask);// make the blocking set // empty, so that all // other signals will be // unblocked during my handler sa_all.sa_flags = 0; sigaction(SIGUSR1, NULL, &sa_all_old);// save existing action for this signal // Register my request for some signals sigaction(SIGUSR1, &sa_all, NULL); sigaction(SIGUSR1, NULL, &sa_all_old);// inspect existing action for this signal sigaction(SIGTERM, &sa_all, NULL); sigaction(SIGTERM, NULL, &sa_all_old); #endif }
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow) { HRESULT hRes = ::CoInitialize(NULL); // If you are running on NT 4.0 or higher you can use the following call instead to // make the EXE free threaded. This means that calls come in on a random RPC thread. // HRESULT hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED); ATLASSERT(SUCCEEDED(hRes)); // Install crash reporting #ifdef TEST_DEPRECATED_FUNCS g_pCrashRptState = Install( CrashCallback, _T("*****@*****.**"), _T("Crash")); #else CString szSubject; szSubject.Format(_T("%s %s Error Report"), APP_NAME, APP_VERSION); CR_INSTALL_INFO info; memset(&info, 0, sizeof(CR_INSTALL_INFO)); info.cb = sizeof(CR_INSTALL_INFO); info.pszAppName = APP_NAME; info.pszAppVersion = APP_VERSION; info.pszEmailSubject = szSubject; info.pszEmailTo = _T("*****@*****.**"); info.pfnCrashCallback = CrashCallback; info.uPriorities[CR_SMTP] = 1; info.uPriorities[CR_SMAPI] = 0; int nInstResult = crInstall(&info); ATLASSERT(nInstResult==0); nInstResult; #endif //TEST_DEPRECATED_FUNCS /* Create another thread */ g_CrashThreadInfo.m_pCrashRptState = g_pCrashRptState; g_CrashThreadInfo.m_bStop = false; g_CrashThreadInfo.m_hWakeUpEvent = CreateEvent(NULL, FALSE, FALSE, _T("WakeUpEvent")); ATLASSERT(g_CrashThreadInfo.m_hWakeUpEvent!=NULL); DWORD dwThreadId = 0; g_hWorkingThread = CreateThread(NULL, 0, CrashThread, (LPVOID)&g_CrashThreadInfo, 0, &dwThreadId); ATLASSERT(g_hWorkingThread!=NULL); // this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used ::DefWindowProc(NULL, 0, 0, 0L); AtlInitCommonControls(ICC_BAR_CLASSES); // add flags to support other controls hRes = _Module.Init(NULL, hInstance); ATLASSERT(SUCCEEDED(hRes)); int nRet = Run(lpstrCmdLine, nCmdShow); _Module.Term(); // Close another thread g_CrashThreadInfo.m_bStop = true; SetEvent(g_CrashThreadInfo.m_hWakeUpEvent); // Wait until thread terminates WaitForSingleObject(g_hWorkingThread, INFINITE); // Uninstall crash reporting #ifdef TEST_DEPRECATED_FUNCS Uninstall(g_pCrashRptState); #else int nUninstResult = crUninstall(); ATLASSERT(nUninstResult==0); nUninstResult; #endif //TEST_DEPRECATED_FUNCS ::CoUninitialize(); return nRet; }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR szCmdLine, int iCmdShow) #endif { /*HMODULE hUser32 = LoadLibrary(_T("user32.dll")); typedef BOOL(*SetProcessDPIAwareFunc)(); SetProcessDPIAwareFunc setDPIAware=NULL; if (hUser32) setDPIAware = (SetProcessDPIAwareFunc)GetProcAddress(hUser32, "SetProcessDPIAware"); if (setDPIAware) setDPIAware(); if (hUser32) FreeLibrary(hUser32);*/ #ifdef IPP InitIpp(); #endif #ifdef CRASHRPT CR_INSTALL_INFO info; memset(&info, 0, sizeof(CR_INSTALL_INFO)); info.cb = sizeof(CR_INSTALL_INFO); info.pszAppName = _T("UVNC"); info.pszAppVersion = _T("1.2.1.1"); info.pszEmailSubject = _T("UVNC viewer 1.2.1.1 Error Report"); info.pszEmailTo = _T("*****@*****.**"); info.uPriorities[CR_SMAPI] = 1; // Third try send report over Simple MAPI // Install all available exception handlers info.dwFlags |= CR_INST_ALL_POSSIBLE_HANDLERS; // Restart the app on crash info.dwFlags |= CR_INST_APP_RESTART; info.dwFlags |= CR_INST_SEND_QUEUED_REPORTS; info.dwFlags |= CR_INST_AUTO_THREAD_HANDLERS; info.pszRestartCmdLine = _T("/restart"); // Define the Privacy Policy URL // Install crash reporting int nResult = crInstall(&info); if (nResult != 0) { // Something goes wrong. Get error message. TCHAR szErrorMsg[512] = _T(""); crGetLastErrorMsg(szErrorMsg, 512); _tprintf_s(_T("%s\n"), szErrorMsg); return 1; } #endif setbuf(stderr, 0); bool console = false; m_hInstResDLL = NULL; // [v1.0.2-jp1 fix] //m_hInstResDLL = LoadLibrary("lang.dll"); HMODULE hmod; HKEY hkey; if((hmod=GetModuleHandle("kernel32.dll"))) { MySetDllDirectory = (LPFNSETDLLDIRECTORY)GetProcAddress(hmod, "SetDllDirectoryA"); if(MySetDllDirectory) MySetDllDirectory(""); else { OSVERSIONINFO osinfo; osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&osinfo); if((osinfo.dwMajorVersion == 5 && osinfo.dwMinorVersion == 0 && strcmp(osinfo.szCSDVersion, "Service Pack 3") >= 0) || (osinfo.dwMajorVersion == 5 && osinfo.dwMinorVersion == 1 && strcmp(osinfo.szCSDVersion, "") >= 0)) { DWORD regval = 1; DWORD reglen = sizeof(DWORD); vnclog.Print(3,"Using Win2k (SP3+) / WinXP (No SP).. Checking SafeDllSearch\n"); read_reg_string(HKEY_LOCAL_MACHINE, "System\\CurrentControlSet\\Control\\Session Manager", "SafeDllSearchMode", (LPBYTE)®val, ®len); if(regval != 0) { vnclog.Print(3,"Trying to set SafeDllSearchMode to 0\n"); regval = 0; if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, "System\\CurrentControlSet\\Control\\Session Manager", 0, KEY_SET_VALUE, &hkey) == ERROR_SUCCESS) { if(RegSetValueEx(hkey, "SafeDllSearchMode", 0, REG_DWORD, (LPBYTE) ®val, sizeof(DWORD)) != ERROR_SUCCESS) vnclog.Print(3,"Error writing SafeDllSearchMode. Error: %u\n",(UINT)GetLastError()); RegCloseKey(hkey); } else vnclog.Print(3,"Error opening Session Manager key for writing. Error: %u\n",(UINT)GetLastError()); } else vnclog.Print(3,"SafeDllSearchMode is set to 0\n"); } } } //limit the vnclang.dll searchpath to avoid char szCurrentDir[MAX_PATH]=""; char szCurrentDir_vnclangdll[MAX_PATH]=""; if (GetModuleFileName(NULL, szCurrentDir, MAX_PATH)) { char* p = strrchr(szCurrentDir, '\\'); *p = '\0'; } strcpy_s (szCurrentDir_vnclangdll,szCurrentDir); strcat_s (szCurrentDir_vnclangdll,"\\"); strcat_s (szCurrentDir_vnclangdll,"vnclang.dll"); m_hInstResDLL = LoadLibrary(szCurrentDir_vnclangdll); if (m_hInstResDLL==NULL) { m_hInstResDLL = hInstance; } if (strcmp(szCmdLine,"")==0) command_line=false; LoadString(m_hInstResDLL, IDS_A1, sz_A1, 64 -1); LoadString(m_hInstResDLL, IDS_A2, sz_A2, 64 -1); LoadString(m_hInstResDLL, IDS_A3, sz_A3, 64 -1); LoadString(m_hInstResDLL, IDS_A4, sz_A4, 64 -1); LoadString(m_hInstResDLL, IDS_A5, sz_A5, 64 -1); LoadString(m_hInstResDLL, IDS_B1, sz_B1, 64 -1); LoadString(m_hInstResDLL, IDS_B2, sz_B2, 64 -1); LoadString(m_hInstResDLL, IDS_B3, sz_B3, 64 -1); LoadString(m_hInstResDLL, IDS_C1, sz_C1, 64 -1); LoadString(m_hInstResDLL, IDS_C2, sz_C2, 64 -1); LoadString(m_hInstResDLL, IDS_C3, sz_C3, 64 -1); LoadString(m_hInstResDLL, IDS_D1, sz_D1, 64 -1); LoadString(m_hInstResDLL, IDS_D2, sz_D2, 64 -1); LoadString(m_hInstResDLL, IDS_D3, sz_D3, 64 -1); LoadString(m_hInstResDLL, IDS_D4, sz_D4, 64 -1); LoadString(m_hInstResDLL, IDS_D5, sz_D5, 64 -1); LoadString(m_hInstResDLL, IDS_D6, sz_D6, 64 -1); LoadString(m_hInstResDLL, IDS_D7, sz_D7, 64 -1); LoadString(m_hInstResDLL, IDS_D8, sz_D8, 64 -1); LoadString(m_hInstResDLL, IDS_D9, sz_D9, 64 -1); LoadString(m_hInstResDLL, IDS_D10, sz_D10, 64 -1); LoadString(m_hInstResDLL, IDS_D11, sz_D11, 64 -1); LoadString(m_hInstResDLL, IDS_D12, sz_D12, 64 -1); LoadString(m_hInstResDLL, IDS_D13, sz_D13, 64 -1); LoadString(m_hInstResDLL, IDS_D14, sz_D14, 64 -1); LoadString(m_hInstResDLL, IDS_D15, sz_D15, 64 -1); LoadString(m_hInstResDLL, IDS_D16, sz_D16, 64 -1); LoadString(m_hInstResDLL, IDS_D17, sz_D17, 64 -1); LoadString(m_hInstResDLL, IDS_D18, sz_D18, 64 -1); LoadString(m_hInstResDLL, IDS_D19, sz_D19, 64 -1); LoadString(m_hInstResDLL, IDS_D20, sz_D20, 64 -1); LoadString(m_hInstResDLL, IDS_D21, sz_D21, 64 -1); LoadString(m_hInstResDLL, IDS_D22, sz_D22, 64 -1); LoadString(m_hInstResDLL, IDS_D23, sz_D23, 64 -1); LoadString(m_hInstResDLL, IDS_D24, sz_D24, 64 -1); LoadString(m_hInstResDLL, IDS_D25, sz_D25, 64 -1); LoadString(m_hInstResDLL, IDS_D26, sz_D26, 64 -1); LoadString(m_hInstResDLL, IDS_D27, sz_D27, 64 -1); LoadString(m_hInstResDLL, IDS_D28, sz_D28, 64 -1); LoadString(m_hInstResDLL, IDS_E1, sz_E1, 64 -1); LoadString(m_hInstResDLL, IDS_E2, sz_E2, 64 -1); LoadString(m_hInstResDLL, IDS_F1, sz_F1, 64 -1); LoadString(m_hInstResDLL, IDS_F3, sz_F3, 64 -1); LoadString(m_hInstResDLL, IDS_F4, sz_F4, 64 -1); LoadString(m_hInstResDLL, IDS_F5, sz_F5, 128 -1); LoadString(m_hInstResDLL, IDS_F6, sz_F6, 64 -1); LoadString(m_hInstResDLL, IDS_F7, sz_F7, 128 -1); LoadString(m_hInstResDLL, IDS_F8, sz_F8, 128 -1); LoadString(m_hInstResDLL, IDS_F10, sz_F10, 64 -1); LoadString(m_hInstResDLL, IDS_F11, sz_F11, 64 -1); LoadString(m_hInstResDLL, IDS_G1, sz_G1, 64 -1); LoadString(m_hInstResDLL, IDS_G1, sz_G2, 64 -1); LoadString(m_hInstResDLL, IDS_G1, sz_G3, 64 -1); LoadString(m_hInstResDLL, IDS_H1, sz_H1, 64 -1); LoadString(m_hInstResDLL, IDS_H2, sz_H2, 64 -1); LoadString(m_hInstResDLL, IDS_H3, sz_H3, 128 -1); LoadString(m_hInstResDLL, IDS_H4, sz_H4, 64 -1); LoadString(m_hInstResDLL, IDS_H5, sz_H5, 64 -1); LoadString(m_hInstResDLL, IDS_H6, sz_H6, 64 -1); LoadString(m_hInstResDLL, IDS_H7, sz_H7, 64 -1); LoadString(m_hInstResDLL, IDS_H8, sz_H8, 64 -1); LoadString(m_hInstResDLL, IDS_H9, sz_H9, 64 -1); LoadString(m_hInstResDLL, IDS_H10, sz_H10, 64 -1); LoadString(m_hInstResDLL, IDS_H11, sz_H11, 64 -1); LoadString(m_hInstResDLL, IDS_H12, sz_H12, 64 -1); LoadString(m_hInstResDLL, IDS_H13, sz_H13, 64 -1); LoadString(m_hInstResDLL, IDS_H14, sz_H14, 64 -1); LoadString(m_hInstResDLL, IDS_H15, sz_H15, 64 -1); LoadString(m_hInstResDLL, IDS_H16, sz_H16, 64 -1); LoadString(m_hInstResDLL, IDS_H17, sz_H17, 64 -1); LoadString(m_hInstResDLL, IDS_H18, sz_H18, 64 -1); LoadString(m_hInstResDLL, IDS_H19, sz_H19, 64 -1); LoadString(m_hInstResDLL, IDS_H20, sz_H20, 64 -1); LoadString(m_hInstResDLL, IDS_H21, sz_H21, 64 -1); LoadString(m_hInstResDLL, IDS_H22, sz_H22, 64 -1); LoadString(m_hInstResDLL, IDS_H23, sz_H23, 64 -1); LoadString(m_hInstResDLL, IDS_H24, sz_H24, 64 -1); LoadString(m_hInstResDLL, IDS_H25, sz_H25, 64 -1); LoadString(m_hInstResDLL, IDS_H26, sz_H26, 64 -1); LoadString(m_hInstResDLL, IDS_H27, sz_H27, 64 -1); LoadString(m_hInstResDLL, IDS_H28, sz_H28, 64 -1); LoadString(m_hInstResDLL, IDS_H29, sz_H29, 64 -1); LoadString(m_hInstResDLL, IDS_H30, sz_H30, 64 -1); LoadString(m_hInstResDLL, IDS_H31, sz_H31, 64 -1); LoadString(m_hInstResDLL, IDS_H32, sz_H32, 64 -1); LoadString(m_hInstResDLL, IDS_H33, sz_H33, 64 -1); LoadString(m_hInstResDLL, IDS_H34, sz_H34, 64 -1); LoadString(m_hInstResDLL, IDS_H35, sz_H35, 64 -1); LoadString(m_hInstResDLL, IDS_H36, sz_H36, 64 -1); LoadString(m_hInstResDLL, IDS_H37, sz_H37, 64 -1); LoadString(m_hInstResDLL, IDS_H38, sz_H38, 128 -1); LoadString(m_hInstResDLL, IDS_H39, sz_H39, 64 -1); LoadString(m_hInstResDLL, IDS_H40, sz_H40, 64 -1); LoadString(m_hInstResDLL, IDS_H41, sz_H41, 64 -1); LoadString(m_hInstResDLL, IDS_H42, sz_H42, 64 -1); LoadString(m_hInstResDLL, IDS_H43, sz_H43, 128 -1); LoadString(m_hInstResDLL, IDS_H44, sz_H44, 64 -1); LoadString(m_hInstResDLL, IDS_H45, sz_H45, 64 -1); LoadString(m_hInstResDLL, IDS_H46, sz_H46, 128 -1); LoadString(m_hInstResDLL, IDS_H47, sz_H47, 64 -1); LoadString(m_hInstResDLL, IDS_H48, sz_H48, 64 -1); LoadString(m_hInstResDLL, IDS_H49, sz_H49, 64 -1); LoadString(m_hInstResDLL, IDS_H50, sz_H50, 64 -1); LoadString(m_hInstResDLL, IDS_H51, sz_H51, 64 -1); LoadString(m_hInstResDLL, IDS_H52, sz_H52, 64 -1); LoadString(m_hInstResDLL, IDS_H53, sz_H53, 64 -1); LoadString(m_hInstResDLL, IDS_H54, sz_H54, 64 -1); LoadString(m_hInstResDLL, IDS_H55, sz_H55, 64 -1); LoadString(m_hInstResDLL, IDS_H56, sz_H56, 64 -1); LoadString(m_hInstResDLL, IDS_H57, sz_H57, 64 -1); LoadString(m_hInstResDLL, IDS_H58, sz_H58, 64 -1); LoadString(m_hInstResDLL, IDS_H59, sz_H59, 64 -1); LoadString(m_hInstResDLL, IDS_H60, sz_H60, 64 -1); LoadString(m_hInstResDLL, IDS_H61, sz_H61, 64 -1); LoadString(m_hInstResDLL, IDS_H62, sz_H62, 64 -1); LoadString(m_hInstResDLL, IDS_H63, sz_H63, 64 -1); LoadString(m_hInstResDLL, IDS_H64, sz_H64, 64 -1); LoadString(m_hInstResDLL, IDS_H65, sz_H65, 64 -1); LoadString(m_hInstResDLL, IDS_H66, sz_H66, 64 -1); LoadString(m_hInstResDLL, IDS_H67, sz_H67, 64 -1); LoadString(m_hInstResDLL, IDS_H68, sz_H68, 64 -1); LoadString(m_hInstResDLL, IDS_H69, sz_H69, 64 -1); LoadString(m_hInstResDLL, IDS_H70, sz_H70, 64 -1); LoadString(m_hInstResDLL, IDS_H71, sz_H71, 64 -1); LoadString(m_hInstResDLL, IDS_H72, sz_H72, 128 -1); LoadString(m_hInstResDLL, IDS_H73, sz_H73, 64 -1); LoadString(m_hInstResDLL, IDS_I1, sz_I1, 64 -1); LoadString(m_hInstResDLL, IDS_I2, sz_I2, 64 -1); LoadString(m_hInstResDLL, IDS_I3, sz_I3, 64 -1); LoadString(m_hInstResDLL, IDS_J1, sz_J1, 128 -1); LoadString(m_hInstResDLL, IDS_J2, sz_J2, 64 -1); LoadString(m_hInstResDLL, IDS_K1, sz_K1, 64 -1); LoadString(m_hInstResDLL, IDS_K2, sz_K2, 64 -1); LoadString(m_hInstResDLL, IDS_K3, sz_K3, sizeof(sz_K3)/sizeof(sz_K3[0])); LoadString(m_hInstResDLL, IDS_K4, sz_K4, 64 -1); LoadString(m_hInstResDLL, IDS_K5, sz_K5, 64 -1); LoadString(m_hInstResDLL, IDS_K6, sz_K6, 64 -1); LoadString(m_hInstResDLL, IDS_L1, sz_L1, 64 -1); LoadString(m_hInstResDLL, IDS_L2, sz_L2, 64 -1); LoadString(m_hInstResDLL, IDS_L3, sz_L3, 64 -1); LoadString(m_hInstResDLL, IDS_L4, sz_L4, 64 -1); LoadString(m_hInstResDLL, IDS_L5, sz_L5, 64 -1); LoadString(m_hInstResDLL, IDS_L6, sz_L6, 64 -1); LoadString(m_hInstResDLL, IDS_L7, sz_L7, 64 -1); LoadString(m_hInstResDLL, IDS_L8, sz_L8, 64 -1); LoadString(m_hInstResDLL, IDS_L9, sz_L9, 64 -1); LoadString(m_hInstResDLL, IDS_L10, sz_L10, 64 -1); LoadString(m_hInstResDLL, IDS_L11, sz_L11, 64 -1); LoadString(m_hInstResDLL, IDS_L12, sz_L12, 64 -1); LoadString(m_hInstResDLL, IDS_L13, sz_L13, 64 -1); LoadString(m_hInstResDLL, IDS_L14, sz_L14, 64 -1); LoadString(m_hInstResDLL, IDS_L15, sz_L15, 64 -1); LoadString(m_hInstResDLL, IDS_L16, sz_L16, 64 -1); LoadString(m_hInstResDLL, IDS_L17, sz_L17, 64 -1); LoadString(m_hInstResDLL, IDS_L18, sz_L18, 64 -1); LoadString(m_hInstResDLL, IDS_L19, sz_L19, 64 -1); LoadString(m_hInstResDLL, IDS_L20, sz_L20, 64 -1); LoadString(m_hInstResDLL, IDS_L21, sz_L21, 64 -1); LoadString(m_hInstResDLL, IDS_L22, sz_L22, 64 -1); LoadString(m_hInstResDLL, IDS_L23, sz_L23, 64 -1); LoadString(m_hInstResDLL, IDS_L24, sz_L24, 64 -1); LoadString(m_hInstResDLL, IDS_L25, sz_L25, 64 -1); LoadString(m_hInstResDLL, IDS_L26, sz_L26, 64 -1); LoadString(m_hInstResDLL, IDS_L27, sz_L27, 64 -1); LoadString(m_hInstResDLL, IDS_L28, sz_L28, 64 -1); LoadString(m_hInstResDLL, IDS_L29, sz_L29, 64 -1); LoadString(m_hInstResDLL, IDS_L30, sz_L30, 64 -1); LoadString(m_hInstResDLL, IDS_L31, sz_L31, 64 -1); LoadString(m_hInstResDLL, IDS_L32, sz_L32, 64 -1); LoadString(m_hInstResDLL, IDS_L33, sz_L33, 64 -1); LoadString(m_hInstResDLL, IDS_L34, sz_L34, 64 -1); LoadString(m_hInstResDLL, IDS_L35, sz_L35, 64 -1); LoadString(m_hInstResDLL, IDS_L36, sz_L36, 64 -1); LoadString(m_hInstResDLL, IDS_L37, sz_L37, 64 -1); LoadString(m_hInstResDLL, IDS_L38, sz_L38, 64 -1); LoadString(m_hInstResDLL, IDS_L39, sz_L39, 64 -1); LoadString(m_hInstResDLL, IDS_L40, sz_L40, 64 -1); LoadString(m_hInstResDLL, IDS_L41, sz_L41, 64 -1); LoadString(m_hInstResDLL, IDS_L42, sz_L42, 64 -1); LoadString(m_hInstResDLL, IDS_L43, sz_L43, 64 -1); LoadString(m_hInstResDLL, IDS_L44, sz_L44, 64 -1); LoadString(m_hInstResDLL, IDS_L45, sz_L45, 64 -1); LoadString(m_hInstResDLL, IDS_L46, sz_L46, 64 -1); LoadString(m_hInstResDLL, IDS_L47, sz_L47, 64 -1); LoadString(m_hInstResDLL, IDS_L48, sz_L48, 64 -1); LoadString(m_hInstResDLL, IDS_L49, sz_L49, 64 -1); LoadString(m_hInstResDLL, IDS_L50, sz_L50, 64 -1); LoadString(m_hInstResDLL, IDS_L51, sz_L51, 128 -1); LoadString(m_hInstResDLL, IDS_L52, sz_L52, 64 -1); LoadString(m_hInstResDLL, IDS_L53, sz_L53, 64 -1); LoadString(m_hInstResDLL, IDS_L54, sz_L54, 64 -1); LoadString(m_hInstResDLL, IDS_L55, sz_L55, 64 -1); LoadString(m_hInstResDLL, IDS_L56, sz_L56, 64 -1); LoadString(m_hInstResDLL, IDS_L57, sz_L57, 64 -1); LoadString(m_hInstResDLL, IDS_L58, sz_L58, 64 -1); LoadString(m_hInstResDLL, IDS_L59, sz_L59, 64 -1); LoadString(m_hInstResDLL, IDS_L60, sz_L60, 64 -1); LoadString(m_hInstResDLL, IDS_L61, sz_L61, 64 -1); LoadString(m_hInstResDLL, IDS_L62, sz_L62, 64 -1); LoadString(m_hInstResDLL, IDS_L63, sz_L63, 64 -1); LoadString(m_hInstResDLL, IDS_L64, sz_L64, 64 -1); LoadString(m_hInstResDLL, IDS_L65, sz_L65, 64 -1); LoadString(m_hInstResDLL, IDS_L66, sz_L66, 64 -1); LoadString(m_hInstResDLL, IDS_L67, sz_L67, 64 -1); LoadString(m_hInstResDLL, IDS_L68, sz_L68, 64 -1); LoadString(m_hInstResDLL, IDS_L69, sz_L69, 64 -1); LoadString(m_hInstResDLL, IDS_L70, sz_L70, 64 -1); LoadString(m_hInstResDLL, IDS_L71, sz_L71, 64 -1); LoadString(m_hInstResDLL, IDS_L72, sz_L72, 64 -1); LoadString(m_hInstResDLL, IDS_L73, sz_L73, 64 -1); LoadString(m_hInstResDLL, IDS_L74, sz_L74, 64 -1); LoadString(m_hInstResDLL, IDS_L75, sz_L75, 64 -1); LoadString(m_hInstResDLL, IDS_L76, sz_L76, 64 -1); LoadString(m_hInstResDLL, IDS_L77, sz_L77, 128 -1); LoadString(m_hInstResDLL, IDS_L78, sz_L78, 64 -1); LoadString(m_hInstResDLL, IDS_L79, sz_L79, 64 -1); LoadString(m_hInstResDLL, IDS_L80, sz_L80, 64 -1); LoadString(m_hInstResDLL, IDS_L81, sz_L81, 128 -1); LoadString(m_hInstResDLL, IDS_L82, sz_L82, 64 -1); LoadString(m_hInstResDLL, IDS_L83, sz_L83, 64 -1); LoadString(m_hInstResDLL, IDS_L84, sz_L84, 64 -1); LoadString(m_hInstResDLL, IDS_L85, sz_L85, 64 -1); LoadString(m_hInstResDLL, IDS_L86, sz_L86, 64 -1); LoadString(m_hInstResDLL, IDS_L87, sz_L87, 64 -1); LoadString(m_hInstResDLL, IDS_L88, sz_L88, 64 -1); LoadString(m_hInstResDLL, IDS_L89, sz_L89, 64 -1); LoadString(m_hInstResDLL, IDS_L90, sz_L90, 64 -1); LoadString(m_hInstResDLL, IDS_L91, sz_L91, 64 -1); LoadString(m_hInstResDLL, IDS_L92, sz_L92, 64 -1); LoadString(m_hInstResDLL, IDS_L93, sz_L93, 64 -1); LoadString(m_hInstResDLL, IDS_L94, sz_L94, 64 -1); LoadString(m_hInstResDLL, IDS_M1, sz_M1, 64 -1); LoadString(m_hInstResDLL, IDS_M2, sz_M2, 64 -1); LoadString(m_hInstResDLL, IDS_M3, sz_M3, 64 -1); LoadString(m_hInstResDLL, IDS_M4, sz_M4, 64 -1); LoadString(m_hInstResDLL, IDS_M5, sz_M5, 64 -1); LoadString(m_hInstResDLL, IDS_M6, sz_M6, 64 -1); LoadString(m_hInstResDLL, IDS_M7, sz_M7, 64 -1); LoadString(m_hInstResDLL, IDS_M8, sz_M8, 64 -1); // 14 April 2008 jdp LoadString(m_hInstResDLL, IDS_H94, sz_H94, 64 -1); LoadString(m_hInstResDLL, IDS_H95, sz_H95, 64 -1); LoadString(m_hInstResDLL, IDS_H96, sz_H96, 64 -1); LoadString(m_hInstResDLL, IDS_H97, sz_H97, 64 -1); LoadString(m_hInstResDLL, IDS_H98, sz_H98, 64 -1); LoadString(m_hInstResDLL, IDS_H99, sz_H99, 64 -1); LoadString(m_hInstResDLL, IDS_H100, sz_H100, 64 -1); LoadString(m_hInstResDLL, IDS_H101, sz_H101, 64 -1); LoadString(m_hInstResDLL, IDS_H102, sz_H102, 128 -1); // RegisterLinkLabel(m_hInstResDLL); ///////////////////////////////////////////////////////////// // The state of the application as a whole is contained in the one app object VNCviewerApp32 app(hInstance, szCmdLine); console = app.m_options.m_logToConsole; // Start a new connection if specified on command line, // or if not in listening mode MSG msg; while(g_passwordfailed==true) { g_passwordfailed=false; if (app.m_options.m_connectionSpecified && !app.m_options.m_listening) { app.NewConnection(false,app.m_options.m_host_options, app.m_options.m_port); } else if (!app.m_options.m_listening) { // This one will also read from config file if specified app.NewConnection(false); } try { while ( GetMessage(&msg, NULL, 0,0) ) { if (!TheAccelKeys.TranslateAccelKeys(&msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } } catch (Exception &e) { if (!g_ConnectionLossAlreadyReported) e.Report(); } } // Clean up winsock WSACleanup(); vnclog.Print(3, _T("Exiting\n")); #ifdef CRASHRPT crUninstall(); #endif if (console) Sleep(2000); return msg.wParam; }