@@ -17,7 +17,7 @@ namespace version
1717 for (const auto component : mapistub::g_pszOutlookQualifiedComponents)
1818 {
1919 auto b64 = false ;
20- auto lpszTempPath = mapistub::GetOutlookPath (component, &b64 );
20+ auto lpszTempPath = mapistub::GetOLMAPI32Path (component);
2121
2222 if (!lpszTempPath.empty ())
2323 {
@@ -34,6 +34,8 @@ namespace version
3434 {
3535 szOut = strings::formatmessage (
3636 IDS_OUTLOOKVERSIONSTRING, lpszTempPath.c_str (), lpszTempVer.c_str (), lpszTempLang.c_str ());
37+ b64 = Is64BitModule (lpszTempPath);
38+
3739 szOut += strings::formatmessage (b64 ? IDS_TRUE : IDS_FALSE);
3840 szOut += L" \n " ; // STRING_OK
3941 }
@@ -194,4 +196,71 @@ namespace version
194196
195197 return szVersionString;
196198 }
199+
200+ bool Is64BitModule (const std::wstring& modulePath)
201+ {
202+ if (modulePath.empty ()) return false ;
203+
204+ const auto hFile = CreateFileW (
205+ modulePath.c_str (), GENERIC_READ, FILE_SHARE_READ, nullptr , OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr );
206+
207+ if (hFile == INVALID_HANDLE_VALUE)
208+ {
209+ output::DebugPrint (
210+ output::dbgLevel::Generic, L" Is64BitModule: Failed to open file %ws\n " , modulePath.c_str ());
211+ return false ;
212+ }
213+
214+ // Read DOS header
215+ IMAGE_DOS_HEADER dosHeader = {};
216+ DWORD bytesRead = 0 ;
217+ if (!ReadFile (hFile, &dosHeader, sizeof (dosHeader), &bytesRead, nullptr ) || bytesRead != sizeof (dosHeader) ||
218+ dosHeader.e_magic != IMAGE_DOS_SIGNATURE)
219+ {
220+ CloseHandle (hFile);
221+ return false ;
222+ }
223+
224+ // Seek to PE header
225+ if (SetFilePointer (hFile, dosHeader.e_lfanew , nullptr , FILE_BEGIN) == INVALID_SET_FILE_POINTER)
226+ {
227+ CloseHandle (hFile);
228+ return false ;
229+ }
230+
231+ // Read PE signature
232+ DWORD peSignature = 0 ;
233+ if (!ReadFile (hFile, &peSignature, sizeof (peSignature), &bytesRead, nullptr ) ||
234+ bytesRead != sizeof (peSignature) || peSignature != IMAGE_NT_SIGNATURE)
235+ {
236+ CloseHandle (hFile);
237+ return false ;
238+ }
239+
240+ // Read file header to get machine type
241+ IMAGE_FILE_HEADER fileHeader = {};
242+ if (!ReadFile (hFile, &fileHeader, sizeof (fileHeader), &bytesRead, nullptr ) || bytesRead != sizeof (fileHeader))
243+ {
244+ CloseHandle (hFile);
245+ return false ;
246+ }
247+
248+ CloseHandle (hFile);
249+
250+ // Check machine type to determine if it's 64-bit
251+ switch (fileHeader.Machine )
252+ {
253+ case IMAGE_FILE_MACHINE_AMD64:
254+ case IMAGE_FILE_MACHINE_IA64:
255+ case IMAGE_FILE_MACHINE_ARM64:
256+ return true ;
257+ case IMAGE_FILE_MACHINE_I386:
258+ case IMAGE_FILE_MACHINE_ARM:
259+ case IMAGE_FILE_MACHINE_ARMNT:
260+ return false ;
261+ default :
262+ // Unknown architecture, assume 32-bit
263+ return false ;
264+ }
265+ }
197266} // namespace version
0 commit comments