X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fxml_windows.c;h=a88c56485e050163411d29c0698979541a17fcf5;hb=088dff37aa334c218e1cac96cc847f5dd14f7124;hp=12cc922f7a7f0aa38d9b53930dbd01491459cf12;hpb=f7eef564a0b927f289f964bef77fbdb935fd6f27;p=wimlib diff --git a/src/xml_windows.c b/src/xml_windows.c index 12cc922f..a88c5648 100644 --- a/src/xml_windows.c +++ b/src/xml_windows.c @@ -405,7 +405,7 @@ set_info_from_kernel32(struct windows_info_ctx *ctx, goto invalid; pe_hdr = (u8 *)contents + e_lfanew; - if (*(u32 *)pe_hdr != cpu_to_le32(0x00004550)) /* "PE\0\0" */ + if (*(le32 *)pe_hdr != cpu_to_le32(0x00004550)) /* "PE\0\0" */ goto invalid; pe_arch = le16_to_cpu(*(le16 *)(pe_hdr + 4)); @@ -432,6 +432,7 @@ set_info_from_software_hive(struct windows_info_ctx *ctx, s64 major_version = -1; s64 minor_version = -1; tchar *version_string; + tchar *build_string; /* Image flags */ copy_registry_string(ctx, regf, version_key, T("EditionID"), @@ -494,8 +495,28 @@ set_info_from_software_hive(struct windows_info_ctx *ctx, } /* Build number */ - copy_registry_string(ctx, regf, version_key, T("CurrentBuild"), - T("WINDOWS/VERSION/BUILD")); + + /* Note: "CurrentBuild" is marked as obsolete in Windows XP registries + * (example value: "1.511.1 () (Obsolete data - do not use)"), and + * "CurrentBuildNumber" contains the correct value. But oddly enough, + * it is "CurrentBuild" that contains the correct value on *later* + * versions of Windows. */ + if (get_string_from_registry(ctx, regf, version_key, T("CurrentBuild"), + &build_string)) + { + if (tstrchr(build_string, T('.'))) { + FREE(build_string); + build_string = NULL; + get_string_from_registry(ctx, regf, version_key, + T("CurrentBuildNumber"), + &build_string); + } + if (build_string) { + set_string_property(ctx, T("WINDOWS/VERSION/BUILD"), + build_string); + FREE(build_string); + } + } } /* Gather the default language from the SYSTEM registry hive. */