// 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; }
extern "C" DLLEXPORT /*export without name mangling*/ int WinVNCDll_Init(HINSTANCE hInstance) { // handle dpi on aero HMODULE hUser32 = LoadLibrary(_T("user32.dll")); typedef BOOL (*SetProcessDPIAwareFunc)(); SetProcessDPIAwareFunc setDPIAware = (SetProcessDPIAwareFunc)GetProcAddress(hUser32, "SetProcessDPIAware"); if (setDPIAware) setDPIAware(); FreeLibrary(hUser32); #ifdef IPP InitIpp(); #endif bool Injected_autoreconnect=false; SPECIAL_SC_EXIT=false; SPECIAL_SC_PROMPT=false; SetOSVersion(); 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 1; *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(2); // 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 = new VSocketSystem(); if (!socksys->Initialised()) { MessageBoxSecure(NULL, sz_ID_FAILED_INIT, szAppName, MB_OK); return 2; } //OK m_WinVNCDll_Initialized = true; return 0; }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) #endif { #ifdef IPP InitIpp(); #endif #ifdef CRASHRPT Install(NULL, _T("*****@*****.**"), _T("")); #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 (szCurrentDir_vnclangdll,szCurrentDir); strcat (szCurrentDir_vnclangdll,"\\"); strcat (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 #ifdef _WIN32_WCE VNCviewerApp app(hInstance, szCmdLine); #else VNCviewerApp32 app(hInstance, szCmdLine); #endif 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")); if (console) Sleep(2000); return msg.wParam; }
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; }