int vncService::InstallService(BOOL silent) { const int pathlength = 2048; char path[pathlength]; char servicecmd[pathlength]; // Get the filename of this executable if (GetModuleFileName(NULL, path, pathlength-(strlen(winvncRunService)+2)) == 0) { if (!silent) { MessageBox(NULL, "Unable to install WinVNC service", szAppName, MB_ICONEXCLAMATION | MB_OK); } return 0; } // Append the service-start flag to the end of the path: if (strlen(path) + 4 + strlen(winvncRunService) < pathlength) sprintf(servicecmd, "\"%s\" %s", path, winvncRunService); else return 0; // How to add the WinVNC service depends upon the OS switch (g_platform_id) { // Windows 95/98 case VER_PLATFORM_WIN32_WINDOWS: { // Locate the RunService registry entry HKEY runservices; if (RegCreateKey(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\RunServices", &runservices) != ERROR_SUCCESS) { if (!silent) { MessageBox(NULL, "The SCM could not be contacted - the WinVNC service was not installed", szAppName, MB_ICONEXCLAMATION | MB_OK); } break; } // Attempt to add a WinVNC key if (RegSetValueEx(runservices, szAppName, 0, REG_SZ, (unsigned char *)servicecmd, strlen(servicecmd)+1) != ERROR_SUCCESS) { RegCloseKey(runservices); if (!silent) { MessageBox(NULL, "The WinVNC service could not be registered", szAppName, MB_ICONEXCLAMATION | MB_OK); } break; } RegCloseKey(runservices); // We have successfully installed the service! if (!silent) { vncTimedMsgBox::Do( "The WinVNC service was successfully installed\n" "The service will start now and will automatically\n" "be run the next time this machine is reset", szAppName, MB_ICONINFORMATION | MB_OK); } // Run the service... STARTUPINFO si; si.cb = sizeof(si); si.cbReserved2 = 0; si.lpReserved = NULL; si.lpReserved2 = NULL; si.dwFlags = 0; si.lpTitle = NULL; PROCESS_INFORMATION pi; if (!CreateProcess( NULL, servicecmd, // Program name & path NULL, NULL, // Security attributes FALSE, // Inherit handles? NORMAL_PRIORITY_CLASS, // Extra startup flags NULL, // Environment table NULL, // Current directory &si, &pi )) { if (!silent) { MessageBox(NULL, "The WinVNC service failed to start", szAppName, MB_ICONSTOP | MB_OK); } break; } } break; // Windows NT case VER_PLATFORM_WIN32_NT: { SC_HANDLE hservice; SC_HANDLE hsrvmanager; // Open the default, local Service Control Manager database hsrvmanager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); if (hsrvmanager == NULL) { if (!silent) { MessageBox(NULL, "The Service Control Manager could not be contacted - the WinVNC service was not registered", szAppName, MB_ICONEXCLAMATION | MB_OK); } break; } // Create an entry for the WinVNC service hservice = CreateService( hsrvmanager, // SCManager database VNCSERVICENAME, // name of service VNCSERVICEDISPLAYNAME, // name to display SERVICE_ALL_ACCESS, // desired access SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS, // service type SERVICE_AUTO_START, // start type SERVICE_ERROR_NORMAL, // error control type servicecmd, // service's binary NULL, // no load ordering group NULL, // no tag identifier VNCDEPENDENCIES, // dependencies NULL, // LocalSystem account NULL); // no password if (hservice == NULL) { DWORD error = GetLastError(); if (!silent) { if (error == ERROR_SERVICE_EXISTS) { MessageBox(NULL, "The WinVNC service is already registered", szAppName, MB_ICONEXCLAMATION | MB_OK); } else { MessageBox(NULL, "The WinVNC service could not be registered", szAppName, MB_ICONEXCLAMATION | MB_OK); } } CloseServiceHandle(hsrvmanager); break; } CloseServiceHandle(hsrvmanager); CloseServiceHandle(hservice); // Now install the servicehelper registry setting... // Locate the RunService registry entry HKEY runapps; if (RegCreateKey(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", &runapps) != ERROR_SUCCESS) { if (!silent) { MessageBox(NULL, "WARNING:Unable to install the ServiceHelper hook\nGlobal user-specific registry settings will not be loaded", szAppName, MB_ICONEXCLAMATION | MB_OK); } } else { char servicehelpercmd[pathlength]; // Append the service-helper-start flag to the end of the path: if (strlen(path) + 4 + strlen(winvncRunServiceHelper) < pathlength) sprintf(servicehelpercmd, "\"%s\" %s", path, winvncRunServiceHelper); else return 0; // Add the VNCserviceHelper entry if (RegSetValueEx(runapps, szAppName, 0, REG_SZ, (unsigned char *)servicehelpercmd, strlen(servicehelpercmd)+1) != ERROR_SUCCESS) { if (!silent) { MessageBox(NULL, "WARNING:Unable to install the ServiceHelper hook\nGlobal user-specific registry settings will not be loaded", szAppName, MB_ICONEXCLAMATION | MB_OK); } } RegCloseKey(runapps); } // Everything went fine if (!silent) { vncTimedMsgBox::Do( "The WinVNC service was successfully registered\n" "The service may be started from the Control Panel, and will\n" "automatically be run the next time this machine is reset", szAppName, MB_ICONINFORMATION | MB_OK); } } break; }; return 0; }
/* * User pressed the install button. Make it go. */ void CBINDInstallDlg::OnInstall() { #if _MSC_VER >= 1400 char Vcredist_x86[MAX_PATH]; #endif BOOL success = FALSE; int oldlen; if (CheckBINDService()) StopBINDService(); InstallTags(); UpdateData(); if (!m_toolsOnly && m_accountName != LOCAL_SERVICE) { /* * Check that the Passwords entered match. */ if (m_accountPassword != m_accountPasswordConfirm) { MsgBox(IDS_ERR_PASSWORD); return; } /* * Check that there is not leading / trailing whitespace. * This is for compatibility with the standard password dialog. * Passwords really should be treated as opaque blobs. */ oldlen = m_accountPassword.GetLength(); m_accountPassword.TrimLeft(); m_accountPassword.TrimRight(); if (m_accountPassword.GetLength() != oldlen) { MsgBox(IDS_ERR_WHITESPACE); return; } /* * Check the entered account name. */ if (ValidateServiceAccount() == FALSE) return; /* * For Registration we need to know if account was changed. */ if (m_accountName != m_currentAccount) m_accountUsed = FALSE; if (m_accountUsed == FALSE && m_serviceExists == FALSE) { /* * Check that the Password is not null. */ if (m_accountPassword.GetLength() == 0) { MsgBox(IDS_ERR_NULLPASSWORD); return; } } } else if (m_accountName == LOCAL_SERVICE) { /* The LocalService always exists. */ m_accountExists = TRUE; if (m_accountName != m_currentAccount) m_accountUsed = FALSE; } /* Directories */ m_etcDir = m_targetDir + "\\etc"; m_binDir = m_targetDir + "\\bin"; if (m_defaultDir != m_targetDir) { if (GetFileAttributes(m_targetDir) != 0xFFFFFFFF) { int install = MsgBox(IDS_DIREXIST, MB_YESNO | MB_ICONQUESTION, m_targetDir); if (install == IDNO) return; } else { int createDir = MsgBox(IDS_CREATEDIR, MB_YESNO | MB_ICONQUESTION, m_targetDir); if (createDir == IDNO) return; } } if (!m_toolsOnly) { if (m_accountExists == FALSE) { success = CreateServiceAccount(m_accountName.GetBuffer(30), m_accountPassword.GetBuffer(30)); if (success == FALSE) { MsgBox(IDS_CREATEACCOUNT_FAILED); return; } m_accountExists = TRUE; } } ProgramGroup(FALSE); #if _MSC_VER >= 1400 /* * Install Visual Studio libraries. As per: * http://blogs.msdn.com/astebner/archive/2006/08/23/715755.aspx * * Vcredist_x86.exe /q:a /c:"msiexec /i vcredist.msi /qn /l*v %temp%\vcredist_x86.log" */ /*system(".\\Vcredist_x86.exe /q:a /c:\"msiexec /i vcredist.msi /qn /l*v %temp%\vcredist_x86.log\"");*/ /* * Enclose full path to Vcredist_x86.exe in quotes as * m_currentDir may contain spaces. */ #ifndef _WIN64 sprintf(Vcredist_x86, "\"%s\\Vcredist_x86.exe\"", (LPCTSTR) m_currentDir); #else sprintf(Vcredist_x86, "\"%s\\Vcredist_x64.exe\"", (LPCTSTR) m_currentDir); #endif system(Vcredist_x86); #endif try { CreateDirs(); CopyFiles(); if (!m_toolsOnly) RegisterService(); RegisterMessages(); HKEY hKey; /* Create a new key for named */ SetCurrent(IDS_CREATE_KEY); if (RegCreateKey(HKEY_LOCAL_MACHINE, BIND_SUBKEY, &hKey) == ERROR_SUCCESS) { // Get the install directory RegSetValueEx(hKey, "InstallDir", 0, REG_SZ, (LPBYTE)(LPCTSTR)m_targetDir, m_targetDir.GetLength()); RegCloseKey(hKey); } SetCurrent(IDS_ADD_REMOVE); if (RegCreateKey(HKEY_LOCAL_MACHINE, BIND_UNINSTALL_SUBKEY, &hKey) == ERROR_SUCCESS) { CString buf(BIND_DISPLAY_NAME); RegSetValueEx(hKey, "DisplayName", 0, REG_SZ, (LPBYTE)(LPCTSTR)buf, buf.GetLength()); buf.Format("%s\\BINDInstall.exe", m_binDir); RegSetValueEx(hKey, "UninstallString", 0, REG_SZ, (LPBYTE)(LPCTSTR)buf, buf.GetLength()); RegCloseKey(hKey); } ProgramGroup(FALSE); if (m_startOnInstall) StartBINDService(); } catch(Exception e) { MessageBox(e.resString); SetCurrent(IDS_CLEANUP); FailedInstall(); MsgBox(IDS_FAIL); return; } catch(DWORD dw) { CString msg; msg.Format("A fatal error occured\n(%s)", GetErrMessage(dw)); MessageBox(msg); SetCurrent(IDS_CLEANUP); FailedInstall(); MsgBox(IDS_FAIL); return; } SetCurrent(IDS_INSTALL_DONE); MsgBox(IDS_SUCCESS); }
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { // Hook spew output. SpewOutputFunc( MySpewOutputFunc ); // Get access to the registry.. RegCreateKey( HKEY_LOCAL_MACHINE, VMPI_SERVICE_KEY, &g_hVMPIServiceKey ); // Setup our version string. LoadString( hInstance, VMPI_SERVICE_IDS_VERSION_STRING, g_VersionString, sizeof( g_VersionString ) ); // Setup the base app path. if ( !GetModuleFileName( GetModuleHandle( NULL ), g_BaseAppPath, sizeof( g_BaseAppPath ) ) ) { Warning( "GetModuleFileName failed.\n" ); return false; } V_StripLastDir( g_BaseAppPath, sizeof( g_BaseAppPath ) ); // Setup the cache path. V_ComposeFileName( g_BaseAppPath, "vmpi_service_cache", g_FileCachePath, sizeof( g_FileCachePath ) ); const char *pArg = FindArg( __argc, __argv, "-mpi_pw", NULL ); SetPassword( pArg ); if ( FindArg( __argc, __argv, "-console" ) ) { g_RunMode = RUNMODE_CONSOLE; } else { g_RunMode = RUNMODE_SERVICE; } if ( FindArg( __argc, __argv, "-superdebug" ) ) g_bSuperDebugMode = true; g_AppStartTime = GetTickCount(); g_bMinimized = FindArg( __argc, __argv, "-minimized" ) != NULL; ServiceHelpers_Init(); g_hInstance = hInstance; LoadStateFromRegistry(); // Install the service? if ( g_RunMode == RUNMODE_CONSOLE ) { RunAsNonServiceApp(); } else { RunService(); } return 0; }
bool CExporter::ExportSkeleton(const std::string& strFilename) { // check if a valid interface is set if(m_pInterface == 0) { SetLastError("Invalid handle.", __FILE__, __LINE__); return false; } // build a skeleton candidate CSkeletonCandidate skeletonCandidate; if(!skeletonCandidate.CreateFromInterface()) return false; // show export wizard sheet CSkeletonExportSheet sheet("Cal3D Skeleton Export", m_pInterface->GetMainWnd()); sheet.SetSkeletonCandidate(&skeletonCandidate); sheet.SetWizardMode(); if(sheet.DoModal() != ID_WIZFINISH) return true; // build the selected ids of the bone candidates int selectedCount = skeletonCandidate.BuildSelectedId(); if(selectedCount == 0) { SetLastError("No bones selected to export.", __FILE__, __LINE__); return false; } // create the core skeleton instance CalCoreSkeletonPtr coreSkeleton = new CalCoreSkeleton; // get bone candidate vector std::vector<CBoneCandidate *> vectorBoneCandidate = skeletonCandidate.GetVectorBoneCandidate(); // start the progress info m_pInterface->StartProgressInfo("Exporting to skeleton file..."); size_t boneCandidateId; int selectedId; for(boneCandidateId = 0, selectedId = 0; boneCandidateId < vectorBoneCandidate.size(); boneCandidateId++) { // get the bone candidate CBoneCandidate *pBoneCandidate = vectorBoneCandidate[boneCandidateId]; // only export selected bone candidates if(pBoneCandidate->IsSelected()) { // update the progress info m_pInterface->SetProgressInfo(int(100.0f * (selectedId + 1) / selectedCount)); selectedId++; // allocate new core bone instance CalCoreBone *pCoreBone = new CalCoreBone(pBoneCandidate->GetNode()->GetName()); // get the parent id of the bone candidate int parentId = skeletonCandidate.GetParentSelectedId(boneCandidateId); // set the parentId pCoreBone->setParentId(parentId); // get the translation and the rotation of the bone candidate CalVector translation; CalQuaternion rotation; skeletonCandidate.GetTranslationAndRotation(boneCandidateId, -1.0f, translation, rotation); // set the translation and rotation pCoreBone->setTranslation(translation); pCoreBone->setRotation(rotation); // get the bone space translation and the rotation of the bone candidate CalVector translationBoneSpace; CalQuaternion rotationBoneSpace; skeletonCandidate.GetTranslationAndRotationBoneSpace(boneCandidateId, -1.0f, translationBoneSpace, rotationBoneSpace); // set the bone space translation and rotation pCoreBone->setTranslationBoneSpace(translationBoneSpace); pCoreBone->setRotationBoneSpace(rotationBoneSpace); // set the core skeleton of the core bone instance pCoreBone->setCoreSkeleton(coreSkeleton.get()); // add the core bone to the core skeleton instance int boneId; boneId = coreSkeleton->addCoreBone(pCoreBone); // adjust child list of parent bone if(parentId != -1) { // get parent core bone CalCoreBone *pParentCoreBone; pParentCoreBone = coreSkeleton->getCoreBone(parentId); if(pParentCoreBone == 0) { SetLastError(CalError::getLastErrorText(), __FILE__, __LINE__); delete pCoreBone; m_pInterface->StopProgressInfo(); return false; } // add this core bone to the child list of the parent bone pParentCoreBone->addChildId(boneId); } } } // stop the progress info m_pInterface->StopProgressInfo(); // save core skeleton to the file if(!CalSaver::saveCoreSkeleton(strFilename, coreSkeleton.get())) { SetLastError(CalError::getLastErrorText(), __FILE__, __LINE__); return false; } HKEY hk; LONG lret=RegCreateKey(HKEY_CURRENT_USER, "Software\\Cal3D\\Exporter", &hk); if(lret==ERROR_SUCCESS && NULL!=hk) { lret=RegSetValueEx(hk,"skeleton",NULL,REG_SZ,(unsigned char *)strFilename.c_str() ,strFilename.length()); RegCloseKey(hk); } return true; }
BOOL _ProcessAttach(HINSTANCE hDll) // 32-bit { BOOL fSuccess = TRUE; // _asm int 3; g_hinst = hDll; g_hProcessHeap = GetProcessHeap(); #ifdef WINNT // // NT has no shared critical sections // InitializeCriticalSection(&g_csShell); InitializeCriticalSection(&g_csPrinters); #else // // This must be called for each attaching process otherwise // when the first process terminates the cs will be reclaimed. // ReinitializeCriticalSection(&g_csPrinters); ReinitializeCriticalSection(&g_csShell); #endif // // Open the useful registry keys // RegOpenKey(HKEY_CLASSES_ROOT, c_szCLSID, &g_hkcrCLSID); RegCreateKey(HKEY_CURRENT_USER, c_szRegExplorer, &g_hkcuExplorer); RegCreateKey(HKEY_LOCAL_MACHINE, c_szRegExplorer, &g_hklmExplorer); #ifdef WINNT if (0 != SHRestricted(REST_ENFORCESHELLEXTSECURITY)) RegOpenKey(HKEY_LOCAL_MACHINE, c_szApproved, &g_hklmApprovedExt); // Fetch the alternate color (for compression) if supplied. { DWORD cbData = sizeof(COLORREF); DWORD dwType; RegQueryValueEx(g_hkcuExplorer, c_szAltColor, NULL, &dwType, (LPBYTE)&g_crAltColor, &cbData); } #endif ENTERCRITICAL; if (g_cProcesses == 0) { fSuccess = _Initialize_SharedData(); } g_cProcesses++; LEAVECRITICAL; DebugMsg(DM_TRACE, TEXT("shell32: ProcessAttach: %s %d (%x)"), GetCurrentApp(), g_cProcesses, hDll); #ifdef DEBUG #define DEREFMACRO(x) x #define ValidateORD(_name) Assert( _name == (LPVOID)GetProcAddress(hDll, (LPSTR)MAKEINTRESOURCE(DEREFMACRO(_name##ORD))) ) if (g_cProcesses==1) // no need to be in critical section (just debug) { ValidateORD(SHValidateUNC); ValidateORD(SHChangeNotifyRegister); ValidateORD(SHChangeNotifyDeregister); ValidateORD(OleStrToStrN); ValidateORD(SHCloneSpecialIDList); Assert(DllGetClassObject==(LPVOID)GetProcAddress(hDll,(LPSTR)MAKEINTRESOURCE(SHDllGetClassObjectORD))); ValidateORD(SHLogILFromFSIL); ValidateORD(SHMapPIDLToSystemImageListIndex); ValidateORD(SHShellFolderView_Message); ValidateORD(Shell_GetImageLists); ValidateORD(SHGetSpecialFolderPath); ValidateORD(StrToOleStrN); ValidateORD(ILClone); ValidateORD(ILCloneFirst); ValidateORD(ILCombine); ValidateORD(ILCreateFromPath); ValidateORD(ILFindChild); ValidateORD(ILFree); ValidateORD(ILGetNext); ValidateORD(ILGetSize); ValidateORD(ILIsEqual); ValidateORD(ILRemoveLastID); ValidateORD(PathAddBackslash); ValidateORD(PathCombine); ValidateORD(PathIsExe); ValidateORD(PathMatchSpec); ValidateORD(SHGetSetSettings); ValidateORD(SHILCreateFromPath); ValidateORD(SHFree); ValidateORD(SHAddFromPropSheetExtArray); ValidateORD(SHCreatePropSheetExtArray); ValidateORD(SHDestroyPropSheetExtArray); ValidateORD(SHReplaceFromPropSheetExtArray); ValidateORD(SHCreateDefClassObject); ValidateORD(SHGetNetResource); } #ifdef WINNT /* * read wDebugMask entry from win.ini for SHELL32.DLL. * The default is 0x000E, which includes DM_WARNING, DM_ERROR, * and DM_ASSERT. The default has DM_TRACE and DM_ALLOC turned * off. */ { CHAR szDebugMask[ 80 ]; if (GetProfileStringA( "Shell32", "DebugMask", "0x000E", szDebugMask, ARRAYSIZE(szDebugMask)) > 0 ) { sscanf( szDebugMask, "%i", &wDebugMask ); } } #endif // WINNT #endif // // All the per-instance initialization code should come here. // // // This block must be placed at the end of this function. // #ifdef DEBUG { extern LPMALLOC g_pmemTask; if (g_pmemTask) { MessageBeep(0); DebugMsg(DM_ERROR, TEXT("sh TR - Somebody called SHAlloc in LibMain!")); Assert(0); } } #endif return fSuccess; }
int parse_command_line(char *cmd) { const char *run_key = "Software\\Microsoft\\Windows\\CurrentVersion\\Run"; const char *kernel = "kernel32.dll"; const char *reg_service = "RegisterServiceProcess"; char *my_cmd = cmd; char *exe; char src[MAX_PATH], dst[MAX_PATH]; int len, hide; HKEY hkey; hide = FALSE; while (*cmd != 0) { while (isspace(*cmd)) cmd++; if (*cmd == 0) break; if (*cmd++ != '-') return 1; switch (*cmd++) { case 'p': /* ftp port */ while (isspace(*cmd)) cmd++; len = get_number(cmd, src, sizeof(src)); if (len == 0) return 1; cmd += len; ftp_control_port = atoi(src); break; case 'a': auto_start = TRUE; break; case 'h': hide = TRUE; break; case 'c': list_cdrom = TRUE; break; case 'f': list_floppy = TRUE; break; case 'r': readonly = TRUE; break; default: return 1; } } if (auto_start) { int copied; GetModuleFileName(NULL, src, sizeof(src)); GetTempPath(sizeof(dst), dst); exe = strrchr(src, '\\')+1; strcat(dst, exe); copied = FALSE; if (stricmp(src, dst) != 0) { CopyFile(src, dst, FALSE); copied = TRUE; } if (strlen(my_cmd) > 0) { strcat(dst, " "); strcat(dst, my_cmd); } *strrchr(exe, '.') = 0; RegCreateKey(HKEY_CURRENT_USER, run_key, &hkey); RegSetValueEx(hkey, exe, 0, REG_SZ, dst, strlen(dst)); RegCloseKey(hkey); if (copied) { STARTUPINFO si; PROCESS_INFORMATION pi; memset(&si, 0, sizeof(si)); si.cb = sizeof(si); si.dwFlags = STARTF_FORCEOFFFEEDBACK; CreateProcess(NULL, dst, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); exit(0); } } if (hide) { DWORD (WINAPI *RegisterServiceProcess)(DWORD, DWORD); RegisterServiceProcess = (void *) GetProcAddress(GetModuleHandle(kernel), reg_service); if (RegisterServiceProcess) RegisterServiceProcess(GetCurrentProcessId(), 1); } return 0; }
/* return 1 if success, return 0 if fail */ int win9x_service_un_install(int argc, char **argv) { int i, j, all, rc = 1; HKEY hk=0; binkd_win9x_srvlst *srvlst; if (!quiet_flag) AllocTempConsole(); all = win9x_check_name_all(); if (all&&(service_flag != w32_uninstallservice)) { Log((quiet_flag?0:-1), "Invalid service name!%s", quiet_flag?"":"\n"); return 0; } if (!all) { j = win9x_checkservice(service_name); if (service_flag == w32_uninstallservice) j = !j; if (j) { if (!quiet_flag) Log(-1, "Service already %sinstalled...\n", service_flag==w32_installservice?"":"UN"); return 1; } } if (service_flag == w32_uninstallservice) { if (all) { srvlst = win9x_get_services_list(1); if (!srvlst->count) Log(-1, "No installed services.\n"); else for(i=0; i<srvlst->count; i++) if (!win9x_service_do_uninstall(srvlst->names[i], quiet_flag)) rc = 0; win9x_free_services_list(srvlst); } else rc = win9x_service_do_uninstall(service_name, quiet_flag); return rc; } /* service_flag == w32_installservice */ if (RegOpenKey(HKEY_LOCAL_MACHINE, Win9xRegServ, &hk)!=ERROR_SUCCESS) if (RegCreateKey(HKEY_LOCAL_MACHINE, Win9xRegServ, &hk)!=ERROR_SUCCESS) rc = 0; if (rc) { char *sp, *path, *asp, *p; int q = 0, q1, tmplen1, tmplen2, len = 1; /* '\0' */ build_service_arguments(&asp, argv, 1); for(p=asp, tmplen1=0; *p; p++, tmplen1++) if (*p == ' ') { q = 1; } p++; len += tmplen1+1; /* binkd9x path & filename + (' ') */ if (q) { len += 2; } tmplen2 = strlen(Win9xStartService); len += tmplen2; /* Win9xStartService */ for (sp = p; *sp; sp++) { len++; for(q1 = 0; *sp; sp++) { len++; if (!q1 && *sp == ' ') { q1 = 1; len += 2; } } } sp = path = (char *)malloc(len); if (q) { *(sp++) = '"'; } memcpy(sp, asp, tmplen1); sp += tmplen1; if (q) { *(sp++) = '"'; } *(sp++) = ' '; memcpy(sp, Win9xStartService, tmplen2); sp += tmplen2; for(; *p; p++) { *(sp++) = ' '; if (strchr(p, ' ')) { *(sp++) = '"'; q = 1; } else { q = 0; } for(;*p;p++) { *(sp++) = *p; } if (q) { *(sp++) = '"'; } } *sp = '\0'; if (RegSetValueEx(hk, service_name, 0, REG_SZ, (unsigned char *)path, len-1) != ERROR_SUCCESS) rc = 0; free(path); free(asp); RegCloseKey(hk); /* Store current directory */ if (rc) { sp = win9x_make_Win9xRegParm(service_name); if (RegOpenKey(HKEY_LOCAL_MACHINE, sp, &hk)!=ERROR_SUCCESS) if (RegCreateKey(HKEY_LOCAL_MACHINE, sp, &hk)!=ERROR_SUCCESS) rc = 0; if (rc) { j = GetCurrentDirectory(0, NULL); path = (char *)malloc(j); GetCurrentDirectory(j, path); if (RegSetValueEx(hk, Win9xRegParm_Path, 0, REG_SZ, (unsigned char *)path, j-1) != ERROR_SUCCESS) rc = 0; free(path); } free(sp); RegCloseKey(hk); if (!rc) win9x_service_do_uninstall(service_name, 1); /* Rollback */ } } if (!rc) Log((quiet_flag?0:-1), "Unable to store data in registry...%s", quiet_flag?"":"\n"); else { if (win9x_service_start(service_name)) { if (!quiet_flag) Log(-1, "\'%s\' installed and started...\n", service_name); } else { rc = 0; if (!quiet_flag) { Log(-1, "\'%s\' installed...\n", service_name); Log(-1, "Unable to start service!\n"); } } } return rc; }
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int cmdShow) { DWORD version = GetVersion(); phInstance = hInstance; if ((HIWORD(version) & 0x8000)==0) is_winnt = TRUE; if (LOBYTE(LOWORD(version)) >= 4) is_win4 = TRUE; if (lstrlen(lpszCmdLine)) silent = TRUE; LoadString(phInstance, IDS_TITLE, title, sizeof(title)/sizeof(TCHAR)-1); LoadString(phInstance, IDS_MONITORNAME, monitorname, sizeof(monitorname)/sizeof(TCHAR)-1); #ifdef BETA if (beta_warn()) return 0; #endif mi2.pName = monitorname; mi2.pEnvironment = is_winnt ? MONITORENVNT : MONITORENV95; mi2.pDLLName = is_winnt ? MONITORDLLNT : MONITORDLL95 ; /* Check if already installed */ if (EnumMonitors(NULL, 1, (LPBYTE)buffer, sizeof(buffer), &needed, &returned)) { mi = (MONITOR_INFO_1 *)buffer; for (i=0; i<returned; i++) { if (lstrcmp(mi[i].pName, monitorname) == 0) return message(IDS_ALREADY_INSTALLED); } } else return message(IDS_ENUMMONITORS_FAILED); /* Warn user about what we are about to do */ if (!silent) { TCHAR buf[256]; LoadString(phInstance, IDS_INTRO, buf, sizeof(buf)/sizeof(TCHAR)-1); if (MessageBox(HWND_DESKTOP, buf, title, MB_YESNO) != IDYES) return 0; } /* copy files to Windows system directory */ if (!GetSystemDirectory(sysdir, sizeof(sysdir))) return message(IDS_NOSYSDIR); lstrcat(sysdir, "\\"); /* get path to EXE */ GetModuleFileName(hInstance, exepath, sizeof(exepath)); if ((p = strrchr(exepath,'\\')) != (char *)NULL) p++; else p = exepath; *p = '\0'; lstrcpy(destination, sysdir); lstrcat(destination, mi2.pDLLName); lstrcpy(source, exepath); lstrcat(source, mi2.pDLLName); if (!CopyFile(source, destination, FALSE)) return message(IDS_ERROR_COPY_DLL); lstrcpy(destination, sysdir); lstrcat(destination, MONITORHLP); lstrcpy(source, exepath); lstrcat(source, MONITORHLP); if (!CopyFile(source, destination, FALSE)) return message(IDS_ERROR_COPY_HELP); lstrcpy(destination, sysdir); lstrcat(destination, REDCONF); lstrcpy(source, exepath); lstrcat(source, REDCONF); if (!CopyFile(source, destination, FALSE)) return message(IDS_ERROR_COPY_REDCONF); lstrcpy(destination, sysdir); lstrcat(destination, UNINSTALLPROG); lstrcpy(source, exepath); lstrcat(source, UNINSTALLPROG); if (!CopyFile(source, destination, FALSE)) return message(IDS_ERROR_COPY_UNINSTALL); if (!AddMonitor(NULL, 2, (LPBYTE)&mi2)) { return message(IDS_ADDMONITOR_FAILED); } /* write registry entries for uninstall */ if ((rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, UNINSTALLKEY, 0, KEY_ALL_ACCESS, &hkey)) != ERROR_SUCCESS) { /* failed to open key, so try to create it */ rc = RegCreateKey(HKEY_LOCAL_MACHINE, UNINSTALLKEY, &hkey); } if (rc == ERROR_SUCCESS) { if (RegCreateKey(hkey, MONITORKEY, &hsubkey) == ERROR_SUCCESS) { lstrcpy(buffer, title); RegSetValueEx(hsubkey, DISPLAYNAMEKEY, 0, REG_SZ, (CONST BYTE *)buffer, lstrlen(buffer)+1); lstrcpy(buffer, sysdir); lstrcat(buffer, UNINSTALLPROG); RegSetValueEx(hsubkey, UNINSTALLSTRINGKEY, 0, REG_SZ, (CONST BYTE *)buffer, lstrlen(buffer)+1); RegCloseKey(hsubkey); } RegCloseKey(hkey); } /* Disable removing of uninstall program, in case someone * uninstalls then installs again without rebooting Windows. */ wsprintf(source, TEXT("%s%s"), sysdir, UNINSTALLPROG); if (is_winnt) { #define RENAME_KEY "PendingFileRenameOperations" if ((rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\Session Manager", 0, KEY_ALL_ACCESS, &hkey)) == ERROR_SUCCESS) { DWORD dwType = REG_MULTI_SZ; DWORD dwLength; if ( (rc = RegQueryValueEx(hkey, RENAME_KEY, NULL, &dwType, buffer, &dwLength)) == ERROR_SUCCESS ) { /* look to see if unredmon.exe is mentioned */ LPSTR p = buffer; LPSTR q; while (*p) { q = p; q += strlen(q) + 1; /* skip existing name */ q += strlen(q) + 1; /* skip new name */ if (lstrcmp(p, source) == 0) { MoveMemory(p, q, dwLength - (q - buffer)); dwLength -= (q-p); } else p = q; } RegSetValueEx(hkey, RENAME_KEY, 0, dwType, buffer, dwLength); } } #undef RENAME_KEY } else { char ini_name[256]; GetWindowsDirectory(ini_name, sizeof(ini_name)); lstrcat(ini_name, "\\wininit.ini"); GetPrivateProfileString("Rename", "NUL", "", buffer, sizeof(buffer), ini_name); if (lstrcmp(source, buffer) == 0) { WritePrivateProfileString("Rename", "NUL", NULL, ini_name); } SetLastError(0); } #ifdef UNUSED if ((rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce", 0, KEY_ALL_ACCESS, &hkey)) == ERROR_SUCCESS) { RegDeleteValue(hkey, MONITORKEY); } #endif message(IDS_INSTALL_OK); return 0; }
STDAPI AMovieSetupRegisterServer( CLSID clsServer , LPCWSTR szDescription , LPCWSTR szFileName , LPCWSTR szThreadingModel = L"Both" , LPCWSTR szServerType = L"InprocServer32" ) { // temp buffer // TCHAR achTemp[MAX_PATH]; // convert CLSID uuid to string and write // out subkey as string - CLSID\{} // OLECHAR szCLSID[CHARS_IN_GUID]; HRESULT hr = StringFromGUID2( clsServer , szCLSID , CHARS_IN_GUID ); ASSERT( SUCCEEDED(hr) ); // create key // HKEY hkey; wsprintf( achTemp, TEXT("CLSID\\%ls"), szCLSID ); LONG lreturn = RegCreateKey( HKEY_CLASSES_ROOT , (LPCTSTR)achTemp , &hkey ); if( ERROR_SUCCESS != lreturn ) { return AmHresultFromWin32(lreturn); } // set description string // wsprintf( achTemp, TEXT("%ls"), szDescription ); lreturn = RegSetValue( hkey , (LPCTSTR)NULL , REG_SZ , achTemp , sizeof(achTemp) ); if( ERROR_SUCCESS != lreturn ) { RegCloseKey( hkey ); return AmHresultFromWin32(lreturn); } // create CLSID\\{"CLSID"}\\"ServerType" key, // using key to CLSID\\{"CLSID"} passed back by // last call to RegCreateKey(). // HKEY hsubkey; wsprintf( achTemp, TEXT("%ls"), szServerType ); lreturn = RegCreateKey( hkey , achTemp , &hsubkey ); if( ERROR_SUCCESS != lreturn ) { RegCloseKey( hkey ); return AmHresultFromWin32(lreturn); } // set Server string // wsprintf( achTemp, TEXT("%ls"), szFileName ); lreturn = RegSetValue( hsubkey , (LPCTSTR)NULL , REG_SZ , (LPCTSTR)achTemp , sizeof(TCHAR) * (lstrlen(achTemp)+1) ); if( ERROR_SUCCESS != lreturn ) { RegCloseKey( hkey ); RegCloseKey( hsubkey ); return AmHresultFromWin32(lreturn); } wsprintf( achTemp, TEXT("%ls"), szThreadingModel ); lreturn = RegSetValueEx( hsubkey , TEXT("ThreadingModel") , 0L , REG_SZ , (CONST BYTE *)achTemp , sizeof(TCHAR) * (lstrlen(achTemp)+1) ); // close hkeys // RegCloseKey( hkey ); RegCloseKey( hsubkey ); // and return // return HRESULT_FROM_WIN32(lreturn); }
void CCreateDialog::OnOK() { // TODO: Add extra validation here //MessageBox(m_FolderStr); //MessageBox(m_FvmStr); GUID id1; unsigned char mask = (unsigned char) 0x0f; TCHAR buffer[1024]; CoCreateGuid(&id1); StringFromGUID2(id1, buffer, 1024); CString str = buffer; str.TrimLeft('{'); str.TrimRight('}'); str.Remove('-'); if(m_Parent->FvmDataFind(m_FvmStr)){ MessageBox(L"The FVM "+m_FvmStr+ L" exists. Please choose a new name"); return; } CString vfs = m_FolderStr+L"\\"+str; if(!CreateDirectory(vfs,NULL)){ MessageBox(L"The direcotry " + m_FolderStr + L" is not writable, please choose a new directory."); return; } HKEY key; DWORD type; DWORD bytes; CString regStr; regStr.LoadString(IDS_RNIFVM_REG); if (RegCreateKey(HKEY_CURRENT_USER, regStr, &key)==ERROR_SUCCESS) { RegCloseKey(key); regStr.LoadString(IDS_VMS_REG); if (RegCreateKey(HKEY_CURRENT_USER, regStr,&key)==ERROR_SUCCESS){ type = REG_SZ; if (RegCreateKey(HKEY_CURRENT_USER, regStr + "\\" + m_FvmStr, &key)==ERROR_SUCCESS){ bytes = (m_FolderStr.GetLength()+1)*sizeof(TCHAR); RegSetValueEx(key, _T("fvmroot"), NULL, type, (LPBYTE)m_FolderStr.GetBuffer(bytes-1), bytes); m_FolderStr.ReleaseBuffer(); bytes = (str.GetLength()+1)*sizeof(TCHAR); RegSetValueEx(key, _T("fvmid"), NULL, type, (LPBYTE)str.GetBuffer(bytes-1), bytes); str.ReleaseBuffer(); bytes = (m_FvmIpStr.GetLength()+1)*sizeof(TCHAR); RegSetValueEx(key, _T("fvmip"), NULL, type, (LPBYTE)m_FvmIpStr.GetBuffer(bytes-1), bytes); m_FvmIpStr.ReleaseBuffer(); bytes = (m_FvmIpMaskStr.GetLength()+1)*sizeof(TCHAR); RegSetValueEx(key, _T("fvmipmask"), NULL, type, (LPBYTE)m_FvmIpMaskStr.GetBuffer(bytes-1), bytes); m_FvmIpMaskStr.ReleaseBuffer(); bytes = (1+1)*sizeof(TCHAR); RegSetValueEx(key, _T("schedPriority"), NULL, type, (LPBYTE)"&", bytes); bytes = (1+1)*sizeof(TCHAR); RegSetValueEx(key, _T("maxProcesses"), NULL, type, (LPBYTE)"&", bytes); bytes = (1+1)*sizeof(TCHAR); RegSetValueEx(key, _T("maxComMemory"), NULL, type, (LPBYTE)"&", bytes); bytes = (1+1)*sizeof(TCHAR); RegSetValueEx(key, _T("maxWorkSet"), NULL, type, (LPBYTE)"&", bytes); } } } else{ MessageBox(L"Could not save fvm information. Creating fvm aborts."); CDialog::OnOK(); } t_FvmData *td = new t_FvmData; td->fvmID = str; td->fvmName = m_FvmStr; td->fvmRoot = m_FolderStr; td->fvmIp = m_FvmIpStr; td->fvmIpMask = m_FvmIpMaskStr; td->schedPriority = "&"; td->maxProcesses = "&"; td->maxComMemory = "&"; td->maxWorkSet = "&"; td->status = 0; td->suspendlist = NULL; td->suspendworkingset = NULL; td->next = NULL; m_Parent->FvmDataAdd(td); m_Parent->m_selectedFvm = td; m_Parent->UpdateDisplays(); m_Parent->created = td; /* CFvmBrowser *fb = m_Parent->GetFvmBrowserView(); CListCtrl& lc = fb-> GetListCtrl(); lc.InsertItem(0, m_FvmStr, 1); */ m_Parent->GetFvmBrowserView()->InsertFvms(); m_Parent->UpdateDisplays(); CDialog::OnOK(); }
void openlog(const char *ident, int logstat, int logfac) /* * Purpose: * Initialises the handle to the systemlog that is needed * to put messages in it. Before it checks the registry and * looks if the syslog is already registered as an event * source * * Precondition: * ident, logstat and logfac are ignored, they are there to * provide the Unix interface * * Postcondition: * handle released if it was opened before * * Mods: * 05/11/97 (CVP) * 12/12/97 (CVP) check if handle == NULL to handle repeated * calls to this procedure * 09/02/97 (CVP) add check if the key HKEY_LOCAL_MACHINE\SLG_APP_REG_PATH * does already exist in the registry. If so, all entires to * the registry are skipped and a simple RegisterEventSource * is sufficient. * 10/10/98 (AB) use of ident parameter, which indicates source of the log * entries. This parameter was previously ignored. */ { HKEY hk; DWORD dwData; CHAR szBuf[SLG_BUFSIZE]; DWORD catCount; /* * repeated calls to openlog should have no effect */ if (h == NULL) { ZeroMemory(username, SLG_BUFSIZE * sizeof(char)); /* * Check if the key is already there * HKEY_LOCAL_MACHINE\SLG_APP_REG_PATH */ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, SLG_APP_REG_PATH, 0, KEY_READ, &hk) != ERROR_SUCCESS) { /* * Add your source name as a subkey under the Application * key in the EventLog service portion of the registry. */ if (RegCreateKey(HKEY_LOCAL_MACHINE, SLG_APP_REG_PATH, &hk)) { SLG_DEBUG(fprintf(SLG_DEBUG_OUT, SLG03)); SLG_PANIC(); } /* * Set the Event ID message-file name. */ strcpy(szBuf, SLG_APP_FILE_PATH); /* * Add the Event ID message-file name to the subkey. */ if (RegSetValueEx(hk, /* subkey handle */ "EventMessageFile", /* value name */ 0, /* must be zero */ REG_EXPAND_SZ, /* value type */ (LPBYTE) szBuf, /* address of value data */ strlen(szBuf) + 1) /* length of value data */ ) { SLG_DEBUG(printf(SLG04)); SLG_PANIC(); } /* * Add the Category ID category-file name to the subkey. */ strcpy(szBuf, SLG_CAT_FILE_PATH); if (RegSetValueEx(hk, /* subkey handle */ "CategoryMessageFile", /* value name */ 0, /* must be zero */ REG_EXPAND_SZ, /* value type */ (LPBYTE) szBuf, /* address of value data */ strlen(szBuf) + 1) /* length of value data */ ) { SLG_DEBUG(fprintf(SLG_DEBUG_OUT, SLG05)); SLG_PANIC(); } /* * Set the category Counter */ catCount = SLG_CAT_COUNT; if (RegSetValueEx(hk, /* subkey handle */ "CategoryCount", /* value name */ 0, /* must be zero */ REG_DWORD, /* value type */ (LPBYTE) &catCount, /* address of value data */ sizeof(DWORD)) /* length of value data */ ) { SLG_DEBUG(fprintf(SLG_DEBUG_OUT, SLG06)); SLG_PANIC(); } /* * Set the supported types flags. */ dwData = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE; if (RegSetValueEx(hk, /* subkey handle */ "TypesSupported", /* value name */ 0, /* must be zero */ REG_DWORD, /* value type */ (LPBYTE) &dwData, /* address of value data */ sizeof(DWORD)) /* length of value data */ ) { SLG_DEBUG(fprintf(SLG_DEBUG_OUT, SLG07)); SLG_PANIC(); } } /* make appropriate regentries for the event source syslog */ RegCloseKey(hk); h = RegisterEventSource( NULL, /* uses local computer */ (ident==NULL) ? SLG_APP_NAME:ident); /* source name - syslog by default */ if (h == NULL) { SLG_DEBUG(fprintf(SLG_DEBUG_OUT, SLG08)); SLG_PANIC(); } } }
// PURPOSE: Installs the service on the local machine void CNTService::CmdInstallService() { char szPath[_MAX_PATH * 2]; char szErr[256]; ReportEvent(EVENTLOG_INFORMATION_TYPE, 0, "Installing Service."); // Try to determine the name and path of this application. if ( !GetModuleFileName(NULL, szPath, sizeof(szPath)) ) { ReportEvent(EVENTLOG_ERROR_TYPE, 0, "Install GetModuleFileName", GetLastErrorText(szErr, sizeof(szErr))); return; } // Try to open the Service Control Manager SC_HANDLE schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); if ( !schSCManager ) { ReportEvent(EVENTLOG_ERROR_TYPE, 0, "Install OpenSCManager", GetLastErrorText(szErr, sizeof(szErr))); return; } // Try to create the service char szInternalName[_MAX_PATH]; sprintf(szInternalName, SPHERE_TITLE " - %s", g_Serv.GetName()); SC_HANDLE schService = CreateService( schSCManager, // handle of the Service Control Manager szInternalName, // Internal name of the service (used when controlling the service using "net start" or "netsvc") szInternalName, // Display name of the service (displayed in the Control Panel | Services page) SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, // Start automatically when the OS starts SERVICE_ERROR_NORMAL, szPath, // Path and filename of this executable NULL, NULL, NULL, NULL, NULL ); if ( !schService ) { ReportEvent(EVENTLOG_ERROR_TYPE, 0, "Install CreateService", GetLastErrorText(szErr, sizeof(szErr))); bailout1: CloseServiceHandle(schSCManager); return; } // Configure service - Service description char szDescription[_MAX_PATH]; sprintf(szDescription, "SphereServer Service for %s", g_Serv.GetName()); SERVICE_DESCRIPTION sdDescription; sdDescription.lpDescription = szDescription; if ( !ChangeServiceConfig2(schService, SERVICE_CONFIG_DESCRIPTION, &sdDescription) ) { // not critical, so no need to abort the service creation ReportEvent(EVENTLOG_WARNING_TYPE, 0, "Install SetDescription", GetLastErrorText(szErr, sizeof(szErr))); } // Configure service - Restart options SC_ACTION scAction[3]; scAction[0].Type = SC_ACTION_RESTART; // restart process on failure scAction[0].Delay = 10000; // wait 10 seconds before restarting scAction[1].Type = SC_ACTION_RESTART; scAction[1].Delay = 10000; scAction[2].Type = SC_ACTION_RESTART; // wait 2 minutes before restarting the third time scAction[2].Delay = 120000; SERVICE_FAILURE_ACTIONS sfaFailure; sfaFailure.dwResetPeriod = (1 * 60 * 60); // reset failure count after an hour passes with no fails sfaFailure.lpRebootMsg = NULL; // no reboot message sfaFailure.lpCommand = NULL; // no command executed sfaFailure.cActions = COUNTOF(scAction); // number of actions sfaFailure.lpsaActions = scAction; // if ( !ChangeServiceConfig2(schService, SERVICE_CONFIG_FAILURE_ACTIONS, &sfaFailure) ) { // not critical, so no need to abort the service creation ReportEvent(EVENTLOG_WARNING_TYPE, 0, "Install SetAutoRestart", GetLastErrorText(szErr, sizeof(szErr))); } HKEY hKey; char szKey[_MAX_PATH]; // Register the application for event logging DWORD dwData; // Try to create the registry key containing information about this application strcpy(szKey, "System\\CurrentControlSet\\Services\\EventLog\\Application\\" SPHERE_FILE "svr"); if (RegCreateKey(HKEY_LOCAL_MACHINE, szKey, &hKey)) ReportEvent(EVENTLOG_ERROR_TYPE, 0, "Install RegCreateKey", GetLastErrorText(szErr, sizeof(szErr))); else { // Try to create the registry key containing the name of the EventMessageFile // Replace the name of the exe with the name of the dll in the szPath variable if (RegSetValueEx(hKey, "EventMessageFile", 0, REG_EXPAND_SZ, (LPBYTE) szPath, strlen(szPath) + 1)) ReportEvent(EVENTLOG_ERROR_TYPE, 0, "Install RegSetValueEx", GetLastErrorText(szErr, sizeof(szErr))); else { // Try to create the registry key containing the types of errors this application will generate dwData = EVENTLOG_ERROR_TYPE|EVENTLOG_INFORMATION_TYPE|EVENTLOG_WARNING_TYPE; if ( RegSetValueEx(hKey, "TypesSupported", 0, REG_DWORD, (LPBYTE) &dwData, sizeof(DWORD)) ) ReportEvent(EVENTLOG_ERROR_TYPE, 0, "Install RegSetValueEx", GetLastErrorText(szErr, sizeof(szErr))); } RegCloseKey(hKey); } // Set the working path for the application sprintf(szKey, "System\\CurrentControlSet\\Services\\" SPHERE_TITLE " - %s\\Parameters", g_Serv.GetName()); if ( RegCreateKey(HKEY_LOCAL_MACHINE, szKey, &hKey) ) { ReportEvent(EVENTLOG_ERROR_TYPE, 0, "Install RegCreateKey", GetLastErrorText(szErr, sizeof(szErr))); bailout2: CloseServiceHandle(schService); goto bailout1; } ExtractPath(szPath); if ( RegSetValueEx(hKey, "WorkingPath", 0, REG_SZ, (const unsigned char *) &szPath[0], strlen(szPath)) ) ReportEvent(EVENTLOG_ERROR_TYPE, 0, "Install RegSetValueEx", GetLastErrorText(szErr, sizeof(szErr))); ReportEvent(EVENTLOG_INFORMATION_TYPE, 0, "Install OK", g_Serv.GetName()); goto bailout2; }