Commit 53d671d7 authored by Marcus Meissner's avatar Marcus Meissner Committed by Alexandre Julliard

oleview: Fixed LoadString buffer sizes.

parent 395c4163
...@@ -301,14 +301,14 @@ void RefreshDetails(HTREEITEM item) ...@@ -301,14 +301,14 @@ void RefreshDetails(HTREEITEM item)
memset(&tci, 0, sizeof(TCITEM)); memset(&tci, 0, sizeof(TCITEM));
tci.mask = TCIF_TEXT; tci.mask = TCIF_TEXT;
tci.pszText = wszBuf; tci.pszText = wszBuf;
tci.cchTextMax = sizeof(WCHAR[MAX_LOAD_STRING]); tci.cchTextMax = sizeof(wszBuf)/sizeof(wszBuf[0]);
LoadString(globals.hMainInst, IDS_TAB_IMPL, LoadString(globals.hMainInst, IDS_TAB_IMPL,
wszBuf, sizeof(WCHAR[MAX_LOAD_STRING])); wszBuf, sizeof(wszBuf)/sizeof(wszBuf[0]));
SendMessage(details.hTab, TCM_INSERTITEM, 1, (LPARAM)&tci); SendMessage(details.hTab, TCM_INSERTITEM, 1, (LPARAM)&tci);
LoadString(globals.hMainInst, IDS_TAB_ACTIV, LoadString(globals.hMainInst, IDS_TAB_ACTIV,
wszBuf, sizeof(WCHAR[MAX_LOAD_STRING])); wszBuf, sizeof(wszBuf)/sizeof(wszBuf[0]));
SendMessage(details.hTab, TCM_INSERTITEM, 2, (LPARAM)&tci); SendMessage(details.hTab, TCM_INSERTITEM, 2, (LPARAM)&tci);
} }
} }
...@@ -336,13 +336,13 @@ static void CreateTabCtrl(HWND hWnd) ...@@ -336,13 +336,13 @@ static void CreateTabCtrl(HWND hWnd)
memset(&tci, 0, sizeof(TCITEM)); memset(&tci, 0, sizeof(TCITEM));
tci.mask = TCIF_TEXT; tci.mask = TCIF_TEXT;
tci.pszText = buffer; tci.pszText = buffer;
tci.cchTextMax = sizeof(WCHAR[MAX_LOAD_STRING]); tci.cchTextMax = sizeof(buffer)/sizeof(buffer[0]);
details.hTab = CreateWindow(WC_TABCONTROL, NULL, WS_CHILD|WS_VISIBLE, details.hTab = CreateWindow(WC_TABCONTROL, NULL, WS_CHILD|WS_VISIBLE,
0, 0, 0, 0, hWnd, (HMENU)TAB_WINDOW, globals.hMainInst, NULL); 0, 0, 0, 0, hWnd, (HMENU)TAB_WINDOW, globals.hMainInst, NULL);
ShowWindow(details.hTab, SW_HIDE); ShowWindow(details.hTab, SW_HIDE);
LoadString(globals.hMainInst, IDS_TAB_REG, buffer, sizeof(WCHAR[MAX_LOAD_STRING])); LoadString(globals.hMainInst, IDS_TAB_REG, buffer, sizeof(buffer)/sizeof(buffer[0]));
SendMessage(details.hTab, TCM_INSERTITEM, 0, (LPARAM)&tci); SendMessage(details.hTab, TCM_INSERTITEM, 0, (LPARAM)&tci);
details.hReg = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, NULL, details.hReg = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, NULL,
......
...@@ -284,9 +284,9 @@ static int MenuCommand(WPARAM wParam, HWND hWnd) ...@@ -284,9 +284,9 @@ static int MenuCommand(WPARAM wParam, HWND hWnd)
{ {
case IDM_ABOUT: case IDM_ABOUT:
LoadString(globals.hMainInst, IDS_ABOUT, wszAbout, LoadString(globals.hMainInst, IDS_ABOUT, wszAbout,
sizeof(WCHAR[MAX_LOAD_STRING])); sizeof(wszAbout)/sizeof(wszAbout[0]));
LoadString(globals.hMainInst, IDS_ABOUTVER, wszAboutVer, LoadString(globals.hMainInst, IDS_ABOUTVER, wszAboutVer,
sizeof(WCHAR[MAX_LOAD_STRING])); sizeof(wszAboutVer)/sizeof(wszAboutVer[0]));
ShellAbout(hWnd, wszAbout, wszAboutVer, NULL); ShellAbout(hWnd, wszAbout, wszAboutVer, NULL);
break; break;
case IDM_COPYCLSID: case IDM_COPYCLSID:
...@@ -403,8 +403,8 @@ static int MenuCommand(WPARAM wParam, HWND hWnd) ...@@ -403,8 +403,8 @@ static int MenuCommand(WPARAM wParam, HWND hWnd)
static WCHAR wszName[MAX_LOAD_STRING]; static WCHAR wszName[MAX_LOAD_STRING];
static WCHAR wszFilter[MAX_LOAD_STRING]; static WCHAR wszFilter[MAX_LOAD_STRING];
LoadString(globals.hMainInst, IDS_OPEN, wszTitle, sizeof(wszTitle)); LoadString(globals.hMainInst, IDS_OPEN, wszTitle, sizeof(wszTitle)/sizeof(wszTitle[0]));
LoadString(globals.hMainInst, IDS_OPEN_TYPELIB_FILTER, wszFilter, sizeof(wszFilter)); LoadString(globals.hMainInst, IDS_OPEN_TYPELIB_FILTER, wszFilter, sizeof(wszFilter)/sizeof(wszFilter[0]));
InitOpenFileName(hWnd, &ofn, wszFilter, wszTitle, wszName); InitOpenFileName(hWnd, &ofn, wszFilter, wszTitle, wszName);
if(GetOpenFileName(&ofn)) CreateTypeLibWindow(globals.hMainInst, wszName); if(GetOpenFileName(&ofn)) CreateTypeLibWindow(globals.hMainInst, wszName);
break; break;
...@@ -425,8 +425,8 @@ static void UpdateStatusBar(int itemID) ...@@ -425,8 +425,8 @@ static void UpdateStatusBar(int itemID)
{ {
WCHAR info[MAX_LOAD_STRING]; WCHAR info[MAX_LOAD_STRING];
if(!LoadString(globals.hMainInst, itemID, info, sizeof(WCHAR[MAX_LOAD_STRING]))) if(!LoadString(globals.hMainInst, itemID, info, sizeof(info)/sizeof(info[0])))
LoadString(globals.hMainInst, IDS_READY, info, sizeof(WCHAR[MAX_LOAD_STRING])); LoadString(globals.hMainInst, IDS_READY, info, sizeof(info)/sizeof(info[0]));
SendMessage(globals.hStatusBar, SB_SETTEXT, 0, (LPARAM)info); SendMessage(globals.hStatusBar, SB_SETTEXT, 0, (LPARAM)info);
} }
...@@ -475,7 +475,7 @@ static BOOL InitApplication(HINSTANCE hInst) ...@@ -475,7 +475,7 @@ static BOOL InitApplication(HINSTANCE hInst)
WNDCLASS wc; WNDCLASS wc;
WCHAR wszAppName[MAX_LOAD_STRING]; WCHAR wszAppName[MAX_LOAD_STRING];
LoadString(hInst, IDS_APPNAME, wszAppName, sizeof(WCHAR[MAX_LOAD_STRING])); LoadString(hInst, IDS_APPNAME, wszAppName, sizeof(wszAppName)/sizeof(wszAppName[0]));
memset(&wc, 0, sizeof(WNDCLASS)); memset(&wc, 0, sizeof(WNDCLASS));
wc.lpfnWndProc = WndProc; wc.lpfnWndProc = WndProc;
...@@ -507,8 +507,8 @@ static BOOL InitInstance(HINSTANCE hInst, int nCmdShow) ...@@ -507,8 +507,8 @@ static BOOL InitInstance(HINSTANCE hInst, int nCmdShow)
{5, IDM_VIEW, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0} {5, IDM_VIEW, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0}
}; };
LoadString(hInst, IDS_APPNAME, wszAppName, sizeof(WCHAR[MAX_LOAD_STRING])); LoadString(hInst, IDS_APPNAME, wszAppName, sizeof(wszAppName)/sizeof(wszAppName[0]));
LoadString(hInst, IDS_APPTITLE, wszTitle, sizeof(WCHAR[MAX_LOAD_STRING])); LoadString(hInst, IDS_APPTITLE, wszTitle, sizeof(wszTitle)/sizeof(wszTitle[0]));
hWnd = CreateWindow(wszAppName, wszTitle, WS_OVERLAPPEDWINDOW, hWnd = CreateWindow(wszAppName, wszTitle, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInst, NULL); CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInst, NULL);
......
...@@ -109,9 +109,9 @@ void CreateInst(HTREEITEM item, WCHAR *wszMachineName) ...@@ -109,9 +109,9 @@ void CreateInst(HTREEITEM item, WCHAR *wszMachineName)
if(FAILED(hRes)) if(FAILED(hRes))
{ {
LoadString(globals.hMainInst, IDS_CGCOFAIL, wszMessage, LoadString(globals.hMainInst, IDS_CGCOFAIL, wszMessage,
sizeof(WCHAR[MAX_LOAD_STRING])); sizeof(wszMessage)/sizeof(wszMessage[0]));
LoadString(globals.hMainInst, IDS_ABOUT, wszTitle, LoadString(globals.hMainInst, IDS_ABOUT, wszTitle,
sizeof(WCHAR[MAX_LOAD_STRING])); sizeof(wszTitle)/sizeof(wszTitle[0]));
#define CASE_ERR(i) case i: \ #define CASE_ERR(i) case i: \
MultiByteToWideChar(CP_ACP, 0, #i, -1, wszFlagName, MAX_LOAD_STRING); \ MultiByteToWideChar(CP_ACP, 0, #i, -1, wszFlagName, MAX_LOAD_STRING); \
...@@ -130,7 +130,7 @@ void CreateInst(HTREEITEM item, WCHAR *wszMachineName) ...@@ -130,7 +130,7 @@ void CreateInst(HTREEITEM item, WCHAR *wszMachineName)
CASE_ERR(CO_E_APPDIDNTREG); CASE_ERR(CO_E_APPDIDNTREG);
CASE_ERR(CLASS_E_CLASSNOTAVAILABLE); CASE_ERR(CLASS_E_CLASSNOTAVAILABLE);
default: default:
LoadString(globals.hMainInst, IDS_ERROR_UNKN, wszFlagName, MAX_LOAD_STRING); LoadString(globals.hMainInst, IDS_ERROR_UNKN, wszFlagName, sizeof(wszFlagName)/sizeof(wszFlagName[0]));
} }
wsprintfW(&wszMessage[lstrlenW(wszMessage)], wszFormat, wsprintfW(&wszMessage[lstrlenW(wszMessage)], wszFormat,
...@@ -419,7 +419,7 @@ static void AddTypeLib(void) ...@@ -419,7 +419,7 @@ static void AddTypeLib(void)
&& *buffer) && *buffer)
{ {
LoadString(globals.hMainInst, IDS_TL_VER, wszVer, LoadString(globals.hMainInst, IDS_TL_VER, wszVer,
sizeof(WCHAR[MAX_LOAD_STRING])); sizeof(wszVer)/sizeof(wszVer[0]));
wsprintfW(&buffer[lstrlenW(buffer)], wszFormat, wszVer, valName); wsprintfW(&buffer[lstrlenW(buffer)], wszFormat, wszVer, valName);
U(tvis).item.pszText = buffer; U(tvis).item.pszText = buffer;
...@@ -550,43 +550,43 @@ static void AddBaseEntries(void) ...@@ -550,43 +550,43 @@ static void AddBaseEntries(void)
tvis.hParent = TVI_ROOT; tvis.hParent = TVI_ROOT;
LoadString(globals.hMainInst, IDS_TREE_I, U(tvis).item.pszText, LoadString(globals.hMainInst, IDS_TREE_I, U(tvis).item.pszText,
sizeof(WCHAR[MAX_LOAD_STRING])); MAX_LOAD_STRING);
U(tvis).item.lParam = CreateITEM_INFO(REGTOP, wszInterface, NULL, NULL); U(tvis).item.lParam = CreateITEM_INFO(REGTOP, wszInterface, NULL, NULL);
tree.hI = TreeView_InsertItem(globals.hTree, &tvis); tree.hI = TreeView_InsertItem(globals.hTree, &tvis);
LoadString(globals.hMainInst, IDS_TREE_TL, U(tvis).item.pszText, LoadString(globals.hMainInst, IDS_TREE_TL, U(tvis).item.pszText,
sizeof(WCHAR[MAX_LOAD_STRING])); MAX_LOAD_STRING);
U(tvis).item.lParam = CreateITEM_INFO(REGTOP, wszTypeLib, NULL, NULL); U(tvis).item.lParam = CreateITEM_INFO(REGTOP, wszTypeLib, NULL, NULL);
tree.hTL = TreeView_InsertItem(globals.hTree, &tvis); tree.hTL = TreeView_InsertItem(globals.hTree, &tvis);
LoadString(globals.hMainInst, IDS_TREE_AID, U(tvis).item.pszText, LoadString(globals.hMainInst, IDS_TREE_AID, U(tvis).item.pszText,
sizeof(WCHAR[MAX_LOAD_STRING])); MAX_LOAD_STRING);
U(tvis).item.lParam = CreateITEM_INFO(REGTOP|REGPATH, wszAppID, NULL, NULL); U(tvis).item.lParam = CreateITEM_INFO(REGTOP|REGPATH, wszAppID, NULL, NULL);
tree.hAID = TreeView_InsertItem(globals.hTree, &tvis); tree.hAID = TreeView_InsertItem(globals.hTree, &tvis);
LoadString(globals.hMainInst, IDS_TREE_OC, U(tvis).item.pszText, LoadString(globals.hMainInst, IDS_TREE_OC, U(tvis).item.pszText,
sizeof(WCHAR[MAX_LOAD_STRING])); MAX_LOAD_STRING);
U(tvis).item.lParam = (LPARAM)NULL; U(tvis).item.lParam = (LPARAM)NULL;
tree.hOC = TreeView_InsertItem(globals.hTree, &tvis); tree.hOC = TreeView_InsertItem(globals.hTree, &tvis);
tvis.hParent = tree.hOC; tvis.hParent = tree.hOC;
LoadString(globals.hMainInst, IDS_TREE_AO, U(tvis).item.pszText, LoadString(globals.hMainInst, IDS_TREE_AO, U(tvis).item.pszText,
sizeof(WCHAR[MAX_LOAD_STRING])); MAX_LOAD_STRING);
U(tvis).item.lParam = CreateITEM_INFO(REGTOP, wszCLSID, NULL, NULL); U(tvis).item.lParam = CreateITEM_INFO(REGTOP, wszCLSID, NULL, NULL);
tree.hAO = TreeView_InsertItem(globals.hTree, &tvis); tree.hAO = TreeView_InsertItem(globals.hTree, &tvis);
LoadString(globals.hMainInst, IDS_TREE_CLO, U(tvis).item.pszText, LoadString(globals.hMainInst, IDS_TREE_CLO, U(tvis).item.pszText,
sizeof(WCHAR[MAX_LOAD_STRING])); MAX_LOAD_STRING);
tree.hCLO = TreeView_InsertItem(globals.hTree, &tvis); tree.hCLO = TreeView_InsertItem(globals.hTree, &tvis);
LoadString(globals.hMainInst, IDS_TREE_O1O, U(tvis).item.pszText, LoadString(globals.hMainInst, IDS_TREE_O1O, U(tvis).item.pszText,
sizeof(WCHAR[MAX_LOAD_STRING])); MAX_LOAD_STRING);
U(tvis).item.lParam = (LPARAM)NULL; U(tvis).item.lParam = (LPARAM)NULL;
tree.hO1O = TreeView_InsertItem(globals.hTree, &tvis); tree.hO1O = TreeView_InsertItem(globals.hTree, &tvis);
LoadString(globals.hMainInst, IDS_TREE_GBCC, U(tvis).item.pszText, LoadString(globals.hMainInst, IDS_TREE_GBCC, U(tvis).item.pszText,
sizeof(WCHAR[MAX_LOAD_STRING])); MAX_LOAD_STRING);
U(tvis).item.lParam = CreateITEM_INFO(REGTOP|REGPATH, U(tvis).item.lParam = CreateITEM_INFO(REGTOP|REGPATH,
wszComponentCategories, NULL, NULL); wszComponentCategories, NULL, NULL);
tree.hGBCC = TreeView_InsertItem(globals.hTree, &tvis); tree.hGBCC = TreeView_InsertItem(globals.hTree, &tvis);
......
...@@ -105,7 +105,7 @@ static void ShowLastError(void) ...@@ -105,7 +105,7 @@ static void ShowLastError(void)
WCHAR wszTitle[MAX_LOAD_STRING]; WCHAR wszTitle[MAX_LOAD_STRING];
LoadString(globals.hMainInst, IDS_TYPELIBTITLE, wszTitle, LoadString(globals.hMainInst, IDS_TYPELIBTITLE, wszTitle,
sizeof(WCHAR[MAX_LOAD_STRING])); sizeof(wszTitle)/sizeof(wszTitle[0]));
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL, error, 0, (LPTSTR) &lpMsgBuf, 0, NULL); NULL, error, 0, (LPTSTR) &lpMsgBuf, 0, NULL);
MessageBox(NULL, lpMsgBuf, wszTitle, MB_OK | MB_ICONERROR); MessageBox(NULL, lpMsgBuf, wszTitle, MB_OK | MB_ICONERROR);
...@@ -731,7 +731,7 @@ static int EnumImplTypes(ITypeInfo *pTypeInfo, int cImplTypes, HTREEITEM hParent ...@@ -731,7 +731,7 @@ static int EnumImplTypes(ITypeInfo *pTypeInfo, int cImplTypes, HTREEITEM hParent
if(!cImplTypes) return 0; if(!cImplTypes) return 0;
LoadString(globals.hMainInst, IDS_INHERITINTERFACES, wszInheritedInterfaces, LoadString(globals.hMainInst, IDS_INHERITINTERFACES, wszInheritedInterfaces,
sizeof(WCHAR[MAX_LOAD_STRING])); sizeof(wszInheritedInterfaces)/sizeof(wszInheritedInterfaces[0]));
U(tvis).item.mask = TVIF_TEXT; U(tvis).item.mask = TVIF_TEXT;
U(tvis).item.cchTextMax = MAX_LOAD_STRING; U(tvis).item.cchTextMax = MAX_LOAD_STRING;
...@@ -1191,7 +1191,7 @@ static int PopulateTree(void) ...@@ -1191,7 +1191,7 @@ static int PopulateTree(void)
WCHAR wszError[MAX_LOAD_STRING]; WCHAR wszError[MAX_LOAD_STRING];
LoadString(globals.hMainInst, IDS_ERROR_LOADTYPELIB, LoadString(globals.hMainInst, IDS_ERROR_LOADTYPELIB,
wszError, sizeof(WCHAR[MAX_LOAD_STRING])); wszError, sizeof(wszError)/sizeof(wszError[0]));
wsprintfW(wszMessage, wszError, typelib.wszFileName, hRes); wsprintfW(wszMessage, wszError, typelib.wszFileName, hRes);
MessageBox(globals.hMainWnd, wszMessage, NULL, MB_OK|MB_ICONEXCLAMATION); MessageBox(globals.hMainWnd, wszMessage, NULL, MB_OK|MB_ICONEXCLAMATION);
return 1; return 1;
...@@ -1516,8 +1516,8 @@ static void UpdateTypeLibStatusBar(int itemID) ...@@ -1516,8 +1516,8 @@ static void UpdateTypeLibStatusBar(int itemID)
{ {
WCHAR info[MAX_LOAD_STRING]; WCHAR info[MAX_LOAD_STRING];
if(!LoadString(globals.hMainInst, itemID, info, sizeof(WCHAR[MAX_LOAD_STRING]))) if(!LoadString(globals.hMainInst, itemID, info, sizeof(info)/sizeof(info[0])))
LoadString(globals.hMainInst, IDS_READY, info, sizeof(WCHAR[MAX_LOAD_STRING])); LoadString(globals.hMainInst, IDS_READY, info, sizeof(info)/sizeof(info[0]));
SendMessage(typelib.hStatusBar, SB_SETTEXT, 0, (LPARAM)info); SendMessage(typelib.hStatusBar, SB_SETTEXT, 0, (LPARAM)info);
} }
...@@ -1615,7 +1615,7 @@ BOOL TypeLibRegisterClass(void) ...@@ -1615,7 +1615,7 @@ BOOL TypeLibRegisterClass(void)
BOOL CreateTypeLibWindow(HINSTANCE hInst, WCHAR *wszFileName) BOOL CreateTypeLibWindow(HINSTANCE hInst, WCHAR *wszFileName)
{ {
WCHAR wszTitle[MAX_LOAD_STRING]; WCHAR wszTitle[MAX_LOAD_STRING];
LoadString(hInst, IDS_TYPELIBTITLE, wszTitle, sizeof(WCHAR[MAX_LOAD_STRING])); LoadString(hInst, IDS_TYPELIBTITLE, wszTitle, sizeof(wszTitle)/sizeof(wszTitle[0]));
if(wszFileName) lstrcpyW(typelib.wszFileName, wszFileName); if(wszFileName) lstrcpyW(typelib.wszFileName, wszFileName);
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment