Commit 2ce0e940 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

winedbg, winedump: Embed wine build-id information info minidump, and display it.

parent 2505dfcc
...@@ -615,11 +615,29 @@ static unsigned dump_system_info(struct dump_context* dc) ...@@ -615,11 +615,29 @@ static unsigned dump_system_info(struct dump_context* dc)
OSVERSIONINFOW osInfo; OSVERSIONINFOW osInfo;
DWORD written; DWORD written;
ULONG slen; ULONG slen;
DWORD wine_extra = 0;
const char *(CDECL *wine_get_build_id)(void);
void (CDECL *wine_get_host_version)(const char **sysname, const char **release);
const char* build_id = NULL;
const char* sys_name = NULL;
const char* release_name = NULL;
GetSystemInfo(&sysInfo); GetSystemInfo(&sysInfo);
osInfo.dwOSVersionInfoSize = sizeof(osInfo); osInfo.dwOSVersionInfoSize = sizeof(osInfo);
GetVersionExW(&osInfo); GetVersionExW(&osInfo);
wine_get_build_id = (void *)GetProcAddress(GetModuleHandleA("ntdll.dll"), "wine_get_build_id");
wine_get_host_version = (void *)GetProcAddress(GetModuleHandleA("ntdll.dll"), "wine_get_host_version");
if (wine_get_build_id && wine_get_host_version)
{
/* cheat minidump system information by adding specific wine information */
wine_extra = 4 + 4 * sizeof(slen);
build_id = wine_get_build_id();
wine_get_host_version(&sys_name, &release_name);
wine_extra += strlen(build_id) + 1 + strlen(sys_name) + 1 + strlen(release_name) + 1;
}
mdSysInfo.ProcessorArchitecture = sysInfo.u.s.wProcessorArchitecture; mdSysInfo.ProcessorArchitecture = sysInfo.u.s.wProcessorArchitecture;
mdSysInfo.ProcessorLevel = sysInfo.wProcessorLevel; mdSysInfo.ProcessorLevel = sysInfo.wProcessorLevel;
mdSysInfo.ProcessorRevision = sysInfo.wProcessorRevision; mdSysInfo.ProcessorRevision = sysInfo.wProcessorRevision;
...@@ -630,7 +648,7 @@ static unsigned dump_system_info(struct dump_context* dc) ...@@ -630,7 +648,7 @@ static unsigned dump_system_info(struct dump_context* dc)
mdSysInfo.BuildNumber = osInfo.dwBuildNumber; mdSysInfo.BuildNumber = osInfo.dwBuildNumber;
mdSysInfo.PlatformId = osInfo.dwPlatformId; mdSysInfo.PlatformId = osInfo.dwPlatformId;
mdSysInfo.CSDVersionRva = dc->rva + sizeof(mdSysInfo); mdSysInfo.CSDVersionRva = dc->rva + sizeof(mdSysInfo) + wine_extra;
mdSysInfo.u1.Reserved1 = 0; mdSysInfo.u1.Reserved1 = 0;
mdSysInfo.u1.s.SuiteMask = VER_SUITE_TERMINAL; mdSysInfo.u1.s.SuiteMask = VER_SUITE_TERMINAL;
...@@ -672,6 +690,28 @@ static unsigned dump_system_info(struct dump_context* dc) ...@@ -672,6 +690,28 @@ static unsigned dump_system_info(struct dump_context* dc)
} }
append(dc, &mdSysInfo, sizeof(mdSysInfo)); append(dc, &mdSysInfo, sizeof(mdSysInfo));
/* write Wine specific system information just behind the structure, and before any string */
if (wine_extra)
{
char code[] = {'W','I','N','E'};
WriteFile(dc->hFile, code, 4, &written, NULL);
/* number of sub-info, so that we can extend structure if needed */
slen = 3;
WriteFile(dc->hFile, &slen, sizeof(slen), &written, NULL);
/* we store offsets from just after the WINE marker */
slen = 4 * sizeof(DWORD);
WriteFile(dc->hFile, &slen, sizeof(slen), &written, NULL);
slen += strlen(build_id) + 1;
WriteFile(dc->hFile, &slen, sizeof(slen), &written, NULL);
slen += strlen(sys_name) + 1;
WriteFile(dc->hFile, &slen, sizeof(slen), &written, NULL);
WriteFile(dc->hFile, build_id, strlen(build_id) + 1, &written, NULL);
WriteFile(dc->hFile, sys_name, strlen(sys_name) + 1, &written, NULL);
WriteFile(dc->hFile, release_name, strlen(release_name) + 1, &written, NULL);
dc->rva += wine_extra;
}
/* write the service pack version string after this stream. It is referenced within the /* write the service pack version string after this stream. It is referenced within the
stream by its RVA in the file. */ stream by its RVA in the file. */
slen = lstrlenW(osInfo.szCSDVersion) * sizeof(WCHAR); slen = lstrlenW(osInfo.szCSDVersion) * sizeof(WCHAR);
......
...@@ -174,6 +174,7 @@ static enum dbg_start minidump_do_reload(struct tgt_process_minidump_data* data) ...@@ -174,6 +174,7 @@ static enum dbg_start minidump_do_reload(struct tgt_process_minidump_data* data)
MINIDUMP_MODULE_LIST* mml; MINIDUMP_MODULE_LIST* mml;
MINIDUMP_MODULE* mm; MINIDUMP_MODULE* mm;
MINIDUMP_STRING* mds; MINIDUMP_STRING* mds;
MINIDUMP_DIRECTORY* dir;
WCHAR exec_name[1024]; WCHAR exec_name[1024];
WCHAR nameW[1024]; WCHAR nameW[1024];
unsigned len; unsigned len;
...@@ -212,7 +213,7 @@ static enum dbg_start minidump_do_reload(struct tgt_process_minidump_data* data) ...@@ -212,7 +213,7 @@ static enum dbg_start minidump_do_reload(struct tgt_process_minidump_data* data)
} }
} }
if (MiniDumpReadDumpStream(data->mapping, SystemInfoStream, NULL, &stream, NULL)) if (MiniDumpReadDumpStream(data->mapping, SystemInfoStream, &dir, &stream, NULL))
{ {
MINIDUMP_SYSTEM_INFO* msi = stream; MINIDUMP_SYSTEM_INFO* msi = stream;
const char *str; const char *str;
...@@ -305,6 +306,21 @@ static enum dbg_start minidump_do_reload(struct tgt_process_minidump_data* data) ...@@ -305,6 +306,21 @@ static enum dbg_start minidump_do_reload(struct tgt_process_minidump_data* data)
} }
dbg_printf(" on Windows %s (%u)\n", str, msi->BuildNumber); dbg_printf(" on Windows %s (%u)\n", str, msi->BuildNumber);
/* FIXME CSD: msi->CSDVersionRva */ /* FIXME CSD: msi->CSDVersionRva */
if (sizeof(MINIDUMP_SYSTEM_INFO) + 4 > dir->Location.DataSize &&
msi->CSDVersionRva >= dir->Location.Rva + sizeof(MINIDUMP_SYSTEM_INFO) + 4)
{
const char* code = (const char*)stream + sizeof(MINIDUMP_SYSTEM_INFO);
const DWORD* wes;
if (code[0] == 'W' && code[1] == 'I' && code[2] == 'N' && code[3] == 'E' &&
*(wes = (const DWORD*)(code += 4)) >= 3)
{
/* assume we have wine extensions */
dbg_printf(" [on %s, on top of %s (%s)]\n",
code + wes[1], code + wes[2], code + wes[3]);
}
}
} }
dbg_curr_process = dbg_add_process(&be_process_minidump_io, pid, hProc); dbg_curr_process = dbg_add_process(&be_process_minidump_io, pid, hProc);
......
...@@ -341,6 +341,21 @@ void mdmp_dump(void) ...@@ -341,6 +341,21 @@ void mdmp_dump(void)
printf(" x86.AMDExtendedCpuFeatures: %x\n", printf(" x86.AMDExtendedCpuFeatures: %x\n",
msi->Cpu.X86CpuInfo.AMDExtendedCpuFeatures); msi->Cpu.X86CpuInfo.AMDExtendedCpuFeatures);
} }
if (sizeof(MINIDUMP_SYSTEM_INFO) + 4 > dir->Location.DataSize &&
msi->CSDVersionRva >= dir->Location.Rva + 4)
{
const char* code = PRD(dir->Location.Rva + sizeof(MINIDUMP_SYSTEM_INFO), 4);
const DWORD* wes;
if (code && code[0] == 'W' && code[1] == 'I' && code[2] == 'N' && code[3] == 'E' &&
*(wes = (const DWORD*)(code += 4)) >= 3)
{
/* assume we have wine extensions */
printf(" Wine details:\n");
printf(" build-id: %s\n", code + wes[1]);
printf(" system: %s\n", code + wes[2]);
printf(" release: %s\n", code + wes[3]);
}
}
} }
break; break;
case MiscInfoStream: case MiscInfoStream:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment