CVS: winex/dlls/shlwapi ordinal.c,1.7,1.8
[email protected] 1 Aug 2007 12:29:55 -0000
| Newsgroups | gmane.comp.emulators.winex.cvs |
|---|---|
| Message-ID | <[email protected]> |
Subject: winex/dlls/shlwapi ordinal.c,1.7,1.8Update of /var/lib/cvsd/cvsroot/winex/dlls/shlwapi
In directory agravaine:/tmp/cvs-serv28822/dlls/shlwapi
Modified Files:
ordinal.c
Log Message:
- fixed GetModuleFileNameA() to properly return a truncated filename error code. GetModuleFileNameW() just calls GetModuleFileNameA(), so its error codes should be updated as well.
- fixed all the calls to GetModuleFileNameA/W() to check for small buffer and bad module errors. Currently small buffer errors are just reported and are allowed to proceed with either an empty string or truncated string for the filename. In the case of an error retrieving the module filename (error == 0), the calling function reports the error and returns immediately.
Index: ordinal.c
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/dlls/shlwapi/ordinal.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- ordinal.c 27 Mar 2007 20:08:26 -0000 1.7
+++ ordinal.c 1 Aug 2007 12:29:53 -0000 1.8
@@ -2055,15 +2055,28 @@
*/
DWORD WINAPI SHLWAPI_377 (LPCSTR new_mod, HMODULE inst_hwnd, LPVOID z)
{
- CHAR mod_path[2*MAX_PATH];
- LPSTR ptr;
+ CHAR mod_path[2*MAX_PATH];
+ LPSTR ptr;
+ DWORD error;
+
+
+ error = GetModuleFileNameA(inst_hwnd, mod_path, 2*MAX_PATH);
+
+ if (error == 2 * MAX_PATH)
+ ERR("the buffer for GetModuleFileName() is too small!\n");
+
+ else if (error == 0){
+ ERR("could not retrieve the module filename for 0x%lx\n", inst_hwnd);
+
+ return 0;
+ }
+
- GetModuleFileNameA(inst_hwnd, mod_path, 2*MAX_PATH);
ptr = strrchr(mod_path, '\\');
if (ptr) {
- strcpy(ptr+1, new_mod);
- TRACE("loading %s\n", debugstr_a(mod_path));
- return (DWORD)LoadLibraryA(mod_path);
+ strcpy(ptr+1, new_mod);
+ TRACE("loading %s\n", debugstr_a(mod_path));
+ return (DWORD)LoadLibraryA(mod_path);
}
return 0;
}
@@ -2078,15 +2091,27 @@
HMODULE inst_hwnd, /* [in] calling module handle */
LPVOID z) /* [???] 4 */
{
- WCHAR mod_path[2*MAX_PATH];
- LPWSTR ptr;
+ WCHAR mod_path[2*MAX_PATH];
+ LPWSTR ptr;
+ DWORD error;
+
+ error = GetModuleFileNameW(inst_hwnd, mod_path, 2*MAX_PATH);
+
+ if (error == 2 * MAX_PATH)
+ ERR("the buffer for GetModuleFileName() is too small!\n");
+
+ else if (error == 0){
+ ERR("could not retrieve the filename of module 0x%lx\n", inst_hwnd);
+
+ return 0;
+ }
+
- GetModuleFileNameW(inst_hwnd, mod_path, 2*MAX_PATH);
ptr = strrchrW(mod_path, '\\');
if (ptr) {
- strcpyW(ptr+1, new_mod);
- TRACE("loading %s\n", debugstr_w(mod_path));
- return (DWORD)LoadLibraryW(mod_path);
+ strcpyW(ptr+1, new_mod);
+ TRACE("loading %s\n", debugstr_w(mod_path));
+ return (DWORD)LoadLibraryW(mod_path);
}
return 0;
}