Skip to content

Commit 8aa8ffc

Browse files
committed
Fix error codes
1 parent 7bc87f5 commit 8aa8ffc

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

msi-interop/file_utils.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
#define ERROR_FILE_NOT_FOUND 2L
2020
#endif
2121

22+
#ifndef ERROR_FILE_INVALID
23+
#define ERROR_FILE_INVALID 1006L
24+
#endif
25+
2226
#ifndef ERROR_OPEN_FAILED
2327
#define ERROR_OPEN_FAILED 110L
2428
#endif
@@ -271,9 +275,7 @@ MSI_INTEROP_EXPORT UINT WINAPI MsiGetFileVersionA(LPCSTR szFilePath, LPSTR lpVer
271275
/* Check for MZ signature */
272276
if (!is_pe_file(data, length)) {
273277
g_free(contents);
274-
/* Not a PE file -- return empty version info via ERROR_FILE_NOT_FOUND
275-
* which matches Windows behavior for non-PE files */
276-
return ERROR_FILE_NOT_FOUND;
278+
return ERROR_FILE_INVALID;
277279
}
278280

279281
/* Try to find VS_FIXEDFILEINFO */
@@ -282,10 +284,7 @@ MSI_INTEROP_EXPORT UINT WINAPI MsiGetFileVersionA(LPCSTR szFilePath, LPSTR lpVer
282284

283285
if (!found_version) {
284286
g_free(contents);
285-
/* The file is a PE but has no version info. Return empty strings
286-
* if buffers are provided; this matches the Windows behavior of
287-
* returning ERROR_FILE_NOT_FOUND for files without version resources. */
288-
return ERROR_FILE_NOT_FOUND;
287+
return ERROR_FILE_INVALID;
289288
}
290289

291290
/* Format the version string */
@@ -351,7 +350,7 @@ MSI_INTEROP_EXPORT UINT WINAPI MsiGetFileVersionW(LPCWSTR szFilePath, LPWSTR lpV
351350
/* Check for MZ signature */
352351
if (!is_pe_file(data, length)) {
353352
g_free(contents);
354-
return ERROR_FILE_NOT_FOUND;
353+
return ERROR_FILE_INVALID;
355354
}
356355

357356
/* Try to find VS_FIXEDFILEINFO */
@@ -360,7 +359,7 @@ MSI_INTEROP_EXPORT UINT WINAPI MsiGetFileVersionW(LPCWSTR szFilePath, LPWSTR lpV
360359

361360
if (!found_version) {
362361
g_free(contents);
363-
return ERROR_FILE_NOT_FOUND;
362+
return ERROR_FILE_INVALID;
364363
}
365364

366365
/* Format the version string */

0 commit comments

Comments
 (0)