diff options
author | George Hazan <ghazan@miranda.im> | 2018-03-12 18:36:38 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-03-12 18:36:38 +0300 |
commit | a70058727e91037ca532a52decbcc8c3aea2d03e (patch) | |
tree | 01a995fe17b4e80e7445948f086d72e2555d1998 /plugins/CrashDumper | |
parent | 83f3e1dee4b5b3a27a2ca5c177b4ecfd1b02411f (diff) |
CrashDumper:
- fixes #1186 (Hide DbChecker from VersionInfo);
- massive code cleaning;
- version bump
Diffstat (limited to 'plugins/CrashDumper')
-rw-r--r-- | plugins/CrashDumper/src/crshdmp.cpp | 11 | ||||
-rw-r--r-- | plugins/CrashDumper/src/dumper.cpp | 302 | ||||
-rw-r--r-- | plugins/CrashDumper/src/exhndlr.cpp | 43 | ||||
-rw-r--r-- | plugins/CrashDumper/src/ui.cpp | 12 | ||||
-rw-r--r-- | plugins/CrashDumper/src/upload.cpp | 2 | ||||
-rw-r--r-- | plugins/CrashDumper/src/utils.cpp | 148 | ||||
-rw-r--r-- | plugins/CrashDumper/src/version.h | 6 |
7 files changed, 239 insertions, 285 deletions
diff --git a/plugins/CrashDumper/src/crshdmp.cpp b/plugins/CrashDumper/src/crshdmp.cpp index d775326ea1..64d10f56f6 100644 --- a/plugins/CrashDumper/src/crshdmp.cpp +++ b/plugins/CrashDumper/src/crshdmp.cpp @@ -67,7 +67,7 @@ INT_PTR StoreVersionInfoToFile(WPARAM, LPARAM lParam) CreateDirectoryTreeW(VersionInfoFolder);
wchar_t path[MAX_PATH];
- mir_snwprintf(path, TEXT("%s\\VersionInfo.txt"), VersionInfoFolder);
+ mir_snwprintf(path, L"%s\\VersionInfo.txt", VersionInfoFolder);
HANDLE hDumpFile = CreateFile(path, GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
if (hDumpFile != INVALID_HANDLE_VALUE) {
@@ -143,7 +143,7 @@ INT_PTR OpenUrl(WPARAM wParam, LPARAM) {
switch (wParam) {
case 0:
- ShellExecute(nullptr, TEXT("explore"), CrashLogFolder, nullptr, nullptr, SW_SHOW);
+ ShellExecute(nullptr, L"explore", CrashLogFolder, nullptr, nullptr, SW_SHOW);
break;
case 1:
@@ -184,7 +184,7 @@ INT_PTR ServiceModeLaunch(WPARAM, LPARAM) static int FoldersPathChanged(WPARAM, LPARAM)
{
- FOLDERSGETDATA fgd = { 0 };
+ FOLDERSGETDATA fgd = {};
fgd.cbSize = sizeof(FOLDERSGETDATA);
fgd.nMaxPathSize = MAX_PATH;
fgd.flags = FF_TCHAR;
@@ -198,7 +198,7 @@ static int FoldersPathChanged(WPARAM, LPARAM) int OptionsInit(WPARAM wParam, LPARAM)
{
- OPTIONSDIALOGPAGE odp = { 0 };
+ OPTIONSDIALOGPAGE odp = {};
odp.position = -790000000;
odp.hInstance = hInst;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS);
@@ -366,10 +366,9 @@ extern "C" int __declspec(dllexport) Load(void) profname = Utils_ReplaceVarsW(L"%miranda_profilename%.dat");
profpath = Utils_ReplaceVarsW(L"%miranda_userdata%");
if (catchcrashes && !needrestart)
- mir_snwprintf(CrashLogFolder, TEXT("%s\\CrashLog"), profpath);
+ mir_snwprintf(CrashLogFolder, L"%s\\CrashLog", profpath);
wcsncpy_s(VersionInfoFolder, profpath, _TRUNCATE);
-
HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
HookEvent(ME_OPT_INITIALISE, OptionsInit);
HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdown);
diff --git a/plugins/CrashDumper/src/dumper.cpp b/plugins/CrashDumper/src/dumper.cpp index a96fba0025..1c81ee98b8 100644 --- a/plugins/CrashDumper/src/dumper.cpp +++ b/plugins/CrashDumper/src/dumper.cpp @@ -29,48 +29,41 @@ void CreateMiniDump(HANDLE hDumpFile, PEXCEPTION_POINTERS exc_ptr) exceptionInfo.ExceptionPointers = exc_ptr;
exceptionInfo.ClientPointers = false;
- MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(),
- hDumpFile, MiniDumpNormal, &exceptionInfo, nullptr, nullptr);
+ MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hDumpFile, MiniDumpNormal, &exceptionInfo, nullptr, nullptr);
}
-
-void WriteBBFile(CMStringW& buffer, bool hdr)
+void WriteBBFile(CMStringW &buffer, bool hdr)
{
- static const wchar_t header[] = TEXT("[spoiler=VersionInfo][quote]");
- static const wchar_t footer[] = TEXT("[/quote][/spoiler]");
+ static const wchar_t header[] = L"[spoiler=VersionInfo][quote]";
+ static const wchar_t footer[] = L"[/quote][/spoiler]";
buffer.Append(hdr ? header : footer);
}
-
-void WriteUtfFile(HANDLE hDumpFile, char* bufu)
+void WriteUtfFile(HANDLE hDumpFile, char *bufu)
{
DWORD bytes;
-
static const unsigned char bytemark[] = { 0xEF, 0xBB, 0xBF };
WriteFile(hDumpFile, bytemark, 3, &bytes, nullptr);
WriteFile(hDumpFile, bufu, (DWORD)mir_strlen(bufu), &bytes, nullptr);
}
-
BOOL CALLBACK LoadedModules64(LPCSTR, DWORD64 ModuleBase, ULONG ModuleSize, PVOID UserContext)
{
- CMStringW& buffer = *(CMStringW*)UserContext;
-
const HMODULE hModule = (HMODULE)ModuleBase;
wchar_t path[MAX_PATH];
GetModuleFileName(hModule, path, MAX_PATH);
- buffer.AppendFormat(TEXT("%s %p - %p"), path, (void*)ModuleBase, (void*)(ModuleBase + ModuleSize));
+ CMStringW &buffer = *(CMStringW*)UserContext;
+ buffer.AppendFormat(L"%s %p - %p", path, (void*)ModuleBase, (void*)(ModuleBase + ModuleSize));
GetVersionInfo(hModule, buffer);
- wchar_t timebuf[30] = TEXT("");
+ wchar_t timebuf[30] = L"";
GetLastWriteTime(path, timebuf, 30);
- buffer.AppendFormat(TEXT(" [%s]\r\n"), timebuf);
-
+ buffer.AppendFormat(L" [%s]\r\n", timebuf);
return TRUE;
}
@@ -82,7 +75,7 @@ struct FindData BOOL CALLBACK LoadedModulesFind64(LPCSTR ModuleName, DWORD64 ModuleBase, ULONG ModuleSize, PVOID UserContext)
{
- FindData* data = (FindData*)UserContext;
+ FindData *data = (FindData*)UserContext;
if ((DWORD)(data->Offset - ModuleBase) < ModuleSize) {
const size_t len = _countof(data->pModule->ModuleName);
@@ -99,7 +92,6 @@ BOOL CALLBACK LoadedModulesFind64(LPCSTR ModuleName, DWORD64 ModuleBase, ULONG M return TRUE;
}
-
void GetLinkedModulesInfo(wchar_t *moduleName, CMStringW &buffer)
{
HANDLE hDllFile = CreateFile(moduleName, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
@@ -114,19 +106,21 @@ void GetLinkedModulesInfo(wchar_t *moduleName, CMStringW &buffer) LPVOID dllAddr = MapViewOfFile(hDllMapping, FILE_MAP_READ, 0, 0, 0);
- static const wchar_t format[] = TEXT(" Plugin statically linked to missing module: %S\r\n");
-
__try {
PIMAGE_NT_HEADERS nthdrs = ImageNtHeader(dllAddr);
ULONG tableSize;
- PIMAGE_IMPORT_DESCRIPTOR importData = (PIMAGE_IMPORT_DESCRIPTOR)ImageDirectoryEntryToData(dllAddr, FALSE,
- IMAGE_DIRECTORY_ENTRY_IMPORT, &tableSize);
+ PIMAGE_IMPORT_DESCRIPTOR importData = (PIMAGE_IMPORT_DESCRIPTOR)ImageDirectoryEntryToData(dllAddr, FALSE, IMAGE_DIRECTORY_ENTRY_IMPORT, &tableSize);
if (importData) {
+ CMStringW wszEnvPath;
+ DWORD dwLen = GetEnvironmentVariableW(L"Path", nullptr, 0);
+ wszEnvPath.Preallocate(dwLen + 1);
+ GetEnvironmentVariableW(L"Path", wszEnvPath.GetBuffer(), dwLen);
+
while (importData->Name) {
char *szImportModule = (char*)ImageRvaToVa(nthdrs, dllAddr, importData->Name, nullptr);
- if (!SearchPathA(nullptr, szImportModule, nullptr, NULL, nullptr, nullptr))
- buffer.AppendFormat(format, szImportModule);
+ if (!SearchPathW(wszEnvPath, _A2T(szImportModule), nullptr, NULL, nullptr, nullptr))
+ buffer.AppendFormat(L" Plugin statically linked to missing module: %S\r\n", szImportModule);
importData++; //go to next record
}
@@ -136,22 +130,22 @@ void GetLinkedModulesInfo(wchar_t *moduleName, CMStringW &buffer) PIMAGE_EXPORT_DIRECTORY exportData = (PIMAGE_EXPORT_DIRECTORY)ImageDirectoryEntryToData(dllAddr, FALSE,
IMAGE_DIRECTORY_ENTRY_EXPORT, &tableSize);
if (exportData) {
- ULONG* funcAddr = (ULONG*)ImageRvaToVa(nthdrs, dllAddr, exportData->AddressOfNames, nullptr);
+ ULONG *funcAddr = (ULONG*)ImageRvaToVa(nthdrs, dllAddr, exportData->AddressOfNames, nullptr);
for (unsigned i = 0; i < exportData->NumberOfNames; ++i) {
- char* funcName = (char*)ImageRvaToVa(nthdrs, dllAddr, funcAddr[i], nullptr);
+ char *funcName = (char*)ImageRvaToVa(nthdrs, dllAddr, funcAddr[i], nullptr);
if (mir_strcmp(funcName, "DatabasePluginInfo") == 0) {
- buffer.Append(TEXT(" This dll is a Miranda database plugin, another database is active right now\r\n"));
+ buffer.Append(L" This dll is a Miranda database plugin, another database is active right now\r\n");
found = true;
break;
}
- else if(mir_strcmp(funcName, "MirandaPluginInfoEx") == 0) {
+ else if (mir_strcmp(funcName, "MirandaPluginInfoEx") == 0) {
found = true;
break;
}
}
}
if (!found)
- buffer.Append(TEXT(" This dll is not a Miranda plugin and should be removed from plugins directory\r\n"));
+ buffer.Append(L" This dll is not a Miranda plugin and should be removed from plugins directory\r\n");
}
__except (EXCEPTION_EXECUTE_HANDLER) {}
@@ -160,25 +154,22 @@ void GetLinkedModulesInfo(wchar_t *moduleName, CMStringW &buffer) CloseHandle(hDllFile);
}
-
-struct ListItem
+static int CompareDlls(const wchar_t *p1, const wchar_t *p2)
{
- ListItem() : str(), next(nullptr) {}
-
- CMStringW str;
- ListItem *next;
-};
+ return mir_wstrcmpi(p1, p2);
+}
-static void GetPluginsString(CMStringW& buffer, unsigned& flags)
+static void GetPluginsString(CMStringW &buffer, unsigned &flags)
{
- buffer.AppendFormat(TEXT("Service Mode: %s\r\n"), servicemode ? TEXT("Yes") : TEXT("No"));
+ buffer.AppendFormat(L"Service Mode: %s\r\n", servicemode ? L"Yes" : L"No");
wchar_t path[MAX_PATH];
GetModuleFileName(nullptr, path, MAX_PATH);
- LPTSTR fname = wcsrchr(path, TEXT('\\'));
- if (fname == nullptr) fname = path;
- mir_snwprintf(fname, MAX_PATH - (fname - path), TEXT("\\plugins\\*.dll"));
+ LPTSTR fname = wcsrchr(path, '\\');
+ if (fname == nullptr)
+ fname = path;
+ mir_snwprintf(fname, MAX_PATH - (fname - path), L"\\plugins\\*.dll");
WIN32_FIND_DATA FindFileData;
HANDLE hFind = FindFirstFile(path, &FindFileData);
@@ -186,29 +177,28 @@ static void GetPluginsString(CMStringW& buffer, unsigned& flags) size_t count = 0, ucount = 0;
- CMStringW ubuffer;
- ListItem* dlllist = nullptr;
-
- static const wchar_t format[] = TEXT("\xa4 %s v.%s%d.%d.%d.%d%s [%s] - %S %s\r\n");
+ CMStringW ubuffer, tmp;
+ LIST<wchar_t> arDlls(10, CompareDlls);
do {
bool loaded = false;
- mir_snwprintf(fname, MAX_PATH - (fname - path), TEXT("\\plugins\\%s"), FindFileData.cFileName);
+ mir_snwprintf(fname, MAX_PATH - (fname - path), L"\\plugins\\%s", FindFileData.cFileName);
HMODULE hModule = GetModuleHandle(path);
if (hModule == nullptr && servicemode) {
hModule = LoadLibrary(path);
loaded = true;
}
- if (hModule == nullptr) {
+
+ if (hModule == nullptr && wcsicmp(FindFileData.cFileName, L"dbchecker.dll")) {
if ((flags & VI_FLAG_PRNVAR) && IsPluginEnabled(FindFileData.cFileName)) {
- wchar_t timebuf[30] = TEXT("");
+ wchar_t timebuf[30] = L"";
GetLastWriteTime(&FindFileData.ftLastWriteTime, timebuf, 30);
- ubuffer.AppendFormat(format, FindFileData.cFileName,
- (flags & VI_FLAG_FORMAT) ? TEXT("[b]") : TEXT(""),
+ ubuffer.AppendFormat(L"\xa4 %s v.%s%d.%d.%d.%d%s [%s] - %S %s\r\n", FindFileData.cFileName,
+ (flags & VI_FLAG_FORMAT) ? L"[b]" : L"",
0, 0, 0, 0,
- (flags & VI_FLAG_FORMAT) ? TEXT("[/b]") : TEXT(""),
- timebuf, "<unknown>", TEXT(""));
+ (flags & VI_FLAG_FORMAT) ? L"[/b]" : L"",
+ timebuf, "<unknown>", L"");
GetLinkedModulesInfo(path, ubuffer);
ubuffer.Append(L"\r\n");
@@ -218,25 +208,22 @@ static void GetPluginsString(CMStringW& buffer, unsigned& flags) continue;
}
- PLUGININFOEX* pi = GetMirInfo(hModule);
+ PLUGININFOEX *pi = GetMirInfo(hModule);
if (pi != nullptr) {
- wchar_t timebuf[30] = TEXT("");
+ wchar_t timebuf[30] = L"";
GetLastWriteTime(&FindFileData.ftLastWriteTime, timebuf, 30);
- const wchar_t *unica = !(((PLUGININFOEX*)pi)->flags & UNICODE_AWARE) ? TEXT("|ANSI|") : TEXT("");
+ const wchar_t *unica = !(((PLUGININFOEX*)pi)->flags & UNICODE_AWARE) ? L"|ANSI|" : L"";
- ListItem* lst = new ListItem;
int v1, v2, v3, v4;
-
DWORD unused, verInfoSize = GetFileVersionInfoSize(path, &unused);
if (verInfoSize != 0) {
UINT blockSize;
- VS_FIXEDFILEINFO* fi;
- void* pVerInfo = mir_alloc(verInfoSize);
+ VS_FIXEDFILEINFO *fi;
+ void *pVerInfo = mir_alloc(verInfoSize);
GetFileVersionInfo(path, 0, verInfoSize, pVerInfo);
VerQueryValue(pVerInfo, L"\\", (LPVOID*)&fi, &blockSize);
- v1 = HIWORD(fi->dwProductVersionMS), v2 = LOWORD(fi->dwProductVersionMS),
- v3 = HIWORD(fi->dwProductVersionLS), v4 = LOWORD(fi->dwProductVersionLS);
+ v1 = HIWORD(fi->dwProductVersionMS), v2 = LOWORD(fi->dwProductVersionMS), v3 = HIWORD(fi->dwProductVersionLS), v4 = LOWORD(fi->dwProductVersionLS);
mir_free(pVerInfo);
}
else {
@@ -244,67 +231,48 @@ static void GetPluginsString(CMStringW& buffer, unsigned& flags) v1 = HIBYTE(HIWORD(ver)), v2 = LOBYTE(HIWORD(ver)), v3 = HIBYTE(LOWORD(ver)), v4 = LOBYTE(LOWORD(ver));
}
- lst->str.AppendFormat(format, FindFileData.cFileName,
- (flags & VI_FLAG_FORMAT) ? TEXT("[b]") : TEXT(""),
+ tmp.Format(L"\xa4 %s v.%s%d.%d.%d.%d%s [%s] - %S %s\r\n", FindFileData.cFileName,
+ (flags & VI_FLAG_FORMAT) ? L"[b]" : L"",
v1, v2, v3, v4,
- (flags & VI_FLAG_FORMAT) ? TEXT("[/b]") : TEXT(""),
+ (flags & VI_FLAG_FORMAT) ? L"[/b]" : L"",
timebuf, pi->shortName ? pi->shortName : "", unica);
+ arDlls.insert(tmp.Detach());
- ListItem* lsttmp = dlllist;
- ListItem* lsttmppv = nullptr;
- while (lsttmp != nullptr) {
- if (lsttmp->str.CompareNoCase(lst->str) > 0)
- break;
- lsttmppv = lsttmp;
- lsttmp = lsttmp->next;
- }
- lst->next = lsttmp;
- if (lsttmppv == nullptr)
- dlllist = lst;
- else
- lsttmppv->next = lst;
-
- if (mir_wstrcmpi(FindFileData.cFileName, TEXT("weather.dll")) == 0)
+ if (mir_wstrcmpi(FindFileData.cFileName, L"weather.dll") == 0)
flags |= VI_FLAG_WEATHER;
++count;
}
- if (loaded) FreeLibrary(hModule);
- } while (FindNextFile(hFind, &FindFileData));
+ if (loaded)
+ FreeLibrary(hModule);
+ }
+ while (FindNextFile(hFind, &FindFileData));
FindClose(hFind);
- 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(""));
+ buffer.AppendFormat(L"\r\n%sActive Plugins (%u):%s\r\n", (flags & VI_FLAG_FORMAT) ? L"[b]" : L"", count, (flags & VI_FLAG_FORMAT) ? L"[/b]" : L"");
- ListItem* lsttmp = dlllist;
- while (lsttmp != nullptr) {
- buffer.Append(lsttmp->str);
- ListItem* lsttmp1 = lsttmp->next;
- delete lsttmp;
- lsttmp = lsttmp1;
+ for (auto &str : arDlls) {
+ buffer.Append(str);
+ mir_free(str);
}
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.AppendFormat(L"\r\n%sUnloadable Plugins (%u):%s\r\n", (flags & VI_FLAG_FORMAT) ? L"[b]" : L"", ucount, (flags & VI_FLAG_FORMAT) ? L"[/b]" : L"");
buffer.Append(ubuffer);
}
}
-
struct ProtoCount
{
- char countse;
- char countsd;
+ int countse;
+ int countsd;
bool nloaded;
};
-static void GetProtocolStrings(CMStringW& buffer)
+static void GetProtocolStrings(CMStringW &buffer)
{
- PROTOACCOUNT **accList;
int accCount;
- int i, j;
-
+ PROTOACCOUNT **accList;
Proto_EnumAccounts(&accCount, &accList);
int protoCount;
@@ -312,15 +280,14 @@ static void GetProtocolStrings(CMStringW& buffer) Proto_EnumProtocols(&protoCount, &protoList);
int protoCountMy = 0;
- char** protoListMy = (char**)alloca((protoCount + accCount) * sizeof(char*));
+ char **protoListMy = (char**)alloca((protoCount + accCount) * sizeof(char*));
- for (i = 0; i < protoCount; i++) {
- if (protoList[i]->type != PROTOTYPE_PROTOCOL)
- continue;
- protoListMy[protoCountMy++] = protoList[i]->szName;
- }
+ for (int i = 0; i < protoCount; i++)
+ if (protoList[i]->type == PROTOTYPE_PROTOCOL)
+ protoListMy[protoCountMy++] = protoList[i]->szName;
- for (j = 0; j < accCount; j++) {
+ for (int j = 0; j < accCount; j++) {
+ int i;
for (i = 0; i < protoCountMy; i++)
if (!mir_strcmp(protoListMy[i], accList[j]->szProtoName))
break;
@@ -332,8 +299,8 @@ static void GetProtocolStrings(CMStringW& buffer) ProtoCount *protos = (ProtoCount*)alloca(sizeof(ProtoCount) * protoCountMy);
memset(protos, 0, sizeof(ProtoCount) * protoCountMy);
- for (j = 0; j < accCount; j++)
- for (i = 0; i < protoCountMy; i++)
+ for (int j = 0; j < accCount; j++)
+ for (int i = 0; i < protoCountMy; i++)
if (!mir_strcmp(protoListMy[i], accList[j]->szProtoName)) {
protos[i].nloaded = accList[j]->bDynDisabled != 0;
if (Proto_IsAccountEnabled(accList[j]))
@@ -343,21 +310,22 @@ static void GetProtocolStrings(CMStringW& buffer) break;
}
- for (i = 0; i < protoCountMy; i++)
- buffer.AppendFormat(TEXT("%-24s %d - Enabled %d - Disabled %sLoaded\r\n"),
- (wchar_t*)_A2T(protoListMy[i]), protos[i].countse,
- protos[i].countsd, protos[i].nloaded ? L"Not " : L"");
+ for (int i = 0; i < protoCountMy; i++) {
+ auto &p = protos[i];
+ buffer.AppendFormat(L"%-24s %d - Enabled %d - Disabled %sLoaded\r\n",
+ (wchar_t*)_A2T(protoListMy[i]), p.countse, p.countsd, p.nloaded ? L"Not " : L"");
+ }
}
-
-static void GetWeatherStrings(CMStringW& buffer, unsigned flags)
+static void GetWeatherStrings(CMStringW &buffer, unsigned flags)
{
wchar_t path[MAX_PATH];
GetModuleFileName(nullptr, path, MAX_PATH);
- LPTSTR fname = wcsrchr(path, TEXT('\\'));
- if (fname == nullptr) fname = path;
- mir_snwprintf(fname, MAX_PATH - (fname - path), TEXT("\\plugins\\weather\\*.ini"));
+ LPTSTR fname = wcsrchr(path, L'\\');
+ if (fname == nullptr)
+ fname = path;
+ mir_snwprintf(fname, MAX_PATH - (fname - path), L"\\plugins\\weather\\*.ini");
WIN32_FIND_DATA FindFileData;
HANDLE hFind = FindFirstFile(path, &FindFileData);
@@ -366,7 +334,7 @@ static void GetWeatherStrings(CMStringW& buffer, unsigned flags) do {
if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue;
- mir_snwprintf(fname, MAX_PATH - (fname - path), TEXT("\\plugins\\weather\\%s"), FindFileData.cFileName);
+ mir_snwprintf(fname, MAX_PATH - (fname - path), L"\\plugins\\weather\\%s", FindFileData.cFileName);
HANDLE hDumpFile = CreateFile(path, GENERIC_READ, FILE_SHARE_READ, nullptr,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
@@ -377,7 +345,7 @@ static void GetWeatherStrings(CMStringW& buffer, unsigned flags) ReadFile(hDumpFile, buf, 8190, &bytes, nullptr);
buf[bytes] = 0;
- char* ver = strstr(buf, "Version=");
+ char *ver = strstr(buf, "Version=");
if (ver != nullptr) {
char *endid = strchr(ver, '\r');
if (endid != nullptr) *endid = 0;
@@ -394,37 +362,35 @@ static void GetWeatherStrings(CMStringW& buffer, unsigned flags) if (endid != nullptr) *endid = 0;
else {
endid = strchr(id, '\n');
- if (endid != nullptr) *endid = 0;
+ if (endid != nullptr)
+ *endid = 0;
}
id += 5;
}
- wchar_t timebuf[30] = TEXT("");
+ wchar_t timebuf[30] = L"";
GetLastWriteTime(&FindFileData.ftLastWriteTime, timebuf, 30);
-
- static const wchar_t format[] = TEXT(" %s v.%s%S%s [%s] - %S\r\n");
-
- buffer.AppendFormat(format, FindFileData.cFileName,
- (flags & VI_FLAG_FORMAT) ? TEXT("[b]") : TEXT(""),
+ buffer.AppendFormat(L" %s v.%s%S%s [%s] - %S\r\n", FindFileData.cFileName,
+ (flags & VI_FLAG_FORMAT) ? L"[b]" : L"",
ver,
- (flags & VI_FLAG_FORMAT) ? TEXT("[/b]") : TEXT(""),
+ (flags & VI_FLAG_FORMAT) ? L"[/b]" : L"",
timebuf, id);
CloseHandle(hDumpFile);
}
- } while (FindNextFile(hFind, &FindFileData));
+ }
+ while (FindNextFile(hFind, &FindFileData));
FindClose(hFind);
}
-
static void GetIconStrings(CMStringW& buffer)
{
wchar_t path[MAX_PATH];
GetModuleFileName(nullptr, path, MAX_PATH);
- LPTSTR fname = wcsrchr(path, TEXT('\\'));
+ LPTSTR fname = wcsrchr(path, L'\\');
if (fname == nullptr) fname = path;
- mir_snwprintf(fname, MAX_PATH - (fname - path), TEXT("\\Icons\\*.*"));
+ mir_snwprintf(fname, MAX_PATH - (fname - path), L"\\Icons\\*.*");
WIN32_FIND_DATA FindFileData;
HANDLE hFind = FindFirstFile(path, &FindFileData);
@@ -433,15 +399,14 @@ static void GetIconStrings(CMStringW& buffer) do {
if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue;
- wchar_t timebuf[30] = TEXT("");
+ wchar_t timebuf[30] = L"";
GetLastWriteTime(&FindFileData.ftLastWriteTime, timebuf, 30);
- buffer.AppendFormat(TEXT(" %s [%s]\r\n"), FindFileData.cFileName, timebuf);
+ buffer.AppendFormat(L" %s [%s]\r\n", FindFileData.cFileName, timebuf);
} while (FindNextFile(hFind, &FindFileData));
FindClose(hFind);
}
-
void PrintVersionInfo(CMStringW& buffer, unsigned flags)
{
GetProcessorString(buffer);
@@ -470,34 +435,31 @@ void PrintVersionInfo(CMStringW& buffer, unsigned flags) buffer.Append(L"\r\n");
}
- buffer.AppendFormat(TEXT("\r\nMiranda NG Version: %s"), vertxt);
+ buffer.AppendFormat(L"\r\nMiranda NG Version: %s", vertxt);
GetWow64String(buffer);
buffer.Append(L"\r\n");
wchar_t path[MAX_PATH], mirtime[30];
GetModuleFileName(nullptr, path, MAX_PATH);
GetLastWriteTime(path, mirtime, 30);
- buffer.AppendFormat(TEXT("Build time: %s\r\n"), mirtime);
+ buffer.AppendFormat(L"Build time: %s\r\n", mirtime);
wchar_t profpn[MAX_PATH];
- mir_snwprintf(profpn, TEXT("%s\\%s"), profpathfull, profname);
+ mir_snwprintf(profpn, L"%s\\%s", profpathfull, profname);
DATABASELINK *db = FindDatabasePlugin(profpn);
- buffer.AppendFormat(TEXT("Profile: %s (%s)\r\n"), profpn, db->szFullName);
+ buffer.AppendFormat(L"Profile: %s (%s)\r\n", profpn, db->szFullName);
if (flags & VI_FLAG_PRNVAR) {
WIN32_FIND_DATA FindFileData;
-
HANDLE hFind = FindFirstFile(profpn, &FindFileData);
if (hFind != INVALID_HANDLE_VALUE) {
FindClose(hFind);
unsigned __int64 fsize = (unsigned __int64)FindFileData.nFileSizeHigh << 32 | FindFileData.nFileSizeLow;
- buffer.AppendFormat(TEXT("Profile size: %I64u Bytes\r\n"), fsize),
-
- GetLastWriteTime(&FindFileData.ftCreationTime, mirtime, 30);
- buffer.AppendFormat(TEXT("Profile creation date: %s\r\n"), mirtime);
+ buffer.AppendFormat(L"Profile size: %I64u Bytes\r\n", fsize), GetLastWriteTime(&FindFileData.ftCreationTime, mirtime, 30);
+ buffer.AppendFormat(L"Profile creation date: %s\r\n", mirtime);
}
}
mir_free(profpathfull);
@@ -505,42 +467,41 @@ void PrintVersionInfo(CMStringW& buffer, unsigned flags) GetLanguagePackString(buffer);
buffer.Append(L"\r\n");
- // buffer.AppendFormat(TEXT("Nightly: %s\r\n"), wcsstr(vertxt, TEXT("alpha")) ? TEXT("Yes") : TEXT("No"));
- // buffer.AppendFormat(TEXT("Unicode: %s\r\n"), wcsstr(vertxt, TEXT("Unicode")) ? TEXT("Yes") : TEXT("No"));
+ // buffer.AppendFormat(L"Nightly: %s\r\n"), wcsstr(vertxt, L"alpha")) ? L"Yes") : L"No"));
+ // buffer.AppendFormat(L"Unicode: %s\r\n"), wcsstr(vertxt, L"Unicode")) ? L"Yes") : L"No"));
GetPluginsString(buffer, flags);
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(""));
+ buffer.AppendFormat(L"\r\n%sWeather ini files:%s\r\n-------------------------------------------------------------------------------\r\n",
+ (flags & VI_FLAG_FORMAT) ? L"[b]" : L"",
+ (flags & VI_FLAG_FORMAT) ? L"[/b]" : L"");
GetWeatherStrings(buffer, flags);
}
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(""));
+ buffer.AppendFormat(L"\r\n%sProtocols and Accounts:%s\r\n-------------------------------------------------------------------------------\r\n",
+ (flags & VI_FLAG_FORMAT) ? L"[b]" : L"",
+ (flags & VI_FLAG_FORMAT) ? L"[/b]" : L"");
GetProtocolStrings(buffer);
}
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(""));
+ buffer.AppendFormat(L"\r\n%sIcon Packs:%s\r\n-------------------------------------------------------------------------------\r\n",
+ (flags & VI_FLAG_FORMAT) ? L"[b]" : L"",
+ (flags & VI_FLAG_FORMAT) ? L"[/b]" : L"");
GetIconStrings(buffer);
}
if (flags & VI_FLAG_PRNDLL) {
__try {
- buffer.Append(TEXT("\r\nLoaded Modules:\r\n-------------------------------------------------------------------------------\r\n"));
+ buffer.Append(L"\r\nLoaded Modules:\r\n-------------------------------------------------------------------------------\r\n");
EnumerateLoadedModules64(GetCurrentProcess(), LoadedModules64, &buffer);
}
__except (EXCEPTION_EXECUTE_HANDLER) {}
}
}
-
void CreateCrashReport(HANDLE hDumpFile, PEXCEPTION_POINTERS exc_ptr, const wchar_t* msg)
{
if (exc_ptr->ContextRecord == nullptr || (exc_ptr->ContextRecord->ContextFlags & CONTEXT_CONTROL) == 0)
@@ -548,7 +509,7 @@ void CreateCrashReport(HANDLE hDumpFile, PEXCEPTION_POINTERS exc_ptr, const wcha CONTEXT context = *exc_ptr->ContextRecord;
- STACKFRAME64 frame = { 0 };
+ STACKFRAME64 frame = {};
#if defined(_AMD64_)
#define IMAGE_FILE_MACHINE IMAGE_FILE_MACHINE_AMD64
@@ -577,7 +538,7 @@ void CreateCrashReport(HANDLE hDumpFile, PEXCEPTION_POINTERS exc_ptr, const wcha GetISO8061Time(nullptr, curtime, 30);
CMStringW buffer;
- buffer.AppendFormat(TEXT("Miranda Crash Report from %s. Crash Dumper v.%d.%d.%d.%d\r\n"),
+ buffer.AppendFormat(L"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)));
@@ -593,18 +554,18 @@ void CreateCrashReport(HANDLE hDumpFile, PEXCEPTION_POINTERS exc_ptr, const wcha SymSetOptions(SYMOPT_UNDNAME | SYMOPT_DEFERRED_LOADS | SYMOPT_LOAD_LINES);
SymInitialize(hProcess, nullptr, TRUE);
- buffer.Append(TEXT("\r\nStack Trace:\r\n---------------------------------------------------------------\r\n"));
+ buffer.Append(L"\r\nStack Trace:\r\n---------------------------------------------------------------\r\n");
for (int i = 81; --i;) {
- char symbuf[sizeof(IMAGEHLP_SYMBOL64) + MAX_SYM_NAME * sizeof(wchar_t) + 4] = { 0 };
+ char symbuf[sizeof(IMAGEHLP_SYMBOL64) + MAX_SYM_NAME * sizeof(wchar_t) + 4] = {};
PIMAGEHLP_SYMBOL64 pSym = (PIMAGEHLP_SYMBOL64)symbuf;
pSym->SizeOfStruct = sizeof(IMAGEHLP_SYMBOL64);
pSym->MaxNameLength = MAX_SYM_NAME;
- IMAGEHLP_LINE64 Line = { 0 };
+ IMAGEHLP_LINE64 Line = {};
Line.SizeOfStruct = sizeof(Line);
- IMAGEHLP_MODULE64 Module = { 0 };
+ IMAGEHLP_MODULE64 Module = {};
Module.SizeOfStruct = sizeof(IMAGEHLP_MODULE64_V2);
char undName[MAX_SYM_NAME] = "";
@@ -634,7 +595,7 @@ void CreateCrashReport(HANDLE hDumpFile, PEXCEPTION_POINTERS exc_ptr, const wcha }
}
- const char* name;
+ const char *name;
if (undFullName[0] != 0)
name = undFullName;
else if (undName[0] != 0)
@@ -651,37 +612,32 @@ void CreateCrashReport(HANDLE hDumpFile, PEXCEPTION_POINTERS exc_ptr, const wcha HMODULE hModule = (HMODULE)Module.BaseOfImage;
PLUGININFOEX *pi = GetMirInfo(hModule);
if (pi != nullptr) {
- static const wchar_t formatc[] = TEXT("\r\nLikely cause of the crash plugin: %S\r\n\r\n");
-
if (pi->shortName) {
CMStringW crashcause;
- crashcause.AppendFormat(formatc, pi->shortName);
+ crashcause.AppendFormat(L"\r\nLikely cause of the crash plugin: %S\r\n\r\n", pi->shortName);
buffer.Insert(crashpos, crashcause);
}
crashpos = 0;
}
}
-
- static const wchar_t formatd[] = TEXT("%p (%S %p): %S (%d): %S\r\n");
-
- buffer.AppendFormat(formatd, (void*)frame.AddrPC.Offset, moduleName, (void*)Module.BaseOfImage,lineFileName, Line.LineNumber, name);
+ buffer.AppendFormat(L"%p (%S %p): %S (%d): %S\r\n", (void*)frame.AddrPC.Offset, moduleName, (void*)Module.BaseOfImage, lineFileName, Line.LineNumber, name);
}
+
SymCleanup(hProcess);
buffer.Append(L"\r\n");
PrintVersionInfo(buffer, VI_FLAG_PRNDLL);
-
int len = WideCharToMultiByte(CP_UTF8, 0, buffer.c_str(), -1, nullptr, 0, nullptr, nullptr);
char* dst = (char*)(len > 8192 ? malloc(len) : alloca(len));
WideCharToMultiByte(CP_UTF8, 0, buffer.c_str(), -1, dst, len, nullptr, nullptr);
WriteUtfFile(hDumpFile, dst);
- if (len > 8192) free(dst);
-
+ if (len > 8192)
+ free(dst);
- if (db_get_b(0, PluginName, "ShowCrashMessageBox", 1) && msg && MessageBox(nullptr, msg, TEXT("Miranda Crash Dumper"), MB_YESNO | MB_ICONERROR | MB_TASKMODAL | MB_DEFBUTTON2 | MB_TOPMOST) == IDYES)
+ if (db_get_b(0, PluginName, "ShowCrashMessageBox", 1) && msg && IDYES == MessageBox(nullptr, msg, L"Miranda Crash Dumper", MB_YESNO | MB_ICONERROR | MB_TASKMODAL | MB_DEFBUTTON2 | MB_TOPMOST))
StoreStringToClip(buffer);
}
diff --git a/plugins/CrashDumper/src/exhndlr.cpp b/plugins/CrashDumper/src/exhndlr.cpp index 14cc07f3b0..32b4b224d1 100644 --- a/plugins/CrashDumper/src/exhndlr.cpp +++ b/plugins/CrashDumper/src/exhndlr.cpp @@ -47,30 +47,28 @@ int myDebugFilter(unsigned int code, PEXCEPTION_POINTERS ep) void myfilterWorker(PEXCEPTION_POINTERS exc_ptr, bool notify)
{
wchar_t path[MAX_PATH];
- SYSTEMTIME st;
HANDLE hDumpFile = nullptr;
+ SYSTEMTIME st;
GetLocalTime(&st);
CreateDirectoryTreeW(CrashLogFolder);
__try {
if (dtsubfldr) {
- mir_snwprintf(path, TEXT("%s\\%02d.%02d.%02d"), CrashLogFolder, st.wYear, st.wMonth, st.wDay);
+ mir_snwprintf(path, L"%s\\%02d.%02d.%02d", CrashLogFolder, st.wYear, st.wMonth, st.wDay);
CreateDirectory(path, nullptr);
- mir_snwprintf(path, TEXT("%s\\%02d.%02d.%02d\\crash%02d%02d%02d%02d%02d%02d.mdmp"), CrashLogFolder,
+ mir_snwprintf(path, L"%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_snwprintf(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);
+ mir_snwprintf(path, L"%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, nullptr, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr);
if (hDumpFile != INVALID_HANDLE_VALUE)
CreateMiniDump(hDumpFile, exc_ptr);
else if (GetLastError() != ERROR_ALREADY_EXISTS)
- MessageBox(nullptr, TranslateT("Crash Report write location is not available"),
- TEXT("Miranda Crash Dumper"), MB_OK | MB_ICONERROR | MB_TASKMODAL | MB_TOPMOST);
-
+ MessageBox(nullptr, TranslateT("Crash Report write location is not available"), L"Miranda Crash Dumper", MB_OK | MB_ICONERROR | MB_TASKMODAL | MB_TOPMOST);
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
@@ -78,18 +76,19 @@ void myfilterWorker(PEXCEPTION_POINTERS exc_ptr, bool notify) bool empty = GetFileSize(hDumpFile, nullptr) == 0;
CloseHandle(hDumpFile);
- if (empty) DeleteFile(path);
+ if (empty)
+ DeleteFile(path);
__try {
if (dtsubfldr) {
- mir_snwprintf(path, TEXT("%s\\%02d.%02d.%02d"), CrashLogFolder, st.wYear, st.wMonth, st.wDay);
+ mir_snwprintf(path, L"%s\\%02d.%02d.%02d", CrashLogFolder, st.wYear, st.wMonth, st.wDay);
CreateDirectory(path, nullptr);
- mir_snwprintf(path, TEXT("%s\\%02d.%02d.%02d\\crash%02d%02d%02d%02d%02d%02d.txt"), CrashLogFolder,
+ mir_snwprintf(path, L"%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_snwprintf(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);
+ else
+ mir_snwprintf(path, L"%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, nullptr, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr);
@@ -100,27 +99,29 @@ void myfilterWorker(PEXCEPTION_POINTERS exc_ptr, bool notify) }
__except (myDebugFilter(GetExceptionCode(), GetExceptionInformation())) {}
- bool empty1 = GetFileSize(hDumpFile, nullptr) == 0;
+ empty = GetFileSize(hDumpFile, nullptr) == 0;
CloseHandle(hDumpFile);
- if (empty1) DeleteFile(path);
+ if (empty)
+ DeleteFile(path);
}
LONG WINAPI myfilter(PEXCEPTION_POINTERS exc_ptr)
{
- if (exc_ptr == lastptr) return EXCEPTION_EXECUTE_HANDLER;
+ if (exc_ptr == lastptr)
+ return EXCEPTION_EXECUTE_HANDLER;
+
lastptr = exc_ptr;
-
myfilterWorker(exc_ptr, true);
-
return exchndlr ? ((LPTOP_LEVEL_EXCEPTION_FILTER)exchndlr)(exc_ptr) : EXCEPTION_CONTINUE_SEARCH;
}
LONG WINAPI myfilterv(PEXCEPTION_POINTERS exc_ptr)
{
if (0xC0000000L <= exc_ptr->ExceptionRecord->ExceptionCode && 0xC0000500L >= exc_ptr->ExceptionRecord->ExceptionCode) {
- if (exc_ptr == lastptr) return EXCEPTION_EXECUTE_HANDLER;
+ if (exc_ptr == lastptr)
+ return EXCEPTION_EXECUTE_HANDLER;
+
lastptr = exc_ptr;
-
myfilterWorker(exc_ptr, true);
}
return EXCEPTION_CONTINUE_SEARCH;
diff --git a/plugins/CrashDumper/src/ui.cpp b/plugins/CrashDumper/src/ui.cpp index 65fa95377b..d09ac5b809 100644 --- a/plugins/CrashDumper/src/ui.cpp +++ b/plugins/CrashDumper/src/ui.cpp @@ -69,7 +69,7 @@ INT_PTR CALLBACK DlgProcView(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara CHARFORMAT2 chf;
chf.cbSize = sizeof(chf);
SendDlgItemMessage(hwndDlg, IDC_VIEWVERSIONINFO, EM_GETCHARFORMAT, SCF_DEFAULT, (LPARAM)&chf);
- mir_wstrcpy(chf.szFaceName, TEXT("Courier New"));
+ mir_wstrcpy(chf.szFaceName, L"Courier New");
SendDlgItemMessage(hwndDlg, IDC_VIEWVERSIONINFO, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&chf);
CMStringW buffer;
@@ -279,8 +279,8 @@ LRESULT CALLBACK DlgProcPopup(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) case 3:
wchar_t path[MAX_PATH];
- mir_snwprintf(path, TEXT("%s\\VersionInfo.txt"), VersionInfoFolder);
- ShellExecute(nullptr, TEXT("open"), path, nullptr, nullptr, SW_SHOW);
+ mir_snwprintf(path, L"%s\\VersionInfo.txt", VersionInfoFolder);
+ ShellExecute(nullptr, L"open", path, nullptr, nullptr, SW_SHOW);
break;
}
@@ -297,7 +297,7 @@ LRESULT CALLBACK DlgProcPopup(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) void ShowMessage(int type, const wchar_t* format, ...)
{
- POPUPDATAT pi = { 0 };
+ POPUPDATAT pi = {};
va_list va;
va_start(va, format);
@@ -306,12 +306,12 @@ void ShowMessage(int type, const wchar_t* format, ...) va_end(va);
if (ServiceExists(MS_POPUP_ADDPOPUPT)) {
- mir_wstrcpy(pi.lptzContactName, TEXT(PluginName));
+ mir_wstrcpy(pi.lptzContactName, _A2W(PluginName));
pi.lchIcon = LoadIconEx(IDI_VI);
pi.PluginWindowProc = DlgProcPopup;
pi.PluginData = (void*)type;
PUAddPopupT(&pi);
}
- else MessageBox(nullptr, pi.lptzText, TEXT(PluginName), MB_OK | MB_ICONINFORMATION);
+ else MessageBox(nullptr, pi.lptzText, _A2W(PluginName), MB_OK | MB_ICONINFORMATION);
}
diff --git a/plugins/CrashDumper/src/upload.cpp b/plugins/CrashDumper/src/upload.cpp index 62baee1071..338cbccfa2 100644 --- a/plugins/CrashDumper/src/upload.cpp +++ b/plugins/CrashDumper/src/upload.cpp @@ -91,7 +91,7 @@ bool InternetDownloadFile(const char *szUrl, VerTrnsfr* szReq) {
int result = 0xBADBAD;
char* szRedirUrl = nullptr;
- NETLIBHTTPREQUEST nlhr = { 0 };
+ NETLIBHTTPREQUEST nlhr = {};
// initialize the netlib request
nlhr.cbSize = sizeof(nlhr);
diff --git a/plugins/CrashDumper/src/utils.cpp b/plugins/CrashDumper/src/utils.cpp index d46bf807ea..7a5e8b9d4f 100644 --- a/plugins/CrashDumper/src/utils.cpp +++ b/plugins/CrashDumper/src/utils.cpp @@ -22,7 +22,7 @@ static HINSTANCE hKernel = GetModuleHandleA("kernel32.dll"); int GetTZOffset(void)
{
- TIME_ZONE_INFORMATION tzInfo = { 0 };
+ TIME_ZONE_INFORMATION tzInfo = {};
DWORD type = GetTimeZoneInformation(&tzInfo);
int offset = 0;
@@ -51,15 +51,15 @@ void GetISO8061Time(SYSTEMTIME *stLocal, LPTSTR lpszString, DWORD dwSize) }
if (clsdates) {
- GetDateFormat(LOCALE_INVARIANT, 0, stLocal, TEXT("d MMM yyyy"), lpszString, dwSize);
+ GetDateFormat(LOCALE_INVARIANT, 0, stLocal, L"d MMM yyyy", lpszString, dwSize);
int dlen = (int)mir_wstrlen(lpszString);
- GetTimeFormat(LOCALE_INVARIANT, 0, stLocal, TEXT(" H:mm:ss"), lpszString + dlen, dwSize - dlen);
+ GetTimeFormat(LOCALE_INVARIANT, 0, stLocal, L" H:mm:ss", lpszString + dlen, dwSize - dlen);
}
else {
int offset = GetTZOffset();
// Build a string showing the date and time.
- mir_snwprintf(lpszString, dwSize, TEXT("%d-%02d-%02d %02d:%02d:%02d%+03d%02d"),
+ mir_snwprintf(lpszString, dwSize, L"%d-%02d-%02d %02d:%02d:%02d%+03d%02d",
stLocal->wYear, stLocal->wMonth, stLocal->wDay,
stLocal->wHour, stLocal->wMinute, stLocal->wSecond,
offset / 60, offset % 60);
@@ -105,43 +105,43 @@ void GetInternetExplorerVersion(CMStringW &buffer) HKEY hKey;
DWORD size;
- wchar_t ieVersion[1024] = { 0 };
- wchar_t ieBuild[512] = { 0 };
- wchar_t iVer[64] = { 0 };
+ wchar_t ieVersion[1024] = {};
+ wchar_t ieBuild[512] = {};
+ wchar_t iVer[64] = {};
- if (!RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\Internet Explorer"), 0, KEY_QUERY_VALUE, &hKey)) {
+ if (!RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Internet Explorer", 0, KEY_QUERY_VALUE, &hKey)) {
size = _countof(ieBuild);
- if (RegQueryValueEx(hKey, TEXT("Build"), nullptr, nullptr, (LPBYTE)ieBuild, &size) != ERROR_SUCCESS)
+ if (RegQueryValueEx(hKey, L"Build", nullptr, nullptr, (LPBYTE)ieBuild, &size) != ERROR_SUCCESS)
ieBuild[0] = 0;
size = _countof(ieVersion);
- if (RegQueryValueEx(hKey, TEXT("Version"), nullptr, nullptr, (LPBYTE)ieVersion, &size) != ERROR_SUCCESS)
+ if (RegQueryValueEx(hKey, L"Version", nullptr, nullptr, (LPBYTE)ieVersion, &size) != ERROR_SUCCESS)
ieVersion[0] = 0;
size = _countof(iVer);
- if (RegQueryValueEx(hKey, TEXT("IVer"), nullptr, nullptr, (LPBYTE)iVer, &size) != ERROR_SUCCESS)
+ if (RegQueryValueEx(hKey, L"IVer", nullptr, nullptr, (LPBYTE)iVer, &size) != ERROR_SUCCESS)
iVer[0] = 0;
RegCloseKey(hKey);
}
- buffer.Append(TEXT("Internet Explorer: "));
+ buffer.Append(L"Internet Explorer: ");
if (ieVersion[0] == 0) {
if (iVer[0] == 0)
- buffer.Append(TEXT("<not installed>"));
- else if (mir_wstrcmp(iVer, TEXT("100")) == 0)
- buffer.Append(TEXT("1.0"));
- else if (mir_wstrcmp(iVer, TEXT("101")) == 0)
- buffer.Append(TEXT("NT"));
- else if (mir_wstrcmp(iVer, TEXT("102")) == 0)
- buffer.Append(TEXT("2.0"));
- else if (mir_wstrcmp(iVer, TEXT("103")) == 0)
- buffer.Append(TEXT("3.0"));
+ buffer.Append(L"<not installed>");
+ else if (mir_wstrcmp(iVer, L"100") == 0)
+ buffer.Append(L"1.0");
+ else if (mir_wstrcmp(iVer, L"101") == 0)
+ buffer.Append(L"NT");
+ else if (mir_wstrcmp(iVer, L"102") == 0)
+ buffer.Append(L"2.0");
+ else if (mir_wstrcmp(iVer, L"103") == 0)
+ buffer.Append(L"3.0");
}
else buffer.Append(ieVersion);
if (ieBuild[0] != 0)
- buffer.AppendFormat(TEXT(" (build %s)"), ieBuild);
+ buffer.AppendFormat(L" (build %s)", ieBuild);
}
void TrimMultiSpaces(wchar_t *str)
@@ -150,7 +150,7 @@ void TrimMultiSpaces(wchar_t *str) bool trimst = false;
for (;;) {
- if (*src == TEXT(' ')) {
+ if (*src == ' ') {
if (!trimst) {
trimst = true;
*dest++ = *src;
@@ -166,152 +166,150 @@ void TrimMultiSpaces(wchar_t *str) void GetProcessorString(CMStringW &buffer)
{
- HKEY hKey;
- DWORD size;
+ wchar_t cpuIdent[512] = {};
+ wchar_t cpuName[512] = {};
- wchar_t cpuIdent[512] = { 0 };
- wchar_t cpuName[512] = { 0 };
-
- if (!RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("Hardware\\Description\\System\\CentralProcessor\\0"), 0, KEY_QUERY_VALUE, &hKey)) {
- size = _countof(cpuName);
- if (RegQueryValueEx(hKey, TEXT("ProcessorNameString"), nullptr, nullptr, (LPBYTE)cpuName, &size) != ERROR_SUCCESS)
- mir_wstrcpy(cpuName, TEXT("Unknown"));
+ HKEY hKey;
+ if (!RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Hardware\\Description\\System\\CentralProcessor\\0", 0, KEY_QUERY_VALUE, &hKey)) {
+ DWORD size = _countof(cpuName);
+ if (RegQueryValueEx(hKey, L"ProcessorNameString", nullptr, nullptr, (LPBYTE)cpuName, &size) != ERROR_SUCCESS)
+ mir_wstrcpy(cpuName, L"Unknown");
size = _countof(cpuIdent);
- if (RegQueryValueEx(hKey, TEXT("Identifier"), nullptr, nullptr, (LPBYTE)cpuIdent, &size) != ERROR_SUCCESS)
- if (RegQueryValueEx(hKey, TEXT("VendorIdentifier"), nullptr, nullptr, (LPBYTE)cpuIdent, &size) != ERROR_SUCCESS)
- mir_wstrcpy(cpuIdent, TEXT("Unknown"));
+ if (RegQueryValueEx(hKey, L"Identifier", nullptr, nullptr, (LPBYTE)cpuIdent, &size) != ERROR_SUCCESS)
+ if (RegQueryValueEx(hKey, L"VendorIdentifier", nullptr, nullptr, (LPBYTE)cpuIdent, &size) != ERROR_SUCCESS)
+ mir_wstrcpy(cpuIdent, L"Unknown");
RegCloseKey(hKey);
}
TrimMultiSpaces(cpuName);
- buffer.AppendFormat(TEXT("CPU: %s [%s]"), cpuName, cpuIdent);
+ buffer.AppendFormat(L"CPU: %s [%s]", cpuName, cpuIdent);
if (IsProcessorFeaturePresent(PF_NX_ENABLED))
- buffer.Append(TEXT(" [DEP Enabled]"));
+ buffer.Append(L" [DEP Enabled]");
- SYSTEM_INFO si = { 0 };
+ SYSTEM_INFO si = {};
GetSystemInfo(&si);
if (si.dwNumberOfProcessors > 1)
- buffer.AppendFormat(TEXT(" [%u CPUs]"), si.dwNumberOfProcessors);
+ buffer.AppendFormat(L" [%u CPUs]", si.dwNumberOfProcessors);
}
void GetFreeMemoryString(CMStringW &buffer)
{
unsigned ram;
- MEMORYSTATUSEX ms = { 0 };
+ MEMORYSTATUSEX ms = {};
ms.dwLength = sizeof(ms);
GlobalMemoryStatusEx(&ms);
ram = (unsigned int)((ms.ullTotalPhys / (1024 * 1024)) + 1);
- buffer.AppendFormat(TEXT("Installed RAM: %u MBytes"), ram);
+ buffer.AppendFormat(L"Installed RAM: %u MBytes", ram);
}
void GetFreeDiskString(LPCTSTR dirname, CMStringW &buffer)
{
- ULARGE_INTEGER tnb, tfb, fs = { 0 };
+ ULARGE_INTEGER tnb, tfb, fs = {};
GetDiskFreeSpaceEx(dirname, &fs, &tnb, &tfb);
fs.QuadPart /= (1024 * 1024);
- buffer.AppendFormat(TEXT("Free disk space on Miranda partition: %u MBytes"), fs.LowPart);
+ buffer.AppendFormat(L"Free disk space on Miranda partition: %u MBytes", fs.LowPart);
}
void ReadableExceptionInfo(PEXCEPTION_RECORD excrec, CMStringW& buffer)
{
- buffer.Append(TEXT("Exception: "));
+ buffer.Append(L"Exception: ");
switch (excrec->ExceptionCode) {
case EXCEPTION_BREAKPOINT:
- buffer.Append(TEXT("User Defined Breakpoint"));
+ buffer.Append(L"User Defined Breakpoint");
break;
case EXCEPTION_ACCESS_VIOLATION:
- buffer.Append(TEXT("Access Violation"));
+ buffer.Append(L"Access Violation");
break;
case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
- buffer.Append(TEXT("Array Bounds Exceeded"));
+ buffer.Append(L"Array Bounds Exceeded");
break;
case EXCEPTION_DATATYPE_MISALIGNMENT:
- buffer.Append(TEXT("Datatype Misalignment"));
+ buffer.Append(L"Datatype Misalignment");
break;
case EXCEPTION_FLT_DENORMAL_OPERAND:
- buffer.Append(TEXT("Floating Point denormlized operand"));
+ buffer.Append(L"Floating Point denormlized operand");
break;
case EXCEPTION_FLT_DIVIDE_BY_ZERO:
- buffer.Append(TEXT("Floating Point divide by 0"));
+ buffer.Append(L"Floating Point divide by 0");
break;
case EXCEPTION_FLT_INEXACT_RESULT:
- buffer.Append(TEXT("Floating Point inexact result"));
+ buffer.Append(L"Floating Point inexact result");
break;
case EXCEPTION_FLT_INVALID_OPERATION:
- buffer.Append(TEXT("Floating Point invalid operation"));
+ buffer.Append(L"Floating Point invalid operation");
break;
case EXCEPTION_FLT_OVERFLOW:
- buffer.Append(TEXT("Floating Point overflow"));
+ buffer.Append(L"Floating Point overflow");
break;
case EXCEPTION_FLT_STACK_CHECK:
- buffer.Append(TEXT("Floating Point stack overflow/underflow"));
+ buffer.Append(L"Floating Point stack overflow/underflow");
break;
case EXCEPTION_FLT_UNDERFLOW:
- buffer.Append(TEXT("Floating Point underflow"));
+ buffer.Append(L"Floating Point underflow");
break;
case EXCEPTION_ILLEGAL_INSTRUCTION:
- buffer.Append(TEXT("Invalid instruction executed"));
+ buffer.Append(L"Invalid instruction executed");
break;
case EXCEPTION_IN_PAGE_ERROR:
- buffer.Append(TEXT("Access to the not present page"));
+ buffer.Append(L"Access to the not present page");
break;
case EXCEPTION_INT_DIVIDE_BY_ZERO:
- buffer.Append(TEXT("Integer divide by zero"));
+ buffer.Append(L"Integer divide by zero");
break;
case EXCEPTION_INT_OVERFLOW:
- buffer.Append(TEXT("Integer overflow"));
+ buffer.Append(L"Integer overflow");
break;
case EXCEPTION_PRIV_INSTRUCTION:
- buffer.Append(TEXT("Priveleged instruction executed"));
+ buffer.Append(L"Priveleged instruction executed");
break;
case EXCEPTION_STACK_OVERFLOW:
- buffer.Append(TEXT("Stack overflow"));
+ buffer.Append(L"Stack overflow");
break;
case 0xe06d7363:
- buffer.Append(TEXT("Unhandled C++ software exception"));
+ buffer.Append(L"Unhandled C++ software exception");
break;
default:
- buffer.AppendFormat(TEXT("%x"), excrec->ExceptionCode);
+ buffer.AppendFormat(L"%x", excrec->ExceptionCode);
break;
}
- buffer.AppendFormat(TEXT(" at address %p."), excrec->ExceptionAddress);
+ buffer.AppendFormat(L" at address %p.", excrec->ExceptionAddress);
if (excrec->ExceptionCode == EXCEPTION_ACCESS_VIOLATION || excrec->ExceptionCode == EXCEPTION_IN_PAGE_ERROR) {
switch (excrec->ExceptionInformation[0]) {
case 0:
- buffer.AppendFormat(TEXT(" Reading from address %p."), (LPVOID)excrec->ExceptionInformation[1]);
+ buffer.AppendFormat(L" Reading from address %p.", (LPVOID)excrec->ExceptionInformation[1]);
break;
case 1:
- buffer.AppendFormat(TEXT(" Writing to address %p."), (LPVOID)excrec->ExceptionInformation[1]);
+ buffer.AppendFormat(L" Writing to address %p.", (LPVOID)excrec->ExceptionInformation[1]);
break;
case 8:
- buffer.AppendFormat(TEXT(" DEP at address %p."), (LPVOID)excrec->ExceptionInformation[1]);
+ buffer.AppendFormat(L" DEP at address %p.", (LPVOID)excrec->ExceptionInformation[1]);
break;
}
}
@@ -338,7 +336,7 @@ void GetAdminString(CMStringW &buffer) b = TRUE;
}
- buffer.AppendFormat(TEXT("Administrator privileges: %s"), b ? TEXT("Yes") : TEXT("No"));
+ buffer.AppendFormat(L"Administrator privileges: %s", b ? L"Yes" : L"No");
}
void GetLanguageString(CMStringW &buffer)
@@ -351,25 +349,25 @@ void GetLanguageString(CMStringW &buffer) GetLocaleInfo(MAKELCID(GetUserDefaultUILanguage(), SORT_DEFAULT), LOCALE_SENGLANGUAGE, name3, 256);
GetLocaleInfo(MAKELCID(GetSystemDefaultUILanguage(), SORT_DEFAULT), LOCALE_SENGLANGUAGE, name4, 256);
- buffer.AppendFormat(TEXT("OS Languages: (UI | Locale (User/System)) : %s/%s | %s/%s"), name3, name4, name1, name2);
+ buffer.AppendFormat(L"OS Languages: (UI | Locale (User/System)) : %s/%s | %s/%s", name3, name4, name1, name2);
}
void GetLanguagePackString(CMStringW &buffer)
{
- buffer.Append(TEXT("Language pack: "));
+ buffer.Append(L"Language pack: ");
if (packlcid != LOCALE_USER_DEFAULT) {
wchar_t lang[MAX_PATH], ctry[MAX_PATH];
if (GetLocaleInfo(packlcid, LOCALE_SENGLANGUAGE, lang, MAX_PATH)) {
if (GetLocaleInfo(packlcid, LOCALE_SISO3166CTRYNAME, ctry, MAX_PATH))
- buffer.AppendFormat(TEXT("%s (%s) [%04x]"), lang, ctry, packlcid);
+ buffer.AppendFormat(L"%s (%s) [%04x]", lang, ctry, packlcid);
else
buffer.Append(lang);
}
else
- buffer.Append(TEXT("Locale id invalid"));
+ buffer.Append(L"Locale id invalid");
}
else
- buffer.Append(TEXT("No language pack installed"));
+ buffer.Append(L"No language pack installed");
}
void GetWow64String(CMStringW &buffer)
@@ -379,7 +377,7 @@ void GetWow64String(CMStringW &buffer) wow64 = 0;
if (wow64)
- buffer.Append(TEXT(" [running inside WOW64]"));
+ buffer.Append(L" [running inside WOW64]");
}
void GetVersionInfo(HMODULE hLib, CMStringW& buffer)
@@ -396,7 +394,7 @@ void GetVersionInfo(HMODULE hLib, CMStringW& buffer) if (((char*)res - (char*)versionInfo) < vl) {
VS_FIXEDFILEINFO *vsInfo = (VS_FIXEDFILEINFO*)res;
- buffer.AppendFormat(TEXT(" v.%u.%u.%u.%u"),
+ buffer.AppendFormat(L" v.%u.%u.%u.%u",
HIWORD(vsInfo->dwFileVersionMS), LOWORD(vsInfo->dwFileVersionMS),
HIWORD(vsInfo->dwFileVersionLS), LOWORD(vsInfo->dwFileVersionLS));
}
diff --git a/plugins/CrashDumper/src/version.h b/plugins/CrashDumper/src/version.h index ccfecebc07..af1c0543f6 100644 --- a/plugins/CrashDumper/src/version.h +++ b/plugins/CrashDumper/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0
-#define __MINOR_VERSION 0
-#define __RELEASE_NUM 5
-#define __BUILD_NUM 2
+#define __MINOR_VERSION 1
+#define __RELEASE_NUM 0
+#define __BUILD_NUM 1
#include <stdver.h>
|