From 00e955153e8716fa37b02304770fdd69b74d0e92 Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Sun, 30 Jun 2013 16:27:11 +0000 Subject: VI report format adopted to CrashDumper git-svn-id: http://svn.miranda-ng.org/main/trunk@5195 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/VersionInfo/src/CPlugin.cpp | 5 +- plugins/VersionInfo/src/CPlugin.h | 11 -- plugins/VersionInfo/src/CVersionInfo.cpp | 310 ++++++++++++++++++------------ plugins/VersionInfo/src/CVersionInfo.h | 4 +- plugins/VersionInfo/src/dlgHandlers.cpp | 5 +- plugins/VersionInfo/src/hooked_events.cpp | 1 - plugins/VersionInfo/src/main.cpp | 2 +- plugins/VersionInfo/src/utils.cpp | 104 +++++----- plugins/VersionInfo/src/utils.h | 3 +- 9 files changed, 244 insertions(+), 201 deletions(-) diff --git a/plugins/VersionInfo/src/CPlugin.cpp b/plugins/VersionInfo/src/CPlugin.cpp index 8e1a57399b..00f6949d38 100644 --- a/plugins/VersionInfo/src/CPlugin.cpp +++ b/plugins/VersionInfo/src/CPlugin.cpp @@ -20,9 +20,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "common.h" -const int cPLUGIN_UUID_MARK = 4; -TCHAR PLUGIN_UUID_MARK[cPLUGIN_UUID_MARK]; - #define PLUGIN_UNCERTAIN_MARK "?" #define RJUST 70 @@ -118,7 +115,7 @@ std::tstring CPlugin::getInformations(DWORD flags, TCHAR *szHighlightHeader, TCH UUIDToString(pluginID, aux, SIZEOF(aux)); lpzInformations = aux; } - else lpzInformations = (IsUUIDNull(pluginID)) ? _T(" ") : PLUGIN_UUID_MARK; + else lpzInformations = _T(" "); lpzInformations += std::tstring(_T(" ") + lpzFileName + _T(" v.") + szHighlightHeader + lpzVersion + szHighlightFooter + _T(" [") + lpzTimestamp + _T("] - ") + lpzShortName); if (lpzUnicodeInfo.size() > 0) diff --git a/plugins/VersionInfo/src/CPlugin.h b/plugins/VersionInfo/src/CPlugin.h index 32b564653c..f78826a44d 100644 --- a/plugins/VersionInfo/src/CPlugin.h +++ b/plugins/VersionInfo/src/CPlugin.h @@ -22,17 +22,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef CPLUGIN_H #define CPLUGIN_H -#define DEF_UUID_CHARMARK "¤" - -extern const int cPLUGIN_UUID_MARK; -extern TCHAR PLUGIN_UUID_MARK[]; - -//using namespace std; - - - #define tstring wstring - - class CPlugin { private: std::tstring lpzFileName; diff --git a/plugins/VersionInfo/src/CVersionInfo.cpp b/plugins/VersionInfo/src/CVersionInfo.cpp index a477ae1258..bc84d46001 100644 --- a/plugins/VersionInfo/src/CVersionInfo.cpp +++ b/plugins/VersionInfo/src/CVersionInfo.cpp @@ -94,7 +94,6 @@ CVersionInfo::~CVersionInfo() lpzNightly.~basic_string(); lpzUnicodeBuild.~basic_string(); lpzBuildTime.~basic_string(); - lpzOSVersion.~basic_string(); lpzMirandaPath.~basic_string(); lpzCPUName.~basic_string(); lpzCPUIdentifier.~basic_string(); @@ -146,16 +145,16 @@ bool CVersionInfo::GetMirandaVersion() CallService(MS_SYSTEM_GETVERSIONTEXT, (WPARAM)str_size, (LPARAM)str); this->lpzMirandaVersion = _A2T(str); //Is it a nightly? - if (lpzMirandaVersion.find( _T("alpha"),0) != std::string::npos) + if (lpzMirandaVersion.find( _T("alpha"), 0) != std::string::npos) lpzNightly = _T("Yes"); else lpzNightly = _T("No"); lpzUnicodeBuild = _T("Yes"); - TCHAR time[128], date[128]; - GetModuleTimeStamp(date, time); - lpzBuildTime = std::tstring(time) + _T(" (UTC) on ") + std::tstring(date); + TCHAR mirtime[128]; + GetModuleTimeStamp(mirtime, 128); + lpzBuildTime = mirtime; return TRUE; } @@ -166,135 +165,40 @@ bool CVersionInfo::GetOSVersion() osvi.dwOSVersionInfoSize = sizeof(osvi); GetVersionEx(&osvi); - //Now fill the private members. - TCHAR aux[256]; - wsprintf(aux, _T("%d.%d.%d %s"), osvi.dwMajorVersion, osvi.dwMinorVersion, LOWORD(osvi.dwBuildNumber), osvi.szCSDVersion); - lpzOSVersion = aux; - //OSName //Let's read the registry. HKEY hKey; TCHAR szKey[MAX_PATH], szValue[MAX_PATH]; - lstrcpyn(szKey, _T("Hardware\\Description\\System\\CentralProcessor\\0"), MAX_PATH); - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) { - DWORD type, size, result; - - lstrcpyn(szValue, _T("Identifier"), MAX_PATH); - result = RegQueryValueEx(hKey, szValue, 0, &type, NULL, &size); - if (result == ERROR_SUCCESS) { - TCHAR *aux = new TCHAR[size+1]; - result = RegQueryValueEx(hKey, szValue, 0, &type, (LPBYTE) aux, &size); - lpzCPUIdentifier = aux; - delete[] aux; - } - else { - NotifyError(GetLastError(), _T("RegQueryValueEx()"), __LINE__); - lpzCPUIdentifier = _T(""); - } - - lstrcpyn(szValue, _T("ProcessorNameString"), MAX_PATH); - result = RegQueryValueEx(hKey, szValue, 0, &type, NULL, &size); //get the size - if (result == ERROR_SUCCESS) { - TCHAR *aux = new TCHAR[size+1]; - result = RegQueryValueEx(hKey, szValue, 0, &type, (LPBYTE) aux, &size); - lpzCPUName = aux; - delete[] aux; - } - else { //else try to use cpuid instruction to get the proc name - char szName[50]; - #if (!defined(WIN64) && !defined(_WIN64)) - __asm - { - push eax //save the registers - push ebx - push ecx - push edx - - xor eax, eax //get simple name - cpuid - mov DWORD PTR szName[0], ebx - mov DWORD PTR szName[4], edx - mov DWORD PTR szName[8], ecx - mov DWORD PTR szName[12], 0 - - mov eax, 0x80000000 //try to get pretty name - cpuid - - cmp eax, 0x80000004 - jb end //if we don't have the extension end the check - - mov DWORD PTR szName[0], 0 //make the string null - - mov eax, 0x80000002 //first part of the string - cpuid - mov DWORD PTR szName[0], eax - mov DWORD PTR szName[4], ebx - mov DWORD PTR szName[8], ecx - mov DWORD PTR szName[12], edx - - mov eax, 0x80000003 //second part of the string - cpuid - mov DWORD PTR szName[16], eax - mov DWORD PTR szName[20], ebx - mov DWORD PTR szName[24], ecx - mov DWORD PTR szName[28], edx - - mov eax, 0x80000004 //third part of the string - cpuid - mov DWORD PTR szName[32], eax - mov DWORD PTR szName[36], ebx - mov DWORD PTR szName[40], ecx - mov DWORD PTR szName[44], edx - -end: - pop edx //load them back - pop ecx - pop ebx - pop eax - } - szName[SIZEOF(szName) - 1] = '\0'; - #else - szName[0] = 0; - #endif - - if ( !szName[0] ) - lpzCPUName = _T(""); - else - lpzCPUName = _A2T(szName); - } - } - - bDEPEnabled = IsProcessorFeaturePresent(PF_NX_ENABLED); - switch (osvi.dwPlatformId) { case VER_PLATFORM_WIN32_WINDOWS: lstrcpyn(szKey, _T("Software\\Microsoft\\Windows\\CurrentVersion"), MAX_PATH); lstrcpyn(szValue, _T("Version"), MAX_PATH); break; - case VER_PLATFORM_WIN32_NT: + case VER_PLATFORM_WIN32_NT: lstrcpyn(szKey, _T("Software\\Microsoft\\Windows NT\\CurrentVersion"), MAX_PATH); lstrcpyn(szValue, _T("ProductName"), MAX_PATH); break; } - RegCloseKey(hKey); - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,szKey,0,KEY_QUERY_VALUE,&hKey) == ERROR_SUCCESS) { + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) { DWORD type, size, result; //Get the size of the value we'll read. - result = RegQueryValueEx((HKEY)hKey,szValue,(LPDWORD)NULL, (LPDWORD)&type,(LPBYTE)NULL, - (LPDWORD)&size); + result = RegQueryValueEx((HKEY)hKey, szValue, (LPDWORD)NULL, (LPDWORD)&type, (LPBYTE)NULL, (LPDWORD)&size); if (result == ERROR_SUCCESS) { //Read it. TCHAR *aux = new TCHAR[size+1]; - result = RegQueryValueEx((HKEY)hKey,szValue,(LPDWORD)NULL, (LPDWORD)&type,(LPBYTE)aux,(LPDWORD)&size); - lpzOSName = aux; + result = RegQueryValueEx((HKEY)hKey, szValue, (LPDWORD)NULL, (LPDWORD)&type, (LPBYTE)aux, (LPDWORD)&size); + lpzOSName.append(_T("Microsoft ")); + lpzOSName.append(aux); + lpzOSName.append(_T(" Edition")); delete[] aux; } else { NotifyError(GetLastError(), _T("RegQueryValueEx()"), __LINE__); lpzOSName = _T(""); } + RegCloseKey(hKey); } else { NotifyError(GetLastError(), _T("RegOpenKeyEx()"), __LINE__); @@ -312,7 +216,7 @@ end: case 2195: lpzOSName = _T("Microsoft Windows 2000"); break; //What about service packs? case 2600: lpzOSName = _T("Microsoft Windows XP"); break; case 3790: - if ( GetSystemMetrics( 89 )) //R2 ? + if (GetSystemMetrics(89)) //R2 ? lpzOSName = _T("Microsoft Windows 2003 R2"); else lpzOSName = _T("Microsoft Windows 2003"); @@ -320,10 +224,71 @@ end: break; //added windows 2003 info } + HMODULE hKernel32 = LoadLibrary(_T("kernel32.dll")); + if (hKernel32) { + SYSTEM_INFO si = {0}; + // Call GetNativeSystemInfo if supported or GetSystemInfo otherwise. + MyGetSystemInfo = (void (WINAPI *) (LPSYSTEM_INFO)) GetProcAddress(hKernel32, "GetNativeSystemInfo"); + if (MyGetSystemInfo != NULL) + MyGetSystemInfo(&si); + else + GetSystemInfo(&si); + + if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) + lpzOSName.append(_T(", 64-bit ")); + else if (si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_INTEL) + lpzOSName.append(_T(", 32-bit ")); + + lpzOSName.append(osvi.szCSDVersion); + lpzOSName.append(_T(" (build ")); + TCHAR buildno[MAX_PATH]; + _itot(osvi.dwBuildNumber, buildno, 10); + lpzOSName.append(buildno); + lpzOSName.append(_T(")")); + FreeLibrary(hKernel32); + } + else { + lpzOSName.append(_T(" ")); + lpzOSName.append(osvi.szCSDVersion); + lpzOSName.append(_T(" (build ")); + lpzOSName.append((TCHAR *)LOWORD(osvi.dwBuildNumber)); + lpzOSName.append(_T(")")); + } + return TRUE; } -bool CVersionInfo::GetHWSettings() { +bool CVersionInfo::GetHWSettings() +{ + //CPU Info + HKEY hKey; + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Hardware\\Description\\System\\CentralProcessor\\0"), 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) + { + TCHAR cpuIdent[512] = {0}, cpuName[512] = {0}; + DWORD size; + if (RegQueryValueEx(hKey, _T("ProcessorNameString"), NULL, NULL, (LPBYTE)cpuName, &size) != ERROR_SUCCESS) + _tcscpy(cpuName, _T("Unknown")); + lpzCPUName = cpuName; + + if (RegQueryValueEx(hKey, TEXT("Identifier"), NULL, NULL, (LPBYTE) cpuIdent, &size) != ERROR_SUCCESS) + if (RegQueryValueEx(hKey, TEXT("VendorIdentifier"), NULL, NULL, (LPBYTE) cpuIdent, &size) != ERROR_SUCCESS) + _tcscpy(cpuIdent, _T("Unknown")); + lpzCPUIdentifier = cpuIdent; + + RegCloseKey(hKey); + } + + while (true) + { + std::tstring::size_type pos = lpzCPUName.find(_T(" ")); + if (pos != std::tstring::npos) + lpzCPUName.replace(lpzCPUName.begin() + pos, lpzCPUName.begin() + pos + 2, _T(" ")); + else + break; + } + + bDEPEnabled = IsProcessorFeaturePresent(PF_NX_ENABLED); + //Free space on Miranda Partition. TCHAR szMirandaPath[MAX_PATH] = { 0 }; { @@ -402,7 +367,13 @@ bool CVersionInfo::GetProfileSettings() mir_sntprintf( number, SIZEOF(number), _T("%.2f KBytes"), double(fd.nFileSizeLow) / 1024 ); lpzProfileSize = number; - FillLocalTime(lpzProfileCreationDate, &fd.ftCreationTime); + FILETIME ftLocal; + SYSTEMTIME stLocal; + TCHAR lpszString[128]; + FileTimeToLocalFileTime(&fd.ftCreationTime, &ftLocal); + FileTimeToSystemTime(&ftLocal, &stLocal); + GetISO8061Time(&stLocal, lpszString, 128); + lpzProfileCreationDate = lpszString; } else { DWORD error = GetLastError(); @@ -636,14 +607,88 @@ bool CVersionInfo::GetLangpackInfo() return true; } +/*bool CVersionInfo::GetWeatherInfo() +{ + TCHAR path[MAX_PATH]; + GetModuleFileName(NULL, path, MAX_PATH); + + LPTSTR fname = _tcsrchr(path, TEXT('\\')); + if (fname == NULL) + fname = path; + _tcscat(fname, _T("\\plugins\\weather\\*.ini")); + + WIN32_FIND_DATA FindFileData; + HANDLE hFind = FindFirstFile(path, &FindFileData); + if (hFind == INVALID_HANDLE_VALUE) return; + + do + { + if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; + + crs_sntprintf(fname, MAX_PATH-(fname-path), TEXT("\\plugins\\weather\\%s"), FindFileData.cFileName); + HANDLE hDumpFile = CreateFile(path, GENERIC_READ, FILE_SHARE_READ, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + + if (hDumpFile != INVALID_HANDLE_VALUE) + { + char buf[8192]; + + DWORD bytes = 0; + ReadFile(hDumpFile, buf, 8190, &bytes, NULL); + buf[bytes] = 0; + + char* ver = strstr(buf, "Version="); + if (ver != NULL) + { + char *endid = strchr(ver, '\r'); + if (endid != NULL) *endid = 0; + else + { + endid = strchr(ver, '\n'); + if (endid != NULL) *endid = 0; + } + ver += 8; + } + + char *id = strstr(buf, "Name="); + if (id != NULL) + { + char *endid = strchr(id, '\r'); + if (endid != NULL) *endid = 0; + else + { + endid = strchr(id, '\n'); + if (endid != NULL) *endid = 0; + } + id += 5; + } + + TCHAR timebuf[30] = TEXT(""); + GetLastWriteTime(&FindFileData.ftLastWriteTime, timebuf, 30); + + + static const TCHAR format[] = TEXT(" %s v.%s%S%s [%s] - %S\r\n"); + + buffer.appendfmt(format, FindFileData.cFileName, + (flags & VI_FLAG_FORMAT) ? TEXT("[b]") : TEXT(""), + ver, + (flags & VI_FLAG_FORMAT) ? TEXT("[/b]") : TEXT(""), + timebuf, id); + CloseHandle(hDumpFile); + } + } + while (FindNextFile(hFind, &FindFileData)); + FindClose(hFind); +}*/ + std::tstring GetPluginTimestamp(FILETIME *fileTime) { SYSTEMTIME sysTime; - FileTimeToSystemTime(fileTime, &sysTime); //convert the file tyme to system time - - //char time[256]; + FILETIME ftLocal; + FileTimeToLocalFileTime(fileTime, &ftLocal); + FileTimeToSystemTime(&ftLocal, &sysTime); //convert the file tyme to system time TCHAR date[256]; //lovely - GetDateFormat(EnglishLocale, 0, &sysTime, _T("dd' 'MMM' 'yyyy"), date, SIZEOF(date)); + GetISO8061Time(&sysTime, date, 256); return date; } @@ -662,7 +707,8 @@ bool CVersionInfo::GetPluginLists() DWORD loadError; // SYSTEMTIME sysTime; //for timestamp - mirandaVersion=(DWORD)CallService(MS_SYSTEM_GETVERSION,0,0); + //bWeatherPlugin = false; + mirandaVersion = (DWORD)CallService(MS_SYSTEM_GETVERSION, 0, 0); { GetModuleFileName(GetModuleHandle(NULL), szMirandaPath, SIZEOF(szMirandaPath)); TCHAR* str2 = _tcsrchr(szMirandaPath,'\\'); @@ -686,6 +732,9 @@ bool CVersionInfo::GetPluginLists() if (!ValidExtension(fd.cFileName, _T("dll"))) continue; //do not report plugins that do not have extension .dll + //if (_tcsicmp(fd.cFileName, _T("weather.dll")) == 0) + //bWeatherPlugin = true; + hInstPlugin = GetModuleHandle(fd.cFileName); //try to get the handle of the module if (hInstPlugin) //if we got it then the dll is loaded (enabled) @@ -755,7 +804,8 @@ bool CVersionInfo::GetPluginLists() else { ZeroMemory(&pluginInfo, sizeof(pluginInfo)); MessageBox(NULL, fd.cFileName, _T("Invalid plugin"), MB_OK); - } } + } + } //Let's get the info. if (MirandaPluginInfo != NULL) {//a valid miranda plugin @@ -800,7 +850,8 @@ bool CVersionInfo::GetPluginLists() AddPlugin(thePlugin, listUnloadablePlugins); if (pluginInfo) FreePluginInfo(pluginInfo); - } } + } + } } while (FindNextFile(hFind,&fd)); FindClose(hFind); @@ -808,7 +859,8 @@ bool CVersionInfo::GetPluginLists() return TRUE; } -bool CVersionInfo::AddPlugin(CPlugin &aPlugin, std::list &aList) { +bool CVersionInfo::AddPlugin(CPlugin &aPlugin, std::list &aList) +{ std::list::iterator pos = aList.begin(); bool inserted = FALSE; @@ -961,10 +1013,11 @@ void CVersionInfo::AddInfoHeader(int suppressHeader, int forumStyle, int beautif out.append( _T("Installed RAM: ") + std::tstring(szRAM) + _T(" MBytes\r\n")); //operating system - out.append( _T("Operating System: ") + lpzOSName + _T(" [version: ") + lpzOSVersion + _T("]\r\n")); + out.append( _T("Operating System: ") + lpzOSName + _T("\r\n")); //shell, IE, administrator - out.append( _T("Shell: ") + lpzShell + _T(", Internet Explorer ") + lpzIEVersion + _T("\r\n")); + out.append( _T("Shell: ") + lpzShell + _T("\r\n")); + out.append( _T("Internet Explorer: ") + lpzIEVersion + _T("\r\n")); out.append( _T("Administrator privileges: ") + lpzAdministratorPrivileges + _T("\r\n")); //languages @@ -973,7 +1026,7 @@ void CVersionInfo::AddInfoHeader(int suppressHeader, int forumStyle, int beautif //FreeDiskSpace if (luiFreeDiskSpace) { TCHAR szDiskSpace[64]; wsprintf(szDiskSpace, _T("%d"), luiFreeDiskSpace); - out.append( _T("Free disk space on Miranda partition: ") + std::tstring(szDiskSpace) + _T(" MBytes\r\n")); + out.append( _T("Free disk space on Miranda partition: ") + std::tstring(szDiskSpace) + _T(" MBytes\r\n\r\n")); } //Miranda @@ -981,8 +1034,6 @@ void CVersionInfo::AddInfoHeader(int suppressHeader, int forumStyle, int beautif out.append( _T("Miranda NG version: ") + lpzMirandaVersion); if (bIsWOW64) out.append( _T(" [running inside WOW64]")); - if (bServiceMode) - out.append( _T(" [service mode]")); out.append( _T("\r\nBuild time: ") + lpzBuildTime + _T("\r\n")); out.append( _T("Profile path: ") + lpzProfilePath + _T("\r\n")); @@ -991,7 +1042,12 @@ void CVersionInfo::AddInfoHeader(int suppressHeader, int forumStyle, int beautif out.append( _T("Language pack: ") + lpzLangpackInfo); out.append((lpzLangpackModifiedDate.size() > 0) ? _T(", modified: ") + lpzLangpackModifiedDate : _T("")); out.append( _T("\r\n")); - + out.append(_T("Service Mode: ")); + if (bServiceMode) + out.append( _T("Yes")); + else + out.append( _T("No")); + // out.append( _T("Nightly: ") + lpzNightly + _T("\r\n")); // out.append( _T("Unicode core: ") + lpzUnicodeBuild); @@ -1077,7 +1133,7 @@ std::tstring CVersionInfo::GetInformationsAsString(int bDisableForumStyle) { BeautifyReport(beautify, horizLine, _T("\r\n"), out); GetStringFromDatabase("BeautifyInactiveHeaderBegin", _T(""), buffer, SIZEOF(buffer)); BeautifyReport(beautify, buffer, headerHighlightStart, out); - AddSectionAndCount(listInactivePlugins, _T("Inactive Plugins"), out); + AddSectionAndCount(listInactivePlugins, _T("Unloadable Plugins"), out); GetStringFromDatabase("BeautifyInactiveHeaderEnd", _T(""), buffer, SIZEOF(buffer)); BeautifyReport(beautify, buffer, headerHighlightEnd, out); out.append( _T("\r\n")); @@ -1097,6 +1153,8 @@ std::tstring CVersionInfo::GetInformationsAsString(int bDisableForumStyle) { out.append(GetListAsString(listUnloadablePlugins, flags, beautify)); BeautifyReport(beautify, normalPluginsEnd, _T(""), out); } + //if (bWeatherPlugin) + AddInfoFooter(suppressHeader, forumStyle, beautify, out); return out; } diff --git a/plugins/VersionInfo/src/CVersionInfo.h b/plugins/VersionInfo/src/CVersionInfo.h index 8f78fc382d..51155b9148 100644 --- a/plugins/VersionInfo/src/CVersionInfo.h +++ b/plugins/VersionInfo/src/CVersionInfo.h @@ -50,7 +50,6 @@ class CVersionInfo std::list listInactivePlugins; std::list listUnloadablePlugins; //OS and hardware informations. - std::tstring lpzOSVersion; std::tstring lpzOSName; unsigned int luiProcessors; unsigned int luiRAM; @@ -62,7 +61,7 @@ class CVersionInfo unsigned int luiEvents; unsigned int luiUnreadEvents; unsigned int luiDBSize; - bool bExpertSettingsOn; + //bool bWeatherPlugin; //Configuration bool GetLinkedModulesInfo(TCHAR *moduleName, std::tstring &linkedModules); @@ -79,6 +78,7 @@ class CVersionInfo bool GetLangpackInfo(); bool GetPluginLists(); bool GetEventCount(); //TODO + //bool GetWeatherInfo(); //OSInformations bool GetOSVersion(); bool GetHWSettings(); diff --git a/plugins/VersionInfo/src/dlgHandlers.cpp b/plugins/VersionInfo/src/dlgHandlers.cpp index 6ffb2cf332..e6242c6bf6 100644 --- a/plugins/VersionInfo/src/dlgHandlers.cpp +++ b/plugins/VersionInfo/src/dlgHandlers.cpp @@ -487,9 +487,8 @@ INT_PTR CALLBACK DlgProcOpts(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) EnableWindow(GetDlgItem(hWnd, IDC_GETINFONOW), TRUE); //Disabled plugins too? db_set_b(NULL, ModuleName, "ShowInactive", IsDlgButtonChecked(hWnd, IDC_DISABLEDTOO)?TRUE:FALSE); - - GetStringFromDatabase("UUIDCharMark", _T(DEF_UUID_CHARMARK), PLUGIN_UUID_MARK, cPLUGIN_UUID_MARK); - } } + } + } break; } diff --git a/plugins/VersionInfo/src/hooked_events.cpp b/plugins/VersionInfo/src/hooked_events.cpp index 9d0aa826c2..6e9b74d5f6 100644 --- a/plugins/VersionInfo/src/hooked_events.cpp +++ b/plugins/VersionInfo/src/hooked_events.cpp @@ -31,7 +31,6 @@ int OnModulesLoaded(WPARAM wParam, LPARAM lParam) { hOutputLocation = FoldersRegisterCustomPathT(LPGEN("VersionInfo"), LPGEN("Output folder"), MIRANDA_PATHT); - GetStringFromDatabase("UUIDCharMark", _T(DEF_UUID_CHARMARK), PLUGIN_UUID_MARK, cPLUGIN_UUID_MARK); return 0; } diff --git a/plugins/VersionInfo/src/main.cpp b/plugins/VersionInfo/src/main.cpp index a5c3324c65..caf9cbffe7 100644 --- a/plugins/VersionInfo/src/main.cpp +++ b/plugins/VersionInfo/src/main.cpp @@ -76,7 +76,7 @@ extern "C" int __declspec(dllexport) Load(void) InitServices(); HookEvents(); - hiVIIcon = LoadIcon(hInst,MAKEINTRESOURCE(IDI_MAIN)); + hiVIIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_MAIN)); //get the name of the dll itself TCHAR filePath[512] = {0}; diff --git a/plugins/VersionInfo/src/utils.cpp b/plugins/VersionInfo/src/utils.cpp index 1dd59343bc..f5b23d10b7 100644 --- a/plugins/VersionInfo/src/utils.cpp +++ b/plugins/VersionInfo/src/utils.cpp @@ -198,25 +198,32 @@ void TimeStampToSysTime(DWORD Unix,SYSTEMTIME* SysTime) FileTimeToSystemTime((FILETIME*)&FileReal,SysTime); } -void GetModuleTimeStamp(TCHAR* ptszDate, TCHAR* ptszTime) +void GetISO8061Time(SYSTEMTIME* stLocal, LPTSTR lpszString, DWORD dwSize) +{ + SYSTEMTIME loctime; + if (stLocal == NULL) + { + stLocal = &loctime; + GetLocalTime(stLocal); + } + + GetDateFormat(LOCALE_INVARIANT, 0, stLocal, TEXT("d MMM yyyy"), lpszString, dwSize); + int dlen = (int)_tcslen(lpszString); + GetTimeFormat(LOCALE_INVARIANT, 0, stLocal, TEXT(" H:mm:ss"), lpszString+dlen, dwSize-dlen); +} + +void GetModuleTimeStamp(LPTSTR lpszString, DWORD dwSize) { TCHAR tszModule[MAX_PATH]; - HANDLE mapfile,file; - DWORD timestamp,filesize; - LPVOID mapmem; - SYSTEMTIME systime; - GetModuleFileName(NULL,tszModule,SIZEOF(tszModule)); - file = CreateFile(tszModule,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL); - filesize = GetFileSize(file,NULL); - mapfile = CreateFileMapping(file, NULL, PAGE_READONLY, 0, filesize, NULL); - mapmem = MapViewOfFile(mapfile, FILE_MAP_READ, 0, 0, 0); - timestamp = GetTimestampForLoadedLibrary((HINSTANCE)mapmem); - TimeStampToSysTime(timestamp,&systime); - GetTimeFormat(LOCALE_USER_DEFAULT, 0, &systime, _T("HH':'mm':'ss"), ptszTime, 40 ); - GetDateFormat(EnglishLocale, 0, &systime, _T("dd' 'MMMM' 'yyyy"), ptszDate, 40); - UnmapViewOfFile(mapmem); - CloseHandle(mapfile); - CloseHandle(file); + GetModuleFileName(NULL, tszModule, SIZEOF(tszModule)); + WIN32_FIND_DATA fd; + if (FindFirstFile(tszModule, &fd) != INVALID_HANDLE_VALUE) { + FILETIME ftLocal; + SYSTEMTIME stLocal; + FileTimeToLocalFileTime(&fd.ftLastWriteTime, &ftLocal); + FileTimeToSystemTime(&ftLocal, &stLocal); + GetISO8061Time(&stLocal, lpszString, dwSize); + } } //From Egodust or Cyreve... I don't really know. @@ -437,48 +444,41 @@ BOOL GetWindowsShell(TCHAR *shellPath, size_t shSize) BOOL GetInternetExplorerVersion(TCHAR *ieVersion, size_t ieSize) { HKEY hKey; - TCHAR ieVer[1024]; - DWORD size = SIZEOF(ieVer); - TCHAR ieBuild[64] = {0}; - - _tcsncpy(ieVer, _T(""), size); + TCHAR ieVer[1024] = {0}, ieBuild[64] = {0}, iVer[64] = {0}; if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Internet Explorer"), 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) { - if (RegQueryValueEx(hKey, _T("Version"), NULL, NULL, (LPBYTE) ieVer, &size) == ERROR_SUCCESS) - { - TCHAR *pos = _tcschr(ieVer, '.'); - if (pos) - { - pos = _tcschr(pos + 1, '.'); - if (pos) { *pos = 0; } - _tcsncpy(ieBuild, pos + 1, SIZEOF(ieBuild)); - pos = _tcschr(ieBuild, '.'); - if (pos) { *pos = 0; } - } - } - else{ - size = SIZEOF(ieVer); - if (RegQueryValueEx(hKey, _T("Build"), NULL, NULL, (LPBYTE) ieVer, &size) == ERROR_SUCCESS) - { - TCHAR *pos = ieVer + 1; - _tcsncpy(ieBuild, pos, SIZEOF(ieBuild)); - *pos = 0; - pos = _tcschr(ieBuild, '.'); - if (pos) { *pos = 0; } - } - else{ - _tcsncpy(ieVer, _T(""), size); - } - } + DWORD size; + if (RegQueryValueEx(hKey, _T("Version"), NULL, NULL, (LPBYTE) ieVer, &size) != ERROR_SUCCESS) + ieVer[0] = 0; + if (RegQueryValueEx(hKey, _T("Build"), NULL, NULL, (LPBYTE) ieBuild, &size) != ERROR_SUCCESS) + ieBuild[0] = 0; + if (RegQueryValueEx(hKey, _T("IVer"), NULL, NULL, (LPBYTE) iVer, &size) != ERROR_SUCCESS) + iVer[0] = 0; + RegCloseKey(hKey); } - - _tcsncpy(ieVersion, ieVer, ieSize); - if ( ieBuild[0] ) + + if (ieVer[0] == 0) + { + if (iVer[0] == 0) + _tcsncpy(ieVersion, _T(""), ieSize); + else if (_tcscmp(iVer, _T("100")) == 0) + _tcsncpy(ieVersion, _T("1.0"), ieSize); + else if (_tcscmp(iVer, _T("101")) == 0) + _tcsncpy(ieVersion, _T("NT"), ieSize); + else if (_tcscmp(iVer, _T("102")) == 0) + _tcsncpy(ieVersion, _T("2.0"), ieSize); + else if (_tcscmp(iVer, TEXT("103")) == 0) + _tcsncpy(ieVersion, _T("3.0"), ieSize); + } else + _tcsncpy(ieVersion, ieVer, ieSize); + + if (ieBuild[0] != 0) { - _tcsncat(ieVersion, _T("."), ieSize); + _tcsncat(ieVersion, _T(" (build "), ieSize); _tcsncat(ieVersion, ieBuild, ieSize); + _tcsncat(ieVersion, _T(")"), ieSize); } return TRUE; diff --git a/plugins/VersionInfo/src/utils.h b/plugins/VersionInfo/src/utils.h index 9f8bf4a653..c53678c933 100644 --- a/plugins/VersionInfo/src/utils.h +++ b/plugins/VersionInfo/src/utils.h @@ -22,7 +22,8 @@ int SplitStringInfo(const TCHAR *szWholeText, TCHAR *szStartText, TCHAR *szEndTe bool DoesDllExist(char *dllName); //utils.cpp -void GetModuleTimeStamp(TCHAR*, TCHAR*); +void GetModuleTimeStamp(LPTSTR lpszString, DWORD dwSize); +void GetISO8061Time(SYSTEMTIME* stLocal, LPTSTR lpszString, DWORD dwSize); void NotifyError(DWORD, const TCHAR*, int); //utils.cpp -- cgit v1.2.3