diff options
author | George Hazan <george.hazan@gmail.com> | 2015-06-19 19:35:42 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-06-19 19:35:42 +0000 |
commit | 4c814798c7bc7f6a0f92c21b027b26290622aa2f (patch) | |
tree | 9bbfb38bd639f352300aa16ff7c45f5a9b2dba6d /plugins/CrashDumper | |
parent | f0f0cd088f1ec3a85abee825ddbc214f3f6b92c3 (diff) |
SIZEOF replaced with more secure analog - _countof
git-svn-id: http://svn.miranda-ng.org/main/trunk@14270 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/CrashDumper')
-rw-r--r-- | plugins/CrashDumper/src/crshdmp.cpp | 8 | ||||
-rw-r--r-- | plugins/CrashDumper/src/crshdmp_icons.cpp | 6 | ||||
-rw-r--r-- | plugins/CrashDumper/src/dumper.cpp | 6 | ||||
-rw-r--r-- | plugins/CrashDumper/src/exhndlr.cpp | 20 | ||||
-rw-r--r-- | plugins/CrashDumper/src/ui.cpp | 8 | ||||
-rw-r--r-- | plugins/CrashDumper/src/utils.cpp | 10 |
6 files changed, 29 insertions, 29 deletions
diff --git a/plugins/CrashDumper/src/crshdmp.cpp b/plugins/CrashDumper/src/crshdmp.cpp index 554761f09a..5cdccfc845 100644 --- a/plugins/CrashDumper/src/crshdmp.cpp +++ b/plugins/CrashDumper/src/crshdmp.cpp @@ -68,7 +68,7 @@ INT_PTR StoreVersionInfoToFile(WPARAM, LPARAM lParam) CreateDirectoryTree(VersionInfoFolder);
TCHAR path[MAX_PATH];
- mir_sntprintf(path, SIZEOF(path), TEXT("%s\\VersionInfo.txt"), VersionInfoFolder);
+ mir_sntprintf(path, _countof(path), TEXT("%s\\VersionInfo.txt"), VersionInfoFolder);
HANDLE hDumpFile = CreateFile(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hDumpFile != INVALID_HANDLE_VALUE) {
@@ -159,7 +159,7 @@ INT_PTR CopyLinkToClipboard(WPARAM, LPARAM) ptrT tmp(db_get_wsa(NULL, PluginName, "Username"));
if (tmp != NULL) {
TCHAR buffer[MAX_PATH];
- mir_sntprintf(buffer, SIZEOF(buffer), _T("http://vi.miranda-ng.org/detail/%s"), tmp);
+ mir_sntprintf(buffer, _countof(buffer), _T("http://vi.miranda-ng.org/detail/%s"), tmp);
int bufLen = (sizeof(buffer) + 1) * sizeof(TCHAR);
HANDLE hData = GlobalAlloc(GMEM_MOVEABLE, bufLen);
@@ -241,7 +241,7 @@ static int ToolbarModulesLoaded(WPARAM, LPARAM) static int ModulesLoaded(WPARAM, LPARAM)
{
char temp[MAX_PATH];
- CallService(MS_SYSTEM_GETVERSIONTEXT, (WPARAM)SIZEOF(temp), (LPARAM)temp);
+ CallService(MS_SYSTEM_GETVERSIONTEXT, (WPARAM)_countof(temp), (LPARAM)temp);
crs_a2t(vertxt, temp);
if (ServiceExists(MS_FOLDERS_REGISTER_PATH)) {
@@ -373,7 +373,7 @@ extern "C" int __declspec(dllexport) Load(void) profname = Utils_ReplaceVarsT(_T("%miranda_profilename%.dat"));
profpath = Utils_ReplaceVarsT(_T("%miranda_userdata%"));
if (catchcrashes && !needrestart)
- mir_sntprintf(CrashLogFolder, SIZEOF(CrashLogFolder), TEXT("%s\\CrashLog"), profpath);
+ mir_sntprintf(CrashLogFolder, _countof(CrashLogFolder), TEXT("%s\\CrashLog"), profpath);
_tcsncpy_s(VersionInfoFolder, profpath, _TRUNCATE);
diff --git a/plugins/CrashDumper/src/crshdmp_icons.cpp b/plugins/CrashDumper/src/crshdmp_icons.cpp index d7c5df3424..d3ccc95dff 100644 --- a/plugins/CrashDumper/src/crshdmp_icons.cpp +++ b/plugins/CrashDumper/src/crshdmp_icons.cpp @@ -30,12 +30,12 @@ static IconItem iconList[] = void InitIcons(void)
{
- Icon_Register(hInst, LPGEN("Crash Dumper"), iconList, SIZEOF(iconList), PluginName);
+ Icon_Register(hInst, LPGEN("Crash Dumper"), iconList, _countof(iconList), PluginName);
}
HICON LoadIconEx(int iconId, bool big)
{
- for (int i = 0; i < SIZEOF(iconList); i++)
+ for (int i = 0; i < _countof(iconList); i++)
if (iconList[i].defIconID == iconId)
return IcoLib_GetIconByHandle(iconList[i].hIcolib, big);
@@ -44,7 +44,7 @@ HICON LoadIconEx(int iconId, bool big) HANDLE GetIconHandle(int iconId)
{
- for (int i = 0; i < SIZEOF(iconList); i++)
+ for (int i = 0; i < _countof(iconList); i++)
if (iconList[i].defIconID == iconId)
return iconList[i].hIcolib;
diff --git a/plugins/CrashDumper/src/dumper.cpp b/plugins/CrashDumper/src/dumper.cpp index 35153a6954..80e6b474fc 100644 --- a/plugins/CrashDumper/src/dumper.cpp +++ b/plugins/CrashDumper/src/dumper.cpp @@ -85,14 +85,14 @@ BOOL CALLBACK LoadedModulesFind64(LPCSTR ModuleName, DWORD64 ModuleBase, ULONG M FindData* data = (FindData*)UserContext;
if ((DWORD)(data->Offset - ModuleBase) < ModuleSize) {
- const size_t len = SIZEOF(data->pModule->ModuleName);
+ const size_t len = _countof(data->pModule->ModuleName);
strncpy(data->pModule->ModuleName, ModuleName, len);
data->pModule->ModuleName[len - 1] = 0;
data->pModule->BaseOfImage = ModuleBase;
const HMODULE hModule = (HMODULE)ModuleBase;
- GetModuleFileNameA(hModule, data->pModule->LoadedImageName, SIZEOF(data->pModule->LoadedImageName));
+ GetModuleFileNameA(hModule, data->pModule->LoadedImageName, _countof(data->pModule->LoadedImageName));
return FALSE;
}
@@ -475,7 +475,7 @@ void PrintVersionInfo(CMString& buffer, unsigned flags) buffer.AppendFormat(TEXT("Build time: %s\r\n"), mirtime);
TCHAR profpn[MAX_PATH];
- mir_sntprintf(profpn, SIZEOF(profpn), TEXT("%s\\%s"), profpathfull, profname);
+ mir_sntprintf(profpn, _countof(profpn), TEXT("%s\\%s"), profpathfull, profname);
buffer.AppendFormat(TEXT("Profile: %s\r\n"), profpn);
diff --git a/plugins/CrashDumper/src/exhndlr.cpp b/plugins/CrashDumper/src/exhndlr.cpp index a7aaab2a45..91535bb12e 100644 --- a/plugins/CrashDumper/src/exhndlr.cpp +++ b/plugins/CrashDumper/src/exhndlr.cpp @@ -30,12 +30,12 @@ int myDebugFilter(unsigned int code, PEXCEPTION_POINTERS ep) char str[256];
int off = mir_snprintf(str, "dbghelp.dll v.5.0 or later required to provide a crash report\n");
- off += mir_snprintf(str + off, SIZEOF(str) - off, "Missing Module: %s ", dlld->szDll);
+ off += mir_snprintf(str + off, _countof(str) - off, "Missing Module: %s ", dlld->szDll);
if (dlld->dlp.fImportByName)
- mir_snprintf(str + off, SIZEOF(str) - off, "Function: %s ", dlld->dlp.szProcName);
+ mir_snprintf(str + off, _countof(str) - off, "Function: %s ", dlld->dlp.szProcName);
else
- mir_snprintf(str + off, SIZEOF(str) - off, "Ordinal: %x ", dlld->dlp.dwOrdinal);
+ mir_snprintf(str + off, _countof(str) - off, "Ordinal: %x ", dlld->dlp.dwOrdinal);
MessageBoxA(NULL, str, "Miranda Crash Dumper", MB_OK | MB_ICONERROR | MB_TASKMODAL | MB_TOPMOST);
}
@@ -55,13 +55,13 @@ void myfilterWorker(PEXCEPTION_POINTERS exc_ptr, bool notify) __try {
if (dtsubfldr) {
- mir_sntprintf(path, SIZEOF(path), TEXT("%s\\%02d.%02d.%02d"), CrashLogFolder, st.wYear, st.wMonth, st.wDay);
+ mir_sntprintf(path, _countof(path), TEXT("%s\\%02d.%02d.%02d"), CrashLogFolder, st.wYear, st.wMonth, st.wDay);
CreateDirectory(path, NULL);
- mir_sntprintf(path, SIZEOF(path), TEXT("%s\\%02d.%02d.%02d\\crash%02d%02d%02d%02d%02d%02d.mdmp"), CrashLogFolder,
+ mir_sntprintf(path, _countof(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, SIZEOF(path), TEXT("%s\\crash%02d%02d%02d%02d%02d%02d.mdmp"), CrashLogFolder,
+ mir_sntprintf(path, _countof(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);
@@ -82,18 +82,18 @@ void myfilterWorker(PEXCEPTION_POINTERS exc_ptr, bool notify) __try {
if (dtsubfldr) {
- mir_sntprintf(path, SIZEOF(path), TEXT("%s\\%02d.%02d.%02d"), CrashLogFolder, st.wYear, st.wMonth, st.wDay);
+ mir_sntprintf(path, _countof(path), TEXT("%s\\%02d.%02d.%02d"), CrashLogFolder, st.wYear, st.wMonth, st.wDay);
CreateDirectory(path, NULL);
- mir_sntprintf(path, SIZEOF(path), TEXT("%s\\%02d.%02d.%02d\\crash%02d%02d%02d%02d%02d%02d.txt"), CrashLogFolder,
+ mir_sntprintf(path, _countof(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, SIZEOF(path), TEXT("%s\\crash%02d%02d%02d%02d%02d%02d.txt"), CrashLogFolder,
+ mir_sntprintf(path, _countof(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, SIZEOF(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);
+ mir_sntprintf(path, _countof(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);
if (hDumpFile != INVALID_HANDLE_VALUE)
CreateCrashReport(hDumpFile, exc_ptr, notify ? path : NULL);
diff --git a/plugins/CrashDumper/src/ui.cpp b/plugins/CrashDumper/src/ui.cpp index b5ea469cba..5f6066cafa 100644 --- a/plugins/CrashDumper/src/ui.cpp +++ b/plugins/CrashDumper/src/ui.cpp @@ -233,10 +233,10 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP case WM_NOTIFY:
if (((LPNMHDR)lParam)->code == (unsigned)PSN_APPLY) {
char szSetting[100];
- GetDlgItemTextA(hwndDlg, IDC_USERNAME, szSetting, SIZEOF(szSetting));
+ GetDlgItemTextA(hwndDlg, IDC_USERNAME, szSetting, _countof(szSetting));
db_set_s(NULL, PluginName, "Username", szSetting);
- GetDlgItemTextA(hwndDlg, IDC_PASSWORD, szSetting, SIZEOF(szSetting));
+ GetDlgItemTextA(hwndDlg, IDC_PASSWORD, szSetting, _countof(szSetting));
db_set_s(NULL, PluginName, "Password", szSetting);
db_set_b(NULL, PluginName, "UploadChanged", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_UPLOADCHN));
@@ -282,7 +282,7 @@ LRESULT CALLBACK DlgProcPopup(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) case 3:
TCHAR path[MAX_PATH];
- mir_sntprintf(path, SIZEOF(path), TEXT("%s\\VersionInfo.txt"), VersionInfoFolder);
+ mir_sntprintf(path, _countof(path), TEXT("%s\\VersionInfo.txt"), VersionInfoFolder);
ShellExecute(NULL, TEXT("open"), path, NULL, NULL, SW_SHOW);
break;
@@ -305,7 +305,7 @@ void ShowMessage(int type, const TCHAR* format, ...) va_list va;
va_start(va, format);
- int len = mir_vsntprintf(pi.lptzText, SIZEOF(pi.lptzText) - 1, format, va);
+ int len = mir_vsntprintf(pi.lptzText, _countof(pi.lptzText) - 1, format, va);
pi.lptzText[len] = 0;
va_end(va);
diff --git a/plugins/CrashDumper/src/utils.cpp b/plugins/CrashDumper/src/utils.cpp index 652bace135..f904e6ef5c 100644 --- a/plugins/CrashDumper/src/utils.cpp +++ b/plugins/CrashDumper/src/utils.cpp @@ -288,15 +288,15 @@ void GetInternetExplorerVersion(CMString &buffer) TCHAR iVer[64] = { 0 };
if (!RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\Internet Explorer"), 0, KEY_QUERY_VALUE, &hKey)) {
- size = SIZEOF(ieBuild);
+ size = _countof(ieBuild);
if (RegQueryValueEx(hKey, TEXT("Build"), NULL, NULL, (LPBYTE)ieBuild, &size) != ERROR_SUCCESS)
ieBuild[0] = 0;
- size = SIZEOF(ieVersion);
+ size = _countof(ieVersion);
if (RegQueryValueEx(hKey, TEXT("Version"), NULL, NULL, (LPBYTE)ieVersion, &size) != ERROR_SUCCESS)
ieVersion[0] = 0;
- size = SIZEOF(iVer);
+ size = _countof(iVer);
if (RegQueryValueEx(hKey, TEXT("IVer"), NULL, NULL, (LPBYTE)iVer, &size) != ERROR_SUCCESS)
iVer[0] = 0;
@@ -351,11 +351,11 @@ void GetProcessorString(CMString &buffer) TCHAR cpuName[512] = { 0 };
if (!RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("Hardware\\Description\\System\\CentralProcessor\\0"), 0, KEY_QUERY_VALUE, &hKey)) {
- size = SIZEOF(cpuName);
+ size = _countof(cpuName);
if (RegQueryValueEx(hKey, TEXT("ProcessorNameString"), NULL, NULL, (LPBYTE)cpuName, &size) != ERROR_SUCCESS)
mir_tstrcpy(cpuName, TEXT("Unknown"));
- size = SIZEOF(cpuIdent);
+ size = _countof(cpuIdent);
if (RegQueryValueEx(hKey, TEXT("Identifier"), NULL, NULL, (LPBYTE)cpuIdent, &size) != ERROR_SUCCESS)
if (RegQueryValueEx(hKey, TEXT("VendorIdentifier"), NULL, NULL, (LPBYTE)cpuIdent, &size) != ERROR_SUCCESS)
mir_tstrcpy(cpuIdent, TEXT("Unknown"));
|