diff options
author | George Hazan <george.hazan@gmail.com> | 2013-11-10 17:48:31 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-11-10 17:48:31 +0000 |
commit | 64e1340acd813704c9e9009b0a4e6fc9a3fb5adf (patch) | |
tree | a8a83a6c695ef78ce804340124f45e7aafa7d45a /plugins/CrashDumper/src/utils.cpp | |
parent | 972be4fb5cc3c045ae640170421cf5a9dc18ffce (diff) |
bkstring removed from CrashDumper
git-svn-id: http://svn.miranda-ng.org/main/trunk@6857 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/CrashDumper/src/utils.cpp')
-rw-r--r-- | plugins/CrashDumper/src/utils.cpp | 332 |
1 files changed, 149 insertions, 183 deletions
diff --git a/plugins/CrashDumper/src/utils.cpp b/plugins/CrashDumper/src/utils.cpp index c60ea9a5e1..2542c3d30d 100644 --- a/plugins/CrashDumper/src/utils.cpp +++ b/plugins/CrashDumper/src/utils.cpp @@ -37,7 +37,7 @@ void CheckForOtherCrashReportingPlugins(void) TEXT("Miranda Crash Dumper"), MB_OK | MB_ICONERROR | MB_TASKMODAL | MB_TOPMOST);
}
-void GetOSDisplayString(bkstring& buffer)
+void GetOSDisplayString(CMString& buffer)
{
OSVERSIONINFOEX osvi = {0};
SYSTEM_INFO si = {0};
@@ -56,30 +56,30 @@ void GetOSDisplayString(bkstring& buffer) GetNativeSystemInfo(&si);
if (VER_PLATFORM_WIN32_NT == osvi.dwPlatformId && osvi.dwMajorVersion > 4) {
- buffer.append(TEXT("Operating System: Microsoft "));
+ buffer.Append(TEXT("Operating System: Microsoft "));
// Test for the specific product.
if (osvi.dwMajorVersion == 6) {
switch (osvi.dwMinorVersion) {
case 0:
if (osvi.wProductType == VER_NT_WORKSTATION)
- buffer.append(TEXT("Windows Vista "));
+ buffer.Append(TEXT("Windows Vista "));
else
- buffer.append(TEXT("Windows Server 2008 "));
+ buffer.Append(TEXT("Windows Server 2008 "));
break;
case 1:
if (osvi.wProductType == VER_NT_WORKSTATION)
- buffer.append(TEXT("Windows 7 "));
+ buffer.Append(TEXT("Windows 7 "));
else
- buffer.append(TEXT("Windows Server 2008 R2 "));
+ buffer.Append(TEXT("Windows Server 2008 R2 "));
break;
default:
if (osvi.wProductType == VER_NT_WORKSTATION)
- buffer.append(TEXT("Windows 8 "));
+ buffer.Append(TEXT("Windows 8 "));
else
- buffer.append(TEXT("Windows Server 2012 "));
+ buffer.Append(TEXT("Windows Server 2012 "));
break;
}
@@ -88,163 +88,163 @@ void GetOSDisplayString(bkstring& buffer) switch(dwType) {
case PRODUCT_ULTIMATE:
- buffer.append(TEXT("Ultimate Edition"));
+ buffer.Append(TEXT("Ultimate Edition"));
break;
case PRODUCT_HOME_PREMIUM:
- buffer.append(TEXT("Home Premium Edition"));
+ buffer.Append(TEXT("Home Premium Edition"));
break;
case PRODUCT_HOME_BASIC:
- buffer.append(TEXT("Home Basic Edition"));
+ buffer.Append(TEXT("Home Basic Edition"));
break;
case PRODUCT_ENTERPRISE:
- buffer.append(TEXT("Enterprise Edition"));
+ buffer.Append(TEXT("Enterprise Edition"));
break;
case PRODUCT_BUSINESS:
- buffer.append(TEXT("Business Edition"));
+ buffer.Append(TEXT("Business Edition"));
break;
case PRODUCT_STARTER:
- buffer.append(TEXT("Starter Edition"));
+ buffer.Append(TEXT("Starter Edition"));
break;
case PRODUCT_CLUSTER_SERVER:
- buffer.append(TEXT("Cluster Server Edition"));
+ buffer.Append(TEXT("Cluster Server Edition"));
break;
case PRODUCT_DATACENTER_SERVER:
- buffer.append(TEXT("Datacenter Edition"));
+ buffer.Append(TEXT("Datacenter Edition"));
break;
case PRODUCT_DATACENTER_SERVER_CORE:
- buffer.append(TEXT("Datacenter Edition (core installation)"));
+ buffer.Append(TEXT("Datacenter Edition (core installation)"));
break;
case PRODUCT_ENTERPRISE_SERVER:
- buffer.append(TEXT("Enterprise Edition"));
+ buffer.Append(TEXT("Enterprise Edition"));
break;
case PRODUCT_ENTERPRISE_SERVER_CORE:
- buffer.append(TEXT("Enterprise Edition (core installation)"));
+ buffer.Append(TEXT("Enterprise Edition (core installation)"));
break;
case PRODUCT_ENTERPRISE_SERVER_IA64:
- buffer.append(TEXT("Enterprise Edition for Itanium-based Systems"));
+ buffer.Append(TEXT("Enterprise Edition for Itanium-based Systems"));
break;
case PRODUCT_SMALLBUSINESS_SERVER:
- buffer.append(TEXT("Small Business Server"));
+ buffer.Append(TEXT("Small Business Server"));
break;
case PRODUCT_SMALLBUSINESS_SERVER_PREMIUM:
- buffer.append(TEXT("Small Business Server Premium Edition"));
+ buffer.Append(TEXT("Small Business Server Premium Edition"));
break;
case PRODUCT_STANDARD_SERVER:
- buffer.append(TEXT("Standard Edition"));
+ buffer.Append(TEXT("Standard Edition"));
break;
case PRODUCT_STANDARD_SERVER_CORE:
- buffer.append(TEXT("Standard Edition (core installation)"));
+ buffer.Append(TEXT("Standard Edition (core installation)"));
break;
case PRODUCT_WEB_SERVER:
- buffer.append(TEXT("Web Server Edition"));
+ buffer.Append(TEXT("Web Server Edition"));
break;
}
if (si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64)
- buffer.append(TEXT(", 64-bit"));
+ buffer.Append(TEXT(", 64-bit"));
else if (si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_INTEL)
- buffer.append(TEXT(", 32-bit"));
+ buffer.Append(TEXT(", 32-bit"));
}
if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2) {
if (GetSystemMetrics(SM_SERVERR2))
- buffer.append(TEXT("Windows Server 2003 R2, "));
+ buffer.Append(TEXT("Windows Server 2003 R2, "));
else if (osvi.wSuiteMask==VER_SUITE_STORAGE_SERVER)
- buffer.append(TEXT("Windows Storage Server 2003"));
+ buffer.Append(TEXT("Windows Storage Server 2003"));
else if (osvi.wProductType == VER_NT_WORKSTATION &&
si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
- buffer.append(TEXT("Windows XP Professional x64 Edition"));
- else buffer.append(TEXT("Windows Server 2003, "));
+ buffer.Append(TEXT("Windows XP Professional x64 Edition"));
+ else buffer.Append(TEXT("Windows Server 2003, "));
// Test for the server type.
if (osvi.wProductType != VER_NT_WORKSTATION) {
if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64) {
if(osvi.wSuiteMask & VER_SUITE_DATACENTER)
- buffer.append(TEXT("Datacenter Edition for Itanium-based Systems"));
+ buffer.Append(TEXT("Datacenter Edition for Itanium-based Systems"));
else if(osvi.wSuiteMask & VER_SUITE_ENTERPRISE)
- buffer.append(TEXT("Enterprise Edition for Itanium-based Systems"));
+ buffer.Append(TEXT("Enterprise Edition for Itanium-based Systems"));
}
else if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) {
if(osvi.wSuiteMask & VER_SUITE_DATACENTER)
- buffer.append(TEXT("Datacenter x64 Edition"));
+ buffer.Append(TEXT("Datacenter x64 Edition"));
else if(osvi.wSuiteMask & VER_SUITE_ENTERPRISE)
- buffer.append(TEXT("Enterprise x64 Edition"));
- else buffer.append(TEXT("Standard x64 Edition"));
+ buffer.Append(TEXT("Enterprise x64 Edition"));
+ else buffer.Append(TEXT("Standard x64 Edition"));
}
else {
if (osvi.wSuiteMask & VER_SUITE_COMPUTE_SERVER)
- buffer.append(TEXT("Compute Cluster Edition"));
+ buffer.Append(TEXT("Compute Cluster Edition"));
else if(osvi.wSuiteMask & VER_SUITE_DATACENTER)
- buffer.append(TEXT("Datacenter Edition"));
+ buffer.Append(TEXT("Datacenter Edition"));
else if(osvi.wSuiteMask & VER_SUITE_ENTERPRISE)
- buffer.append(TEXT("Enterprise Edition"));
+ buffer.Append(TEXT("Enterprise Edition"));
else if (osvi.wSuiteMask & VER_SUITE_BLADE)
- buffer.append(TEXT("Web Edition"));
- else buffer.append(TEXT("Standard Edition"));
+ buffer.Append(TEXT("Web Edition"));
+ else buffer.Append(TEXT("Standard Edition"));
}
}
}
if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1) {
- buffer.append(TEXT("Windows XP "));
+ buffer.Append(TEXT("Windows XP "));
if (osvi.wSuiteMask & VER_SUITE_PERSONAL)
- buffer.append(TEXT("Home Edition"));
+ buffer.Append(TEXT("Home Edition"));
else
- buffer.append(TEXT("Professional"));
+ buffer.Append(TEXT("Professional"));
}
if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0) {
- buffer.append(TEXT("Windows 2000 "));
+ buffer.Append(TEXT("Windows 2000 "));
if (osvi.wProductType == VER_NT_WORKSTATION)
- buffer.append(TEXT("Professional"));
+ buffer.Append(TEXT("Professional"));
else {
if(osvi.wSuiteMask & VER_SUITE_DATACENTER)
- buffer.append(TEXT("Datacenter Server"));
+ buffer.Append(TEXT("Datacenter Server"));
else if(osvi.wSuiteMask & VER_SUITE_ENTERPRISE)
- buffer.append(TEXT("Advanced Server"));
- else buffer.append(TEXT("Server"));
+ buffer.Append(TEXT("Advanced Server"));
+ else buffer.Append(TEXT("Server"));
}
}
if (osvi.szCSDVersion[0] != 0) {
- buffer.append(TEXT(" "));
- buffer.append(osvi.szCSDVersion);
+ buffer.Append(TEXT(" "));
+ buffer.Append(osvi.szCSDVersion);
}
- buffer.appendfmt(TEXT(" (build %d)"), osvi.dwBuildNumber);
+ buffer.AppendFormat(TEXT(" (build %d)"), osvi.dwBuildNumber);
}
else {
if (VER_PLATFORM_WIN32_NT == osvi.dwPlatformId) {
- buffer.append(TEXT("Microsoft Windows NT "));
+ buffer.Append(TEXT("Microsoft Windows NT "));
if (osvi.wProductType == VER_NT_WORKSTATION)
- buffer.append(TEXT("Workstation 4.0 "));
+ buffer.Append(TEXT("Workstation 4.0 "));
else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE)
- buffer.append(TEXT("Server 4.0, Enterprise Edition "));
+ buffer.Append(TEXT("Server 4.0, Enterprise Edition "));
else
- buffer.append(TEXT("Server 4.0 "));
+ buffer.Append(TEXT("Server 4.0 "));
}
if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS && osvi.dwMajorVersion == 4) {
if (osvi.dwMinorVersion == 0) {
- buffer.append(TEXT("Microsoft Windows 95 "));
+ buffer.Append(TEXT("Microsoft Windows 95 "));
if (osvi.szCSDVersion[1]==TEXT('C') || osvi.szCSDVersion[1]==TEXT('B'))
- buffer.append(TEXT("OSR2 "));
+ buffer.Append(TEXT("OSR2 "));
}
if (osvi.dwMinorVersion == 10) {
- buffer.append(TEXT("Microsoft Windows 98 "));
+ buffer.Append(TEXT("Microsoft Windows 98 "));
if (osvi.szCSDVersion[1]==TEXT('A') || osvi.szCSDVersion[1]==TEXT('B'))
- buffer.append(TEXT("SE "));
+ buffer.Append(TEXT("SE "));
}
if (osvi.dwMinorVersion == 90)
- buffer.append(TEXT("Microsoft Windows Millennium Edition"));
+ buffer.Append(TEXT("Microsoft Windows Millennium Edition"));
- buffer.appendfmt(TEXT("(build %d)"), LOWORD(osvi.dwBuildNumber));
+ buffer.AppendFormat(TEXT("(build %d)"), LOWORD(osvi.dwBuildNumber));
}
else if (osvi.dwPlatformId == VER_PLATFORM_WIN32s)
- buffer.append(TEXT("Microsoft Win32s"));
+ buffer.Append(TEXT("Microsoft Win32s"));
}
}
@@ -274,20 +274,17 @@ int GetTZOffset(void) void GetISO8061Time(SYSTEMTIME* stLocal, LPTSTR lpszString, DWORD dwSize)
{
SYSTEMTIME loctime;
- if (stLocal == NULL)
- {
+ if (stLocal == NULL) {
stLocal = &loctime;
GetLocalTime(stLocal);
}
- if (clsdates)
- {
+ if (clsdates) {
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);
}
- else
- {
+ else {
int offset = GetTZOffset();
// Build a string showing the date and time.
@@ -332,8 +329,7 @@ PLUGININFOEX* GetMirInfo(HMODULE hModule) return bpi(mirandaVersion);
}
-
-void GetInternetExplorerVersion(bkstring& buffer)
+void GetInternetExplorerVersion(CMString& buffer)
{
HKEY hKey;
DWORD size;
@@ -342,9 +338,7 @@ void GetInternetExplorerVersion(bkstring& buffer) TCHAR ieBuild[512] = {0};
TCHAR iVer[64] = {0};
- if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\Internet Explorer"), 0,
- KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
- {
+ if (!RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\Internet Explorer"), 0, KEY_QUERY_VALUE, &hKey)) {
size = SIZEOF(ieBuild);
if (RegQueryValueEx(hKey, TEXT("Build"), NULL, NULL, (LPBYTE) ieBuild, &size) != ERROR_SUCCESS)
ieBuild[0] = 0;
@@ -360,48 +354,38 @@ void GetInternetExplorerVersion(bkstring& buffer) RegCloseKey(hKey);
}
- buffer.append(TEXT("Internet Explorer: "));
- if (ieVersion[0] == 0)
- {
+ buffer.Append(TEXT("Internet Explorer: "));
+ if (ieVersion[0] == 0) {
if (iVer[0] == 0)
- buffer.append(TEXT("<not installed>"));
+ buffer.Append(TEXT("<not installed>"));
else if (_tcscmp(iVer, TEXT("100")) == 0)
- buffer.append(TEXT("1.0"));
+ buffer.Append(TEXT("1.0"));
else if (_tcscmp(iVer, TEXT("101")) == 0)
- buffer.append(TEXT("NT"));
+ buffer.Append(TEXT("NT"));
else if (_tcscmp(iVer, TEXT("102")) == 0)
- buffer.append(TEXT("2.0"));
+ buffer.Append(TEXT("2.0"));
else if (_tcscmp(iVer, TEXT("103")) == 0)
- buffer.append(TEXT("3.0"));
- }
- else
- {
- buffer.append(ieVersion);
+ buffer.Append(TEXT("3.0"));
}
+ else buffer.Append(ieVersion);
+
if (ieBuild[0] != 0)
- {
- buffer.appendfmt(TEXT(" (build %s)"), ieBuild);
- }
+ buffer.AppendFormat(TEXT(" (build %s)"), ieBuild);
}
-
void TrimMultiSpaces(TCHAR* str)
{
TCHAR *src = str, *dest = str;
bool trimst = false;
- for (;;)
- {
- if (*src == TEXT(' '))
- {
- if (!trimst)
- {
+ for (;;) {
+ if (*src == TEXT(' ')) {
+ if (!trimst) {
trimst = true;
*dest++ = *src;
}
}
- else
- {
+ else {
trimst = false;
*dest++ = *src;
}
@@ -409,7 +393,7 @@ void TrimMultiSpaces(TCHAR* str) }
}
-void GetProcessorString(bkstring& buffer)
+void GetProcessorString(CMString& buffer)
{
HKEY hKey;
DWORD size;
@@ -417,9 +401,7 @@ void GetProcessorString(bkstring& buffer) TCHAR cpuIdent[512] = {0};
TCHAR cpuName[512] = {0};
- if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("Hardware\\Description\\System\\CentralProcessor\\0"), 0,
- KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
- {
+ if (!RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("Hardware\\Description\\System\\CentralProcessor\\0"), 0, KEY_QUERY_VALUE, &hKey)) {
size = SIZEOF(cpuName);
if (RegQueryValueEx(hKey, TEXT("ProcessorNameString"), NULL, NULL, (LPBYTE) cpuName, &size) != ERROR_SUCCESS)
_tcscpy(cpuName, TEXT("Unknown"));
@@ -432,170 +414,163 @@ void GetProcessorString(bkstring& buffer) RegCloseKey(hKey);
}
TrimMultiSpaces(cpuName);
- buffer.appendfmt(TEXT("CPU: %s [%s]"), cpuName, cpuIdent);
+ buffer.AppendFormat(TEXT("CPU: %s [%s]"), cpuName, cpuIdent);
if (IsProcessorFeaturePresent(PF_NX_ENABLED))
- buffer.append(TEXT(" [DEP Enabled]"));
+ buffer.Append(TEXT(" [DEP Enabled]"));
SYSTEM_INFO si = {0};
GetSystemInfo(&si);
if (si.dwNumberOfProcessors > 1)
- buffer.appendfmt(TEXT(" [%u CPUs]"), si.dwNumberOfProcessors);
+ buffer.AppendFormat(TEXT(" [%u CPUs]"), si.dwNumberOfProcessors);
}
-void GetFreeMemoryString(bkstring& buffer)
+void GetFreeMemoryString(CMString& buffer)
{
unsigned ram;
MEMORYSTATUSEX ms = {0};
ms.dwLength = sizeof(ms);
GlobalMemoryStatusEx(&ms);
ram = (unsigned int) ((ms.ullTotalPhys / (1024 * 1024)) + 1);
- buffer.appendfmt(TEXT("Installed RAM: %u MBytes"), ram);
+ buffer.AppendFormat(TEXT("Installed RAM: %u MBytes"), ram);
}
-void GetFreeDiskString(LPCTSTR dirname, bkstring& buffer)
+void GetFreeDiskString(LPCTSTR dirname, CMString& buffer)
{
ULARGE_INTEGER tnb, tfb, fs = {0};
GetDiskFreeSpaceEx(dirname, &fs, &tnb, &tfb);
fs.QuadPart /= (1024*1024);
- buffer.appendfmt(TEXT("Free disk space on Miranda partition: %u MBytes"), fs.LowPart);
+ buffer.AppendFormat(TEXT("Free disk space on Miranda partition: %u MBytes"), fs.LowPart);
}
-void ReadableExceptionInfo(PEXCEPTION_RECORD excrec, bkstring& buffer)
+void ReadableExceptionInfo(PEXCEPTION_RECORD excrec, CMString& buffer)
{
- buffer.append(TEXT("Exception: "));
+ buffer.Append(TEXT("Exception: "));
- switch (excrec->ExceptionCode)
- {
+ switch (excrec->ExceptionCode) {
case EXCEPTION_BREAKPOINT:
- buffer.append(TEXT("User Defined Breakpoint"));
+ buffer.Append(TEXT("User Defined Breakpoint"));
break;
case EXCEPTION_ACCESS_VIOLATION:
- buffer.append(TEXT("Access Violation"));
+ buffer.Append(TEXT("Access Violation"));
break;
case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
- buffer.append(TEXT("Array Bounds Exceeded"));
+ buffer.Append(TEXT("Array Bounds Exceeded"));
break;
case EXCEPTION_DATATYPE_MISALIGNMENT:
- buffer.append(TEXT("Datatype Misalignment"));
+ buffer.Append(TEXT("Datatype Misalignment"));
break;
case EXCEPTION_FLT_DENORMAL_OPERAND:
- buffer.append(TEXT("Floating Point denormlized operand"));
+ buffer.Append(TEXT("Floating Point denormlized operand"));
break;
case EXCEPTION_FLT_DIVIDE_BY_ZERO:
- buffer.append(TEXT("Floating Point divide by 0"));
+ buffer.Append(TEXT("Floating Point divide by 0"));
break;
case EXCEPTION_FLT_INEXACT_RESULT:
- buffer.append(TEXT("Floating Point inexact result"));
+ buffer.Append(TEXT("Floating Point inexact result"));
break;
case EXCEPTION_FLT_INVALID_OPERATION:
- buffer.append(TEXT("Floating Point invalid operation"));
+ buffer.Append(TEXT("Floating Point invalid operation"));
break;
case EXCEPTION_FLT_OVERFLOW:
- buffer.append(TEXT("Floating Point overflow"));
+ buffer.Append(TEXT("Floating Point overflow"));
break;
case EXCEPTION_FLT_STACK_CHECK:
- buffer.append(TEXT("Floating Point stack overflow/underflow"));
+ buffer.Append(TEXT("Floating Point stack overflow/underflow"));
break;
case EXCEPTION_FLT_UNDERFLOW:
- buffer.append(TEXT("Floating Point underflow"));
+ buffer.Append(TEXT("Floating Point underflow"));
break;
case EXCEPTION_ILLEGAL_INSTRUCTION:
- buffer.append(TEXT("Invalid instruction executed"));
+ buffer.Append(TEXT("Invalid instruction executed"));
break;
case EXCEPTION_IN_PAGE_ERROR:
- buffer.append(TEXT("Access to the not present page"));
+ buffer.Append(TEXT("Access to the not present page"));
break;
case EXCEPTION_INT_DIVIDE_BY_ZERO:
- buffer.append(TEXT("Integer divide by zero"));
+ buffer.Append(TEXT("Integer divide by zero"));
break;
case EXCEPTION_INT_OVERFLOW:
- buffer.append(TEXT("Integer overflow"));
+ buffer.Append(TEXT("Integer overflow"));
break;
case EXCEPTION_PRIV_INSTRUCTION:
- buffer.append(TEXT("Priveleged instruction executed"));
+ buffer.Append(TEXT("Priveleged instruction executed"));
break;
case EXCEPTION_STACK_OVERFLOW:
- buffer.append(TEXT("Stack overflow"));
+ buffer.Append(TEXT("Stack overflow"));
break;
case 0xe06d7363:
- buffer.append(TEXT("Unhandled C++ software exception"));
+ buffer.Append(TEXT("Unhandled C++ software exception"));
break;
default:
- buffer.appendfmt(TEXT("%x"), excrec->ExceptionCode);
+ buffer.AppendFormat(TEXT("%x"), excrec->ExceptionCode);
break;
}
- buffer.appendfmt(TEXT(" at address %p."), excrec->ExceptionAddress);
+ buffer.AppendFormat(TEXT(" at address %p."), excrec->ExceptionAddress);
- if (excrec->ExceptionCode == EXCEPTION_ACCESS_VIOLATION ||
- excrec->ExceptionCode == EXCEPTION_IN_PAGE_ERROR)
- {
- switch(excrec->ExceptionInformation[0])
- {
+ if (excrec->ExceptionCode == EXCEPTION_ACCESS_VIOLATION || excrec->ExceptionCode == EXCEPTION_IN_PAGE_ERROR) {
+ switch(excrec->ExceptionInformation[0]) {
case 0:
- buffer.appendfmt(TEXT(" Reading from address %p."), (LPVOID)excrec->ExceptionInformation[1]);
+ buffer.AppendFormat(TEXT(" Reading from address %p."), (LPVOID)excrec->ExceptionInformation[1]);
break;
case 1:
- buffer.appendfmt(TEXT(" Writing to address %p."), (LPVOID)excrec->ExceptionInformation[1]);
+ buffer.AppendFormat(TEXT(" Writing to address %p."), (LPVOID)excrec->ExceptionInformation[1]);
break;
case 8:
- buffer.appendfmt(TEXT(" DEP at address %p."), (LPVOID)excrec->ExceptionInformation[1]);
+ buffer.AppendFormat(TEXT(" DEP at address %p."), (LPVOID)excrec->ExceptionInformation[1]);
break;
}
}
}
-void GetAdminString(bkstring& buffer)
+void GetAdminString(CMString& buffer)
{
BOOL b;
- __try
- {
+ __try {
SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
PSID AdministratorsGroup;
b = AllocateAndInitializeSid(&NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID,
DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &AdministratorsGroup);
- if (b)
- {
+ if (b) {
if (!CheckTokenMembership(NULL, AdministratorsGroup, &b))
b = FALSE;
FreeSid(AdministratorsGroup);
}
- else
- b = GetLastError() == ERROR_CALL_NOT_IMPLEMENTED;
+ else b = GetLastError() == ERROR_CALL_NOT_IMPLEMENTED;
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
b = TRUE;
}
- buffer.appendfmt(TEXT("Administrator privileges: %s"), b ? TEXT("Yes") : TEXT ("No"));
+ buffer.AppendFormat(TEXT("Administrator privileges: %s"), b ? TEXT("Yes") : TEXT ("No"));
}
-void GetLanguageString(bkstring& buffer)
+void GetLanguageString(CMString& buffer)
{
TCHAR name1[256], name2[256], name3[256], name4[256];
@@ -605,22 +580,21 @@ void GetLanguageString(bkstring& buffer) GetLocaleInfo(MAKELCID(GetUserDefaultUILanguage(), SORT_DEFAULT), LOCALE_SENGLANGUAGE, name3, 256);
GetLocaleInfo(MAKELCID(GetSystemDefaultUILanguage(), SORT_DEFAULT), LOCALE_SENGLANGUAGE, name4, 256);
- buffer.appendfmt(TEXT("OS Languages: (UI | Locale (User/System)) : %s/%s | %s/%s"), name3, name4, name1, name2);
+ buffer.AppendFormat(TEXT("OS Languages: (UI | Locale (User/System)) : %s/%s | %s/%s"), name3, name4, name1, name2);
}
-void GetLanguagePackString(bkstring& buffer)
+void GetLanguagePackString(CMString& buffer)
{
- buffer.append(TEXT("Language pack: "));
+ buffer.Append(TEXT("Language pack: "));
if (packlcid == LOCALE_USER_DEFAULT)
- buffer.append(TEXT("No language pack installed"));
- else
- {
+ buffer.Append(TEXT("No language pack installed"));
+ else {
TCHAR path[MAX_PATH] = TEXT("Locale id invalid");
GetLocaleInfo(packlcid, LOCALE_SENGLANGUAGE, path, MAX_PATH);
- buffer.append(path);
+ buffer.Append(path);
GetLocaleInfo(packlcid, LOCALE_SISO3166CTRYNAME, path, MAX_PATH);
- buffer.appendfmt(TEXT(" (%s) [%04x]"), path, packlcid);
+ buffer.AppendFormat(TEXT(" (%s) [%04x]"), path, packlcid);
GetModuleFileName(NULL, path, MAX_PATH);
@@ -634,11 +608,8 @@ void GetLanguagePackString(bkstring& buffer) FindClose(hFind);
mir_sntprintf(fname, MAX_PATH-(fname-path), TEXT("\\%s"), FindFileData.cFileName);
- HANDLE hDumpFile = CreateFile(path, GENERIC_READ, FILE_SHARE_READ, NULL,
- OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
-
- if (hDumpFile != INVALID_HANDLE_VALUE)
- {
+ 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;
@@ -646,8 +617,7 @@ void GetLanguagePackString(bkstring& buffer) buf[bytes] = 0;
char *id = strstr(buf, "FLID:");
- if (id != NULL)
- {
+ if (id != NULL) {
char *endid = strchr(id, '\r');
if (endid != NULL) *endid = 0;
@@ -659,21 +629,20 @@ void GetLanguagePackString(bkstring& buffer) TCHAR* tid;
crsi_a2t(tid, id+5);
- buffer.appendfmt(TEXT(", %s, modified: %s"), tid, mirtime);
+ buffer.AppendFormat(TEXT(", %s, modified: %s"), tid, mirtime);
}
CloseHandle(hDumpFile);
}
}
}
-void GetWow64String(bkstring& buffer)
+void GetWow64String(CMString& buffer)
{
BOOL wow64 = 0;
if (!IsWow64Process(GetCurrentProcess(), &wow64))
- {
wow64 = 0;
- }
- if (wow64) buffer.append(TEXT(" [running inside WOW64]"));
+
+ if (wow64) buffer.Append(TEXT(" [running inside WOW64]"));
}
@@ -696,25 +665,21 @@ bool CreateDirectoryTree(LPTSTR szDir) return res;
}
-void GetVersionInfo(HMODULE hLib, bkstring& buffer)
+void GetVersionInfo(HMODULE hLib, CMString& buffer)
{
HRSRC hVersion = FindResource(hLib, MAKEINTRESOURCE(VS_VERSION_INFO), RT_VERSION);
- if (hVersion != NULL)
- {
+ if (hVersion != NULL) {
HGLOBAL hGlobal = LoadResource(hLib, hVersion);
- if (hGlobal != NULL)
- {
+ if (hGlobal != NULL) {
LPVOID versionInfo = LockResource(hGlobal);
- if (versionInfo != NULL)
- {
+ if (versionInfo != NULL) {
int vl = *(unsigned short*)versionInfo;
unsigned *res = (unsigned*)versionInfo;
while (*res != 0xfeef04bd && ((char*)res - (char*)versionInfo) < vl) ++res;
- if (((char*)res - (char*)versionInfo) < vl)
- {
+ if (((char*)res - (char*)versionInfo) < vl) {
VS_FIXEDFILEINFO *vsInfo = (VS_FIXEDFILEINFO*)res;
- buffer.appendfmt(TEXT(" v.%u.%u.%u.%u"),
+ buffer.AppendFormat(TEXT(" v.%u.%u.%u.%u"),
HIWORD(vsInfo->dwFileVersionMS), LOWORD(vsInfo->dwFileVersionMS),
HIWORD(vsInfo->dwFileVersionLS), LOWORD(vsInfo->dwFileVersionLS));
}
@@ -724,12 +689,13 @@ void GetVersionInfo(HMODULE hLib, bkstring& buffer) }
}
-void StoreStringToClip(bkstring& buffer)
+void StoreStringToClip(CMString& buffer)
{
- HANDLE hData = GlobalAlloc(GMEM_MOVEABLE, buffer.sizebytes() + sizeof(TCHAR));
+ int bufLen = (buffer.GetLength() + 1) * sizeof(TCHAR);
+ HANDLE hData = GlobalAlloc(GMEM_MOVEABLE, bufLen);
LPSTR buf = (LPSTR)GlobalLock(hData);
- memcpy(buf, buffer.c_str(), buffer.sizebytes() + sizeof(TCHAR));
+ memcpy(buf, buffer.c_str(), bufLen);
GlobalUnlock(hData);
|