int CheckUserGroupPasswordUni(char * userin,char *password,const char *machine) { int result = 0; // Marscha@2004 - authSSP: if "New MS-Logon" is checked, call CUPSD in authSSP.dll, // else call "old" mslogon method. if (IsNewMSLogon()){ char szCurrentDir[MAX_PATH]; if (GetModuleFileName(NULL, szCurrentDir, MAX_PATH)) { char* p = strrchr(szCurrentDir, '\\'); *p = '\0'; strcat (szCurrentDir,"\\authSSP.dll"); } HMODULE hModule = LoadLibrary(szCurrentDir); if (hModule) { static omni_mutex authSSPMutex; omni_mutex_lock l( authSSPMutex ); CheckUserPasswordSDUni = (CheckUserPasswordSDUniFn) GetProcAddress(hModule, "CUPSD"); vnclog.Print(LL_INTINFO, VNCLOG("GetProcAddress")); /*HRESULT hr =*/ CoInitialize(NULL); result = CheckUserPasswordSDUni(userin, password, machine); vnclog.Print(LL_INTINFO, "CheckUserPasswordSDUni result=%i", result); CoUninitialize(); FreeLibrary(hModule); //result = CheckUserPasswordSDUni(userin, password, machine); } else { LPCTSTR sz_ID_AUTHSSP_NOT_FO = // to be moved to localization.h "You selected ms-logon, but authSSP.dll\nwas not found.Check you installation"; MessageBoxSecure(NULL, sz_ID_AUTHSSP_NOT_FO, sz_ID_WARNING, MB_OK); } } else result = CheckUserGroupPasswordUni2(userin, password, machine); return result; }
int install_service(void) { SC_HANDLE scm, service; pad(); scm=OpenSCManager(0, 0, SC_MANAGER_CREATE_SERVICE); if(!scm) { MessageBoxSecure(NULL, "Failed to open service control manager", app_name, MB_ICONERROR); return 1; } //"Provides secure remote desktop sharing" service=CreateService(scm,service_name, service_name, SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, service_path, NULL, NULL, VNCDEPENDENCIES, NULL, NULL); if(!service) { DWORD myerror=GetLastError(); if (myerror==ERROR_ACCESS_DENIED) { MessageBoxSecure(NULL, "Failed: Permission denied", app_name, MB_ICONERROR); CloseServiceHandle(scm); return 1; } if (myerror==ERROR_SERVICE_EXISTS) { //MessageBoxSecure(NULL, "Failed: Already exist", //"UltraVnc", MB_ICONERROR); CloseServiceHandle(scm); return 1; } MessageBoxSecure(NULL, "Failed to create a new service", app_name, MB_ICONERROR); CloseServiceHandle(scm); return 1; } else set_service_description(); CloseServiceHandle(service); CloseServiceHandle(scm); return 0; }
void vncPropertiesPoll::Save() { HKEY appkey; DWORD dw; // NEW (R3) PREFERENCES ALGORITHM // The user's prefs are only saved if the user is allowed to override // the machine-local settings specified for them. Otherwise, the // properties entry on the tray icon menu will be greyed out. // GET THE CORRECT KEY TO READ FROM if (m_usersettings) { // Verify that we know who is logged on char username[UNLEN+1]; if (!vncService::CurrentUser((char *)&username, sizeof(username))) return; if (strcmp(username, "") == 0) return; // Try to get the per-user, global registry key for WinVNC if (RegCreateKeyEx(HKEY_CURRENT_USER, WINVNC_REGISTRY_KEY, 0, REG_NONE, REG_OPTION_NON_VOLATILE, KEY_WRITE | KEY_READ, NULL, &appkey, &dw) != ERROR_SUCCESS) return; } else { // Try to get the default local registry key for WinVNC HKEY hkLocal; if (RegCreateKeyEx(HKEY_LOCAL_MACHINE, WINVNC_REGISTRY_KEY, 0, REG_NONE, REG_OPTION_NON_VOLATILE, KEY_READ, NULL, &hkLocal, &dw) != ERROR_SUCCESS) { MessageBoxSecure(NULL, sz_ID_MB1, sz_ID_WVNC, MB_OK); return; } if (RegCreateKeyEx(hkLocal, "Default", 0, REG_NONE, REG_OPTION_NON_VOLATILE, KEY_WRITE | KEY_READ, NULL, &appkey, &dw) != ERROR_SUCCESS) { RegCloseKey(hkLocal); return; } RegCloseKey(hkLocal); } // SAVE PER-USER PREFS IF ALLOWED SaveUserPrefsPoll(appkey); RegCloseKey(appkey); RegCloseKey(HKEY_CURRENT_USER); }
output_message (j_common_ptr cinfo) { char buffer[JMSG_LENGTH_MAX]; /* Create the message */ (*cinfo->err->format_message) (cinfo, buffer); #ifdef USE_WINDOWS_MESSAGEBOX /* Display it in a message dialog box */ MessageBoxSecure(GetActiveWindow(), buffer, "JPEG Library Error", MB_OK | MB_ICONERROR); #else /* Send it to stderr, adding a newline */ fprintf(stderr, "%s\n", buffer); #endif }
BOOL CALLBACK vncConnDialog::vncConnDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { // This is a static method, so we don't know which instantiation we're // dealing with. But we can get a pseudo-this from the parameter to // WM_INITDIALOG, which we therafter store with the window and retrieve // as follows: vncConnDialog *_this = helper::SafeGetWindowUserData<vncConnDialog>(hwnd); switch (uMsg) { case WM_PAINT: { //adzm 2009-06-20 if (GetUpdateRect(hwnd, NULL, TRUE)) { PAINTSTRUCT ps; HDC hdc = BeginPaint(hwnd, &ps); { RECT rcIcon; rcIcon.top = 0; rcIcon.left = 0; rcIcon.bottom = 48; rcIcon.right = 48; RECT rcClient; if (GetClientRect(hwnd, &rcClient)) { int nDifference = (rcClient.bottom - rcIcon.bottom) / 2; if (nDifference > 0) { rcIcon.top += nDifference; rcIcon.bottom += nDifference; } } RECT rcLabel; HWND hwndLabel = GetDlgItem(hwnd, IDC_CONNECTION_NUMBER_STATIC); if (GetWindowRect(hwndLabel, &rcLabel)) { LPRECT lprcLabel = &rcLabel; ScreenToClient(hwnd, (LPPOINT)lprcLabel); ScreenToClient(hwnd, ((LPPOINT)lprcLabel)+1); int nAdjustment = (rcLabel.left - rcIcon.right) / 2; rcIcon.left += nAdjustment; rcIcon.right += nAdjustment; } RECT rcIntersect; if (IntersectRect(&rcIntersect, &rcIcon, &(ps.rcPaint))) { if (_this->m_hicon == NULL) { _this->m_hicon = (HICON)LoadImage(hInstResDLL, MAKEINTRESOURCE(IDI_WINVNC), IMAGE_ICON, 48, 48, 0); } if (_this->m_hicon) { HBRUSH hbr = (HBRUSH)SendMessage(hwnd, WM_CTLCOLORDLG, (WPARAM)hdc, (WPARAM)hwnd); DrawIconEx(hdc, rcIcon.left, rcIcon.top, _this->m_hicon, 48, 48, 0, hbr, DI_NORMAL); } } } EndPaint(hwnd, &ps); } return 0; } // Dialog has just been created case WM_INITDIALOG: { // Save the lParam into our user data so that subsequent calls have // access to the parent C++ object helper::SafeSetWindowUserData(hwnd, lParam); vncConnDialog *_this = (vncConnDialog *) lParam; //adzm 2009-06-20 if (g_szRepeaterHost) { SetDlgItemText(hwnd, IDC_HOSTNAME_EDIT, g_szRepeaterHost); //adzm 2009-06-20 if (SPECIAL_SC_PROMPT) { HWND hwndChild = GetDlgItem(hwnd, IDC_HOSTNAME_EDIT); if (hwndChild) { ShowWindow(hwndChild, SW_HIDE); } hwndChild = GetDlgItem(hwnd, IDC_HOSTNAME_STATIC); if (hwndChild) { ShowWindow(hwndChild, SW_HIDE); } HWND hwndEdit = GetDlgItem(hwnd, IDC_IDCODE); HWND hwndLabel = GetDlgItem(hwnd, IDC_CONNECTION_NUMBER_STATIC); RECT rcEdit; RECT rcLabel; GetWindowRect(hwndEdit, &rcEdit); GetWindowRect(hwndLabel, &rcLabel); LPRECT lprcEdit = &rcEdit; LPRECT lprcLabel = &rcLabel; ScreenToClient(hwnd, (LPPOINT)lprcEdit); ScreenToClient(hwnd, ((LPPOINT)lprcEdit)+1); ScreenToClient(hwnd, (LPPOINT)lprcLabel); ScreenToClient(hwnd, ((LPPOINT)lprcLabel)+1); RECT rcClient; GetClientRect(hwnd, &rcClient); long nTotalHeight = rcEdit.bottom - rcLabel.top; long nAdjustedTop = (rcClient.bottom - nTotalHeight) / 2; long nAdjustment = nAdjustedTop - rcLabel.top; MoveWindow(hwndLabel, rcLabel.left, rcLabel.top + nAdjustment, rcLabel.right - rcLabel.left, rcLabel.bottom - rcLabel.top, TRUE); MoveWindow(hwndEdit, rcEdit.left, rcEdit.top + nAdjustment, rcEdit.right - rcEdit.left, rcEdit.bottom - rcEdit.top, TRUE); HWND hwndCaption = GetDlgItem(hwnd, IDC_CAPTION_STATIC); HFONT hFont = (HFONT)SendMessage(hwndCaption, WM_GETFONT, 0, 0); if (hFont) { LOGFONT lf; if (GetObject(hFont, sizeof(LOGFONT), &lf)) { lf.lfWidth = 0; lf.lfHeight = (lf.lfHeight * 6) / 4; _this->m_hfont = CreateFontIndirect(&lf); if (_this->m_hfont) { SendMessage(hwndCaption, WM_SETFONT, (WPARAM)_this->m_hfont, (LPARAM)TRUE); } } } SetWindowText(hwndCaption, "Connect to Technical Support"); ShowWindow(hwndCaption, SW_SHOWNA); } SetFocus(GetDlgItem(hwnd, IDC_IDCODE)); } else { // Make the text entry box active SetFocus(GetDlgItem(hwnd, IDC_HOSTNAME_EDIT)); } SetForegroundWindow(hwnd); // Return success! return TRUE; } // Dialog has just received a command case WM_COMMAND: switch (LOWORD(wParam)) { // User clicked OK or pressed return case IDOK: { // sf@2002 - host:num & host::num analyse. // Compatible with both RealVNC and TightVNC methods char hostname[_MAX_PATH]; char actualhostname[_MAX_PATH]; char idcode[_MAX_PATH]; char *portp; int port; bool id; // Get the hostname of the VNCviewer GetDlgItemText(hwnd, IDC_HOSTNAME_EDIT, hostname, _MAX_PATH); GetDlgItemText(hwnd, IDC_IDCODE, idcode, _MAX_PATH); if (strcmp(idcode,"")==0) id=false; else id=true; strcpy(actualhostname, hostname); //adzm 2010-02-15 - Multiple repeaters chosen by modulo of ID char finalidcode[_MAX_PATH]; //adzm 2010-08 - this was sending uninitialized data over the wire ZeroMemory(finalidcode, sizeof(finalidcode)); //adzm 2009-06-20 if (id) { size_t i = 0; for (i = 0; i < strlen(idcode); i++) { finalidcode[i] = toupper(idcode[i]); } finalidcode[i] = 0; if (0 != strncmp("ID:", idcode, 3)) { strcpy(finalidcode, "ID:"); for (i = 0; i < strlen(idcode); i++) { finalidcode[i+3] = toupper(idcode[i]); } finalidcode[i+3] = 0; } //adzm 2010-02-15 - At this point, finalidcode is of the form "ID:#####" int numericId = atoi(finalidcode + 3); int numberOfHosts = 1; for (i = 0; i < strlen(hostname); i++) { if (hostname[i] == ';') { numberOfHosts++; } } if (numberOfHosts <= 1) { // then hostname == actualhostname } else { int modulo = numericId % numberOfHosts; char* szToken = strtok(hostname, ";"); while (szToken) { if (modulo == 0) { strcpy(actualhostname, szToken); break; } modulo--; szToken = strtok(NULL, ";"); } } } // Calculate the Display and Port offset. port = INCOMING_PORT_OFFSET; portp = strchr(actualhostname, ':'); if (portp) { *portp++ = '\0'; if (*portp == ':') // Tight127 method { port = atoi(++portp); // Port number after "::" } else // RealVNC method { if (atoi(portp) < 100) // If < 100 after ":" -> display number port += atoi(portp); else port = atoi(portp); // If > 100 after ":" -> Port number } } // Attempt to create a new socket VSocket *tmpsock; tmpsock = new VSocket; if (!tmpsock) { return TRUE; } // Connect out to the specified host on the VNCviewer listen port // To be really good, we should allow a display number here but // for now we'll just assume we're connecting to display zero tmpsock->Create(); if (tmpsock->Connect(actualhostname, port)) { if (id) { tmpsock->Send(finalidcode,250); tmpsock->SetTimeout(0); /* if (strncmp(hostname,"ID",2)!=0) { while (true) { char result[1]; tmpsock->Read(result,1); if (strcmp(result,"2")==0) break; tmpsock->Send("1",1); } }*/ // adzm 2009-07-05 - repeater IDs // Add the new client to this server // adzm 2009-08-02 _this->m_server->AddClient(tmpsock, TRUE, TRUE, 0, NULL, finalidcode, actualhostname, port); } else { // Add the new client to this server // adzm 2009-08-02 _this->m_server->AddClient(tmpsock, TRUE, TRUE, 0, NULL, NULL, actualhostname, port); } // And close the dialog EndDialog(hwnd, TRUE); } else { // Print up an error message MessageBoxSecure(NULL, sz_ID_FAILED_CONNECT_LISTING_VIEW, sz_ID_OUTGOING_CONNECTION, MB_OK | MB_ICONEXCLAMATION ); delete tmpsock; } return TRUE; } // Cancel the dialog case IDCANCEL: EndDialog(hwnd, FALSE); return TRUE; }; break; case WM_DESTROY: EndDialog(hwnd, FALSE); if (_this->m_hicon != NULL) { DestroyIcon(_this->m_hicon); _this->m_hicon = NULL; } if (_this->m_hfont != NULL) { DeleteObject(_this->m_hfont); _this->m_hfont = NULL; } return TRUE; } return 0; }
// 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; }
// winvnc.exe will also be used for helper exe // This allow us to minimize the number of seperate exe bool Myinit(HINSTANCE hInstance) { 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) ; 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); return 0; } return 1; }
int WinVNCAppMain() { vnclog.Print(LL_INTINFO, VNCLOG("***** DBG - WinVNCAPPMain\n")); #ifdef CRASH_ENABLED LPVOID lpvState = Install(NULL, "*****@*****.**", "UltraVNC"); #endif // Set this process to be the last application to be shut down. // Check for previous instances of WinVNC! vncInstHandler *instancehan=new vncInstHandler; if (!multi) // this allow to overwrite the multiple instance check { if (!instancehan->Init()) { vnclog.Print(LL_INTINFO, VNCLOG("%s -- exiting\n"), sz_ID_ANOTHER_INST); // We don't allow multiple instances! if (!fRunningFromExternalService) MessageBoxSecure(NULL, sz_ID_ANOTHER_INST, szAppName, MB_OK); if (instancehan != NULL) delete instancehan; return 0; } } //vnclog.Print(LL_INTINFO, VNCLOG("***** DBG - Previous instance checked - Trying to create server\n")); // CREATE SERVER vncServer server; // Set the name and port number server.SetName(szAppName); vnclog.Print(LL_STATE, VNCLOG("server created ok\n")); ///uninstall driver before cont // sf@2007 - Set Application0 special mode server.RunningFromExternalService(fRunningFromExternalService); // sf@2007 - New impersonation thread stuff for tray icon & menu // Subscribe to shutdown event hShutdownEvent = OpenEvent(EVENT_ALL_ACCESS, FALSE, "Global\\SessionEventUltra"); hShutdownEventcad = OpenEvent(EVENT_MODIFY_STATE, FALSE, "Global\\SessionEventUltraCad"); if (hShutdownEvent) ResetEvent(hShutdownEvent); vnclog.Print(LL_STATE, VNCLOG("***************** SDEvent created \n")); // Create the timer that looks periodicaly for shutdown event mmRes = -1; //InitSDTimer(); while ( !fShutdownOrdered) { //vnclog.Print(LL_STATE, VNCLOG("################## Creating Imp Thread : %d \n"), nn); HANDLE threadHandle; DWORD dwTId; threadHandle = CreateThread(NULL, 0, imp_desktop_thread, &server, 0, &dwTId); if (threadHandle) { WaitForSingleObject( threadHandle, INFINITE ); CloseHandle(threadHandle); } vnclog.Print(LL_STATE, VNCLOG("################## Closing Imp Thread\n")); } //KillSDTimer(); if (instancehan!=NULL) delete instancehan; if (hShutdownEvent)CloseHandle(hShutdownEvent); if (hShutdownEventcad)CloseHandle(hShutdownEventcad); vnclog.Print(LL_STATE, VNCLOG("################## SHUTING DOWN SERVER ####################\n")); //adzm 2009-06-20 if (g_szRepeaterHost) { delete[] g_szRepeaterHost; g_szRepeaterHost = NULL; } return 1; };
int uninstall_service(void) { SC_HANDLE scm, service; SERVICE_STATUS serviceStatus; scm=OpenSCManager(0, 0, SC_MANAGER_CONNECT); if(!scm) { MessageBoxSecure(NULL, "Failed to open service control manager", app_name, MB_ICONERROR); return 1; } service=OpenService(scm, service_name, SERVICE_QUERY_STATUS | DELETE); if(!service) { DWORD myerror=GetLastError(); if (myerror==ERROR_ACCESS_DENIED) { MessageBoxSecure(NULL, "Failed: Permission denied", app_name, MB_ICONERROR); CloseServiceHandle(scm); return 1; } if (myerror==ERROR_SERVICE_DOES_NOT_EXIST) { #if 0 MessageBoxSecure(NULL, "Failed: Service is not installed", app_name, MB_ICONERROR); #endif CloseServiceHandle(scm); return 1; } MessageBoxSecure(NULL, "Failed to open the service", app_name, MB_ICONERROR); CloseServiceHandle(scm); return 1; } if(!QueryServiceStatus(service, &serviceStatus)) { MessageBoxSecure(NULL, "Failed to query service status", app_name, MB_ICONERROR); CloseServiceHandle(service); CloseServiceHandle(scm); return 1; } if(serviceStatus.dwCurrentState!=SERVICE_STOPPED) { //MessageBoxSecure(NULL, "The service is still running, disable it first", // "UltraVnc", MB_ICONERROR); CloseServiceHandle(service); CloseServiceHandle(scm); Sleep(2500);uninstall_service(); return 1; } if(!DeleteService(service)) { MessageBoxSecure(NULL, "Failed to delete the service", app_name, MB_ICONERROR); CloseServiceHandle(service); CloseServiceHandle(scm); return 1; } CloseServiceHandle(service); CloseServiceHandle(scm); return 0; }
bool CheckVideoDriver(bool Box) { typedef BOOL (WINAPI* pEnumDisplayDevices)(PVOID,DWORD,PVOID,DWORD); pEnumDisplayDevices pd=NULL; LPSTR driverName = "mv video hook driver2"; BOOL DriverFound; DEVMODE devmode; FillMemory(&devmode, sizeof(DEVMODE), 0); devmode.dmSize = sizeof(DEVMODE); devmode.dmDriverExtra = 0; /*BOOL change = */EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,&devmode); devmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; HMODULE hUser32=LoadLibrary("USER32"); if (hUser32) pd = (pEnumDisplayDevices)GetProcAddress( hUser32, "EnumDisplayDevicesA"); if (pd) { LPSTR deviceName=NULL; DISPLAY_DEVICE dd; ZeroMemory(&dd, sizeof(dd)); dd.cb = sizeof(dd); devmode.dmDeviceName[0] = '\0'; INT devNum = 0; BOOL result; DriverFound=false; while ((result = (*pd)(NULL,devNum, &dd,0))) { if (strcmp((const char *)&dd.DeviceString[0], driverName) == 0) { DriverFound=true; break; } devNum++; } if (DriverFound) { if (hUser32) FreeLibrary(hUser32); if(Box) { char buf[512]; GetDllProductVersion("mv2.dll",buf,512); if (dd.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) { strcat(buf," driver Active"); HDC testdc=NULL; deviceName = (LPSTR)&dd.DeviceName[0]; testdc = CreateDC("DISPLAY",deviceName,NULL,NULL); if (testdc) { DeleteDC(testdc); strcat(buf," access ok"); } else { strcat(buf," access denied, permission problem"); } } else strcat(buf," driver Not Active"); MessageBoxSecure(NULL,buf,"driver info: required version 1.22",0); } return true; } else if(Box) MessageBoxSecure(NULL,"Driver not found: Perhaps you need to reboot after install","driver info: required version 1.22",0); } if (hUser32) FreeLibrary(hUser32); return false; }
DWORD WINAPI Cadthread(LPVOID lpParam) { OSVERSIONINFO OSversion; OSversion.dwOSVersionInfoSize=sizeof(OSVERSIONINFO); GetVersionEx(&OSversion); HDESK desktop=NULL; desktop = OpenInputDesktop(0, FALSE, DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW | DESKTOP_ENUMERATE | DESKTOP_HOOKCONTROL | DESKTOP_WRITEOBJECTS | DESKTOP_READOBJECTS | DESKTOP_SWITCHDESKTOP | GENERIC_WRITE ); if (desktop == NULL) vnclog.Print(LL_INTERR, VNCLOG("OpenInputdesktop Error \n")); else vnclog.Print(LL_INTERR, VNCLOG("OpenInputdesktop OK\n")); HDESK old_desktop = GetThreadDesktop(GetCurrentThreadId()); DWORD dummy; char new_name[256]; if (desktop) { if (!GetUserObjectInformation(desktop, UOI_NAME, &new_name, 256, &dummy)) { vnclog.Print(LL_INTERR, VNCLOG("!GetUserObjectInformation \n")); } vnclog.Print(LL_INTERR, VNCLOG("SelectHDESK to %s (%x) from %x\n"), new_name, desktop, old_desktop); if (!SetThreadDesktop(desktop)) { vnclog.Print(LL_INTERR, VNCLOG("SelectHDESK:!SetThreadDesktop \n")); } } ////// if(OSversion.dwMajorVersion>=6 && vncService::RunningAsService()) { if( vncService::RunningAsService() &&!IsSoftwareCadEnabled()) { DWORD result=MessageBoxSecure(NULL,"UAC is Disable, make registry changes to allow cad","Warning",MB_YESNO); if (result==IDYES) { HANDLE hProcess=NULL,hPToken=NULL; DWORD id=GetExplorerLogonPid(); if (id!=0) { hProcess = OpenProcess(MAXIMUM_ALLOWED,FALSE,id); if (!hProcess) goto error; if(!OpenProcessToken(hProcess,TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY |TOKEN_DUPLICATE|TOKEN_ASSIGN_PRIMARY|TOKEN_ADJUST_SESSIONID | TOKEN_READ | TOKEN_WRITE, &hPToken)) { CloseHandle(hProcess); goto error; } char dir[MAX_PATH]; char exe_file_name[MAX_PATH]; GetModuleFileName(0, exe_file_name, MAX_PATH); strcpy(dir, exe_file_name); strcat(dir, " -softwarecadhelper"); STARTUPINFO StartUPInfo; PROCESS_INFORMATION ProcessInfo; HANDLE Token=NULL; HANDLE process=NULL; ZeroMemory(&StartUPInfo,sizeof(STARTUPINFO)); ZeroMemory(&ProcessInfo,sizeof(PROCESS_INFORMATION)); StartUPInfo.wShowWindow = SW_SHOW; StartUPInfo.lpDesktop = "Winsta0\\Default"; StartUPInfo.cb = sizeof(STARTUPINFO); CreateProcessAsUser(hPToken,NULL,dir,NULL,NULL,FALSE,DETACHED_PROCESS,NULL,NULL,&StartUPInfo,&ProcessInfo); DWORD errorcode=GetLastError(); if (process) CloseHandle(process); if (Token) CloseHandle(Token); if (ProcessInfo.hProcess) CloseHandle(ProcessInfo.hProcess); if (ProcessInfo.hThread) CloseHandle(ProcessInfo.hThread); if (errorcode == 1314) goto error; goto gotome; error: Enable_softwareCAD_elevated(); } } } } gotome: ///////////////////// if(OSversion.dwMajorVersion==6)//&& OSversion.dwMinorVersion>=1) //win7 // test win7 +Vista { if (hShutdownEventcad==NULL ) hShutdownEventcad = OpenEvent(EVENT_MODIFY_STATE, FALSE, "Global\\SessionEventUltraCad"); if (hShutdownEventcad!=NULL ) SetEvent(hShutdownEventcad); if (old_desktop) SetThreadDesktop(old_desktop); if (desktop) CloseDesktop(desktop); return 0; } HKEY hKey; DWORD isLUAon = 0; if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System"), 0, KEY_READ, &hKey) == ERROR_SUCCESS) { DWORD LUAbufSize = 4; RegQueryValueEx(hKey, TEXT("EnableLUA"), NULL, NULL, (LPBYTE)&isLUAon, &LUAbufSize); RegCloseKey(hKey); } if (isLUAon != 1 && OSversion.dwMajorVersion==6) { if (hShutdownEventcad==NULL ) hShutdownEventcad = OpenEvent(EVENT_MODIFY_STATE, FALSE, "Global\\SessionEventUltraCad"); if (hShutdownEventcad!=NULL ) SetEvent(hShutdownEventcad); if (old_desktop) SetThreadDesktop(old_desktop); if (desktop) CloseDesktop(desktop); return 0; } //Full path needed, sometimes it just default to system32 char WORKDIR[MAX_PATH]; char mycommand[MAX_PATH]; if (GetModuleFileName(NULL, WORKDIR, MAX_PATH)) { char* p = strrchr(WORKDIR, '\\'); if (p == NULL) return 0; *p = '\0'; } strcpy(mycommand,""); strcat(mycommand,WORKDIR);//set the directory strcat(mycommand,"\\"); strcat(mycommand,"cad.exe"); int nr=(LONG_PTR)ShellExecute(GetDesktopWindow(), "open", mycommand, "", 0, SW_SHOWNORMAL); if (nr<=32) { //error // if ( nr==SE_ERR_ACCESSDENIED ) vncTimedMsgBox::Do( sz_ID_CADPERMISSION, sz_ID_ULTRAVNC_WARNING, MB_ICONINFORMATION | MB_OK ); if ( nr==ERROR_PATH_NOT_FOUND || nr==ERROR_FILE_NOT_FOUND) vncTimedMsgBox::Do( sz_ID_CADERRORFILE, sz_ID_ULTRAVNC_WARNING, MB_ICONINFORMATION | MB_OK ); } if (old_desktop) SetThreadDesktop(old_desktop); if (desktop) CloseDesktop(desktop); return 0; }
int CheckUserGroupPasswordUni2(char * userin,char *password,const char *machine) { int result=0; BOOL NT4OS=false; BOOL W2KOS=false; char clientname[256]; strcpy_s(clientname,256,machine); if (!CheckNetapi95() && !CheckNetApiNT()) { return false; } OSVERSIONINFO VerInfo; VerInfo.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); if (!GetVersionEx (&VerInfo)) // If this fails, something has gone wrong { return FALSE; } if (VerInfo.dwPlatformId == VER_PLATFORM_WIN32_NT && VerInfo.dwMajorVersion == 4) { NT4OS=true; } if (VerInfo.dwPlatformId == VER_PLATFORM_WIN32_NT && VerInfo.dwMajorVersion >= 5) { W2KOS=true; } ////////////////////////////////////////////////// // Load reg settings ////////////////////////////////////////////////// char pszgroup1[256]; char pszgroup2[256]; char pszgroup3[256]; char *group1=NULL; char *group2=NULL; char *group3=NULL; long locdom1=1; long locdom2=0; long locdom3=0; group1=Readgroup1(); group2=Readgroup2(); group3=Readgroup3(); locdom1=Readlocdom1(locdom1); locdom2=Readlocdom2(locdom2); locdom3=Readlocdom3(locdom3); strcpy(pszgroup1,"VNCACCESS"); strcpy(pszgroup2,"Administrators"); strcpy(pszgroup3,"VNCVIEWONLY"); if (group1){strcpy(pszgroup1,group1);} if (group2){strcpy(pszgroup2,group2);} if (group3){strcpy(pszgroup3,group3);} savegroup1(pszgroup1); savegroup2(pszgroup2); savegroup3(pszgroup3); savelocdom1(locdom1); savelocdom2(locdom2); savelocdom3(locdom3); if (group1){strcpy(pszgroup1,group1);delete group1;} if (group2){strcpy(pszgroup2,group2);delete group2;} if (group3){strcpy(pszgroup3,group3);delete group3;} ////////////////////////////////////////////////// // logon user only works on NT> // NT4/w2k only as service (system account) // XP> works also as application // Group is not used...admin access rights is needed // MS keep changes there security model for each version.... ////////////////////////////////////////////////// //////////////////////////////////////////////////// if (strcmp(pszgroup1,"")==0 && strcmp(pszgroup2,"")==0 && strcmp(pszgroup3,"")==0) if ( NT4OS || W2KOS){ char szCurrentDir[MAX_PATH]; if (GetModuleFileName(NULL, szCurrentDir, MAX_PATH)) { char* p = strrchr(szCurrentDir, '\\'); if (p == NULL) return false; *p = '\0'; strcat (szCurrentDir,"\\authadmin.dll"); } HMODULE hModule = LoadLibrary(szCurrentDir); if (hModule) { CheckUserGroupPassword = (CheckUserGroupPasswordFn) GetProcAddress( hModule, "CUGP" ); /*HRESULT hr =*/ CoInitialize(NULL); result=CheckUserGroupPassword(userin,password,clientname,pszgroup1,locdom1); CoUninitialize(); FreeLibrary(hModule); } else { MessageBoxSecure(NULL, "authadmin.dll not found", sz_ID_WARNING, MB_OK); result=0; } } if (result==1) goto accessOK; if (strcmp(pszgroup1,"")!=0) { /////////////////////////////////////////////////// // NT4 domain and workgroups // /////////////////////////////////////////////////// { char szCurrentDir[MAX_PATH]; if (GetModuleFileName(NULL, szCurrentDir, MAX_PATH)) { char* p = strrchr(szCurrentDir, '\\'); if (p == NULL) return false; *p = '\0'; strcat (szCurrentDir,"\\workgrpdomnt4.dll"); } HMODULE hModule = LoadLibrary(szCurrentDir); if (hModule) { CheckUserGroupPassword = (CheckUserGroupPasswordFn) GetProcAddress( hModule, "CUGP" ); /*HRESULT hr =*/ CoInitialize(NULL); result=CheckUserGroupPassword(userin,password,clientname,pszgroup1,locdom1); CoUninitialize(); FreeLibrary(hModule); } else { MessageBoxSecure(NULL, "workgrpdomnt4.dll not found", sz_ID_WARNING, MB_OK); result=0; } } if (result==1) goto accessOK; ///////////////////////////////////////////////////////////////// if (CheckAD() && W2KOS && (locdom1==2||locdom1==3)) { char szCurrentDir[MAX_PATH]; if (GetModuleFileName(NULL, szCurrentDir, MAX_PATH)) { char* p = strrchr(szCurrentDir, '\\'); if (p == NULL) return false; *p = '\0'; strcat (szCurrentDir,"\\ldapauth.dll"); } HMODULE hModule = LoadLibrary(szCurrentDir); if (hModule) { CheckUserGroupPassword = (CheckUserGroupPasswordFn) GetProcAddress( hModule, "CUGP" ); /*HRESULT hr =*/ CoInitialize(NULL); result=CheckUserGroupPassword(userin,password,clientname,pszgroup1,locdom1); CoUninitialize(); FreeLibrary(hModule); } else { MessageBoxSecure(NULL, "ldapauth.dll not found", sz_ID_WARNING, MB_OK); result=0; } } if (result==1) goto accessOK; ////////////////////////////////////////////////////////////////////// if (CheckAD() && NT4OS && CheckDsGetDcNameW() && (locdom1==2||locdom1==3)) { char szCurrentDir[MAX_PATH]; if (GetModuleFileName(NULL, szCurrentDir, MAX_PATH)) { char* p = strrchr(szCurrentDir, '\\'); if (p == NULL) return false; *p = '\0'; strcat (szCurrentDir,"\\ldapauthnt4.dll"); } HMODULE hModule = LoadLibrary(szCurrentDir); if (hModule) { CheckUserGroupPassword = (CheckUserGroupPasswordFn) GetProcAddress( hModule, "CUGP" ); /*HRESULT hr =*/ CoInitialize(NULL); result=CheckUserGroupPassword(userin,password,clientname,pszgroup1,locdom1); CoUninitialize(); FreeLibrary(hModule); } else { MessageBoxSecure(NULL, "ldapauthnt4.dll not found", sz_ID_WARNING, MB_OK); result=0; } } if (result==1) goto accessOK; ////////////////////////////////////////////////////////////////////// if (CheckAD() && !NT4OS && !W2KOS && (locdom1==2||locdom1==3)) { char szCurrentDir[MAX_PATH]; if (GetModuleFileName(NULL, szCurrentDir, MAX_PATH)) { char* p = strrchr(szCurrentDir, '\\'); if (p == NULL) return false; *p = '\0'; strcat (szCurrentDir,"\\ldapauth9x.dll"); } HMODULE hModule = LoadLibrary(szCurrentDir); if (hModule) { CheckUserGroupPassword = (CheckUserGroupPasswordFn) GetProcAddress( hModule, "CUGP" ); /*HRESULT hr =*/ CoInitialize(NULL); result=CheckUserGroupPassword(userin,password,clientname,pszgroup1,locdom1); CoUninitialize(); FreeLibrary(hModule); } else { MessageBoxSecure(NULL, "ldapauth9x.dll not found", sz_ID_WARNING, MB_OK); result=0; } } if (result==1) goto accessOK; } ///////////////////////////////////////////////// if (strcmp(pszgroup2,"")!=0) { /////////////////////////////////////////////////// // NT4 domain and workgroups // /////////////////////////////////////////////////// { char szCurrentDir[MAX_PATH]; if (GetModuleFileName(NULL, szCurrentDir, MAX_PATH)) { char* p = strrchr(szCurrentDir, '\\'); if (p == NULL) return false; *p = '\0'; strcat (szCurrentDir,"\\workgrpdomnt4.dll"); } HMODULE hModule = LoadLibrary(szCurrentDir); if (hModule) { CheckUserGroupPassword = (CheckUserGroupPasswordFn) GetProcAddress( hModule, "CUGP" ); /*HRESULT hr =*/ CoInitialize(NULL); result=CheckUserGroupPassword(userin,password,clientname,pszgroup2,locdom2); CoUninitialize(); FreeLibrary(hModule); } else { MessageBoxSecure(NULL, "workgrpdomnt4.dll not found", sz_ID_WARNING, MB_OK); result=0; } } if (result==1) goto accessOK; ////////////////////////////////////////////////////// if ( NT4OS || W2KOS){ char szCurrentDir[MAX_PATH]; if (GetModuleFileName(NULL, szCurrentDir, MAX_PATH)) { char* p = strrchr(szCurrentDir, '\\'); if (p == NULL) return false; *p = '\0'; strcat (szCurrentDir,"\\authadmin.dll"); } HMODULE hModule = LoadLibrary(szCurrentDir); if (hModule) { CheckUserGroupPassword = (CheckUserGroupPasswordFn) GetProcAddress( hModule, "CUGP" ); /*HRESULT hr =*/ CoInitialize(NULL); result=CheckUserGroupPassword(userin,password,clientname,pszgroup2,locdom2); CoUninitialize(); FreeLibrary(hModule); } else { MessageBoxSecure(NULL, "authadmin.dll not found", sz_ID_WARNING, MB_OK); result=0; } } if (result==1) goto accessOK; ////////////////////////////////////////////////////////////////// if (CheckAD() && W2KOS && (locdom2==2||locdom2==3)) { char szCurrentDir[MAX_PATH]; if (GetModuleFileName(NULL, szCurrentDir, MAX_PATH)) { char* p = strrchr(szCurrentDir, '\\'); if (p == NULL) return false; *p = '\0'; strcat (szCurrentDir,"\\ldapauth.dll"); } HMODULE hModule = LoadLibrary(szCurrentDir); if (hModule) { CheckUserGroupPassword = (CheckUserGroupPasswordFn) GetProcAddress( hModule, "CUGP" ); /*HRESULT hr =*/ CoInitialize(NULL); result=CheckUserGroupPassword(userin,password,clientname,pszgroup2,locdom2); CoUninitialize(); FreeLibrary(hModule); } else { MessageBoxSecure(NULL, "ldapauth.dll not found", sz_ID_WARNING, MB_OK); result=0; } } if (result==1) goto accessOK; /////////////////////////////////////////////////////////////////////// if (CheckAD() && NT4OS && CheckDsGetDcNameW() && (locdom2==2||locdom2==3)) { char szCurrentDir[MAX_PATH]; if (GetModuleFileName(NULL, szCurrentDir, MAX_PATH)) { char* p = strrchr(szCurrentDir, '\\'); if (p == NULL) return false; *p = '\0'; strcat (szCurrentDir,"\\ldapauthnt4.dll"); } HMODULE hModule = LoadLibrary(szCurrentDir); if (hModule) { CheckUserGroupPassword = (CheckUserGroupPasswordFn) GetProcAddress( hModule, "CUGP" ); /*HRESULT hr =*/ CoInitialize(NULL); result=CheckUserGroupPassword(userin,password,clientname,pszgroup2,locdom2); CoUninitialize(); FreeLibrary(hModule); } else { MessageBoxSecure(NULL, "ldapauthnt4.dll not found", sz_ID_WARNING, MB_OK); result=0; } } if (result==1) goto accessOK; /////////////////////////////////////////////////////////////////////// if (CheckAD() && !NT4OS && !W2KOS && (locdom2==2||locdom2==3)) { char szCurrentDir[MAX_PATH]; if (GetModuleFileName(NULL, szCurrentDir, MAX_PATH)) { char* p = strrchr(szCurrentDir, '\\'); if (p == NULL) return false; *p = '\0'; strcat (szCurrentDir,"\\ldapauth9x.dll"); } HMODULE hModule = LoadLibrary(szCurrentDir); if (hModule) { CheckUserGroupPassword = (CheckUserGroupPasswordFn) GetProcAddress( hModule, "CUGP" ); /*HRESULT hr =*/ CoInitialize(NULL); result=CheckUserGroupPassword(userin,password,clientname,pszgroup2,locdom2); CoUninitialize(); FreeLibrary(hModule); } else { MessageBoxSecure(NULL, "ldapauth9x.dll not found", sz_ID_WARNING, MB_OK); result=0; } } if (result==1) goto accessOK; } //////////////////////////// if (strcmp(pszgroup3,"")!=0) { /////////////////////////////////////////////////// // NT4 domain and workgroups // /////////////////////////////////////////////////// { char szCurrentDir[MAX_PATH]; if (GetModuleFileName(NULL, szCurrentDir, MAX_PATH)) { char* p = strrchr(szCurrentDir, '\\'); if (p == NULL) return false; *p = '\0'; strcat (szCurrentDir,"\\workgrpdomnt4.dll"); } HMODULE hModule = LoadLibrary(szCurrentDir); if (hModule) { CheckUserGroupPassword = (CheckUserGroupPasswordFn) GetProcAddress( hModule, "CUGP" ); /*HRESULT hr =*/ CoInitialize(NULL); result=CheckUserGroupPassword(userin,password,clientname,pszgroup3,locdom3); CoUninitialize(); FreeLibrary(hModule); } else { MessageBoxSecure(NULL, "workgrpdomnt4.dll not found", sz_ID_WARNING, MB_OK); result=0; } } if (result==1) goto accessOK; //////////////////////////////////////////////////////// if ( NT4OS || W2KOS){ char szCurrentDir[MAX_PATH]; if (GetModuleFileName(NULL, szCurrentDir, MAX_PATH)) { char* p = strrchr(szCurrentDir, '\\'); if (p == NULL) return false; *p = '\0'; strcat (szCurrentDir,"\\authadmin.dll"); } HMODULE hModule = LoadLibrary(szCurrentDir); if (hModule) { CheckUserGroupPassword = (CheckUserGroupPasswordFn) GetProcAddress( hModule, "CUGP" ); /*HRESULT hr =*/ CoInitialize(NULL); result=CheckUserGroupPassword(userin,password,clientname,pszgroup3,locdom3); CoUninitialize(); FreeLibrary(hModule); } else { MessageBoxSecure(NULL, "authadmin.dll not found", sz_ID_WARNING, MB_OK); result=0; } } if (result==1) goto accessOK; //////////////////////////////////////////////////////////////// if (CheckAD() && W2KOS && (locdom3==2||locdom3==3)) { char szCurrentDir[MAX_PATH]; if (GetModuleFileName(NULL, szCurrentDir, MAX_PATH)) { char* p = strrchr(szCurrentDir, '\\'); if (p == NULL) return false; *p = '\0'; strcat (szCurrentDir,"\\ldapauth.dll"); } HMODULE hModule = LoadLibrary(szCurrentDir); if (hModule) { CheckUserGroupPassword = (CheckUserGroupPasswordFn) GetProcAddress( hModule, "CUGP" ); /*HRESULT hr =*/ CoInitialize(NULL); result=CheckUserGroupPassword(userin,password,clientname,pszgroup3,locdom3); CoUninitialize(); FreeLibrary(hModule); } else { MessageBoxSecure(NULL, "ldapauth.dll not found", sz_ID_WARNING, MB_OK); result=0; } } if (result==1) goto accessOK; /////////////////////////////////////////////////////////////////// if (CheckAD() && NT4OS && CheckDsGetDcNameW() && (locdom3==2||locdom3==3)) { char szCurrentDir[MAX_PATH]; if (GetModuleFileName(NULL, szCurrentDir, MAX_PATH)) { char* p = strrchr(szCurrentDir, '\\'); if (p == NULL) return false; *p = '\0'; strcat (szCurrentDir,"\\ldapauthnt4.dll"); } HMODULE hModule = LoadLibrary(szCurrentDir); if (hModule) { CheckUserGroupPassword = (CheckUserGroupPasswordFn) GetProcAddress( hModule, "CUGP" ); /*HRESULT hr =*/ CoInitialize(NULL); result=CheckUserGroupPassword(userin,password,clientname,pszgroup3,locdom3); CoUninitialize(); FreeLibrary(hModule); } else { MessageBoxSecure(NULL, "ldapauthnt4.dll not found", sz_ID_WARNING, MB_OK); result=0; } } if (result==1) goto accessOK2; /////////////////////////////////////////////////////////////////// if (CheckAD() && !NT4OS && !W2KOS && (locdom3==2||locdom3==3)) { char szCurrentDir[MAX_PATH]; if (GetModuleFileName(NULL, szCurrentDir, MAX_PATH)) { char* p = strrchr(szCurrentDir, '\\'); if (p == NULL) return false; *p = '\0'; strcat (szCurrentDir,"\\ldapauth9x.dll"); } HMODULE hModule = LoadLibrary(szCurrentDir); if (hModule) { CheckUserGroupPassword = (CheckUserGroupPasswordFn) GetProcAddress( hModule, "CUGP" ); /*HRESULT hr =*/ CoInitialize(NULL); result=CheckUserGroupPassword(userin,password,clientname,pszgroup3,locdom3); CoUninitialize(); FreeLibrary(hModule); } else { MessageBoxSecure(NULL, "ldapauth9x.dll not found", sz_ID_WARNING, MB_OK); result=0; } } if (result==1) goto accessOK2; } ///////////////////////////////////////////////// // If we reach this place auth failed ///////////////////////////////////////////////// { typedef BOOL (*LogeventFn)(char *machine,char *user); LogeventFn Logevent = 0; char szCurrentDir[MAX_PATH]; if (GetModuleFileName(NULL, szCurrentDir, MAX_PATH)) { char* p = strrchr(szCurrentDir, '\\'); *p = '\0'; strcat (szCurrentDir,"\\logging.dll"); } HMODULE hModule = LoadLibrary(szCurrentDir); if (hModule) { Logevent = (LogeventFn) GetProcAddress( hModule, "LOGFAILEDUSER" ); Logevent((char *)clientname,userin); FreeLibrary(hModule); } return result; } accessOK://full access { typedef BOOL (*LogeventFn)(char *machine,char *user); LogeventFn Logevent = 0; char szCurrentDir[MAX_PATH]; if (GetModuleFileName(NULL, szCurrentDir, MAX_PATH)) { char* p = strrchr(szCurrentDir, '\\'); *p = '\0'; strcat (szCurrentDir,"\\logging.dll"); } HMODULE hModule = LoadLibrary(szCurrentDir); if (hModule) { Logevent = (LogeventFn) GetProcAddress( hModule, "LOGLOGONUSER" ); Logevent((char *)clientname,userin); FreeLibrary(hModule); } return result; } accessOK2://readonly { typedef BOOL (*LogeventFn)(char *machine,char *user); LogeventFn Logevent = 0; char szCurrentDir[MAX_PATH]; if (GetModuleFileName(NULL, szCurrentDir, MAX_PATH)) { char* p = strrchr(szCurrentDir, '\\'); *p = '\0'; strcat (szCurrentDir,"\\logging.dll"); } HMODULE hModule = LoadLibrary(szCurrentDir); if (hModule) { Logevent = (LogeventFn) GetProcAddress( hModule, "LOGLOGONUSER" ); Logevent((char *)clientname,userin); FreeLibrary(hModule); } result=2; } return result; }
void Copy_to_Secure_from_temp_helper(char *lpCmdLine) { IniFile myIniFile_In; IniFile myIniFile_Out; myIniFile_Out.IniFileSetSecure(); myIniFile_In.IniFileSetTemp(lpCmdLine); TCHAR *group1=new char[150]; TCHAR *group2=new char[150]; TCHAR *group3=new char[150]; BOOL BUseRegistry; LONG MSLogonRequired; LONG NewMSLogon; LONG locdom1; LONG locdom2; LONG locdom3; LONG DebugMode=2; LONG Avilog=0; LONG DebugLevel=10; LONG DisableTrayIcon; LONG LoopbackOnly; LONG UseDSMPlugin; LONG AllowLoopback; LONG AuthRequired; LONG ConnectPriority; char DSMPlugin[128]; char *authhosts=new char[150]; LONG AllowShutdown=1; LONG AllowProperties=1; LONG AllowEditClients=1; LONG FileTransferEnabled=0; LONG FTUserImpersonation=1; LONG BlankMonitorEnabled=1; LONG BlankInputsOnly=0; //PGM LONG DefaultScale=1; LONG CaptureAlphaBlending=1; LONG BlackAlphaBlending=1; LONG SocketConnect=1; LONG HTTPConnect; LONG XDMCPConnect; LONG AutoPortSelect=1; LONG PortNumber; LONG HttpPortNumber; LONG IdleTimeout; LONG RemoveWallpaper=1; LONG RemoveAero=1; LONG QuerySetting=1; LONG QueryTimeout=10; LONG QueryAccept; LONG QueryIfNoLogon; LONG EnableRemoteInputs=1; LONG LockSettings=0; LONG DisableLocalInputs=0; LONG EnableJapInput=0; LONG kickrdp=0; LONG clearconsole=0; #define MAXPWLEN 8 char passwd[MAXPWLEN]; LONG TurboMode=1; LONG PollUnderCursor=0; LONG PollForeground=0; LONG PollFullScreen=1; LONG PollConsoleOnly=0; LONG PollOnEventOnly=0; LONG Driver=0; LONG Hook=1; LONG Virtual; LONG SingleWindow=0; char SingleWindowName[32]; char path[512]; LONG MaxCpu=40; //adzm 2010-05-30 - dsmplugin config char DSMPluginConfig[512]; *DSMPluginConfig = '\0'; LONG Primary=1; LONG Secondary=0; BUseRegistry = myIniFile_In.ReadInt("admin", "UseRegistry", 0); if (!myIniFile_Out.WriteInt("admin", "UseRegistry", BUseRegistry)) { //error MessageBoxSecure(NULL,"Permission denied:Uncheck [_] Protect my computer... in run as dialog or use user with write permission." ,myIniFile_Out.myInifile,MB_ICONERROR); } MSLogonRequired=myIniFile_In.ReadInt("admin", "MSLogonRequired", false); myIniFile_Out.WriteInt("admin", "MSLogonRequired", MSLogonRequired); NewMSLogon=myIniFile_In.ReadInt("admin", "NewMSLogon", false); myIniFile_Out.WriteInt("admin", "NewMSLogon", NewMSLogon); myIniFile_In.ReadString("admin_auth","group1",group1,150); myIniFile_In.ReadString("admin_auth","group2",group2,150); myIniFile_In.ReadString("admin_auth","group3",group3,150); myIniFile_Out.WriteString("admin_auth", "group1",group1); myIniFile_Out.WriteString("admin_auth", "group2",group2); myIniFile_Out.WriteString("admin_auth", "group3",group3); locdom1=myIniFile_In.ReadInt("admin_auth", "locdom1",0); locdom2=myIniFile_In.ReadInt("admin_auth", "locdom2",0); locdom3=myIniFile_In.ReadInt("admin_auth", "locdom3",0); myIniFile_Out.WriteInt("admin_auth", "locdom1", locdom1); myIniFile_Out.WriteInt("admin_auth", "locdom2", locdom2); myIniFile_Out.WriteInt("admin_auth", "locdom3", locdom3); DebugMode=myIniFile_In.ReadInt("admin", "DebugMode", 0); Avilog=myIniFile_In.ReadInt("admin", "Avilog", 0); myIniFile_In.ReadString("admin", "path", path,512); DebugLevel=myIniFile_In.ReadInt("admin", "DebugLevel", 0); DisableTrayIcon=myIniFile_In.ReadInt("admin", "DisableTrayIcon", false); LoopbackOnly=myIniFile_In.ReadInt("admin", "LoopbackOnly", false); myIniFile_Out.WriteInt("admin", "DebugMode", DebugMode); myIniFile_Out.WriteInt("admin", "Avilog", Avilog); myIniFile_Out.WriteString("admin", "path", path); myIniFile_Out.WriteInt("admin", "DebugLevel", DebugLevel); myIniFile_Out.WriteInt("admin", "DisableTrayIcon", DisableTrayIcon); myIniFile_Out.WriteInt("admin", "LoopbackOnly", LoopbackOnly); UseDSMPlugin=myIniFile_In.ReadInt("admin", "UseDSMPlugin", false); AllowLoopback=myIniFile_In.ReadInt("admin", "AllowLoopback", false); AuthRequired=myIniFile_In.ReadInt("admin", "AuthRequired", true); ConnectPriority=myIniFile_In.ReadInt("admin", "ConnectPriority", 0); myIniFile_Out.WriteInt("admin", "UseDSMPlugin", UseDSMPlugin); myIniFile_Out.WriteInt("admin", "AllowLoopback", AllowLoopback); myIniFile_Out.WriteInt("admin", "AuthRequired", AuthRequired); myIniFile_Out.WriteInt("admin", "ConnectPriority", ConnectPriority); myIniFile_In.ReadString("admin", "DSMPlugin",DSMPlugin,128); myIniFile_In.ReadString("admin", "AuthHosts",authhosts,150); myIniFile_Out.WriteString("admin", "DSMPlugin",DSMPlugin); myIniFile_Out.WriteString("admin", "AuthHosts",authhosts); //adzm 2010-05-30 - dsmplugin config myIniFile_In.ReadString("admin", "DSMPluginConfig",DSMPluginConfig,512); myIniFile_Out.WriteString("admin", "DSMPluginConfig",DSMPluginConfig); AllowShutdown=myIniFile_In.ReadInt("admin", "AllowShutdown", true); AllowProperties=myIniFile_In.ReadInt("admin", "AllowProperties", true); AllowEditClients=myIniFile_In.ReadInt("admin", "AllowEditClients", true); myIniFile_Out.WriteInt("admin", "AllowShutdown" ,AllowShutdown); myIniFile_Out.WriteInt("admin", "AllowProperties" ,AllowProperties); myIniFile_Out.WriteInt("admin", "AllowEditClients" ,AllowEditClients); FileTransferEnabled=myIniFile_In.ReadInt("admin", "FileTransferEnabled", true); FTUserImpersonation=myIniFile_In.ReadInt("admin", "FTUserImpersonation", true); BlankMonitorEnabled = myIniFile_In.ReadInt("admin", "BlankMonitorEnabled", true); BlankInputsOnly = myIniFile_In.ReadInt("admin", "BlankInputsOnly", false); //PGM DefaultScale = myIniFile_In.ReadInt("admin", "DefaultScale", 1); CaptureAlphaBlending = myIniFile_In.ReadInt("admin", "CaptureAlphaBlending", false); // sf@2005 BlackAlphaBlending = myIniFile_In.ReadInt("admin", "BlackAlphaBlending", false); // sf@2005 Primary = myIniFile_In.ReadInt("admin", "primary", true); Secondary = myIniFile_In.ReadInt("admin", "secondary", false); myIniFile_Out.WriteInt("admin", "FileTransferEnabled", FileTransferEnabled); myIniFile_Out.WriteInt("admin", "FTUserImpersonation", FTUserImpersonation); myIniFile_Out.WriteInt("admin", "BlankMonitorEnabled", BlankMonitorEnabled); myIniFile_Out.WriteInt("admin", "BlankInputsOnly", BlankInputsOnly); //PGM myIniFile_Out.WriteInt("admin", "DefaultScale", DefaultScale); myIniFile_Out.WriteInt("admin", "CaptureAlphaBlending", CaptureAlphaBlending); myIniFile_Out.WriteInt("admin", "BlackAlphaBlending", BlackAlphaBlending); myIniFile_Out.WriteInt("admin", "primary", Primary); myIniFile_Out.WriteInt("admin", "secondary", Secondary); // Connection prefs SocketConnect=myIniFile_In.ReadInt("admin", "SocketConnect", true); HTTPConnect=myIniFile_In.ReadInt("admin", "HTTPConnect", true); XDMCPConnect=myIniFile_In.ReadInt("admin", "XDMCPConnect", true); AutoPortSelect=myIniFile_In.ReadInt("admin", "AutoPortSelect", true); PortNumber=myIniFile_In.ReadInt("admin", "PortNumber", 0); HttpPortNumber=myIniFile_In.ReadInt("admin", "HTTPPortNumber",0); IdleTimeout=myIniFile_In.ReadInt("admin", "IdleTimeout", 0); myIniFile_Out.WriteInt("admin", "SocketConnect", SocketConnect); myIniFile_Out.WriteInt("admin", "HTTPConnect", HTTPConnect); myIniFile_Out.WriteInt("admin", "XDMCPConnect", XDMCPConnect); myIniFile_Out.WriteInt("admin", "AutoPortSelect", AutoPortSelect); myIniFile_Out.WriteInt("admin", "PortNumber", PortNumber); myIniFile_Out.WriteInt("admin", "HTTPPortNumber", HttpPortNumber); myIniFile_Out.WriteInt("admin", "IdleTimeout", IdleTimeout); RemoveWallpaper=myIniFile_In.ReadInt("admin", "RemoveWallpaper", 0); RemoveAero=myIniFile_In.ReadInt("admin", "RemoveAero", 0); myIniFile_Out.WriteInt("admin", "RemoveWallpaper", RemoveWallpaper); myIniFile_Out.WriteInt("admin", "RemoveAero", RemoveAero); // Connection querying settings QuerySetting=myIniFile_In.ReadInt("admin", "QuerySetting", 0); QueryTimeout=myIniFile_In.ReadInt("admin", "QueryTimeout", 0); QueryAccept=myIniFile_In.ReadInt("admin", "QueryAccept", 0); QueryIfNoLogon=myIniFile_In.ReadInt("admin", "QueryIfNoLogon", 0); myIniFile_Out.WriteInt("admin", "QuerySetting", QuerySetting); myIniFile_Out.WriteInt("admin", "QueryTimeout", QueryTimeout); myIniFile_Out.WriteInt("admin", "QueryAccept", QueryAccept); myIniFile_Out.WriteInt("admin", "QueryIfNoLogon", QueryIfNoLogon); myIniFile_In.ReadPassword(passwd,MAXPWLEN); myIniFile_Out.WritePassword(passwd); memset(passwd, '\0', MAXPWLEN); //PGM myIniFile_In.ReadPassword2(passwd,MAXPWLEN); //PGM myIniFile_Out.WritePassword2(passwd); //PGM EnableRemoteInputs=myIniFile_In.ReadInt("admin", "InputsEnabled", 0); LockSettings=myIniFile_In.ReadInt("admin", "LockSetting", 0); DisableLocalInputs=myIniFile_In.ReadInt("admin", "LocalInputsDisabled", 0); EnableJapInput=myIniFile_In.ReadInt("admin", "EnableJapInput", 0); kickrdp=myIniFile_In.ReadInt("admin", "kickrdp", 0); clearconsole=myIniFile_In.ReadInt("admin", "clearconsole", 0); myIniFile_Out.WriteInt("admin", "InputsEnabled", EnableRemoteInputs); myIniFile_Out.WriteInt("admin", "LockSetting", LockSettings); myIniFile_Out.WriteInt("admin", "LocalInputsDisabled", DisableLocalInputs); myIniFile_Out.WriteInt("admin", "EnableJapInput", EnableJapInput); myIniFile_Out.WriteInt("admin", "kickrdp", kickrdp); myIniFile_Out.WriteInt("admin", "clearconsole", clearconsole); TurboMode = myIniFile_In.ReadInt("poll", "TurboMode", 0); PollUnderCursor=myIniFile_In.ReadInt("poll", "PollUnderCursor", 0); PollForeground=myIniFile_In.ReadInt("poll", "PollForeground", 0); PollFullScreen=myIniFile_In.ReadInt("poll", "PollFullScreen", 0); PollConsoleOnly=myIniFile_In.ReadInt("poll", "OnlyPollConsole", 0); PollOnEventOnly=myIniFile_In.ReadInt("poll", "OnlyPollOnEvent", 0); MaxCpu=myIniFile_In.ReadInt("poll", "MaxCpu", 0); Driver=myIniFile_In.ReadInt("poll", "EnableDriver", 0); Hook=myIniFile_In.ReadInt("poll", "EnableHook", 0); Virtual=myIniFile_In.ReadInt("poll", "EnableVirtual", 0); SingleWindow=myIniFile_In.ReadInt("poll","SingleWindow",SingleWindow); myIniFile_In.ReadString("poll", "SingleWindowName", SingleWindowName,32); myIniFile_Out.WriteInt("poll", "TurboMode", TurboMode); myIniFile_Out.WriteInt("poll", "PollUnderCursor", PollUnderCursor); myIniFile_Out.WriteInt("poll", "PollForeground", PollForeground); myIniFile_Out.WriteInt("poll", "PollFullScreen", PollFullScreen); myIniFile_Out.WriteInt("poll", "OnlyPollConsole",PollConsoleOnly); myIniFile_Out.WriteInt("poll", "OnlyPollOnEvent", PollOnEventOnly); myIniFile_Out.WriteInt("poll", "MaxCpu", MaxCpu); myIniFile_Out.WriteInt("poll", "EnableDriver", Driver); myIniFile_Out.WriteInt("poll", "EnableHook", Hook); myIniFile_Out.WriteInt("poll", "EnableVirtual", Virtual); myIniFile_Out.WriteInt("poll", "SingleWindow", SingleWindow); myIniFile_Out.WriteString("poll", "SingleWindowName", SingleWindowName); MaxCpu=myIniFile_In.ReadInt("poll", "MaxCpu",MaxCpu); myIniFile_Out.WriteInt("poll", "MaxCpu", MaxCpu); DeleteFile(lpCmdLine); }
bool do_copy (IniFile& myIniFile_In, IniFile& myIniFile_Out) { TCHAR *group1=new char[150]; TCHAR *group2=new char[150]; TCHAR *group3=new char[150]; BOOL BUseRegistry; LONG MSLogonRequired; LONG NewMSLogon; LONG locdom1; LONG locdom2; LONG locdom3; LONG DebugMode; LONG Avilog; LONG DebugLevel; LONG DisableTrayIcon; LONG LoopbackOnly; LONG UseDSMPlugin; LONG AllowLoopback=1; LONG AuthRequired; LONG ConnectPriority; char DSMPlugin[128]; char *authhosts=new char[150]; LONG AllowShutdown=1; LONG AllowProperties=1; LONG AllowEditClients=1; LONG FileTransferEnabled=0; LONG FTUserImpersonation=1; LONG BlankMonitorEnabled=1; LONG BlankInputsOnly=0; //PGM LONG DefaultScale=1; LONG SocketConnect=1; LONG HTTPConnect; LONG AutoPortSelect=1; LONG PortNumber=5900; LONG HttpPortNumber=5800; LONG IdleTimeout=0; LONG IdleInputTimeout = 0; LONG RemoveWallpaper=0; LONG RemoveAero=0; LONG QuerySetting=1; LONG QueryTimeout=10; LONG QueryAccept=4; LONG QueryIfNoLogon=1; LONG EnableRemoteInputs=1; LONG LockSettings=0; LONG DisableLocalInputs=0; LONG EnableJapInput=0; LONG kickrdp=0; LONG clearconsole=0; #define MAXPWLEN 8 char passwd[MAXPWLEN]; LONG TurboMode=1; LONG PollUnderCursor=0; LONG PollForeground=0; LONG PollFullScreen=1; LONG PollConsoleOnly=0; LONG PollOnEventOnly=0; LONG Driver=0; LONG Hook=1; LONG Virtual=0; LONG SingleWindow=0; char SingleWindowName[32]; LONG FTTimeout = 30; char path[512]; char accept_reject_mesg[512]; LONG MaxCpu=40; char DSMPluginConfig[512]; *DSMPluginConfig = '\0'; LONG Primary=1; LONG Secondary=0; //Beep(100,20000); BUseRegistry = myIniFile_In.ReadInt("admin", "UseRegistry", 0); if (!myIniFile_Out.WriteInt("admin", "UseRegistry", BUseRegistry)) { //error char temp[10]; DWORD error=GetLastError(); MessageBoxSecure(NULL,myIniFile_Out.myInifile,_itoa(error,temp,10),MB_ICONERROR); return false; } MSLogonRequired=myIniFile_In.ReadInt("admin", "MSLogonRequired", false); myIniFile_Out.WriteInt("admin", "MSLogonRequired", MSLogonRequired); NewMSLogon=myIniFile_In.ReadInt("admin", "NewMSLogon", false); myIniFile_Out.WriteInt("admin", "NewMSLogon", NewMSLogon); myIniFile_In.ReadString("admin_auth","group1",group1,150); myIniFile_In.ReadString("admin_auth","group2",group2,150); myIniFile_In.ReadString("admin_auth","group3",group3,150); myIniFile_Out.WriteString("admin_auth", "group1",group1); myIniFile_Out.WriteString("admin_auth", "group2",group2); myIniFile_Out.WriteString("admin_auth", "group3",group3); locdom1=myIniFile_In.ReadInt("admin_auth", "locdom1",0); locdom2=myIniFile_In.ReadInt("admin_auth", "locdom2",0); locdom3=myIniFile_In.ReadInt("admin_auth", "locdom3",0); myIniFile_Out.WriteInt("admin_auth", "locdom1", locdom1); myIniFile_Out.WriteInt("admin_auth", "locdom2", locdom2); myIniFile_Out.WriteInt("admin_auth", "locdom3", locdom3); DebugMode=myIniFile_In.ReadInt("admin", "DebugMode", 0); Avilog=myIniFile_In.ReadInt("admin", "Avilog", 0); myIniFile_In.ReadString("admin", "path", path,512); myIniFile_In.ReadString("admin", "accept_reject_mesg", accept_reject_mesg,512); DebugLevel=myIniFile_In.ReadInt("admin", "DebugLevel", 0); DisableTrayIcon=myIniFile_In.ReadInt("admin", "DisableTrayIcon", false); LoopbackOnly=myIniFile_In.ReadInt("admin", "LoopbackOnly", false); myIniFile_Out.WriteInt("admin", "DebugMode", DebugMode); myIniFile_Out.WriteInt("admin", "Avilog", Avilog); myIniFile_Out.WriteString("admin", "path", path); myIniFile_Out.WriteString("admin", "accept_reject_mesg", accept_reject_mesg); myIniFile_Out.WriteInt("admin", "DebugLevel", DebugLevel); myIniFile_Out.WriteInt("admin", "DisableTrayIcon", DisableTrayIcon); myIniFile_Out.WriteInt("admin", "LoopbackOnly", LoopbackOnly); UseDSMPlugin=myIniFile_In.ReadInt("admin", "UseDSMPlugin", false); myIniFile_In.ReadString("admin", "DSMPluginConfig", DSMPluginConfig, 512); AllowLoopback=myIniFile_In.ReadInt("admin", "AllowLoopback", true); AuthRequired=myIniFile_In.ReadInt("admin", "AuthRequired", true); ConnectPriority=myIniFile_In.ReadInt("admin", "ConnectPriority", 0); myIniFile_Out.WriteInt("admin", "UseDSMPlugin", UseDSMPlugin); myIniFile_Out.WriteString("admin", "DSMPluginConfig", DSMPluginConfig); myIniFile_Out.WriteInt("admin", "AllowLoopback", AllowLoopback); myIniFile_Out.WriteInt("admin", "AuthRequired", AuthRequired); myIniFile_Out.WriteInt("admin", "ConnectPriority", ConnectPriority); myIniFile_In.ReadString("admin", "DSMPlugin",DSMPlugin,128); myIniFile_In.ReadString("admin", "AuthHosts",authhosts,150); myIniFile_Out.WriteString("admin", "DSMPlugin",DSMPlugin); myIniFile_Out.WriteString("admin", "AuthHosts",authhosts); AllowShutdown=myIniFile_In.ReadInt("admin", "AllowShutdown", true); AllowProperties=myIniFile_In.ReadInt("admin", "AllowProperties", true); AllowEditClients=myIniFile_In.ReadInt("admin", "AllowEditClients", true); myIniFile_Out.WriteInt("admin", "AllowShutdown" ,AllowShutdown); myIniFile_Out.WriteInt("admin", "AllowProperties" ,AllowProperties); myIniFile_Out.WriteInt("admin", "AllowEditClients" ,AllowEditClients); FileTransferEnabled=myIniFile_In.ReadInt("admin", "FileTransferEnabled", true); FTUserImpersonation=myIniFile_In.ReadInt("admin", "FTUserImpersonation", true); BlankMonitorEnabled = myIniFile_In.ReadInt("admin", "BlankMonitorEnabled", true); BlankInputsOnly = myIniFile_In.ReadInt("admin", "BlankInputsOnly", false); //PGM DefaultScale = myIniFile_In.ReadInt("admin", "DefaultScale", 1); FTTimeout = myIniFile_In.ReadInt("admin", "FileTransferTimeout", 30); Primary = myIniFile_In.ReadInt("admin", "primary", true); Secondary = myIniFile_In.ReadInt("admin", "secondary", false); myIniFile_Out.WriteInt("admin", "FileTransferEnabled", FileTransferEnabled); myIniFile_Out.WriteInt("admin", "FTUserImpersonation", FTUserImpersonation); myIniFile_Out.WriteInt("admin", "BlankMonitorEnabled", BlankMonitorEnabled); myIniFile_Out.WriteInt("admin", "BlankInputsOnly", BlankInputsOnly); //PGM myIniFile_Out.WriteInt("admin", "DefaultScale", DefaultScale); myIniFile_Out.WriteInt("admin", "FileTransferTimeout", 30); myIniFile_Out.WriteInt("admin", "primary", Primary); myIniFile_Out.WriteInt("admin", "secondary", Secondary); // Connection prefs SocketConnect=myIniFile_In.ReadInt("admin", "SocketConnect", true); HTTPConnect=myIniFile_In.ReadInt("admin", "HTTPConnect", true); AutoPortSelect=myIniFile_In.ReadInt("admin", "AutoPortSelect", true); PortNumber=myIniFile_In.ReadInt("admin", "PortNumber", PortNumber); HttpPortNumber=myIniFile_In.ReadInt("admin", "HTTPPortNumber",HttpPortNumber); IdleTimeout=myIniFile_In.ReadInt("admin", "IdleTimeout", IdleTimeout); IdleInputTimeout = myIniFile_In.ReadInt("admin", "IdleInputTimeout", IdleInputTimeout); myIniFile_Out.WriteInt("admin", "SocketConnect", SocketConnect); myIniFile_Out.WriteInt("admin", "HTTPConnect", HTTPConnect); myIniFile_Out.WriteInt("admin", "AutoPortSelect", AutoPortSelect); myIniFile_Out.WriteInt("admin", "PortNumber", PortNumber); myIniFile_Out.WriteInt("admin", "HTTPPortNumber", HttpPortNumber); myIniFile_Out.WriteInt("admin", "IdleTimeout", IdleTimeout); myIniFile_Out.WriteInt("admin", "IdleInputTimeout", IdleInputTimeout); RemoveWallpaper=myIniFile_In.ReadInt("admin", "RemoveWallpaper", RemoveWallpaper); RemoveAero=myIniFile_In.ReadInt("admin", "RemoveAero", RemoveAero); myIniFile_Out.WriteInt("admin", "RemoveWallpaper", RemoveWallpaper); myIniFile_Out.WriteInt("admin", "RemoveAero", RemoveAero); // Connection querying settings QuerySetting=myIniFile_In.ReadInt("admin", "QuerySetting", QuerySetting); QueryTimeout=myIniFile_In.ReadInt("admin", "QueryTimeout", QueryTimeout); QueryAccept=myIniFile_In.ReadInt("admin", "QueryAccept", QueryAccept); QueryIfNoLogon=myIniFile_In.ReadInt("admin", "QueryIfNoLogon", QueryIfNoLogon); myIniFile_Out.WriteInt("admin", "QuerySetting", QuerySetting); myIniFile_Out.WriteInt("admin", "QueryTimeout", QueryTimeout); myIniFile_Out.WriteInt("admin", "QueryAccept", QueryAccept); myIniFile_Out.WriteInt("admin", "QueryIfNoLogon", QueryIfNoLogon); myIniFile_In.ReadPassword(passwd,MAXPWLEN); myIniFile_Out.WritePassword(passwd); memset(passwd, '\0', MAXPWLEN); //PGM myIniFile_In.ReadPassword2(passwd,MAXPWLEN); //PGM myIniFile_Out.WritePassword2(passwd); //PGM EnableRemoteInputs=myIniFile_In.ReadInt("admin", "InputsEnabled", EnableRemoteInputs); LockSettings=myIniFile_In.ReadInt("admin", "LockSetting", LockSettings); DisableLocalInputs=myIniFile_In.ReadInt("admin", "LocalInputsDisabled", DisableLocalInputs); EnableJapInput=myIniFile_In.ReadInt("admin", "EnableJapInput", EnableJapInput); kickrdp=myIniFile_In.ReadInt("admin", "kickrdp", kickrdp); clearconsole=myIniFile_In.ReadInt("admin", "clearconsole", clearconsole); myIniFile_Out.WriteInt("admin", "InputsEnabled", EnableRemoteInputs); myIniFile_Out.WriteInt("admin", "LockSetting", LockSettings); myIniFile_Out.WriteInt("admin", "LocalInputsDisabled", DisableLocalInputs); myIniFile_Out.WriteInt("admin", "EnableJapInput", EnableJapInput); myIniFile_Out.WriteInt("admin", "kickrdp", kickrdp); myIniFile_Out.WriteInt("admin", "clearconsole", clearconsole); TurboMode = myIniFile_In.ReadInt("poll", "TurboMode", TurboMode); PollUnderCursor=myIniFile_In.ReadInt("poll", "PollUnderCursor", PollUnderCursor); PollForeground=myIniFile_In.ReadInt("poll", "PollForeground", PollForeground); PollFullScreen=myIniFile_In.ReadInt("poll", "PollFullScreen", PollFullScreen); PollConsoleOnly=myIniFile_In.ReadInt("poll", "OnlyPollConsole", PollConsoleOnly); PollOnEventOnly=myIniFile_In.ReadInt("poll", "OnlyPollOnEvent", PollOnEventOnly); MaxCpu=myIniFile_In.ReadInt("poll", "MaxCpu",MaxCpu); Driver=myIniFile_In.ReadInt("poll", "EnableDriver",Driver); Hook=myIniFile_In.ReadInt("poll", "EnableHook", Hook); Virtual=myIniFile_In.ReadInt("poll", "EnableVirtual", Virtual); SingleWindow=myIniFile_In.ReadInt("poll","SingleWindow",SingleWindow); myIniFile_In.ReadString("poll", "SingleWindowName", SingleWindowName,32); myIniFile_Out.WriteInt("poll", "TurboMode", TurboMode); myIniFile_Out.WriteInt("poll", "PollUnderCursor", PollUnderCursor); myIniFile_Out.WriteInt("poll", "PollForeground", PollForeground); myIniFile_Out.WriteInt("poll", "PollFullScreen", PollFullScreen); myIniFile_Out.WriteInt("poll", "OnlyPollConsole",PollConsoleOnly); myIniFile_Out.WriteInt("poll", "OnlyPollOnEvent", PollOnEventOnly); myIniFile_Out.WriteInt("poll", "MaxCpu", MaxCpu); myIniFile_Out.WriteInt("poll", "EnableDriver", Driver); myIniFile_Out.WriteInt("poll", "EnableHook", Hook); myIniFile_Out.WriteInt("poll", "EnableVirtual", Virtual); myIniFile_Out.WriteInt("poll", "SingleWindow", SingleWindow); myIniFile_Out.WriteString("poll", "SingleWindowName", SingleWindowName); return true; }
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; }
// Dialog box handling functions void vncPropertiesPoll::Show(BOOL show, BOOL usersettings) { HANDLE hProcess=NULL; HANDLE hPToken=NULL; DWORD id=GetExplorerLogonPid(); int iImpersonateResult=0; { char WORKDIR[MAX_PATH]; if (!GetTempPath(MAX_PATH,WORKDIR)) { //Function failed, just set something if (GetModuleFileName(NULL, WORKDIR, MAX_PATH)) { char* p = strrchr(WORKDIR, '\\'); if (p == NULL) return; *p = '\0'; } strcpy(m_Tempfile,""); strcat(m_Tempfile,WORKDIR);//set the directory strcat(m_Tempfile,"\\"); strcat(m_Tempfile,INIFILE_NAME); } else { strcpy(m_Tempfile,""); strcat(m_Tempfile,WORKDIR);//set the directory strcat(m_Tempfile,INIFILE_NAME); } } if (id!=0) { hProcess = OpenProcess(MAXIMUM_ALLOWED,FALSE,id); if(OpenProcessToken(hProcess,TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY |TOKEN_DUPLICATE|TOKEN_ASSIGN_PRIMARY|TOKEN_ADJUST_SESSIONID |TOKEN_READ|TOKEN_WRITE,&hPToken)) { ImpersonateLoggedOnUser(hPToken); iImpersonateResult = GetLastError(); if(iImpersonateResult == ERROR_SUCCESS) { ExpandEnvironmentStringsForUser(hPToken, "%TEMP%", m_Tempfile, MAX_PATH); strcat(m_Tempfile,"\\"); strcat(m_Tempfile,INIFILE_NAME); } } } if (show) { if (!m_fUseRegistry) // Use the ini file { // We're trying to edit the default local settings - verify that we can /* if (!myIniFile.IsWritable()) { if(iImpersonateResult == ERROR_SUCCESS)RevertToSelf(); CloseHandle(hProcess); CloseHandle(hPToken); return; } */ } else // Use the registry { // Verify that we know who is logged on if (usersettings) { char username[UNLEN+1]; if (!vncService::CurrentUser(username, sizeof(username))) { if(iImpersonateResult == ERROR_SUCCESS)RevertToSelf(); CloseHandle(hProcess); CloseHandle(hPToken); return; } if (strcmp(username, "") == 0) { MessageBoxSecure(NULL, sz_ID_NO_CURRENT_USER_ERR, sz_ID_WINVNC_ERROR, MB_OK | MB_ICONEXCLAMATION); if(iImpersonateResult == ERROR_SUCCESS)RevertToSelf(); CloseHandle(hProcess); CloseHandle(hPToken); return; } } else { // We're trying to edit the default local settings - verify that we can HKEY hkLocal=NULL; HKEY hkDefault=NULL; BOOL canEditDefaultPrefs = 1; DWORD dw; if (RegCreateKeyEx(HKEY_LOCAL_MACHINE, WINVNC_REGISTRY_KEY, 0, REG_NONE, REG_OPTION_NON_VOLATILE, KEY_READ, NULL, &hkLocal, &dw) != ERROR_SUCCESS) canEditDefaultPrefs = 0; else if (RegCreateKeyEx(hkLocal, "Default", 0, REG_NONE, REG_OPTION_NON_VOLATILE, KEY_WRITE | KEY_READ, NULL, &hkDefault, &dw) != ERROR_SUCCESS) canEditDefaultPrefs = 0; if (hkLocal) RegCloseKey(hkLocal); if (hkDefault) RegCloseKey(hkDefault); if (!canEditDefaultPrefs) { MessageBoxSecure(NULL, sz_ID_CANNOT_EDIT_DEFAULT_PREFS, sz_ID_WINVNC_ERROR, MB_OK | MB_ICONEXCLAMATION); if(iImpersonateResult == ERROR_SUCCESS)RevertToSelf(); if (hProcess) CloseHandle(hProcess); if (hPToken) CloseHandle(hPToken); return; } } } // Now, if the dialog is not already displayed, show it! if (!m_dlgvisible) { if (m_fUseRegistry) { if (usersettings) vnclog.Print(LL_INTINFO, VNCLOG("show per-user Properties\n")); else vnclog.Print(LL_INTINFO, VNCLOG("show default system Properties\n")); // Load in the settings relevant to the user or system //Load(usersettings); m_usersettings=usersettings; // Load in the settings relevant to the user or system Load(usersettings); } else LoadFromIniFile(); for (;;) { m_returncode_valid = FALSE; // Do the dialog box // [v1.0.2-jp1 fix] //int result = DialogBoxParam(hAppInstance, int result = DialogBoxParam(hInstResDLL, MAKEINTRESOURCE(IDD_PROPERTIES), NULL, (DLGPROC) DialogProcPoll, (LONG_PTR) this); if (!m_returncode_valid) result = IDCANCEL; vnclog.Print(LL_INTINFO, VNCLOG("dialog result = %d\n"), result); if (result == -1) { // Dialog box failed, so quit PostQuitMessage(0); if(iImpersonateResult == ERROR_SUCCESS)RevertToSelf(); CloseHandle(hProcess); CloseHandle(hPToken); return; } break; omni_thread::sleep(4); } // Load in all the settings if (!vncService::RunningAsService()) { if (m_fUseRegistry) Load(TRUE); else LoadFromIniFile(); } } } if(iImpersonateResult == ERROR_SUCCESS)RevertToSelf(); if (hProcess) CloseHandle(hProcess); if (hPToken) CloseHandle(hPToken); }