static NTSTATUS SilentUpdateCheckThreadStart( __in PVOID Parameter ) { if (ConnectionAvailable()) { if (QueryXmlData()) { ULONG majorVersion = 0; ULONG minorVersion = 0; // Get the current Process Hacker version PhGetPhVersionNumbers(&majorVersion, &minorVersion, NULL, NULL); // Compare the current version against the latest available version if (CompareVersions(UpdateData.MajorVersion, UpdateData.MinorVersion, majorVersion, minorVersion) > 0) { // Don't spam the user the second they open PH, delay dialog creation for 3 seconds. Sleep(3 * 1000); // Show the dialog asynchronously on a new thread. ShowUpdateDialog(); } } FreeXmlData(); } return STATUS_SUCCESS; }
BOOL OSAL_ConfigController_SetNumValue(const char *ignore, const char *config_name, UINT32 *value) { BOOL result = FALSE; BOOL bXmlRead, bSetInnerText, bXmlWrite; pXmlElement xmlRoot, xmlTopElement, xmlTargetElement; char buf[16] = {0}; if (config_name == NULL) { return result; } pthread_mutex_lock(&g_configmutex); // Open Config XML file xmlRoot = CreateEmptyXmlData(); bXmlRead = ReadXmlFile(xmlRoot, CONFIG_XMLFILE); if (!bXmlRead) { OSALTRACE(OSAL_ERROR, ("cannot read config xml file")); pthread_mutex_unlock(&g_configmutex); return result; } // Find "config_name" xmlTopElement = FindChild(xmlRoot, CONFIG_INTEL_WIMAX); xmlTargetElement = FindChild(xmlTopElement, config_name); if (xmlTargetElement != NULL) { //convert integer to string snprintf(buf, sizeof(buf), "%d", *value); bSetInnerText = SetElementInnerText(xmlTargetElement, buf); if(bSetInnerText == TRUE) { // write to XML file bXmlWrite = WriteXmlFile(xmlTopElement, CONFIG_XMLFILE_TMP); if(bXmlWrite == TRUE) { result = TRUE; } else { OSALTRACE(OSAL_ERROR, ("cannot write config xml file")); result = FALSE; } } } // Close XML FreeXmlData(xmlRoot); //swap the file pthread_mutex_lock(&g_swapfilemutex); rename(CONFIG_XMLFILE_TMP,CONFIG_XMLFILE); pthread_mutex_unlock(&g_swapfilemutex); pthread_mutex_unlock(&g_configmutex); return result; }
BOOL OSAL_ConfigController_GetNumValue(const char *ignore, const char *config_name, UINT32 * value) { BOOL result = FALSE; BOOL bXmlRead; pXmlElement xmlRoot, xmlTopElement, xmlTargetElement; const char *target_data; BOOL bDnDOutputQuery = FALSE; if (config_name == NULL) { return result; } if ( strcasecmp(config_name, OSAL_KEY_ENTRY_DND_OUTPUT_MODE) == 0) { bDnDOutputQuery = TRUE; } pthread_mutex_lock(&g_configmutex); // Open Config XML file xmlRoot = CreateEmptyXmlData(); bXmlRead = ReadXmlFile(xmlRoot, CONFIG_XMLFILE); if (!bXmlRead) { OSALTRACE(OSAL_ERROR, ("cannot read config xml file")); pthread_mutex_unlock(&g_configmutex); return result; } // Find "config_name" xmlTopElement = FindChild(xmlRoot, CONFIG_INTEL_WIMAX); xmlTargetElement = FindChild(xmlTopElement, config_name); if (xmlTargetElement != NULL) { target_data = GetElementInnerText(xmlTargetElement); if (target_data != NULL) { // Copy to the value *value = (UINT32) atoi(target_data); result = TRUE; } } if ( bDnDOutputQuery ) { OSALTRACE(OSAL_DEBUG, ("Result of query is %d, and value is %d.", result, result ? *value : -1)); } // Close XML FreeXmlData(xmlRoot); pthread_mutex_unlock(&g_configmutex); return result; }
BOOL OSAL_ConfigController_GetStrValue(const char *ignore, const char *config_name, char* value,UINT32 maxsize) { BOOL result = FALSE; BOOL bXmlRead; pXmlElement xmlRoot, xmlTopElement, xmlTargetElement; const char *target_data; UINT32 data_size=0; if (config_name == NULL) { return result; } pthread_mutex_lock(&g_configmutex); // Open Config XML file xmlRoot = CreateEmptyXmlData(); bXmlRead = ReadXmlFile(xmlRoot, CONFIG_XMLFILE); if (!bXmlRead) { OSALTRACE(OSAL_ERROR, ("cannot read config xml file")); pthread_mutex_unlock(&g_configmutex); return result; } // Find "config_name" xmlTopElement = FindChild(xmlRoot, CONFIG_INTEL_WIMAX); xmlTargetElement = FindChild(xmlTopElement, config_name); if (xmlTargetElement != NULL) { target_data = GetElementInnerText(xmlTargetElement); data_size = strlen(target_data)+1; if (target_data != NULL) { if(data_size > maxsize -1){ // Copy to the value memcpy(value, target_data, maxsize-1); // Added by Kalyan to make the value as a complete string // and to avoid problems with strlen, strcpy on value without \0 value[maxsize-1] = '\0'; } else { memcpy(value, target_data, data_size); } result = TRUE; } } // Close XML FreeXmlData(xmlRoot); pthread_mutex_unlock(&g_configmutex); return result; }
static NTSTATUS ShowUpdateDialogThreadStart( __in PVOID Parameter ) { BOOL result; MSG message; PH_AUTO_POOL autoPool; PhInitializeAutoPool(&autoPool); UpdateDialogHandle = CreateDialog( (HINSTANCE)PluginInstance->DllBase, MAKEINTRESOURCE(IDD_UPDATE), PhMainWndHandle, UpdaterWndProc ); PhSetEvent(&InitializedEvent); while (result = GetMessage(&message, NULL, 0, 0)) { if (result == -1) break; if (!IsDialogMessage(UpdateDialogHandle, &message)) { TranslateMessage(&message); DispatchMessage(&message); } PhDrainAutoPool(&autoPool); } PhDeleteAutoPool(&autoPool); PhResetEvent(&InitializedEvent); // Ensure global objects are disposed and reset when window closes. if (SetupFilePath) { PhDereferenceObject(SetupFilePath); SetupFilePath = NULL; } if (UpdateCheckThreadHandle) { NtClose(UpdateCheckThreadHandle); UpdateCheckThreadHandle = NULL; } if (DownloadThreadHandle) { NtClose(DownloadThreadHandle); DownloadThreadHandle = NULL; } if (UpdaterDialogThreadHandle) { NtClose(UpdaterDialogThreadHandle); UpdaterDialogThreadHandle = NULL; } if (FontHandle) { DeleteObject(FontHandle); FontHandle = NULL; } FreeXmlData(); if (UpdateDialogHandle) { DestroyWindow(UpdateDialogHandle); UpdateDialogHandle = NULL; } return STATUS_SUCCESS; }