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 | |
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')
-rw-r--r-- | plugins/CrashDumper/src/bkstring.cpp | 188 | ||||
-rw-r--r-- | plugins/CrashDumper/src/bkstring.h | 262 | ||||
-rw-r--r-- | plugins/CrashDumper/src/crshdmp.cpp | 11 | ||||
-rw-r--r-- | plugins/CrashDumper/src/dumper.cpp | 262 | ||||
-rw-r--r-- | plugins/CrashDumper/src/exhndlr.cpp | 24 | ||||
-rw-r--r-- | plugins/CrashDumper/src/ui.cpp | 52 | ||||
-rw-r--r-- | plugins/CrashDumper/src/upload.cpp | 78 | ||||
-rw-r--r-- | plugins/CrashDumper/src/utils.cpp | 332 | ||||
-rw-r--r-- | plugins/CrashDumper/src/utils.h | 30 |
9 files changed, 321 insertions, 918 deletions
diff --git a/plugins/CrashDumper/src/bkstring.cpp b/plugins/CrashDumper/src/bkstring.cpp deleted file mode 100644 index b79301a036..0000000000 --- a/plugins/CrashDumper/src/bkstring.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/*
-Miranda Crash Dumper Plugin
-Copyright (C) 2008 - 2012 Boris Krasnovskiy All Rights Reserved
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation version 2
-of the License.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "utils.h"
-
-bkstring::~bkstring() { if (sizeAlloced) free(buf); }
-
-
-void bkstring::reserve(size_type len)
-{
- if (len >= sizeAlloced || sizeAlloced == 0)
- {
- if (sizeAlloced == 0) buf = NULL;
- buf = (value_type*)realloc(buf, (len+1) * sizeof(value_type));
- if (sizeAlloced == 0) buf[0] = 0;
- sizeAlloced = len+1;
- }
-}
-
-void bkstring::appendfmt(const value_type *fmt, ...)
-{
- areserve(_tcslen(fmt)*2);
-
- va_list vararg;
- va_start(vararg, fmt);
- for (;;)
- {
- int len = mir_vsntprintf(buf + lenBuf, sizeAlloced - lenBuf - 1, fmt, vararg);
- if (len < 0)
- reserve(sizeAlloced + 256);
- else
- {
- lenBuf += len;
- buf[lenBuf] = 0;
- break;
- }
- }
- va_end(vararg);
-}
-
-bkstring& bkstring::append(const value_type* _Ptr)
-{
- size_type len = _tcslen(_Ptr);
- areserve(len);
- memcpy(buf+lenBuf, _Ptr, (len+1)*sizeof(value_type));
- lenBuf += len;
- return *this;
-}
-
-bkstring& bkstring::append(const value_type* _Ptr, size_type _Count)
-{
- size_type len = min(_tcslen(_Ptr), _Count);
- areserve(len);
- memcpy(buf+lenBuf, _Ptr, len*sizeof(value_type));
- lenBuf += len;
- buf[lenBuf] = 0;
- return *this;
-}
-
-bkstring& bkstring::append(const bkstring& _Str, size_type _Off, size_type _Count)
-{
- size_type len = min(_Count, _Str.size() - _Off);
- areserve(len);
- memcpy(buf+lenBuf, _Str.c_str()+_Off, len*sizeof(value_type));
- lenBuf += len;
- buf[lenBuf] = 0;
- return *this;
-}
-
-bkstring& bkstring::append(const bkstring& _Str)
-{
- size_type len = _Str.size();
- areserve(len);
- memcpy(buf+lenBuf, _Str.c_str(), len*sizeof(value_type));
- lenBuf += len;
- buf[lenBuf] = 0;
- return *this;
-}
-
-bkstring& bkstring::append(size_type _Count, value_type _Ch)
-{
- areserve(_Count);
- for(size_type i=0; i<_Count; ++i) buf[lenBuf+i] = _Ch;
- lenBuf += _Count;
- buf[lenBuf] = 0;
- return *this;
-}
-
-
-bkstring& bkstring::assign(const value_type* _Ptr, size_type _Count)
-{
- reserve(_Count);
- memcpy(buf, _Ptr, _Count*sizeof(value_type));
- buf[_Count] = 0;
- lenBuf = _Count;
- return *this;
-}
-
-bkstring& bkstring::assign(const bkstring& _Str, size_type _Off, size_type _Count)
-{
- size_type len = min(_Count, _Str.size() - _Off);
- reserve(len);
- memcpy(buf, _Str.c_str() + _Off, len*sizeof(value_type));
- lenBuf = len;
- buf[len] = 0;
- return *this;
-}
-
-bkstring& bkstring::assign(size_type _Count, value_type _Ch)
-{
- reserve(_Count);
- for(size_type i=0; i<_Count; ++i) buf[i] = _Ch;
- buf[_Count] = 0;
- lenBuf = _Count;
- return *this;
-}
-
-bkstring::size_type bkstring::find(value_type _Ch, size_type _Off) const
-{
- for (size_type i=_Off; i<=lenBuf; ++i)
- if (buf[i] == _Ch) return i;
- return (size_type)npos;
-}
-
-bkstring::size_type bkstring::find(const value_type* _Ptr, size_type _Off) const
-{
- if (_Off > lenBuf) return (size_type)npos;
-
- value_type* pstr = _tcsstr(buf+_Off, _Ptr);
- return pstr ? pstr - buf : npos;
-}
-
-bkstring::size_type bkstring::find_last_of(value_type _Ch, size_type _Off) const
-{
- for (size_type i=(_Off == npos ? lenBuf : _Off); i--;)
- if (buf[i] == _Ch) return i;
- return (size_type)npos;
-}
-
-bkstring& bkstring::insert(size_type _P0, const value_type* _Ptr, size_type _Count)
-{
- size_type len = _tcslen(_Ptr);
- if (_Count < len) len = _Count;
- areserve(len);
- value_type *p = buf + _P0;
- memmove(p+len, p, (lenBuf-_P0+1)*sizeof(value_type));
- memcpy(p, _Ptr, _Count*sizeof(value_type));
- lenBuf += len;
- return *this;
-}
-
-bkstring& bkstring::insert(size_type _P0, size_type _Count, value_type _Ch)
-{
- areserve(_Count);
- value_type *p = buf + _P0;
- memmove(p+_Count, p, (lenBuf-_P0+1)*sizeof(value_type));
- for(size_type i=0; i<_Count; ++i) p[i] = _Ch;
- lenBuf += _Count;
- return *this;
-}
-
-bkstring& bkstring::erase(size_type _Pos, size_type _Count)
-{
- if (_Pos < lenBuf)
- {
- const size_type len = min(lenBuf - _Pos, _Count);
- value_type *p = buf + _Pos;
- lenBuf -= len;
- memmove(p, p+len, (lenBuf - _Pos)*sizeof(value_type));
- buf[lenBuf] = 0;
- }
- return *this;
-}
diff --git a/plugins/CrashDumper/src/bkstring.h b/plugins/CrashDumper/src/bkstring.h deleted file mode 100644 index 8000723225..0000000000 --- a/plugins/CrashDumper/src/bkstring.h +++ /dev/null @@ -1,262 +0,0 @@ -/*
-Miranda Crash Dumper Plugin
-Copyright (C) 2008 - 2012 Boris Krasnovskiy All Rights Reserved
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation version 2
-of the License.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _BKSTRING_H_
-#define _BKSTRING_H_
-
-class bkstring
-{
-public:
- typedef size_t size_type;
- typedef TCHAR value_type;
- typedef value_type* iterator;
- typedef const value_type* const_iterator;
-
- static const size_type npos = size_type(-1);
-
-private:
- value_type* buf;
- size_type sizeAlloced;
- size_type lenBuf;
-
- void areserve(size_type len) { reserve(lenBuf + len); }
-
-public:
-
- explicit bkstring() : buf((TCHAR*)_T("")), sizeAlloced(0), lenBuf(0)
- {}
-
- bkstring(const value_type* _Ptr, size_type _Count) : sizeAlloced(0), lenBuf(0)
- { assign(_Ptr, _Count); }
-
- bkstring(const value_type* _Ptr) : sizeAlloced(0), lenBuf(0)
- { assign(_Ptr); }
-
- bkstring(size_type _Count, value_type _Ch) : sizeAlloced(0), lenBuf(0)
- { assign(_Count, _Ch); }
-
- bkstring(const bkstring& _Str) : sizeAlloced(0), lenBuf(0)
- { assign(_Str); }
-
- bkstring(const bkstring& _Str, size_type _Off, size_type _Count) : sizeAlloced(0), lenBuf(0)
- { assign(_Str, _Off, _Count); }
-
- ~bkstring();
-
- size_type size(void) const { return lenBuf; }
- const value_type* c_str(void) const { return buf; }
-
- void clear(void) { if (lenBuf) { lenBuf = 0; buf[0] = 0; } }
- void insert(const value_type *txt);
- void reserve(size_type len);
-
- bkstring& assign(const value_type* _Ptr)
- { return assign(_Ptr, _tcslen(_Ptr)); }
-
- bkstring& assign(const bkstring& _Str)
- { return assign(_Str, 0, (size_type)npos); }
-
- bkstring& assign(const value_type* _Ptr, size_type _Count);
- bkstring& assign(const bkstring& _Str, size_type off, size_type _Count);
- bkstring& assign(size_type _Count, value_type _Ch);
-
- bkstring& append(const value_type* _Ptr);
- bkstring& append(const value_type* _Ptr, size_type _Count);
- bkstring& append(const bkstring& _Str, size_type _Off, size_type _Count);
- bkstring& append(const bkstring& _Str);
- bkstring& append(size_type _Count, value_type _Ch);
-
- int compare(const bkstring& _Str) const
- { return _tcscmp(buf, _Str.c_str()); }
-
- int compare(size_type _Pos1, size_type _Num1, const bkstring& _Str) const
- { return _tcsncmp(&buf[_Pos1], _Str.c_str(), _Num1); }
-
- int compare(size_type _Pos1, size_type _Num1, const bkstring& _Str, size_type _Off, size_type _Count) const
- { return _tcsncmp(&buf[_Pos1], _Str.c_str()+_Off, min(_Num1, _Count)); }
-
- int compare(const value_type* _Ptr) const
- { return _tcscmp(buf, _Ptr); }
-
- int compare(size_type _Pos1, size_type _Num1, const value_type* _Ptr) const
- { return _tcsncmp(&buf[_Pos1], _Ptr, _Num1); }
-
- int compare(size_type _Pos1, size_type _Num1, const value_type* _Ptr, size_type _Num2) const
- { return _tcsncmp(&buf[_Pos1], _Ptr, min(_Num1, _Num2)); }
-
- int comparei(const bkstring& _Str) const
- { return _tcsicmp(buf, _Str.c_str()); }
-
- int comparei(size_type _Pos1, size_type _Num1, const bkstring& _Str) const
- { return _tcsnicmp(&buf[_Pos1], _Str.c_str(), _Num1); }
-
- int comparei(size_type _Pos1, size_type _Num1, const bkstring& _Str, size_type _Off, size_type _Count) const
- { return _tcsnicmp(&buf[_Pos1], _Str.c_str()+_Off, min(_Num1, _Count)); }
-
- int comparei(const value_type* _Ptr) const
- { return _tcsicmp(buf, _Ptr); }
-
- int comparei(size_type _Pos1, size_type _Num1, const value_type* _Ptr) const
- { return _tcsnicmp(&buf[_Pos1], _Ptr, _Num1); }
-
- int comparei(size_type _Pos1, size_type _Num1, const value_type* _Ptr, size_type _Num2) const
- { return _tcsnicmp(&buf[_Pos1], _Ptr, min(_Num1, _Num2)); }
-
- bool empty(void) const { return lenBuf == 0; };
- bkstring& erase(size_type _Pos = 0, size_type _Count = npos);
-
- size_type find(value_type _Ch, size_type _Off = 0) const;
- size_type find(const value_type* _Ptr, size_type _Off = 0) const;
- size_type find(bkstring& _Str, size_type _Off = 0) const
- { return find(_Str.c_str(), _Off); }
-
- size_type find_last_of(value_type _Ch, size_type _Off = npos) const;
-
- bkstring& insert(size_type _P0, const value_type* _Ptr)
- { return insert(_P0, _Ptr, _tcslen(_Ptr)); }
-
- bkstring& insert(size_type _P0, const bkstring& _Str)
- { return insert(_P0, _Str.c_str(), _Str.size()); };
-
- bkstring& insert(size_type _P0, const value_type* _Ptr, size_type _Count);
- bkstring& insert(size_type _P0, size_type _Count, value_type _Ch);
-
- bkstring substr(size_type _Off = 0, size_type _Count = npos) const
- { return bkstring(*this, _Off, _Count); }
-
- bkstring& operator = (const bkstring& _Str)
- { return assign(_Str); }
-
- bkstring& operator =(const value_type* _Ptr)
- { return assign(_Ptr); }
-
- bkstring& operator = (const value_type _Ch)
- { return assign(1, _Ch); }
-
- bkstring& operator +=(const bkstring& _Str)
- { return append(_Str); }
-
- bkstring& operator += (const value_type* _Ptr)
- { return append(_Ptr); }
-
- bkstring& operator += (const value_type _Ch)
- { return append(1, _Ch); }
-
- value_type& operator[] (int ind) const
- { return buf[ind]; }
-
- friend bkstring operator+ (const bkstring& _Str1, const bkstring& _Str2)
- { bkstring s(_Str1); return s.append(_Str2); }
-
- friend bkstring operator+ (const bkstring& _Str1, const value_type* _Ptr2)
- { bkstring s(_Str1); return s.append(_Ptr2); }
-
- friend bkstring operator+(const value_type* _Ptr1, const bkstring& _Str2)
- { bkstring s(_Ptr1); return s.append(_Str2); }
-
- friend bkstring operator+ (const bkstring& _Str1, const value_type _Ch)
- { bkstring s(_Str1); return s.append(1, _Ch); }
-
- friend bool operator==(const bkstring& _Str1, const bkstring& _Str2)
- { return _Str1.compare(_Str2) == 0; }
-
- friend bool operator==(const bkstring& _Str1, const value_type* _Ptr2)
- { return _Str1.compare(_Ptr2) == 0; }
-
- friend bool operator==(const value_type* _Ptr1, const bkstring& _Str2)
- { return _Str2.compare(_Ptr1) == 0; }
-
- friend bool operator!=(const bkstring& _Str1, const bkstring& _Str2)
- { return _Str1.compare(_Str2) != 0; }
-
- friend bool operator!=(const bkstring& _Str1, const value_type* _Ptr2)
- { return _Str1.compare(_Ptr2) != 0; }
-
- friend bool operator!=(const value_type* _Ptr1, const bkstring& _Str2)
- { return _Str2.compare(_Ptr1) != 0; }
-
- friend bool operator<(const bkstring& _Str1, const bkstring& _Str2)
- { return _Str1.compare(_Str2) < 0; }
-
- friend bool operator<(const bkstring& _Str1, const value_type* _Ptr2)
- { return _Str1.compare(_Ptr2) < 0; }
-
- friend bool operator<(const value_type* _Ptr1, const bkstring& _Str2)
- { return _Str2.compare(_Ptr1) > 0; }
-
- friend bool operator>(const bkstring& _Str1, const bkstring& _Str2)
- { return _Str1.compare(_Str2) > 0; }
-
- friend bool operator>(const bkstring& _Str1, const value_type* _Ptr2)
- { return _Str1.compare(_Ptr2) > 0; }
-
- friend bool operator>(const value_type* _Ptr1, const bkstring& _Str2)
- { return _Str2.compare(_Ptr1) < 0; }
-
- friend bool operator<=(const bkstring& _Str1, const bkstring& _Str2)
- { return _Str1.compare(_Str2) <= 0; }
-
- friend bool operator<=(const bkstring& _Str1, const value_type* _Ptr2)
- { return _Str1.compare(_Ptr2) <= 0; }
-
- friend bool operator<=(const value_type* _Ptr1, const bkstring& _Str2)
- { return _Str2.compare(_Ptr1) >= 0; }
-
- friend bool operator>=(const bkstring& _Str1, const bkstring& _Str2)
- { return _Str1.compare(_Str2) >= 0; }
-
- friend bool operator>=(const bkstring& _Str1, const value_type* _Ptr2)
- { return _Str1.compare(_Ptr2) >= 0; }
-
- friend bool operator>=(const value_type* _Ptr1, const bkstring& _Str2)
- { return _Str2.compare(_Ptr1) <= 0; }
-
- friend bool operator==(const value_type _Ch1, const bkstring& _Str2)
- { return (_Str2.size() == 1) && (_Str2[0] == _Ch1); }
-
- friend bool operator==(const bkstring& _Str1, const value_type _Ch2)
- { return (_Str1.size() == 1) && (_Str1[0] == _Ch2); }
-
- friend bool operator!=(const value_type _Ch1, const bkstring& _Str2)
- { return (_Str2.size() != 1) || (_Str2[0] != _Ch1); }
-
- friend bool operator!=(const bkstring& _Str1, const value_type _Ch2)
- { return (_Str1.size() != 1) || (_Str1[0] != _Ch2); }
-
- iterator begin(void)
- { return buf; }
-
- const_iterator begin(void) const
- { return buf; }
-
- iterator end(void)
- { return buf + lenBuf; }
-
- const_iterator end(void) const
- { return buf + lenBuf; }
-
- // Custom extentions
-
- void appendfmt(const value_type *fmt, ...);
-
- size_type sizebytes(void) const { return lenBuf * sizeof(value_type); }
-};
-
-//const bkstring::size_type bkstring::npos = -1;
-
-#endif
diff --git a/plugins/CrashDumper/src/crshdmp.cpp b/plugins/CrashDumper/src/crshdmp.cpp index 5cea6dac9a..a2992f24db 100644 --- a/plugins/CrashDumper/src/crshdmp.cpp +++ b/plugins/CrashDumper/src/crshdmp.cpp @@ -76,9 +76,7 @@ INT_PTR StoreVersionInfoToFile(WPARAM, LPARAM lParam) if (hDumpFile != INVALID_HANDLE_VALUE)
{
- bkstring buffer;
-
- buffer.reserve(0x1800);
+ CMString buffer;
PrintVersionInfo(buffer, (unsigned int)lParam | VI_FLAG_PRNVAR);
char* bufu = mir_utf8encodeT(buffer.c_str());
@@ -97,9 +95,7 @@ INT_PTR StoreVersionInfoToFile(WPARAM, LPARAM lParam) INT_PTR StoreVersionInfoToClipboard(WPARAM, LPARAM lParam)
{
- bkstring buffer;
- buffer.reserve(0x1800);
-
+ CMString buffer;
WriteBBFile(buffer, true);
PrintVersionInfo(buffer, (unsigned int)lParam | VI_FLAG_PRNVAR | VI_FLAG_FORMAT);
WriteBBFile(buffer, false);
@@ -111,8 +107,7 @@ INT_PTR StoreVersionInfoToClipboard(WPARAM, LPARAM lParam) INT_PTR UploadVersionInfo(WPARAM, LPARAM lParam)
{
- bkstring buffer;
- buffer.reserve(0x1800);
+ CMString buffer;
PrintVersionInfo(buffer);
VerTrnsfr *trn = (VerTrnsfr*)mir_alloc(sizeof(VerTrnsfr));
diff --git a/plugins/CrashDumper/src/dumper.cpp b/plugins/CrashDumper/src/dumper.cpp index f05f828c16..63551c2355 100644 --- a/plugins/CrashDumper/src/dumper.cpp +++ b/plugins/CrashDumper/src/dumper.cpp @@ -34,12 +34,12 @@ void CreateMiniDump(HANDLE hDumpFile, PEXCEPTION_POINTERS exc_ptr) }
-void WriteBBFile(bkstring& buffer, bool hdr)
+void WriteBBFile(CMString& buffer, bool hdr)
{
static const TCHAR header[] = TEXT("[quote][size=1]");
static const TCHAR footer[] = TEXT("[/size][/quote]");
- buffer.append(hdr ? header : footer);
+ buffer.Append(hdr ? header : footer);
}
@@ -55,37 +55,36 @@ void WriteUtfFile(HANDLE hDumpFile, char* bufu) BOOL CALLBACK LoadedModules64(LPCSTR, DWORD64 ModuleBase, ULONG ModuleSize, PVOID UserContext)
{
- bkstring& buffer = *(bkstring*)UserContext;
+ CMString& buffer = *(CMString*)UserContext;
const HMODULE hModule = (HMODULE)ModuleBase;
TCHAR path[MAX_PATH];
GetModuleFileName(hModule, path, MAX_PATH);
- buffer.appendfmt(TEXT("%s %p - %p"), path, (LPVOID)ModuleBase, (LPVOID)(ModuleBase + ModuleSize));
+ buffer.AppendFormat(TEXT("%s %p - %p"), path, (LPVOID)ModuleBase, (LPVOID)(ModuleBase + ModuleSize));
GetVersionInfo(hModule, buffer);
TCHAR timebuf[30] = TEXT("");
GetLastWriteTime(path, timebuf, 30);
- buffer.appendfmt(TEXT(" [%s]\r\n"), timebuf);
+ buffer.AppendFormat(TEXT(" [%s]\r\n"), timebuf);
return TRUE;
}
-typedef struct _FindData
+struct FindData
{
- DWORD64 Offset; IMAGEHLP_MODULE64* pModule;
-} FindData;
-
+ DWORD64 Offset;
+ IMAGEHLP_MODULE64* pModule;
+};
BOOL CALLBACK LoadedModulesFind64(LPCSTR ModuleName, DWORD64 ModuleBase, ULONG ModuleSize, PVOID UserContext)
{
FindData* data = (FindData*)UserContext;
- if ((DWORD)(data->Offset - ModuleBase) < ModuleSize)
- {
+ if ((DWORD)(data->Offset - ModuleBase) < ModuleSize) {
const size_t len = SIZEOF(data->pModule->ModuleName);
strncpy(data->pModule->ModuleName, ModuleName, len);
data->pModule->ModuleName[len-1] = 0;
@@ -101,40 +100,34 @@ BOOL CALLBACK LoadedModulesFind64(LPCSTR ModuleName, DWORD64 ModuleBase, ULONG M }
-void GetLinkedModulesInfo(TCHAR *moduleName, bkstring &buffer)
+void GetLinkedModulesInfo(TCHAR *moduleName, CMString &buffer)
{
HANDLE hDllFile = CreateFile(moduleName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
- if (hDllFile == INVALID_HANDLE_VALUE) return;
+ if (hDllFile == INVALID_HANDLE_VALUE)
+ return;
HANDLE hDllMapping = CreateFileMapping(hDllFile, NULL, PAGE_READONLY, 0, 0, NULL);
- if (hDllMapping == INVALID_HANDLE_VALUE)
- {
+ if (hDllMapping == INVALID_HANDLE_VALUE) {
CloseHandle(hDllFile);
return;
}
LPVOID dllAddr = MapViewOfFile(hDllMapping, FILE_MAP_READ, 0, 0, 0);
-
static const TCHAR format[] = TEXT(" Plugin statically linked to missing module: %S\r\n");
-
- __try
- {
+ __try {
PIMAGE_NT_HEADERS nthdrs = ImageNtHeader(dllAddr);
ULONG tableSize;
PIMAGE_IMPORT_DESCRIPTOR importData = (PIMAGE_IMPORT_DESCRIPTOR)ImageDirectoryEntryToData(dllAddr, FALSE,
IMAGE_DIRECTORY_ENTRY_IMPORT, &tableSize);
- if (importData)
- {
- while (importData->Name)
- {
+ if (importData) {
+ while (importData->Name) {
char* moduleName = (char*)ImageRvaToVa(nthdrs, dllAddr, importData->Name, NULL);
if (!SearchPathA(NULL, moduleName, NULL, NULL, 0, NULL))
- {
- buffer.appendfmt(format, moduleName);
- }
+ buffer.AppendFormat(format, moduleName);
+
importData++; //go to next record
}
}
@@ -142,22 +135,19 @@ void GetLinkedModulesInfo(TCHAR *moduleName, bkstring &buffer) bool found = false;
PIMAGE_EXPORT_DIRECTORY exportData = (PIMAGE_EXPORT_DIRECTORY)ImageDirectoryEntryToData(dllAddr, FALSE,
IMAGE_DIRECTORY_ENTRY_EXPORT, &tableSize);
- if (exportData)
- {
+ if (exportData) {
ULONG* funcAddr = (ULONG*)ImageRvaToVa(nthdrs, dllAddr, exportData->AddressOfNames, NULL);
- for(unsigned i=0; i<exportData->NumberOfNames && !found; ++i)
- {
+ for(unsigned i=0; i<exportData->NumberOfNames && !found; ++i) {
char* funcName = (char*)ImageRvaToVa(nthdrs, dllAddr, funcAddr[i], NULL);
found = strcmp(funcName, "MirandaPluginInfoEx") == 0 || strcmp(funcName, "MirandaPluginInfo") == 0;
- if (strcmp(funcName, "DatabasePluginInfo") == 0)
- {
- buffer.append(TEXT(" This dll is a Miranda database plugin, another database is active right now\r\n"));
+ if (strcmp(funcName, "DatabasePluginInfo") == 0) {
+ buffer.Append(TEXT(" This dll is a Miranda database plugin, another database is active right now\r\n"));
found = true;
}
}
}
if (!found)
- buffer.append(TEXT(" This dll is not a Miranda plugin and should be removed from plugins directory\r\n"));
+ buffer.Append(TEXT(" This dll is not a Miranda plugin and should be removed from plugins directory\r\n"));
}
__except(EXCEPTION_EXECUTE_HANDLER) {}
@@ -171,13 +161,13 @@ struct ListItem {
ListItem() : str(), next(NULL) {}
- bkstring str;
+ CMString str;
ListItem *next;
};
-static void GetPluginsString(bkstring& buffer, unsigned& flags)
+static void GetPluginsString(CMString& buffer, unsigned& flags)
{
- buffer.appendfmt(TEXT("Service Mode: %s\r\n"), servicemode ? TEXT("Yes") : TEXT("No"));
+ buffer.AppendFormat(TEXT("Service Mode: %s\r\n"), servicemode ? TEXT("Yes") : TEXT("No"));
TCHAR path[MAX_PATH];
GetModuleFileName(NULL, path, MAX_PATH);
@@ -192,38 +182,32 @@ static void GetPluginsString(bkstring& buffer, unsigned& flags) size_t count = 0, ucount = 0;
- bkstring ubuffer;
+ CMString ubuffer;
ListItem* dlllist = NULL;
-
static const TCHAR format[] = TEXT("%c %s v.%s%d.%d.%d.%d%s [%s] - %S %s\r\n");
-
- do
- {
+ do {
bool loaded = false;
mir_sntprintf(fname, MAX_PATH-(fname-path), TEXT("\\plugins\\%s"), FindFileData.cFileName);
HMODULE hModule = GetModuleHandle(path);
- if (hModule == NULL && servicemode)
- {
+ if (hModule == NULL && servicemode) {
hModule = LoadLibrary(path);
loaded = true;
}
- if (hModule == NULL)
- {
- if ((flags & VI_FLAG_PRNVAR) && IsPluginEnabled(FindFileData.cFileName))
- {
+ if (hModule == NULL) {
+ if ((flags & VI_FLAG_PRNVAR) && IsPluginEnabled(FindFileData.cFileName)) {
TCHAR timebuf[30] = TEXT("");
GetLastWriteTime(&FindFileData.ftLastWriteTime, timebuf, 30);
- ubuffer.appendfmt(format, TEXT(' '), FindFileData.cFileName,
+ ubuffer.AppendFormat(format, TEXT(' '), FindFileData.cFileName,
(flags & VI_FLAG_FORMAT) ? TEXT("[b]") : TEXT(""),
0, 0, 0, 0,
(flags & VI_FLAG_FORMAT) ? TEXT("[/b]") : TEXT(""),
timebuf, "<unknown>", TEXT(""));
GetLinkedModulesInfo(path, ubuffer);
- ubuffer.append(TEXT("\r\n"));
+ ubuffer.Append(TEXT("\r\n"));
++ucount;
}
@@ -231,8 +215,7 @@ static void GetPluginsString(bkstring& buffer, unsigned& flags) }
PLUGININFOEX* pi = GetMirInfo(hModule);
- if (pi != NULL)
- {
+ if (pi != NULL) {
TCHAR timebuf[30] = TEXT("");
GetLastWriteTime(&FindFileData.ftLastWriteTime, timebuf, 30);
@@ -258,7 +241,7 @@ static void GetPluginsString(bkstring& buffer, unsigned& flags) v1 = HIBYTE(HIWORD(ver)), v2 = LOBYTE(HIWORD(ver)), v3 = HIBYTE(LOWORD(ver)), v4 = LOBYTE(LOWORD(ver));
}
- lst->str.appendfmt(format, ep ? TEXT('\xa4') : TEXT(' '), FindFileData.cFileName,
+ lst->str.AppendFormat(format, ep ? TEXT('\xa4') : TEXT(' '), FindFileData.cFileName,
(flags & VI_FLAG_FORMAT) ? TEXT("[b]") : TEXT(""),
v1, v2, v3, v4,
(flags & VI_FLAG_FORMAT) ? TEXT("[/b]") : TEXT(""),
@@ -266,10 +249,10 @@ static void GetPluginsString(bkstring& buffer, unsigned& flags) ListItem* lsttmp = dlllist;
ListItem* lsttmppv = NULL;
- while (lsttmp != NULL)
- {
- size_t sz = min(lsttmp->str.size(), lst->str.size()) - 2;
- if (lsttmp->str.comparei(2, sz, lst->str, 2, sz) > 0) break;
+ while (lsttmp != NULL) {
+ size_t sz = min(lsttmp->str.GetLength(), lst->str.GetLength()) - 2;
+ if (lsttmp->str.CompareNoCase(lst->str) > 0)
+ break;
lsttmppv = lsttmp;
lsttmp = lsttmp->next;
}
@@ -289,23 +272,21 @@ static void GetPluginsString(bkstring& buffer, unsigned& flags) while (FindNextFile(hFind, &FindFileData));
FindClose(hFind);
- buffer.appendfmt(TEXT("\r\n%sActive Plugins (%u):%s\r\n"),
+ buffer.AppendFormat(TEXT("\r\n%sActive Plugins (%u):%s\r\n"),
(flags & VI_FLAG_FORMAT) ? TEXT("[b]") : TEXT(""), count, (flags & VI_FLAG_FORMAT) ? TEXT("[/b]") : TEXT(""));
ListItem* lsttmp = dlllist;
- while (lsttmp != NULL)
- {
- buffer.append(lsttmp->str);
+ while (lsttmp != NULL) {
+ buffer.Append(lsttmp->str);
ListItem* lsttmp1 = lsttmp->next;
delete lsttmp;
lsttmp = lsttmp1;
}
- if (ucount)
- {
- buffer.appendfmt(TEXT("\r\n%sUnloadable Plugins (%u):%s\r\n"),
+ if (ucount) {
+ buffer.AppendFormat(TEXT("\r\n%sUnloadable Plugins (%u):%s\r\n"),
(flags & VI_FLAG_FORMAT) ? TEXT("[b]") : TEXT(""), ucount, (flags & VI_FLAG_FORMAT) ? TEXT("[/b]") : TEXT(""));
- buffer.append(ubuffer);
+ buffer.Append(ubuffer);
}
}
@@ -317,7 +298,7 @@ struct ProtoCount bool nloaded;
};
-static void GetProtocolStrings(bkstring& buffer)
+static void GetProtocolStrings(CMString& buffer)
{
PROTOACCOUNT **accList;
int accCount;
@@ -362,13 +343,13 @@ static void GetProtocolStrings(bkstring& buffer) }
for (i = 0; i < protoCountMy; i++)
- buffer.appendfmt(TEXT("%-24s %d - Enabled %d - Disabled %sLoaded\r\n"),
+ buffer.AppendFormat(TEXT("%-24s %d - Enabled %d - Disabled %sLoaded\r\n"),
(TCHAR*)_A2T(protoListMy[i]), protos[i].countse,
protos[i].countsd, protos[i].nloaded ? _T("Not ") : _T(""));
}
-static void GetWeatherStrings(bkstring& buffer, unsigned flags)
+static void GetWeatherStrings(CMString& buffer, unsigned flags)
{
TCHAR path[MAX_PATH];
GetModuleFileName(NULL, path, MAX_PATH);
@@ -381,16 +362,14 @@ static void GetWeatherStrings(bkstring& buffer, unsigned flags) HANDLE hFind = FindFirstFile(path, &FindFileData);
if (hFind == INVALID_HANDLE_VALUE) return;
- do
- {
+ do {
if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue;
mir_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)
- {
+ if (hDumpFile != INVALID_HANDLE_VALUE) {
char buf[8192];
DWORD bytes = 0;
@@ -398,12 +377,10 @@ static void GetWeatherStrings(bkstring& buffer, unsigned flags) buf[bytes] = 0;
char* ver = strstr(buf, "Version=");
- if (ver != NULL)
- {
+ if (ver != NULL) {
char *endid = strchr(ver, '\r');
if (endid != NULL) *endid = 0;
- else
- {
+ else {
endid = strchr(ver, '\n');
if (endid != NULL) *endid = 0;
}
@@ -411,12 +388,10 @@ static void GetWeatherStrings(bkstring& buffer, unsigned flags) }
char *id = strstr(buf, "Name=");
- if (id != NULL)
- {
+ if (id != NULL) {
char *endid = strchr(id, '\r');
if (endid != NULL) *endid = 0;
- else
- {
+ else {
endid = strchr(id, '\n');
if (endid != NULL) *endid = 0;
}
@@ -429,7 +404,7 @@ static void GetWeatherStrings(bkstring& buffer, unsigned flags) static const TCHAR format[] = TEXT(" %s v.%s%S%s [%s] - %S\r\n");
- buffer.appendfmt(format, FindFileData.cFileName,
+ buffer.AppendFormat(format, FindFileData.cFileName,
(flags & VI_FLAG_FORMAT) ? TEXT("[b]") : TEXT(""),
ver,
(flags & VI_FLAG_FORMAT) ? TEXT("[/b]") : TEXT(""),
@@ -442,7 +417,7 @@ static void GetWeatherStrings(bkstring& buffer, unsigned flags) }
-static void GetIconStrings(bkstring& buffer)
+static void GetIconStrings(CMString& buffer)
{
TCHAR path[MAX_PATH];
GetModuleFileName(NULL, path, MAX_PATH);
@@ -455,116 +430,107 @@ static void GetIconStrings(bkstring& buffer) HANDLE hFind = FindFirstFile(path, &FindFileData);
if (hFind == INVALID_HANDLE_VALUE) return;
- do
- {
+ do {
if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue;
TCHAR timebuf[30] = TEXT("");
GetLastWriteTime(&FindFileData.ftLastWriteTime, timebuf, 30);
- buffer.appendfmt(TEXT(" %s [%s]\r\n"), FindFileData.cFileName, timebuf);
+ buffer.AppendFormat(TEXT(" %s [%s]\r\n"), FindFileData.cFileName, timebuf);
}
while (FindNextFile(hFind, &FindFileData));
FindClose(hFind);
}
-void PrintVersionInfo(bkstring& buffer, unsigned flags)
+void PrintVersionInfo(CMString& buffer, unsigned flags)
{
GetProcessorString(buffer);
- buffer.append(TEXT("\r\n"));
+ buffer.Append(TEXT("\r\n"));
GetFreeMemoryString(buffer);
- buffer.append(TEXT("\r\n"));
+ buffer.Append(TEXT("\r\n"));
GetOSDisplayString(buffer);
- buffer.append(TEXT("\r\n"));
+ buffer.Append(TEXT("\r\n"));
GetInternetExplorerVersion(buffer);
- buffer.append(TEXT("\r\n"));
+ buffer.Append(TEXT("\r\n"));
GetAdminString(buffer);
- buffer.append(TEXT("\r\n"));
+ buffer.Append(TEXT("\r\n"));
GetLanguageString(buffer);
- buffer.append(TEXT("\r\n"));
+ buffer.Append(TEXT("\r\n"));
TCHAR *profpathfull = Utils_ReplaceVarsT(profpath);
- if (flags & VI_FLAG_PRNVAR)
- {
+ if (flags & VI_FLAG_PRNVAR) {
GetFreeDiskString(profpathfull, buffer);
- buffer.append(TEXT("\r\n"));
+ buffer.Append(TEXT("\r\n"));
}
- buffer.appendfmt(TEXT("\r\nMiranda NG Version: %s"), vertxt);
+ buffer.AppendFormat(TEXT("\r\nMiranda NG Version: %s"), vertxt);
GetWow64String(buffer);
- buffer.append(TEXT("\r\n"));
+ buffer.Append(TEXT("\r\n"));
TCHAR path[MAX_PATH], mirtime[30];
GetModuleFileName(NULL, path, MAX_PATH);
GetLastWriteTime(path, mirtime, 30);
- buffer.appendfmt(TEXT("Build time: %s\r\n"), mirtime);
+ buffer.AppendFormat(TEXT("Build time: %s\r\n"), mirtime);
TCHAR profpn[MAX_PATH];
mir_sntprintf(profpn, SIZEOF(profpn), TEXT("%s\\%s"), profpathfull, profname);
- buffer.appendfmt(TEXT("Profile: %s\r\n"), profpn);
+ buffer.AppendFormat(TEXT("Profile: %s\r\n"), profpn);
- if (flags & VI_FLAG_PRNVAR)
- {
+ if (flags & VI_FLAG_PRNVAR) {
WIN32_FIND_DATA FindFileData;
HANDLE hFind = FindFirstFile(profpn, &FindFileData);
- if (hFind != INVALID_HANDLE_VALUE)
- {
+ if (hFind != INVALID_HANDLE_VALUE) {
FindClose(hFind);
unsigned __int64 fsize = (unsigned __int64)FindFileData.nFileSizeHigh << 32 | FindFileData.nFileSizeLow;
- buffer.appendfmt(TEXT("Profile size: %I64u Bytes\r\n"), fsize),
+ buffer.AppendFormat(TEXT("Profile size: %I64u Bytes\r\n"), fsize),
GetLastWriteTime(&FindFileData.ftCreationTime, mirtime, 30);
- buffer.appendfmt(TEXT("Profile creation date: %s\r\n"), mirtime);
+ buffer.AppendFormat(TEXT("Profile creation date: %s\r\n"), mirtime);
}
}
mir_free(profpathfull);
GetLanguagePackString(buffer);
- buffer.append(TEXT("\r\n"));
+ buffer.Append(TEXT("\r\n"));
- // buffer.appendfmt(TEXT("Nightly: %s\r\n"), _tcsstr(vertxt, TEXT("alpha")) ? TEXT("Yes") : TEXT("No"));
- // buffer.appendfmt(TEXT("Unicode: %s\r\n"), _tcsstr(vertxt, TEXT("Unicode")) ? TEXT("Yes") : TEXT("No"));
+ // buffer.AppendFormat(TEXT("Nightly: %s\r\n"), _tcsstr(vertxt, TEXT("alpha")) ? TEXT("Yes") : TEXT("No"));
+ // buffer.AppendFormat(TEXT("Unicode: %s\r\n"), _tcsstr(vertxt, TEXT("Unicode")) ? TEXT("Yes") : TEXT("No"));
GetPluginsString(buffer, flags);
- if (flags & VI_FLAG_WEATHER)
- {
- buffer.appendfmt(TEXT("\r\n%sWeather ini files:%s\r\n-------------------------------------------------------------------------------\r\n"),
+ if (flags & VI_FLAG_WEATHER) {
+ buffer.AppendFormat(TEXT("\r\n%sWeather ini files:%s\r\n-------------------------------------------------------------------------------\r\n"),
(flags & VI_FLAG_FORMAT) ? TEXT("[b]") : TEXT(""),
(flags & VI_FLAG_FORMAT) ? TEXT("[/b]") : TEXT(""));
GetWeatherStrings(buffer, flags);
}
- if (flags & VI_FLAG_PRNVAR && !servicemode)
- {
- buffer.appendfmt(TEXT("\r\n%sProtocols and Accounts:%s\r\n-------------------------------------------------------------------------------\r\n"),
+ if (flags & VI_FLAG_PRNVAR && !servicemode) {
+ buffer.AppendFormat(TEXT("\r\n%sProtocols and Accounts:%s\r\n-------------------------------------------------------------------------------\r\n"),
(flags & VI_FLAG_FORMAT) ? TEXT("[b]") : TEXT(""),
(flags & VI_FLAG_FORMAT) ? TEXT("[/b]") : TEXT(""));
GetProtocolStrings(buffer);
}
- if (flags & VI_FLAG_PRNVAR)
- {
- buffer.appendfmt(TEXT("\r\n%sIcon Packs:%s\r\n-------------------------------------------------------------------------------\r\n"),
+ if (flags & VI_FLAG_PRNVAR) {
+ buffer.AppendFormat(TEXT("\r\n%sIcon Packs:%s\r\n-------------------------------------------------------------------------------\r\n"),
(flags & VI_FLAG_FORMAT) ? TEXT("[b]") : TEXT(""),
(flags & VI_FLAG_FORMAT) ? TEXT("[/b]") : TEXT(""));
GetIconStrings(buffer);
}
- if (flags & VI_FLAG_PRNDLL)
- {
- __try
- {
- buffer.append(TEXT("\r\nLoaded Modules:\r\n-------------------------------------------------------------------------------\r\n"));
+ if (flags & VI_FLAG_PRNDLL) {
+ __try {
+ buffer.Append(TEXT("\r\nLoaded Modules:\r\n-------------------------------------------------------------------------------\r\n"));
EnumerateLoadedModules64(GetCurrentProcess(), LoadedModules64, &buffer);
}
__except(EXCEPTION_EXECUTE_HANDLER) {}
@@ -604,21 +570,19 @@ void CreateCrashReport(HANDLE hDumpFile, PEXCEPTION_POINTERS exc_ptr, const TCHA const PLUGININFOEX *pluginInfoEx = GetPluginInfoEx();
- bkstring buffer;
- buffer.reserve(0x5000);
-
TCHAR curtime[30];
GetISO8061Time(NULL, curtime, 30);
- buffer.appendfmt(TEXT("Miranda Crash Report from %s. Crash Dumper v.%d.%d.%d.%d\r\n"),
+ CMString buffer;
+ buffer.AppendFormat(TEXT("Miranda Crash Report from %s. Crash Dumper v.%d.%d.%d.%d\r\n"),
curtime,
HIBYTE(HIWORD(pluginInfoEx->version)), LOBYTE(HIWORD(pluginInfoEx->version)),
HIBYTE(LOWORD(pluginInfoEx->version)), LOBYTE(LOWORD(pluginInfoEx->version)));
- size_t crashpos = buffer.size();
+ int crashpos = buffer.GetLength();
ReadableExceptionInfo(exc_ptr->ExceptionRecord, buffer);
- buffer.append(TEXT("\r\n"));
+ buffer.Append(TEXT("\r\n"));
const HANDLE hProcess = GetCurrentProcess();
@@ -626,17 +590,9 @@ void CreateCrashReport(HANDLE hDumpFile, PEXCEPTION_POINTERS exc_ptr, const TCHA SymSetOptions(SYMOPT_UNDNAME | SYMOPT_DEFERRED_LOADS | SYMOPT_LOAD_LINES);
SymInitialize(hProcess, NULL, TRUE);
- buffer.append(TEXT("\r\nStack Trace:\r\n---------------------------------------------------------------\r\n"));
-
- for (int i=81; --i;)
- {
- /*
- char symbuf[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR) + 4] = {0};
- PSYMBOL_INFO pSym = (PSYMBOL_INFO)symbuf;
- pSym->SizeOfStruct = sizeof(SYMBOL_INFO);
- pSym->MaxNameLen = MAX_SYM_NAME;
- */
+ buffer.Append(TEXT("\r\nStack Trace:\r\n---------------------------------------------------------------\r\n"));
+ for (int i=81; --i;) {
char symbuf[sizeof(IMAGEHLP_SYMBOL64) + MAX_SYM_NAME * sizeof(TCHAR) + 4] = {0};
PIMAGEHLP_SYMBOL64 pSym = (PIMAGEHLP_SYMBOL64)symbuf;
pSym->SizeOfStruct = sizeof(IMAGEHLP_SYMBOL64);
@@ -659,19 +615,15 @@ void CreateCrashReport(HANDLE hDumpFile, PEXCEPTION_POINTERS exc_ptr, const TCHA if (frame.AddrPC.Offset == frame.AddrReturn.Offset) break;
- if (frame.AddrPC.Offset != 0)
- {
- if (SymGetSymFromAddr64(hProcess, frame.AddrPC.Offset, &offsetFromSmybol, pSym))
- // if (SymFromAddr(hProcess, frame.AddrPC.Offset, &offsetFromSmybol, pSym))
- {
+ if (frame.AddrPC.Offset != 0) {
+ if (SymGetSymFromAddr64(hProcess, frame.AddrPC.Offset, &offsetFromSmybol, pSym)) {
UnDecorateSymbolName(pSym->Name, undName, MAX_SYM_NAME, UNDNAME_NAME_ONLY);
UnDecorateSymbolName(pSym->Name, undFullName, MAX_SYM_NAME, UNDNAME_COMPLETE);
}
SymGetLineFromAddr64(hProcess, frame.AddrPC.Offset, &offsetFromLine, &Line);
SymGetModuleInfo64(hProcess, frame.AddrPC.Offset, &Module);
- if (Module.ModuleName[0] == 0)
- {
+ if (Module.ModuleName[0] == 0) {
FindData data;
data.Offset = frame.AddrPC.Offset;
data.pModule = &Module;
@@ -692,20 +644,16 @@ void CreateCrashReport(HANDLE hDumpFile, PEXCEPTION_POINTERS exc_ptr, const TCHA const char *lineFileName = Line.FileName ? Line.FileName : "(filename not available)";
const char *moduleName = Module.ModuleName[0] ? Module.ModuleName : "(module-name not available)";
- if (crashpos != 0)
- {
+ if (crashpos != 0) {
HMODULE hModule = (HMODULE)Module.BaseOfImage;
PLUGININFOEX *pi = GetMirInfo(hModule);
- if (pi != NULL)
- {
-
+ if (pi != NULL) {
static const TCHAR formatc[] = TEXT("\r\nLikely cause of the crash plugin: %S\r\n\r\n");
- if (pi->shortName)
- {
- bkstring crashcause;
- crashcause.appendfmt(formatc, pi->shortName);
- buffer.insert(crashpos, crashcause);
+ if (pi->shortName) {
+ CMString crashcause;
+ crashcause.AppendFormat(formatc, pi->shortName);
+ buffer.Insert(crashpos, crashcause);
}
crashpos = 0;
}
@@ -714,12 +662,12 @@ void CreateCrashReport(HANDLE hDumpFile, PEXCEPTION_POINTERS exc_ptr, const TCHA static const TCHAR formatd[] = TEXT("%p (%S %p): %S (%d): %S\r\n");
- buffer.appendfmt(formatd,
+ buffer.AppendFormat(formatd,
(LPVOID)frame.AddrPC.Offset, moduleName, (LPVOID)Module.BaseOfImage,
lineFileName, Line.LineNumber, name);
}
SymCleanup(hProcess);
- buffer.append(TEXT("\r\n"));
+ buffer.Append(TEXT("\r\n"));
PrintVersionInfo(buffer, VI_FLAG_PRNDLL);
diff --git a/plugins/CrashDumper/src/exhndlr.cpp b/plugins/CrashDumper/src/exhndlr.cpp index cf7ceb308d..253ffec924 100644 --- a/plugins/CrashDumper/src/exhndlr.cpp +++ b/plugins/CrashDumper/src/exhndlr.cpp @@ -54,20 +54,17 @@ void myfilterWorker(PEXCEPTION_POINTERS exc_ptr, bool notify) GetLocalTime(&st);
CreateDirectoryTree(CrashLogFolder);
- __try
- {
- if (dtsubfldr)
- {
+ __try {
+ if (dtsubfldr) {
mir_sntprintf(path, MAX_PATH, TEXT("%s\\%02d.%02d.%02d"), CrashLogFolder, st.wYear, st.wMonth, st.wDay);
CreateDirectory(path, NULL);
mir_sntprintf(path, MAX_PATH, TEXT("%s\\%02d.%02d.%02d\\crash%02d%02d%02d%02d%02d%02d.mdmp"), CrashLogFolder,
st.wYear, st.wMonth, st.wDay, st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);
}
else
- {
mir_sntprintf(path, MAX_PATH, TEXT("%s\\crash%02d%02d%02d%02d%02d%02d.mdmp"), CrashLogFolder,
st.wYear, st.wMonth, st.wDay, st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);
- }
+
hDumpFile = CreateFile(path, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
if (hDumpFile != INVALID_HANDLE_VALUE)
CreateMiniDump(hDumpFile, exc_ptr);
@@ -82,20 +79,17 @@ void myfilterWorker(PEXCEPTION_POINTERS exc_ptr, bool notify) CloseHandle(hDumpFile);
if (empty) DeleteFile(path);
- __try
- {
- if (dtsubfldr)
- {
+ __try {
+ if (dtsubfldr) {
mir_sntprintf(path, MAX_PATH, TEXT("%s\\%02d.%02d.%02d"), CrashLogFolder, st.wYear, st.wMonth, st.wDay);
CreateDirectory(path, NULL);
mir_sntprintf(path, MAX_PATH, TEXT("%s\\%02d.%02d.%02d\\crash%02d%02d%02d%02d%02d%02d.txt"), CrashLogFolder,
st.wYear, st.wMonth, st.wDay, st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);
}
else
- {
mir_sntprintf(path, MAX_PATH, TEXT("%s\\crash%02d%02d%02d%02d%02d%02d.txt"), CrashLogFolder,
st.wYear, st.wMonth, st.wDay, st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);
- }
+
hDumpFile = CreateFile(path, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
mir_sntprintf(path, MAX_PATH, TranslateT("Miranda crashed. Crash report stored in the folder:\n %s\n\n Would you like store it in the clipboard as well?"), CrashLogFolder);
@@ -122,8 +116,7 @@ LONG WINAPI myfilter(PEXCEPTION_POINTERS exc_ptr) LONG WINAPI myfilterv(PEXCEPTION_POINTERS exc_ptr)
{
- if (0xC0000000L <= exc_ptr->ExceptionRecord->ExceptionCode && 0xC0000500L >= exc_ptr->ExceptionRecord->ExceptionCode)
- {
+ if (0xC0000000L <= exc_ptr->ExceptionRecord->ExceptionCode && 0xC0000500L >= exc_ptr->ExceptionRecord->ExceptionCode) {
if (exc_ptr == lastptr) return EXCEPTION_EXECUTE_HANDLER;
lastptr = exc_ptr;
@@ -134,8 +127,7 @@ LONG WINAPI myfilterv(PEXCEPTION_POINTERS exc_ptr) DWORD MirandaThreadFilter(DWORD code, EXCEPTION_POINTERS* info)
{
- if (info != lastptr)
- {
+ if (info != lastptr) {
lastptr = info;
myfilterWorker(info, true);
}
diff --git a/plugins/CrashDumper/src/ui.cpp b/plugins/CrashDumper/src/ui.cpp index d2eb282b3f..d8a616c370 100644 --- a/plugins/CrashDumper/src/ui.cpp +++ b/plugins/CrashDumper/src/ui.cpp @@ -60,11 +60,9 @@ BOOL MyResizeGetOffset(HWND hwndCtrl, int nWidth, int nHeight, int* nDx, int* nD INT_PTR CALLBACK DlgProcView(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
- {
+ switch (msg) {
case WM_INITDIALOG:
- if (hViewWnd == NULL)
- {
+ if (hViewWnd == NULL) {
hViewWnd = hwndDlg;
TranslateDialogDefault(hwndDlg);
SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadIconEx(IDI_VI, true));
@@ -76,22 +74,18 @@ INT_PTR CALLBACK DlgProcView(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara _tcscpy(chf.szFaceName, TEXT("Courier New"));
SendDlgItemMessage(hwndDlg, IDC_VIEWVERSIONINFO, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&chf);
- bkstring buffer;
- buffer.reserve(0x1800);
+ CMString buffer;
PrintVersionInfo(buffer, (unsigned int)lParam);
SetDlgItemText(hwndDlg, IDC_VIEWVERSIONINFO, buffer.c_str());
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
if(lParam & VI_FLAG_PRNDLL)
- {
SetWindowText(hwndDlg,TranslateT("View Version Information (with DLLs)"));
- }
Utils_RestoreWindowPositionNoMove(hwndDlg, NULL, PluginName, "ViewInfo_");
ShowWindow(hwndDlg, SW_SHOW);
}
- else
- DestroyWindow(hwndDlg);
+ else DestroyWindow(hwndDlg);
break;
case WM_SIZE:
@@ -103,9 +97,7 @@ INT_PTR CALLBACK DlgProcView(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara GetWindowRect(GetDlgItem(hwndDlg, IDC_FILEVER), &rc);
bsz = rc.bottom - rc.top;
- if (MyResizeGetOffset(GetDlgItem(hwndDlg, IDC_VIEWVERSIONINFO),
- LOWORD(lParam)-20, HIWORD(lParam)-30-bsz, &dx, &dy))
- {
+ if (MyResizeGetOffset(GetDlgItem(hwndDlg, IDC_VIEWVERSIONINFO), LOWORD(lParam)-20, HIWORD(lParam)-30-bsz, &dx, &dy)) {
hDwp = BeginDeferWindowPos(4);
hDwp = MyResizeWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDC_FILEVER), 0, dy, 0, 0);
hDwp = MyResizeWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDC_CLIPVER), dx/2, dy, 0, 0);
@@ -119,17 +111,13 @@ INT_PTR CALLBACK DlgProcView(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara case WM_GETMINMAXINFO:
{
LPMINMAXINFO mmi = (LPMINMAXINFO)lParam;
-
- // The minimum width in points
- mmi->ptMinTrackSize.x = 350;
- // The minimum height in points
- mmi->ptMinTrackSize.y = 300;
+ mmi->ptMinTrackSize.x = 350; // The minimum width in points
+ mmi->ptMinTrackSize.y = 300; // The minimum height in points
}
break;
case WM_COMMAND:
- switch(LOWORD(wParam))
- {
+ switch(LOWORD(wParam)) {
case IDC_CLIPVER:
CallService(MS_CRASHDUMPER_STORETOCLIP, 0, GetWindowLongPtr(hwndDlg, GWLP_USERDATA));
break;
@@ -166,8 +154,7 @@ INT_PTR CALLBACK DlgProcView(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara if (sel.cpMin == sel.cpMax)
EnableMenuItem(hSubMenu, IDM_COPY, MF_BYCOMMAND | MF_GRAYED);
- switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL))
- {
+ switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL)) {
case IDM_COPY:
SendMessage(hView, WM_COPY, 0, 0);
break;
@@ -208,20 +195,16 @@ void DestroyAllWindows(void) INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
- {
+ switch (msg) {
case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
{
- TranslateDialogDefault(hwndDlg);
-
DBVARIANT dbv;
- if (db_get_s(NULL, PluginName, "Username", &dbv) == 0)
- {
+ if (db_get_s(NULL, PluginName, "Username", &dbv) == 0) {
SetDlgItemTextA(hwndDlg, IDC_USERNAME, dbv.pszVal);
db_free(&dbv);
}
- if (db_get_s(NULL, PluginName, "Password", &dbv) == 0)
- {
+ if (db_get_s(NULL, PluginName, "Password", &dbv) == 0) {
CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal)+1, (LPARAM)dbv.pszVal);
SetDlgItemTextA(hwndDlg, IDC_PASSWORD, dbv.pszVal);
db_free(&dbv);
@@ -238,8 +221,7 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP break;
case WM_NOTIFY:
- if (((LPNMHDR)lParam)->code == (unsigned)PSN_APPLY)
- {
+ if (((LPNMHDR)lParam)->code == (unsigned)PSN_APPLY) {
char szSetting[100];
GetDlgItemTextA(hwndDlg, IDC_USERNAME, szSetting, SIZEOF(szSetting));
db_set_s(NULL, PluginName, "Username", szSetting);
@@ -314,8 +296,7 @@ void ShowMessage(int type, const TCHAR* format, ...) pi.lptzText[len] = 0;
va_end(va);
- if (ServiceExists(MS_POPUP_ADDPOPUPT))
- {
+ if (ServiceExists(MS_POPUP_ADDPOPUPT)) {
_tcscpy(pi.lptzContactName, TEXT(PluginName));
pi.lchIcon = LoadIconEx(IDI_VI);
pi.PluginWindowProc = DlgProcPopup;
@@ -323,6 +304,5 @@ void ShowMessage(int type, const TCHAR* format, ...) PUAddPopupT(&pi);
}
- else
- MessageBox(NULL, pi.lptzText, TEXT(PluginName), MB_OK | MB_ICONINFORMATION);
+ else MessageBox(NULL, pi.lptzText, TEXT(PluginName), MB_OK | MB_ICONINFORMATION);
}
diff --git a/plugins/CrashDumper/src/upload.cpp b/plugins/CrashDumper/src/upload.cpp index 437a5f55a0..da280a1959 100644 --- a/plugins/CrashDumper/src/upload.cpp +++ b/plugins/CrashDumper/src/upload.cpp @@ -23,8 +23,7 @@ HANDLE hNetlibUser; static void arrayToHex(BYTE* data, size_t datasz, char* res)
{
char* resptr = res;
- for (unsigned i=0; i<datasz ; i++)
- {
+ for (unsigned i=0; i<datasz ; i++) {
const BYTE ch = data[i];
const char ch0 = (char)(ch >> 4);
@@ -40,16 +39,13 @@ void GetLoginStr(char* user, size_t szuser, char* pass) {
DBVARIANT dbv;
- if (db_get_s(NULL, PluginName, "Username", &dbv) == 0)
- {
+ if (db_get_s(NULL, PluginName, "Username", &dbv) == 0) {
mir_snprintf(user, szuser, "%s", dbv.pszVal);
db_free(&dbv);
}
- else
- user[0] = 0;
+ else user[0] = 0;
- if (db_get_s(NULL, PluginName, "Password", &dbv) == 0)
- {
+ if (db_get_s(NULL, PluginName, "Password", &dbv) == 0) {
CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal)+1, (LPARAM)dbv.pszVal);
BYTE hash[16];
@@ -63,8 +59,7 @@ void GetLoginStr(char* user, size_t szuser, char* pass) db_free(&dbv);
}
- else
- pass[0] = 0;
+ else pass[0] = 0;
}
void OpenAuthUrl(const char* url)
@@ -125,31 +120,23 @@ bool InternetDownloadFile(const char *szUrl, VerTrnsfr* szReq) nlhr.pData = szReq->buf;
nlhr.dataLength = (int)strlen(szReq->buf);
- while (result == 0xBADBAD)
- {
+ while (result == 0xBADBAD) {
// download the page
- NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION,
- (WPARAM)hNetlibUser,(LPARAM)&nlhr);
-
- if (nlhrReply)
- {
+ NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUser,(LPARAM)&nlhr);
+ if (nlhrReply) {
int i;
// if the recieved code is 200 OK
- switch(nlhrReply->resultCode)
- {
+ switch(nlhrReply->resultCode) {
case 200:
if (db_get_b(NULL, PluginName, "UploadChanged", 0))
ProcessVIHash(true);
for (i=nlhrReply->headersCount; i--; )
- {
- if (_stricmp(nlhrReply->headers[i].szName, "OldPlugins") == 0)
- {
+ if (_stricmp(nlhrReply->headers[i].szName, "OldPlugins") == 0) {
i = atoi(nlhrReply->headers[i].szValue);
break;
}
- }
ShowMessage(1, TranslateT("VersionInfo upload successful,\n %d old plugins"), i);
result = 0;
@@ -175,13 +162,10 @@ bool InternetDownloadFile(const char *szUrl, VerTrnsfr* szReq) case 307:
// get the url for the new location and save it to szInfo
// look for the reply header "Location"
- for (i=0; i<nlhrReply->headersCount; i++)
- {
- if (!strcmp(nlhrReply->headers[i].szName, "Location"))
- {
+ for (i=0; i<nlhrReply->headersCount; i++) {
+ if (!strcmp(nlhrReply->headers[i].szName, "Location")) {
size_t rlen = 0;
- if (nlhrReply->headers[i].szValue[0] == '/')
- {
+ if (nlhrReply->headers[i].szValue[0] == '/') {
const char* szPath;
const char* szPref = strstr(szUrl, "://");
szPref = szPref ? szPref + 3 : szUrl;
@@ -206,8 +190,7 @@ bool InternetDownloadFile(const char *szUrl, VerTrnsfr* szReq) ShowMessage(0, TranslateT("Cannot upload VersionInfo. Unknown error"));
}
}
- else
- {
+ else {
result = 1;
ShowMessage(0, TranslateT("Cannot upload VersionInfo. Host unreachable."));
}
@@ -229,11 +212,9 @@ void __cdecl VersionInfoUploadThread(void* arg) mir_free(trn);
}
-
void UploadInit(void)
{
- NETLIBUSER nlu = {0};
- nlu.cbSize = sizeof(nlu);
+ NETLIBUSER nlu = { sizeof(nlu) };
nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_NOHTTPSOPTION | NUF_TCHAR;
nlu.szSettingsModule = (char*)PluginName;
nlu.ptszDescriptiveName = TranslateT("Crash Dumper HTTP connections");
@@ -247,36 +228,27 @@ void UploadClose(void) bool ProcessVIHash(bool store)
{
- bkstring buffer;
- buffer.reserve(0x1800);
+ CMString buffer;
PrintVersionInfo(buffer, 0);
BYTE hash[16];
mir_md5_state_t context;
mir_md5_init(&context);
- mir_md5_append(&context, (PBYTE)buffer.c_str(), (int)buffer.sizebytes());
+ mir_md5_append(&context, (PBYTE)buffer.c_str(), buffer.GetLength()*sizeof(TCHAR));
mir_md5_finish(&context, hash);
char hashstr[40];
arrayToHex(hash, sizeof(hash), hashstr);
- bool result;
- if (store)
- {
+ if (store) {
db_set_s(NULL, PluginName, "VIHash", hashstr);
- result = true;
+ return true;
}
- else
- {
- DBVARIANT dbv;
- if (db_get_s(NULL, PluginName, "VIHash", &dbv) == 0)
- {
- result = strcmp(hashstr, dbv.pszVal) == 0;
- db_free(&dbv);
- }
- else
- result = false;
- }
- return result;
+
+ ptrA VIHash(db_get_sa(NULL, PluginName, "VIHash"));
+ if (VIHash == NULL)
+ return false;
+
+ return strcmp(hashstr, VIHash) == 0;
}
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);
diff --git a/plugins/CrashDumper/src/utils.h b/plugins/CrashDumper/src/utils.h index d736b42d9b..5696458da3 100644 --- a/plugins/CrashDumper/src/utils.h +++ b/plugins/CrashDumper/src/utils.h @@ -35,13 +35,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include <m_options.h>
#include <m_popup.h>
#include <m_netlib.h>
+#include <m_string.h>
#include "m_folders.h"
#include "m_toptoolbar.h"
#include "sdkstuff.h"
#include "version.h"
-#include "bkstring.h"
#include "resource.h"
#define MS_PROTO_ENUMPROTOS "Proto/EnumProtos"
@@ -100,32 +100,32 @@ extern bool dtsubfldr; extern TCHAR CrashLogFolder[MAX_PATH];
extern TCHAR VersionInfoFolder[MAX_PATH];
-void WriteBBFile(bkstring& buffer, bool hdr);
+void WriteBBFile(CMString& buffer, bool hdr);
void WriteUtfFile(HANDLE hDumpFile, char* bufu);
LONG WINAPI myfilter(PEXCEPTION_POINTERS exc_ptr);
LONG WINAPI myfilterv(PEXCEPTION_POINTERS exc_ptr);
DWORD MirandaThreadFilter(DWORD code, EXCEPTION_POINTERS* info);
-void GetOSDisplayString(bkstring& buffer);
-void GetInternetExplorerVersion(bkstring& buffer);
-void GetProcessorString(bkstring& buffer);
-void GetFreeMemoryString(bkstring& buffer);
-void GetFreeDiskString(LPCTSTR dirname, bkstring& buffer);
-void GetAdminString(bkstring& buffer);
-void GetLanguageString(bkstring& buffer);
-void GetLanguagePackString(bkstring& buffer);
-void GetWow64String(bkstring& buffer);
-void GetVersionInfo(HMODULE hLib, bkstring& buffer);
+void GetOSDisplayString(CMString& buffer);
+void GetInternetExplorerVersion(CMString& buffer);
+void GetProcessorString(CMString& buffer);
+void GetFreeMemoryString(CMString& buffer);
+void GetFreeDiskString(LPCTSTR dirname, CMString& buffer);
+void GetAdminString(CMString& buffer);
+void GetLanguageString(CMString& buffer);
+void GetLanguagePackString(CMString& buffer);
+void GetWow64String(CMString& buffer);
+void GetVersionInfo(HMODULE hLib, CMString& buffer);
void GetISO8061Time(SYSTEMTIME* stLocal, LPTSTR lpszString, DWORD dwSize);
-void ReadableExceptionInfo(PEXCEPTION_RECORD excrec, bkstring& buffer);
+void ReadableExceptionInfo(PEXCEPTION_RECORD excrec, CMString& buffer);
void GetLastWriteTime(LPCTSTR fileName, LPTSTR lpszString, DWORD dwSize);
void GetLastWriteTime(FILETIME* ftime, LPTSTR lpszString, DWORD dwSize);
bool CreateDirectoryTree(LPTSTR szDir);
-void StoreStringToClip(bkstring& buffer);
+void StoreStringToClip(CMString& buffer);
void ShowMessage(int type, const TCHAR* format, ...);
bool IsPluginEnabled(TCHAR* filename);
@@ -134,7 +134,7 @@ const PLUGININFOEX* GetPluginInfoEx(void); void CreateMiniDump (HANDLE hDumpFile, PEXCEPTION_POINTERS exc_ptr);
void CreateCrashReport(HANDLE hDumpFile, PEXCEPTION_POINTERS exc_ptr, const TCHAR* msg);
-void PrintVersionInfo(bkstring& buffer, unsigned flags = VI_FLAG_PRNVAR);
+void PrintVersionInfo(CMString& buffer, unsigned flags = VI_FLAG_PRNVAR);
bool ProcessVIHash(bool store);
void InitExceptionHandler(void);
|