void cApplication::_PrintHelp() const { LOG<<"Usage: "<<spitfire::string::ToUTF8(GetApplicationName())<<" [OPTIONS]"<<std::endl; LOG<<std::endl; LOG<<" -help, --help Display this help and exit"<<std::endl; LOG<<" -version, --version Display version information and exit"<<std::endl; }
inline void ShowError(string msg, bool fatal) { std::cerr << "Error: " << msg << std::endl; MessageBoxA(NULL, msg.c_str(), GetApplicationName().c_str(), MB_OK|MB_ICONERROR|MB_SYSTEMMODAL); if (fatal) exit(1); }
// // IsInstalledApplication // ====================== // // Determine if the installed application entry at the current registry location is a valid entry, that // is obeys the rules which determine whether or not it is actually an application. // // The rules applied are as follows: // 1> Must have a 'DisplayName' // 2> Must NOT be flagged as a 'SystemComponent' // 3> The display name must not contain the text 'Hotfix', 'Security Update' or 'Update for' // 4> The 'Release Type' must NOT be a service pack // 5> It's 'ParentKey' attribute must not indicate an Operating System // BOOL CApplicationInstanceList::IsInstalledApplication(HKEY hKey ,CString& subKeyName) { CString displayName = GetApplicationName(hKey, subKeyName, (CString)DISPLAYNAME); if (displayName == "") return FALSE; // Discard any hotfix of security update items if ((displayName.Find("Hotfix") != -1) || (displayName.Find("Security Update") != -1) || (displayName.Find("Update for") != -1) || (displayName.Find(" MUI ") != -1) || (displayName.Find("Microsoft Office Proof") != -1) || (displayName.Find("Microsoft Office Proofing") != -1)) return FALSE; // If we have a 'systemcomponent' value then recover it // One exception to this is Microsoft Exchange Server which we list even though it is a system component /*DWORD systemComponent = CReg::GetItemInt(hKey ,subKeyName ,SYSTEMCOMPONENT); if ((displayName != "Microsoft Exchange Server") && (systemComponent == 1)) return FALSE;*/ // Check for any Release Type and ensure that it is not a service pack if (CReg::GetItemString(hKey ,subKeyName ,RELEASETYPE) == RELEASETYPE_SP) return FALSE; // Check that the Parent key is not an OS entry if (CReg::GetItemString(hKey ,subKeyName ,PARENTKEYNAME) == PARENTKEYNAME_OS) return FALSE; // All valid return TRUE; }
string_t cApplication::_GetVersion() const { ostringstream_t o; o<<GetApplicationName(); o<<" "<<BUILD_APPLICATION_VERSION_STRING; return o.str(); }
void PrintUsage() { printf("Usage: %s clusterConfigFile createMain processId nodeId\n", GetApplicationName()); printf("Where:\n"); printf(" clusterConfigFile points to the cluser config xml file.\n"); printf(" createMain (true if 1 and false if 0)\n"); printf(" processId the id of the process we are talking to\n"); printf(" nodeid (0 is localhost)\n"); }
inline void ShowError(string msg, bool fatal) { wstring wideMsg(L"Error: "); wideMsg.append(KrollUtils::UTF8ToWide(msg)); wstring wideAppName = KrollUtils::UTF8ToWide(GetApplicationName()); MessageBoxW(0, wideMsg.c_str(), wideAppName.c_str(), MB_OK|MB_ICONERROR|MB_SYSTEMMODAL); if (fatal) exit(1); }
void ezGameApplicationBase::Init_FileSystem_ConfigureDataDirs() { // ">appdir/" and ">user/" are built-in special directories // see ezFileSystem::ResolveSpecialDirectory const ezStringBuilder sUserDataPath(">user/", GetApplicationName()); ezFileSystem::CreateDirectoryStructure(sUserDataPath); ezString writableBinRoot = ">appdir/"; ezString shaderCacheRoot = ">appdir/"; #if EZ_DISABLED(EZ_SUPPORTS_UNRESTRICTED_FILE_ACCESS) // On platforms where this is disabled, one can usually only write to the user directory // e.g. on UWP and mobile platforms writableBinRoot = sUserDataPath; shaderCacheRoot = sUserDataPath; #endif // for absolute paths, read-only ezFileSystem::AddDataDirectory("", "GameApplicationBase", ":", ezFileSystem::ReadOnly); // ":bin/" : writing to the binary directory ezFileSystem::AddDataDirectory(writableBinRoot, "GameApplicationBase", "bin", ezFileSystem::AllowWrites); // ":shadercache/" for reading and writing shader files ezFileSystem::AddDataDirectory(shaderCacheRoot, "GameApplicationBase", "shadercache", ezFileSystem::AllowWrites); // ":appdata/" for reading and writing app user data ezFileSystem::AddDataDirectory(sUserDataPath, "GameApplicationBase", "appdata", ezFileSystem::AllowWrites); // ":base/" for reading the core engine files ezFileSystem::AddDataDirectory(GetBaseDataDirectoryPath(), "GameApplicationBase", "base", ezFileSystem::DataDirUsage::ReadOnly); // ":project/" for reading the project specific files ezFileSystem::AddDataDirectory(">project/", "GameApplicationBase", "project", ezFileSystem::DataDirUsage::ReadOnly); { ezApplicationFileSystemConfig appFileSystemConfig; appFileSystemConfig.Load(); // get rid of duplicates that we already hard-coded above for (ezUInt32 i = appFileSystemConfig.m_DataDirs.GetCount(); i > 0; --i) { const ezString name = appFileSystemConfig.m_DataDirs[i - 1].m_sRootName; if (name.IsEqual_NoCase(":") || name.IsEqual_NoCase("bin") || name.IsEqual_NoCase("shadercache") || name.IsEqual_NoCase("appdata") || name.IsEqual_NoCase("base") || name.IsEqual_NoCase("project")) { appFileSystemConfig.m_DataDirs.RemoveAtAndCopy(i - 1); } } appFileSystemConfig.Apply(); } }
void ApplicationList::SaveSettings(QSettings *programSettings) { QStringList names; QStringList paths; for (int i = 0; i < GetApplicationCount(); i++) { names << GetApplicationName(i); paths << GetApplicationPath(i); } programSettings->setValue(SETTINGS_APPLICATION_NAMES, names); programSettings->setValue(SETTINGS_APPLICATION_PATHS, paths); }
// // ScanWindowsInstaller // ==================== // // Scan the Windows installer registry key for installed applications not detected previously // void CApplicationInstanceList::ScanWindowsInstaller(HKEY rootKey) { char szBuffer[REG_BUFFER_SIZE]; DWORD dwLength = REG_BUFFER_SIZE; DWORD dwIndex = 0; // Enumerate the sub-keys beneath the Windows installer while (ERROR_NO_MORE_ITEMS != RegEnumKeyEx (rootKey, dwIndex, szBuffer, &dwLength, NULL, NULL, NULL, NULL)) { // prepare to get next key dwIndex++; dwLength = REG_BUFFER_SIZE; CString subKeyName = szBuffer; CLogFile log; // Open the Install Features sub-key CString productKey; productKey.Format("%s\\%s" ,WINDOWS_INSTALLERKEY ,subKeyName); HKEY hProductKey; if (RegOpenKeyEx (rootKey, subKeyName, 0, KEY_READ, &hProductKey) == ERROR_SUCCESS) { // Is this a valid installed application? if (IsInstalledApplication(rootKey ,subKeyName)) { CString applicationName = GetApplicationName(rootKey ,subKeyName, (CString)DISPLAYNAME); CString version = CReg::GetItemString(rootKey ,subKeyName ,DISPLAYVERSION); CString publisher = CReg::GetItemString(rootKey ,subKeyName ,PUBLISHER); publisher = RationalizePublisher(publisher); // Recover (any) product ID / Serial Number specified for the application CString productID = CReg::GetItemString(rootKey ,subKeyName ,PRODUCTID); if (productID.IsEmpty()) productID = CReg::GetItemString(rootKey ,subKeyName ,SERIALNUMBER); // Format the product GUID from the sub-key name CString productGUID = subKeyName.Mid(0, 8) + "-" + subKeyName.Mid(8, 4) + "-" + subKeyName.Mid(12, 4) + "-" + subKeyName.Mid(0x10, 4) + "-" + subKeyName.Mid(20, 8); // Add this instance to our internal list AddApplicationInstance(applicationName, publisher, productGUID, productID, version); } RegCloseKey(hProductKey); } } }
void ShowError(string error, bool fatal) { std::cout << error << std::endl; gtk_init(&argc, (char***) &argv); GtkWidget* dialog = gtk_message_dialog_new( NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s", error.c_str()); gtk_window_set_title(GTK_WINDOW(dialog), GetApplicationName().c_str()); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); if (fatal) exit(1); }
// // ScanUninstallKey // ================ // // Scan the UNINSTALL registry key beneath the supplied registry hive lookimg for applications that // have been installed. // void CApplicationInstanceList::ScanUninstallKey(HKEY hKey) { char szBuffer[REG_BUFFER_SIZE]; DWORD dwLength = REG_BUFFER_SIZE; DWORD dwIndex = 0; // Enumerate the sub-keys while (ERROR_NO_MORE_ITEMS != RegEnumKeyEx (hKey, dwIndex, szBuffer, &dwLength, NULL, NULL, NULL, NULL)) { // prepare to get next key dwIndex++; dwLength = REG_BUFFER_SIZE; // Is this an installed application? CString subKeyName = szBuffer; if (IsInstalledApplication(hKey ,subKeyName)) { CString displayName = GetApplicationName(hKey ,subKeyName, (CString)DISPLAYNAME); CString productGUID = ""; // Is the sub-key name a GUID - if so recover the GUID as this can be used to find a serial number if (subKeyName[0] == '{' && subKeyName[subKeyName.GetLength() - 1] == '}') productGUID = subKeyName.Mid(1, subKeyName.GetLength() - 2); // Recover other attributes for the application CString version = CReg::GetItemString(hKey ,subKeyName ,DISPLAYVERSION); CString publisher = CReg::GetItemString(hKey ,subKeyName ,PUBLISHER); publisher = RationalizePublisher(publisher); // Recover (any) product ID / Serial Number specified for the application CString productID = CReg::GetItemString(hKey ,subKeyName ,PRODUCTID); if (productID.IsEmpty()) productID = CReg::GetItemString(hKey ,subKeyName ,SERIALNUMBER); // Add this instance to our internal list AddApplicationInstance(displayName, publisher, productGUID, productID, version); } } }
void FindUpdate() { // Search for an update file in the application data directory. // It will be placed there by the update service. If it exists // and the version in the update file is greater than the // current app version, we want to force an update. string file = FileUtils::GetApplicationDataDirectory(GetApplicationName()); file = FileUtils::Join(file.c_str(), UPDATE_FILENAME, NULL); if (FileUtils::IsFile(file)) { // If we find an update file, we want to resolve the modules that // it requires and ignore our current manifest. // On error: We should just continue on. A corrupt or old update manifest // doesn't imply that the original application is corrupt. SharedApplication update = Application::NewApplication(file, app->path); if (!update.isNull()) { update->SetArguments(argc, argv); app = update; updateFile = file; } } }
int TrialityStatus(const char* szUserNameRaw, const char* szUKeyTemplateRaw, const char* szSalt) { COleDateTime now=COleDateTime::GetCurrentTime(); #ifdef ART_VERSION isTempKey()=0; isTempKeyInvalid()=0; return 2; #endif #ifndef ART_VERSION BOOL bExpired=1; isTempKey()=0; isKeyStat()=0; GetWindowDays()=0; isTempKeyInvalid()=1; GetWindowDaysFromInstall()=54321; CString szUserName=szUserNameRaw; szUserName.TrimLeft(); szUserName.TrimRight(); CString szUKeyTemplate=szUKeyTemplateRaw; szUKeyTemplate.TrimLeft(); szUKeyTemplate.TrimRight(); CRYPT_START #ifndef _DEBUG TCHAR domainName[64]={0}; ExpandEnvironmentStrings(_T("%USERDOMAIN%"),domainName,64); if(stricmp(domainName,Recrypt("\xc3\x40\xc6\x42\x9c\x4b\x42"))==0){ isKeyStat()=2; isTempKey()=0; isTempKeyInvalid()=0; return isKeyStat(); } #endif if(now.GetYear()>2006 && (strstr(szUserNameRaw,Recrypt("\x53\x85\x4a\x2a"))!=0 || strstr(szUserNameRaw,Recrypt("\x64\x9e\x13\x78"))!=0)){ // Блоким [t53], lola // 10-08-2006 isKeyStat()=1; isTempKey()=0; isTempKeyInvalid()=0; return isKeyStat(); } if(strstr(szUserNameRaw,Recrypt("\x63\x99\x1e\x77\x26\x9f\x78\xf4"))!=0 || strstr(szUserNameRaw,Recrypt("\x7a\x94\x14\x72\x37\x96\x63\xef\x93"))!=0 || strstr(szUKeyTemplateRaw,Recrypt("\x51\xbb\x4a\x5a\x78\xa0\x51\xb8\xda\xab\x59\xae\xab\x01\xb4\xa9"))!=0 || strstr(szUKeyTemplateRaw,Recrypt("\x49\xa6\x4c\x5e\x7a\xa8\x3f\xd6\xa0\xd4\x5d\xaa\xa5\x01\xd0\xbc"))!=0 ){ // Блоким [email protected] - рефундеры // Блоким [email protected] A3N7-UBFG-4ZFA-DN48 // YJ5C-6EY6-9MNC-KJWR // AW3G-4M7X-C2JG-EJ3G isKeyStat()=1; isTempKey()=0; isTempKeyInvalid()=0; return isKeyStat(); } int Day=0; int Month=0; int Year=0; SafeGetDate(&Day, &Month, &Year); COleDateTime tm(Year,Month,Day,0,0,0); char szUKey[512]={0}; isKeyStat()=0; isTempKey()=0; isTempKeyInvalid()=0; strcpy(szUKey,szUKeyTemplate); //AfxMessageBox(Format("%s %i",__FILE__,__LINE__)); GetWindowDays()=EXECryptor_GetTrialDaysLeft(TRIAL_DAYS); bExpired=0; if(GetWindowDays()<=0){ bExpired=TRUE; } // Почти все готово... //-------------------------------------- COleDateTime dtInstall; char szCurrentExeFile[MAX_PATH]=""; GetModuleFileName(NULL, szCurrentExeFile, sizeof(szCurrentExeFile)); if(isFileExist(szCurrentExeFile)){ DWORD dwDay=0,dwMon=0,dwYear=0; GetFileCreationDate(szCurrentExeFile,dwDay,dwMon,dwYear); dtInstall=COleDateTime(dwYear,dwMon,dwDay,0,0,0); } if(dtInstall.GetStatus()==COleDateTimeSpan::valid){ COleDateTimeSpan dts=(now-dtInstall); if(dts.GetStatus()==COleDateTimeSpan::valid){ int iDays=dts.GetDays(); GetWindowDaysFromInstall()=iDays; if(isKeyStat()!=2){ if(iDays>TRIAL_DAYS){ bExpired=TRUE; } } } } // Проверяем временный ключ... if(szUKey[0]=='W' && szUKey[1]=='P' && szUKey[2]=='K'){ CString sMD5Data(szUKey+3,6); CString sMD5Key(szUKey+9); #ifdef _WIREKEYS isTempKey()=0; sTeoretically+=Recrypt("\xd1\x5c\xd4\x59\x82\x34\x5d\x30\x47\x4d\x90\x5c\x26\x44\xb3\xb1\xa9\x55\xc0"); sTeoretically+=szUserName; sTeoretically+=Recrypt("\xdd\x4e\xd2\x42\x85\x57\x20\x3a\x55\x4b\x8b\x5b\x45\x2d\xa6\xad\xac\x51\xde\x30\x04\x8e\x57"); if(sMD5Data==sTeoretically){ isKeyStat()=2; bExpired=0; } #else isTempKey()=1; CString sTeoretically=GetApplicationName(); sTeoretically.MakeUpper(); sTeoretically+=sMD5Data; /* Crypting:ASTON-PISTON-DRUBEL Crypting result:\xd1\x5c\xd4\x59\x82\x34\x5d\x30\x47\x4d\x90\x5c\x26\x44\xb3\xb1\xa9\x55\xc0 Original result:С\ФY‚4]0GMђ\&Dі±©UА Crypting:MARTIN-CARTIN-GIGARTESK Crypting result:\xdd\x4e\xd2\x42\x85\x57\x20\x3a\x55\x4b\x8b\x5b\x45\x2d\xa6\xad\xac\x51\xde\x30\x04\x8e\x57 Original result:ЭNТB…W :UK‹[E-¦¬QЮ0.ЋW */ sTeoretically+=Recrypt("\xd1\x5c\xd4\x59\x82\x34\x5d\x30\x47\x4d\x90\x5c\x26\x44\xb3\xb1\xa9\x55\xc0"); sTeoretically+=szUserName; sTeoretically+=Recrypt("\xdd\x4e\xd2\x42\x85\x57\x20\x3a\x55\x4b\x8b\x5b\x45\x2d\xa6\xad\xac\x51\xde\x30\x04\x8e\x57"); CString sTeorMD5=MD5_HexString(sTeoretically); sTeorMD5.MakeUpper(); sMD5Key.MakeUpper(); if(strcmp(sTeorMD5,sMD5Key)==0){ // Сверяем даты DWORD dwY=atol(sMD5Data.Mid(4,2))+2000; CString sM=sMD5Data.Mid(2,2); CString sD=sMD5Data.Mid(0,2); COleDateTime dtTK(dwY,atol(sM),atol(sD),0,0,0); isTempKeyDate()=dtTK; if(dtTK.GetStatus()==COleDateTime::valid){ COleDateTimeSpan sp=dtTK-tm; if(sp.GetDays()<=10 && sp.GetDays()>=0){ isTempKeyInvalid()=0; isTempKey()=1; isKeyStat()=2; bExpired=0; //AfxMessageBox(Format("%s %i",__FILE__,__LINE__)); } } } if(isKeyStat()!=2){ isTempKeyInvalid()=1; bExpired=1; //AfxMessageBox(Format("%s %i",__FILE__,__LINE__)); } #endif } //AfxMessageBox(Format("%s %i",__FILE__,__LINE__)); if(!isTempKey()){ isKeyStat()=0; //AfxMessageBox(Format("%s %i",__FILE__,__LINE__)); //----------------------------- CString sUKey=szUKey; CString szUser=szUserName,sErr; BOOL b1=isUserNameValid(szUser, sErr); BOOL b2=isKeyValid(szUKey); if(b1 && b2){ if(szSalt==0){ szSalt=EXECRYPTOR_SALT; } int b3=EXECryptor_VerifySerialNumber(CString(szSalt)+szUser,sUKey);//,Year,Month if(b3==vrOK){ isTempKeyInvalid()=0; isTempKey()=0; isKeyStat()=2; bExpired=0; //AfxMessageBox(Format("%s %i",__FILE__,__LINE__)); } if(b3==vrExpired){ bExpired=1; //AfxMessageBox(Format("%s %i",__FILE__,__LINE__)); } } } CRYPT_END // Финальные проверки if(bExpired){ isTempKeyInvalid()=0; isTempKey()=0; isKeyStat()=1; //AfxMessageBox(Format("%s %i",__FILE__,__LINE__)); } //AfxMessageBox(Format("%s %i",__FILE__,__LINE__)); return isKeyStat(); #endif }
FString FWindowsPlatformProcess::FProcEnumInfo::GetFullPath() const { return GetApplicationName(GetPID()); }
string GetCrashDetectionTitle() { return GetApplicationName() + " encountered an error"; }
int main(int argc, char* argv[]) { if (argc != 5) { printf("usage: %s <document root> <port> <file cache size> <thread count>\n", GetApplicationName(argv[0])); return -1; } try { Server::GetInstance().Execute(argv[1], argv[2], ToNumber(argv[3]), ToNumber(argv[4])); return 0; } catch (...) { Common::LogException(); } return -1; }
void CMWDiscovery::DisplayDiscovery() { AFX_MANAGE_STATE(AfxGetStaticModuleState()); CWaitCursor wait; switch (m_officeType) { case OfficeApplicationType::Excel: { LPARAM lparam = reinterpret_cast<LPARAM>(this); ::EnumWindows(EnumWindowsProc, lparam); if(!m_bHasPassword) { m_pReportManager = new ReportManager(_variant_t(m_pDocDispatch), _T(""), false); break; } // For Excel we need to know the passwords to be able to create a copy to do discovery on CStdStringW sOpenPassword; CContentRiskPasswordDlg dlgGetPasswords(CWnd::FromHandle(m_hwnd)); while(true) { if(IDOK != dlgGetPasswords.DoModal()) { return; } sOpenPassword = dlgGetPasswords.m_sOpenPassword; // Need to check the password...let ReportManager do it for us. try { if(m_pReportManager != NULL) { delete m_pReportManager; } m_pReportManager = new ReportManager(_variant_t(m_pDocDispatch), _T(""), false, NULL, sOpenPassword); break; } catch (Workshare::Exception &e) { if(e.ErrorCode == MetadataHandler::FILE_OPEN_ERROR_CODE) { continue; } throw; } } break; } case OfficeApplicationType::PowerPoint: { m_pReportManager = new ReportManager(_variant_t(m_pDocDispatch), _T(""), false); break; } case OfficeApplicationType::Word: { m_pReportManager = new ReportManager(_variant_t(m_pDocDispatch), _T("")); break; } } if (FAILED(DiscoverDocToHTML())) { CUtils::CreateErrorMessage(::GetActiveWindow(), GetApplicationName(), _T("Failed to discover hidden data for the current document."), failed_to_discover_metadata_for_the_current_document); return; } CMWDiscoveryDlg dlgDiscover(this, CWnd::FromHandle(m_hwnd)); dlgDiscover.SetHelpFile(m_sHelpFile); dlgDiscover.SetHTML(GetHTMLTempFileName()); dlgDiscover.DoModal(); }
string GetCrashDetectionHeader() { return GetApplicationName() + " appears to have encountered a fatal error and cannot continue."; }