It seems to be GetModuleFileName16 that checks exe version on whether
to return long or short paths, not GetModuleFileNameA.
diff --git a/loader/module.c b/loader/module.c
index 53ea615..bac3f6a 100644
--- a/loader/module.c
+++ b/loader/module.c
@@ -1296,6 +1296,11 @@
/***********************************************************************
* GetModuleFileNameA (KERNEL32.235)
+ *
+ * GetModuleFileNameA seems to *always* return the long path;
+ * it's only GetModuleFileName16 that decides between short/long path
+ * by checking if exe version >= 4.0.
+ * (SDK docu doesn't mention this)
*/
DWORD WINAPI GetModuleFileNameA(
HMODULE hModule, /* [in] module handle (32bit) */
@@ -1307,10 +1312,7 @@
if (!wm) /* can happen on start up or the like */
return 0;
- if (PE_HEADER(wm->module)->OptionalHeader.MajorOperatingSystemVersion >= 4.0)
- lstrcpynA( lpFileName, wm->filename, size );
- else
- lstrcpynA( lpFileName, wm->short_filename, size );
+ lstrcpynA( lpFileName, wm->filename, size );
TRACE("%s\n", lpFileName );
return strlen(lpFileName);
diff --git a/loader/ne/module.c b/loader/ne/module.c
index 38c5bf3..5a02442 100644
--- a/loader/ne/module.c
+++ b/loader/ne/module.c
@@ -1388,6 +1388,8 @@
/**********************************************************************
* GetModuleFileName16 (KERNEL.49)
+ *
+ * Comment: see GetModuleFileNameA
*/
INT16 WINAPI GetModuleFileName16( HINSTANCE16 hModule, LPSTR lpFileName,
INT16 nSize )
@@ -1396,7 +1398,10 @@
if (!hModule) hModule = GetCurrentTask();
if (!(pModule = NE_GetPtr( hModule ))) return 0;
- lstrcpynA( lpFileName, NE_MODULE_NAME(pModule), nSize );
+ if (pModule->expected_version >= 0x400)
+ GetLongPathNameA(NE_MODULE_NAME(pModule), lpFileName, nSize);
+ else
+ lstrcpynA( lpFileName, NE_MODULE_NAME(pModule), nSize );
TRACE("%s\n", lpFileName );
return strlen(lpFileName);
}