2004-04-06 00:21:27 +02:00
|
|
|
/*
|
|
|
|
* File minidump.c - management of dumps (read & write)
|
|
|
|
*
|
2005-03-29 15:14:08 +02:00
|
|
|
* Copyright (C) 2004-2005, Eric Pouech
|
2004-04-06 00:21:27 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-04-06 00:21:27 +02:00
|
|
|
*/
|
|
|
|
|
2018-11-28 02:29:44 +01:00
|
|
|
#include "config.h"
|
2004-04-06 00:21:27 +02:00
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
#define NONAMELESSUNION
|
|
|
|
#define NONAMELESSSTRUCT
|
|
|
|
|
2005-03-07 12:03:21 +01:00
|
|
|
#include "ntstatus.h"
|
2005-11-28 17:32:54 +01:00
|
|
|
#define WIN32_NO_STATUS
|
|
|
|
#include "dbghelp_private.h"
|
2005-03-07 12:03:21 +01:00
|
|
|
#include "winternl.h"
|
|
|
|
#include "psapi.h"
|
2004-04-06 00:21:27 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
|
|
|
|
|
2005-03-07 12:03:21 +01:00
|
|
|
/******************************************************************
|
2012-01-23 21:37:05 +01:00
|
|
|
* fetch_process_info
|
2005-03-07 12:03:21 +01:00
|
|
|
*
|
2012-01-23 21:37:05 +01:00
|
|
|
* reads system wide process information, and gather from it the threads information
|
2005-03-07 12:03:21 +01:00
|
|
|
* for process of id 'pid'
|
|
|
|
*/
|
2012-01-23 21:37:05 +01:00
|
|
|
static BOOL fetch_process_info(struct dump_context* dc)
|
2005-03-07 12:03:21 +01:00
|
|
|
{
|
|
|
|
ULONG buf_size = 0x1000;
|
|
|
|
NTSTATUS nts;
|
2012-01-23 21:37:05 +01:00
|
|
|
void* pcs_buffer = NULL;
|
2005-03-07 12:03:21 +01:00
|
|
|
|
2012-01-23 21:37:05 +01:00
|
|
|
if (!(pcs_buffer = HeapAlloc(GetProcessHeap(), 0, buf_size))) return FALSE;
|
2005-03-07 12:03:21 +01:00
|
|
|
for (;;)
|
|
|
|
{
|
2012-01-23 21:37:05 +01:00
|
|
|
nts = NtQuerySystemInformation(SystemProcessInformation,
|
|
|
|
pcs_buffer, buf_size, NULL);
|
2005-03-07 12:03:21 +01:00
|
|
|
if (nts != STATUS_INFO_LENGTH_MISMATCH) break;
|
2012-01-23 21:37:05 +01:00
|
|
|
pcs_buffer = HeapReAlloc(GetProcessHeap(), 0, pcs_buffer, buf_size *= 2);
|
|
|
|
if (!pcs_buffer) return FALSE;
|
2005-03-07 12:03:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (nts == STATUS_SUCCESS)
|
|
|
|
{
|
2012-01-23 21:37:05 +01:00
|
|
|
SYSTEM_PROCESS_INFORMATION* spi = pcs_buffer;
|
|
|
|
unsigned i;
|
|
|
|
|
2005-03-07 12:03:21 +01:00
|
|
|
for (;;)
|
|
|
|
{
|
2012-01-23 21:37:05 +01:00
|
|
|
if (HandleToUlong(spi->UniqueProcessId) == dc->pid)
|
|
|
|
{
|
|
|
|
dc->num_threads = spi->dwThreadCount;
|
|
|
|
dc->threads = HeapAlloc(GetProcessHeap(), 0,
|
|
|
|
dc->num_threads * sizeof(dc->threads[0]));
|
|
|
|
if (!dc->threads) goto failed;
|
|
|
|
for (i = 0; i < dc->num_threads; i++)
|
|
|
|
{
|
|
|
|
dc->threads[i].tid = HandleToULong(spi->ti[i].ClientId.UniqueThread);
|
|
|
|
dc->threads[i].prio_class = spi->ti[i].dwBasePriority; /* FIXME */
|
|
|
|
dc->threads[i].curr_prio = spi->ti[i].dwCurrentPriority;
|
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, pcs_buffer);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
if (!spi->NextEntryOffset) break;
|
|
|
|
spi = (SYSTEM_PROCESS_INFORMATION*)((char*)spi + spi->NextEntryOffset);
|
2005-03-07 12:03:21 +01:00
|
|
|
}
|
|
|
|
}
|
2012-01-23 21:37:05 +01:00
|
|
|
failed:
|
|
|
|
HeapFree(GetProcessHeap(), 0, pcs_buffer);
|
2005-03-07 12:03:21 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2007-04-18 00:19:45 +02:00
|
|
|
static void fetch_thread_stack(struct dump_context* dc, const void* teb_addr,
|
2007-02-19 23:09:24 +01:00
|
|
|
const CONTEXT* ctx, MINIDUMP_MEMORY_DESCRIPTOR* mmd)
|
|
|
|
{
|
|
|
|
NT_TIB tib;
|
2009-12-22 14:21:37 +01:00
|
|
|
ADDRESS64 addr;
|
2007-02-19 23:09:24 +01:00
|
|
|
|
2009-12-22 14:21:37 +01:00
|
|
|
if (ReadProcessMemory(dc->hProcess, teb_addr, &tib, sizeof(tib), NULL) &&
|
|
|
|
dbghelp_current_cpu &&
|
|
|
|
dbghelp_current_cpu->get_addr(NULL /* FIXME */, ctx, cpu_addr_stack, &addr) && addr.Mode == AddrModeFlat)
|
2007-02-19 23:09:24 +01:00
|
|
|
{
|
2009-12-22 14:21:37 +01:00
|
|
|
if (addr.Offset)
|
|
|
|
{
|
|
|
|
addr.Offset -= dbghelp_current_cpu->word_size;
|
|
|
|
/* make sure stack pointer is within the established range of the stack. It could have
|
2008-01-17 23:31:49 +01:00
|
|
|
been clobbered by whatever caused the original exception. */
|
2009-12-22 14:21:37 +01:00
|
|
|
if (addr.Offset < (ULONG_PTR)tib.StackLimit || addr.Offset > (ULONG_PTR)tib.StackBase)
|
2008-01-17 23:31:49 +01:00
|
|
|
mmd->StartOfMemoryRange = (ULONG_PTR)tib.StackLimit;
|
|
|
|
|
|
|
|
else
|
2009-12-22 14:21:37 +01:00
|
|
|
mmd->StartOfMemoryRange = addr.Offset;
|
2008-01-17 23:31:49 +01:00
|
|
|
}
|
2007-02-19 23:09:24 +01:00
|
|
|
else
|
|
|
|
mmd->StartOfMemoryRange = (ULONG_PTR)tib.StackLimit;
|
|
|
|
mmd->Memory.DataSize = (ULONG_PTR)tib.StackBase - mmd->StartOfMemoryRange;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-03-07 12:03:21 +01:00
|
|
|
/******************************************************************
|
|
|
|
* fetch_thread_info
|
|
|
|
*
|
|
|
|
* fetches some information about thread of id 'tid'
|
|
|
|
*/
|
|
|
|
static BOOL fetch_thread_info(struct dump_context* dc, int thd_idx,
|
2007-02-19 23:09:24 +01:00
|
|
|
const MINIDUMP_EXCEPTION_INFORMATION* except,
|
2005-03-07 12:03:21 +01:00
|
|
|
MINIDUMP_THREAD* mdThd, CONTEXT* ctx)
|
|
|
|
{
|
2012-01-23 21:37:05 +01:00
|
|
|
DWORD tid = dc->threads[thd_idx].tid;
|
2005-03-07 12:03:21 +01:00
|
|
|
HANDLE hThread;
|
|
|
|
THREAD_BASIC_INFORMATION tbi;
|
|
|
|
|
|
|
|
memset(ctx, 0, sizeof(*ctx));
|
|
|
|
|
2009-01-03 14:54:11 +01:00
|
|
|
mdThd->ThreadId = tid;
|
2005-03-07 12:03:21 +01:00
|
|
|
mdThd->SuspendCount = 0;
|
|
|
|
mdThd->Teb = 0;
|
|
|
|
mdThd->Stack.StartOfMemoryRange = 0;
|
|
|
|
mdThd->Stack.Memory.DataSize = 0;
|
|
|
|
mdThd->Stack.Memory.Rva = 0;
|
|
|
|
mdThd->ThreadContext.DataSize = 0;
|
|
|
|
mdThd->ThreadContext.Rva = 0;
|
2012-01-23 21:37:05 +01:00
|
|
|
mdThd->PriorityClass = dc->threads[thd_idx].prio_class;
|
|
|
|
mdThd->Priority = dc->threads[thd_idx].curr_prio;
|
2005-03-07 12:03:21 +01:00
|
|
|
|
|
|
|
if ((hThread = OpenThread(THREAD_ALL_ACCESS, FALSE, tid)) == NULL)
|
|
|
|
{
|
2009-01-03 14:54:11 +01:00
|
|
|
FIXME("Couldn't open thread %u (%u)\n", tid, GetLastError());
|
2005-03-07 12:03:21 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NtQueryInformationThread(hThread, ThreadBasicInformation,
|
|
|
|
&tbi, sizeof(tbi), NULL) == STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
mdThd->Teb = (ULONG_PTR)tbi.TebBaseAddress;
|
2007-02-19 23:09:24 +01:00
|
|
|
if (tbi.ExitStatus == STILL_ACTIVE)
|
2005-03-07 12:03:21 +01:00
|
|
|
{
|
2007-02-19 23:09:24 +01:00
|
|
|
if (tid != GetCurrentThreadId() &&
|
|
|
|
(mdThd->SuspendCount = SuspendThread(hThread)) != (DWORD)-1)
|
|
|
|
{
|
|
|
|
ctx->ContextFlags = CONTEXT_FULL;
|
|
|
|
if (!GetThreadContext(hThread, ctx))
|
|
|
|
memset(ctx, 0, sizeof(*ctx));
|
2005-03-07 12:03:21 +01:00
|
|
|
|
2007-02-19 23:09:24 +01:00
|
|
|
fetch_thread_stack(dc, tbi.TebBaseAddress, ctx, &mdThd->Stack);
|
|
|
|
ResumeThread(hThread);
|
|
|
|
}
|
|
|
|
else if (tid == GetCurrentThreadId() && except)
|
2005-03-07 12:03:21 +01:00
|
|
|
{
|
2007-02-19 23:09:24 +01:00
|
|
|
CONTEXT lctx, *pctx;
|
2008-01-27 19:04:04 +01:00
|
|
|
mdThd->SuspendCount = 1;
|
2007-02-19 23:09:24 +01:00
|
|
|
if (except->ClientPointers)
|
|
|
|
{
|
|
|
|
EXCEPTION_POINTERS ep;
|
|
|
|
|
|
|
|
ReadProcessMemory(dc->hProcess, except->ExceptionPointers,
|
|
|
|
&ep, sizeof(ep), NULL);
|
|
|
|
ReadProcessMemory(dc->hProcess, ep.ContextRecord,
|
2009-12-17 21:24:58 +01:00
|
|
|
&lctx, sizeof(lctx), NULL);
|
2007-02-19 23:09:24 +01:00
|
|
|
pctx = &lctx;
|
|
|
|
}
|
|
|
|
else pctx = except->ExceptionPointers->ContextRecord;
|
2008-01-17 22:59:22 +01:00
|
|
|
|
2008-02-14 23:02:25 +01:00
|
|
|
*ctx = *pctx;
|
2007-02-19 23:09:24 +01:00
|
|
|
fetch_thread_stack(dc, tbi.TebBaseAddress, pctx, &mdThd->Stack);
|
2005-03-07 12:03:21 +01:00
|
|
|
}
|
2008-01-27 19:04:04 +01:00
|
|
|
else mdThd->SuspendCount = 0;
|
2005-03-07 12:03:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
CloseHandle(hThread);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* add_module
|
|
|
|
*
|
|
|
|
* Add a module to a dump context
|
|
|
|
*/
|
2007-02-21 21:56:11 +01:00
|
|
|
static BOOL add_module(struct dump_context* dc, const WCHAR* name,
|
2009-12-12 12:18:28 +01:00
|
|
|
DWORD64 base, DWORD size, DWORD timestamp, DWORD checksum,
|
2005-03-29 15:14:08 +02:00
|
|
|
BOOL is_elf)
|
2005-03-07 12:03:21 +01:00
|
|
|
{
|
2008-01-13 17:02:08 +01:00
|
|
|
if (!dc->modules)
|
2009-07-10 14:46:55 +02:00
|
|
|
{
|
|
|
|
dc->alloc_modules = 32;
|
2008-01-13 17:02:08 +01:00
|
|
|
dc->modules = HeapAlloc(GetProcessHeap(), 0,
|
2009-07-10 14:46:55 +02:00
|
|
|
dc->alloc_modules * sizeof(*dc->modules));
|
|
|
|
}
|
2009-08-15 16:31:50 +02:00
|
|
|
else if(dc->num_modules >= dc->alloc_modules)
|
2009-07-10 14:46:55 +02:00
|
|
|
{
|
|
|
|
dc->alloc_modules *= 2;
|
2008-01-13 17:02:08 +01:00
|
|
|
dc->modules = HeapReAlloc(GetProcessHeap(), 0, dc->modules,
|
2009-07-10 14:46:55 +02:00
|
|
|
dc->alloc_modules * sizeof(*dc->modules));
|
|
|
|
}
|
2009-07-14 12:17:22 +02:00
|
|
|
if (!dc->modules)
|
|
|
|
{
|
|
|
|
dc->alloc_modules = dc->num_modules = 0;
|
|
|
|
return FALSE;
|
|
|
|
}
|
2005-03-07 12:03:21 +01:00
|
|
|
if (is_elf ||
|
2009-12-12 12:18:28 +01:00
|
|
|
!GetModuleFileNameExW(dc->hProcess, (HMODULE)(DWORD_PTR)base,
|
2009-07-14 12:17:22 +02:00
|
|
|
dc->modules[dc->num_modules].name,
|
2018-07-12 23:49:34 +02:00
|
|
|
ARRAY_SIZE(dc->modules[dc->num_modules].name)))
|
2009-07-14 12:17:22 +02:00
|
|
|
lstrcpynW(dc->modules[dc->num_modules].name, name,
|
2018-07-12 23:49:34 +02:00
|
|
|
ARRAY_SIZE(dc->modules[dc->num_modules].name));
|
2009-07-14 12:17:22 +02:00
|
|
|
dc->modules[dc->num_modules].base = base;
|
|
|
|
dc->modules[dc->num_modules].size = size;
|
|
|
|
dc->modules[dc->num_modules].timestamp = timestamp;
|
|
|
|
dc->modules[dc->num_modules].checksum = checksum;
|
|
|
|
dc->modules[dc->num_modules].is_elf = is_elf;
|
|
|
|
dc->num_modules++;
|
2005-03-07 12:03:21 +01:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* fetch_pe_module_info_cb
|
|
|
|
*
|
|
|
|
* Callback for accumulating in dump_context a PE modules set
|
|
|
|
*/
|
2007-08-03 00:51:09 +02:00
|
|
|
static BOOL WINAPI fetch_pe_module_info_cb(PCWSTR name, DWORD64 base, ULONG size,
|
|
|
|
PVOID user)
|
2005-03-07 12:03:21 +01:00
|
|
|
{
|
2009-01-19 10:24:06 +01:00
|
|
|
struct dump_context* dc = user;
|
2005-03-29 15:14:08 +02:00
|
|
|
IMAGE_NT_HEADERS nth;
|
|
|
|
|
2007-02-21 21:56:11 +01:00
|
|
|
if (!validate_addr64(base)) return FALSE;
|
|
|
|
|
2005-03-29 15:14:08 +02:00
|
|
|
if (pe_load_nt_header(dc->hProcess, base, &nth))
|
2009-01-19 10:24:06 +01:00
|
|
|
add_module(user, name, base, size,
|
2005-03-29 15:14:08 +02:00
|
|
|
nth.FileHeader.TimeDateStamp, nth.OptionalHeader.CheckSum,
|
|
|
|
FALSE);
|
|
|
|
return TRUE;
|
2005-03-07 12:03:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* fetch_elf_module_info_cb
|
|
|
|
*
|
2005-03-23 14:15:18 +01:00
|
|
|
* Callback for accumulating in dump_context an ELF modules set
|
2005-03-07 12:03:21 +01:00
|
|
|
*/
|
2007-02-21 21:56:17 +01:00
|
|
|
static BOOL fetch_elf_module_info_cb(const WCHAR* name, unsigned long base,
|
2005-03-07 12:03:21 +01:00
|
|
|
void* user)
|
|
|
|
{
|
2009-01-19 10:24:06 +01:00
|
|
|
struct dump_context* dc = user;
|
2010-10-09 08:50:56 +02:00
|
|
|
DWORD_PTR rbase;
|
|
|
|
DWORD size, checksum;
|
2005-03-29 15:14:08 +02:00
|
|
|
|
|
|
|
/* FIXME: there's no relevant timestamp on ELF modules */
|
|
|
|
/* NB: if we have a non-null base from the live-target use it (whenever
|
|
|
|
* the ELF module is relocatable or not). If we have a null base (ELF
|
|
|
|
* module isn't relocatable) then grab its base address from ELF file
|
|
|
|
*/
|
2007-02-21 21:56:22 +01:00
|
|
|
if (!elf_fetch_file_info(name, &rbase, &size, &checksum))
|
2005-03-29 15:14:08 +02:00
|
|
|
size = checksum = 0;
|
2007-02-21 21:56:17 +01:00
|
|
|
add_module(dc, name, base ? base : rbase, size, 0 /* FIXME */, checksum, TRUE);
|
2005-03-29 15:14:08 +02:00
|
|
|
return TRUE;
|
2005-03-07 12:03:21 +01:00
|
|
|
}
|
|
|
|
|
2009-03-13 17:48:27 +01:00
|
|
|
/******************************************************************
|
|
|
|
* fetch_macho_module_info_cb
|
|
|
|
*
|
|
|
|
* Callback for accumulating in dump_context a Mach-O modules set
|
|
|
|
*/
|
|
|
|
static BOOL fetch_macho_module_info_cb(const WCHAR* name, unsigned long base,
|
|
|
|
void* user)
|
|
|
|
{
|
|
|
|
struct dump_context* dc = (struct dump_context*)user;
|
2010-10-09 08:50:56 +02:00
|
|
|
DWORD_PTR rbase;
|
|
|
|
DWORD size, checksum;
|
2009-03-13 17:48:27 +01:00
|
|
|
|
|
|
|
/* FIXME: there's no relevant timestamp on Mach-O modules */
|
|
|
|
/* NB: if we have a non-null base from the live-target use it. If we have
|
|
|
|
* a null base, then grab its base address from Mach-O file.
|
|
|
|
*/
|
2015-08-04 09:40:38 +02:00
|
|
|
if (!macho_fetch_file_info(dc->hProcess, name, base, &rbase, &size, &checksum))
|
2009-03-13 17:48:27 +01:00
|
|
|
size = checksum = 0;
|
|
|
|
add_module(dc, name, base ? base : rbase, size, 0 /* FIXME */, checksum, TRUE);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2008-01-13 17:02:08 +01:00
|
|
|
static void fetch_modules_info(struct dump_context* dc)
|
2005-03-07 12:03:21 +01:00
|
|
|
{
|
2007-02-21 21:56:11 +01:00
|
|
|
EnumerateLoadedModulesW64(dc->hProcess, fetch_pe_module_info_cb, dc);
|
2005-03-07 12:03:21 +01:00
|
|
|
/* Since we include ELF modules in a separate stream from the regular PE ones,
|
|
|
|
* we can always include those ELF modules (they don't eat lots of space)
|
|
|
|
* And it's always a good idea to have a trace of the loaded ELF modules for
|
|
|
|
* a given application in a post mortem debugging condition.
|
|
|
|
*/
|
|
|
|
elf_enum_modules(dc->hProcess, fetch_elf_module_info_cb, dc);
|
2009-03-13 17:48:27 +01:00
|
|
|
macho_enum_modules(dc->hProcess, fetch_macho_module_info_cb, dc);
|
2005-03-07 12:03:21 +01:00
|
|
|
}
|
|
|
|
|
2008-01-27 19:04:17 +01:00
|
|
|
static void fetch_module_versioninfo(LPCWSTR filename, VS_FIXEDFILEINFO* ffi)
|
|
|
|
{
|
|
|
|
DWORD handle;
|
|
|
|
DWORD sz;
|
|
|
|
static const WCHAR backslashW[] = {'\\', '\0'};
|
|
|
|
|
|
|
|
memset(ffi, 0, sizeof(*ffi));
|
|
|
|
if ((sz = GetFileVersionInfoSizeW(filename, &handle)))
|
|
|
|
{
|
|
|
|
void* info = HeapAlloc(GetProcessHeap(), 0, sz);
|
|
|
|
if (info && GetFileVersionInfoW(filename, handle, sz, info))
|
|
|
|
{
|
|
|
|
VS_FIXEDFILEINFO* ptr;
|
|
|
|
UINT len;
|
|
|
|
|
|
|
|
if (VerQueryValueW(info, backslashW, (void*)&ptr, &len))
|
|
|
|
memcpy(ffi, ptr, min(len, sizeof(*ffi)));
|
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, info);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-03-07 12:03:21 +01:00
|
|
|
/******************************************************************
|
2012-01-23 21:37:10 +01:00
|
|
|
* minidump_add_memory_block
|
2005-03-07 12:03:21 +01:00
|
|
|
*
|
|
|
|
* Add a memory block to be dumped in a minidump
|
|
|
|
* If rva is non 0, it's the rva in the minidump where has to be stored
|
2012-05-15 10:15:32 +02:00
|
|
|
* also the rva of the memory block when written (this allows us to reference
|
2005-03-07 12:03:21 +01:00
|
|
|
* a memory block from outside the list of memory blocks).
|
2004-04-06 00:21:27 +02:00
|
|
|
*/
|
2012-01-23 21:37:10 +01:00
|
|
|
void minidump_add_memory_block(struct dump_context* dc, ULONG64 base, ULONG size, ULONG rva)
|
2005-03-07 12:03:21 +01:00
|
|
|
{
|
2009-08-15 16:31:50 +02:00
|
|
|
if (!dc->mem)
|
|
|
|
{
|
|
|
|
dc->alloc_mem = 32;
|
|
|
|
dc->mem = HeapAlloc(GetProcessHeap(), 0, dc->alloc_mem * sizeof(*dc->mem));
|
|
|
|
}
|
|
|
|
else if (dc->num_mem >= dc->alloc_mem)
|
2009-07-10 14:46:55 +02:00
|
|
|
{
|
|
|
|
dc->alloc_mem *= 2;
|
|
|
|
dc->mem = HeapReAlloc(GetProcessHeap(), 0, dc->mem,
|
|
|
|
dc->alloc_mem * sizeof(*dc->mem));
|
|
|
|
}
|
2005-03-07 12:03:21 +01:00
|
|
|
if (dc->mem)
|
|
|
|
{
|
2009-07-14 12:17:22 +02:00
|
|
|
dc->mem[dc->num_mem].base = base;
|
|
|
|
dc->mem[dc->num_mem].size = size;
|
|
|
|
dc->mem[dc->num_mem].rva = rva;
|
|
|
|
dc->num_mem++;
|
2005-03-07 12:03:21 +01:00
|
|
|
}
|
2009-07-10 14:46:55 +02:00
|
|
|
else dc->num_mem = dc->alloc_mem = 0;
|
2005-03-07 12:03:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* writeat
|
|
|
|
*
|
|
|
|
* Writes a chunk of data at a given position in the minidump
|
|
|
|
*/
|
2007-04-18 00:19:45 +02:00
|
|
|
static void writeat(struct dump_context* dc, RVA rva, const void* data, unsigned size)
|
2005-03-07 12:03:21 +01:00
|
|
|
{
|
|
|
|
DWORD written;
|
|
|
|
|
|
|
|
SetFilePointer(dc->hFile, rva, NULL, FILE_BEGIN);
|
|
|
|
WriteFile(dc->hFile, data, size, &written, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* append
|
|
|
|
*
|
|
|
|
* writes a new chunk of data to the minidump, increasing the current
|
|
|
|
* rva in dc
|
|
|
|
*/
|
2009-07-13 23:12:01 +02:00
|
|
|
static void append(struct dump_context* dc, const void* data, unsigned size)
|
2005-03-07 12:03:21 +01:00
|
|
|
{
|
|
|
|
writeat(dc, dc->rva, data, size);
|
|
|
|
dc->rva += size;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* dump_exception_info
|
|
|
|
*
|
|
|
|
* Write in File the exception information from pcs
|
|
|
|
*/
|
2008-01-27 19:03:57 +01:00
|
|
|
static unsigned dump_exception_info(struct dump_context* dc,
|
|
|
|
const MINIDUMP_EXCEPTION_INFORMATION* except)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
|
|
|
MINIDUMP_EXCEPTION_STREAM mdExcpt;
|
2005-03-07 12:03:21 +01:00
|
|
|
EXCEPTION_RECORD rec, *prec;
|
|
|
|
CONTEXT ctx, *pctx;
|
2008-09-24 21:50:05 +02:00
|
|
|
DWORD i;
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2005-03-07 12:03:21 +01:00
|
|
|
mdExcpt.ThreadId = except->ThreadId;
|
2004-04-06 00:21:27 +02:00
|
|
|
mdExcpt.__alignment = 0;
|
2005-03-07 12:03:21 +01:00
|
|
|
if (except->ClientPointers)
|
|
|
|
{
|
|
|
|
EXCEPTION_POINTERS ep;
|
|
|
|
|
|
|
|
ReadProcessMemory(dc->hProcess,
|
|
|
|
except->ExceptionPointers, &ep, sizeof(ep), NULL);
|
|
|
|
ReadProcessMemory(dc->hProcess,
|
|
|
|
ep.ExceptionRecord, &rec, sizeof(rec), NULL);
|
|
|
|
ReadProcessMemory(dc->hProcess,
|
|
|
|
ep.ContextRecord, &ctx, sizeof(ctx), NULL);
|
|
|
|
prec = &rec;
|
|
|
|
pctx = &ctx;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
prec = except->ExceptionPointers->ExceptionRecord;
|
|
|
|
pctx = except->ExceptionPointers->ContextRecord;
|
|
|
|
}
|
|
|
|
mdExcpt.ExceptionRecord.ExceptionCode = prec->ExceptionCode;
|
|
|
|
mdExcpt.ExceptionRecord.ExceptionFlags = prec->ExceptionFlags;
|
|
|
|
mdExcpt.ExceptionRecord.ExceptionRecord = (DWORD_PTR)prec->ExceptionRecord;
|
|
|
|
mdExcpt.ExceptionRecord.ExceptionAddress = (DWORD_PTR)prec->ExceptionAddress;
|
|
|
|
mdExcpt.ExceptionRecord.NumberParameters = prec->NumberParameters;
|
|
|
|
mdExcpt.ExceptionRecord.__unusedAlignment = 0;
|
|
|
|
for (i = 0; i < mdExcpt.ExceptionRecord.NumberParameters; i++)
|
2007-12-31 22:28:09 +01:00
|
|
|
mdExcpt.ExceptionRecord.ExceptionInformation[i] = prec->ExceptionInformation[i];
|
2005-03-07 12:03:21 +01:00
|
|
|
mdExcpt.ThreadContext.DataSize = sizeof(*pctx);
|
|
|
|
mdExcpt.ThreadContext.Rva = dc->rva + sizeof(mdExcpt);
|
|
|
|
|
|
|
|
append(dc, &mdExcpt, sizeof(mdExcpt));
|
|
|
|
append(dc, pctx, sizeof(*pctx));
|
2008-01-27 19:03:57 +01:00
|
|
|
return sizeof(mdExcpt);
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* dump_modules
|
|
|
|
*
|
|
|
|
* Write in File the modules from pcs
|
|
|
|
*/
|
2008-01-27 19:03:57 +01:00
|
|
|
static unsigned dump_modules(struct dump_context* dc, BOOL dump_elf)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
|
|
|
MINIDUMP_MODULE mdModule;
|
|
|
|
MINIDUMP_MODULE_LIST mdModuleList;
|
2005-03-07 12:03:21 +01:00
|
|
|
char tmp[1024];
|
|
|
|
MINIDUMP_STRING* ms = (MINIDUMP_STRING*)tmp;
|
|
|
|
ULONG i, nmod;
|
|
|
|
RVA rva_base;
|
|
|
|
DWORD flags_out;
|
2008-01-27 19:03:57 +01:00
|
|
|
unsigned sz;
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2008-01-13 17:02:08 +01:00
|
|
|
for (i = nmod = 0; i < dc->num_modules; i++)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2008-01-13 17:02:08 +01:00
|
|
|
if ((dc->modules[i].is_elf && dump_elf) ||
|
|
|
|
(!dc->modules[i].is_elf && !dump_elf))
|
2005-03-07 12:03:21 +01:00
|
|
|
nmod++;
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
2005-03-07 12:03:21 +01:00
|
|
|
|
|
|
|
mdModuleList.NumberOfModules = 0;
|
|
|
|
/* reserve space for mdModuleList
|
|
|
|
* FIXME: since we don't support 0 length arrays, we cannot use the
|
|
|
|
* size of mdModuleList
|
|
|
|
* FIXME: if we don't ask for all modules in cb, we'll get a hole in the file
|
|
|
|
*/
|
2008-01-17 22:59:22 +01:00
|
|
|
|
|
|
|
/* the stream size is just the size of the module index. It does not include the data for the
|
|
|
|
names of each module. *Technically* the names are supposed to go into the common string table
|
|
|
|
in the minidump file. Since each string is referenced by RVA they can all safely be located
|
|
|
|
anywhere between streams in the file, so the end of this stream is sufficient. */
|
2005-03-07 12:03:21 +01:00
|
|
|
rva_base = dc->rva;
|
2008-01-27 19:03:57 +01:00
|
|
|
dc->rva += sz = sizeof(mdModuleList.NumberOfModules) + sizeof(mdModule) * nmod;
|
2008-01-13 17:02:08 +01:00
|
|
|
for (i = 0; i < dc->num_modules; i++)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2008-01-13 17:02:08 +01:00
|
|
|
if ((dc->modules[i].is_elf && !dump_elf) ||
|
|
|
|
(!dc->modules[i].is_elf && dump_elf))
|
2005-03-07 12:03:21 +01:00
|
|
|
continue;
|
|
|
|
|
|
|
|
flags_out = ModuleWriteModule | ModuleWriteMiscRecord | ModuleWriteCvRecord;
|
|
|
|
if (dc->type & MiniDumpWithDataSegs)
|
|
|
|
flags_out |= ModuleWriteDataSeg;
|
|
|
|
if (dc->type & MiniDumpWithProcessThreadData)
|
|
|
|
flags_out |= ModuleWriteTlsData;
|
|
|
|
if (dc->type & MiniDumpWithCodeSegs)
|
|
|
|
flags_out |= ModuleWriteCodeSegs;
|
2008-01-13 17:02:08 +01:00
|
|
|
ms->Length = (lstrlenW(dc->modules[i].name) + 1) * sizeof(WCHAR);
|
2005-03-07 12:03:21 +01:00
|
|
|
if (sizeof(ULONG) + ms->Length > sizeof(tmp))
|
|
|
|
FIXME("Buffer overflow!!!\n");
|
2008-01-13 17:02:08 +01:00
|
|
|
lstrcpyW(ms->Buffer, dc->modules[i].name);
|
2005-03-07 12:03:21 +01:00
|
|
|
|
|
|
|
if (dc->cb)
|
|
|
|
{
|
|
|
|
MINIDUMP_CALLBACK_INPUT cbin;
|
|
|
|
MINIDUMP_CALLBACK_OUTPUT cbout;
|
|
|
|
|
|
|
|
cbin.ProcessId = dc->pid;
|
|
|
|
cbin.ProcessHandle = dc->hProcess;
|
|
|
|
cbin.CallbackType = ModuleCallback;
|
|
|
|
|
|
|
|
cbin.u.Module.FullPath = ms->Buffer;
|
2008-01-13 17:02:08 +01:00
|
|
|
cbin.u.Module.BaseOfImage = dc->modules[i].base;
|
|
|
|
cbin.u.Module.SizeOfImage = dc->modules[i].size;
|
|
|
|
cbin.u.Module.CheckSum = dc->modules[i].checksum;
|
|
|
|
cbin.u.Module.TimeDateStamp = dc->modules[i].timestamp;
|
2005-03-07 12:03:21 +01:00
|
|
|
memset(&cbin.u.Module.VersionInfo, 0, sizeof(cbin.u.Module.VersionInfo));
|
|
|
|
cbin.u.Module.CvRecord = NULL;
|
|
|
|
cbin.u.Module.SizeOfCvRecord = 0;
|
|
|
|
cbin.u.Module.MiscRecord = NULL;
|
|
|
|
cbin.u.Module.SizeOfMiscRecord = 0;
|
|
|
|
|
|
|
|
cbout.u.ModuleWriteFlags = flags_out;
|
|
|
|
if (!dc->cb->CallbackRoutine(dc->cb->CallbackParam, &cbin, &cbout))
|
|
|
|
continue;
|
|
|
|
flags_out &= cbout.u.ModuleWriteFlags;
|
|
|
|
}
|
|
|
|
if (flags_out & ModuleWriteModule)
|
|
|
|
{
|
2012-05-15 10:15:32 +02:00
|
|
|
/* fetch CPU dependent module info (like UNWIND_INFO) */
|
2012-01-23 21:37:16 +01:00
|
|
|
dbghelp_current_cpu->fetch_minidump_module(dc, i, flags_out);
|
|
|
|
|
2008-01-13 17:02:08 +01:00
|
|
|
mdModule.BaseOfImage = dc->modules[i].base;
|
|
|
|
mdModule.SizeOfImage = dc->modules[i].size;
|
|
|
|
mdModule.CheckSum = dc->modules[i].checksum;
|
|
|
|
mdModule.TimeDateStamp = dc->modules[i].timestamp;
|
2005-03-07 12:03:21 +01:00
|
|
|
mdModule.ModuleNameRva = dc->rva;
|
|
|
|
ms->Length -= sizeof(WCHAR);
|
2007-04-29 00:14:15 +02:00
|
|
|
append(dc, ms, sizeof(ULONG) + ms->Length + sizeof(WCHAR));
|
2008-01-27 19:04:17 +01:00
|
|
|
fetch_module_versioninfo(ms->Buffer, &mdModule.VersionInfo);
|
2005-03-07 12:03:21 +01:00
|
|
|
mdModule.CvRecord.DataSize = 0; /* FIXME */
|
|
|
|
mdModule.CvRecord.Rva = 0; /* FIXME */
|
|
|
|
mdModule.MiscRecord.DataSize = 0; /* FIXME */
|
|
|
|
mdModule.MiscRecord.Rva = 0; /* FIXME */
|
|
|
|
mdModule.Reserved0 = 0; /* FIXME */
|
|
|
|
mdModule.Reserved1 = 0; /* FIXME */
|
|
|
|
writeat(dc,
|
|
|
|
rva_base + sizeof(mdModuleList.NumberOfModules) +
|
|
|
|
mdModuleList.NumberOfModules++ * sizeof(mdModule),
|
|
|
|
&mdModule, sizeof(mdModule));
|
|
|
|
}
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
2005-03-07 12:03:21 +01:00
|
|
|
writeat(dc, rva_base, &mdModuleList.NumberOfModules,
|
|
|
|
sizeof(mdModuleList.NumberOfModules));
|
2008-01-27 19:03:57 +01:00
|
|
|
|
|
|
|
return sz;
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
|
|
|
|
2018-11-28 02:29:44 +01:00
|
|
|
#ifdef __i386__
|
|
|
|
extern void do_x86cpuid(unsigned int ax, unsigned int *p);
|
|
|
|
__ASM_GLOBAL_FUNC( do_x86cpuid,
|
|
|
|
"pushl %esi\n\t"
|
|
|
|
"pushl %ebx\n\t"
|
|
|
|
"movl 12(%esp),%eax\n\t"
|
|
|
|
"movl 16(%esp),%esi\n\t"
|
|
|
|
"cpuid\n\t"
|
|
|
|
"movl %eax,(%esi)\n\t"
|
|
|
|
"movl %ebx,4(%esi)\n\t"
|
|
|
|
"movl %ecx,8(%esi)\n\t"
|
|
|
|
"movl %edx,12(%esi)\n\t"
|
|
|
|
"popl %ebx\n\t"
|
|
|
|
"popl %esi\n\t"
|
|
|
|
"ret" )
|
2018-11-28 02:29:45 +01:00
|
|
|
extern int have_x86cpuid(void);
|
|
|
|
__ASM_GLOBAL_FUNC( have_x86cpuid,
|
|
|
|
"pushfl\n\t"
|
|
|
|
"pushfl\n\t"
|
|
|
|
"movl (%esp),%ecx\n\t"
|
|
|
|
"xorl $0x00200000,(%esp)\n\t"
|
|
|
|
"popfl\n\t"
|
|
|
|
"pushfl\n\t"
|
|
|
|
"popl %eax\n\t"
|
|
|
|
"popfl\n\t"
|
|
|
|
"xorl %ecx,%eax\n\t"
|
|
|
|
"andl $0x00200000,%eax\n\t"
|
|
|
|
"ret" )
|
2018-11-28 02:29:44 +01:00
|
|
|
#else
|
|
|
|
static void do_x86cpuid(unsigned int ax, unsigned int *p)
|
2008-11-10 11:27:52 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-11-28 02:29:45 +01:00
|
|
|
static int have_x86cpuid(void)
|
2008-11-10 11:27:52 +01:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2018-11-28 02:29:45 +01:00
|
|
|
#endif
|
2008-11-10 11:27:52 +01:00
|
|
|
|
2004-04-06 00:21:27 +02:00
|
|
|
/******************************************************************
|
|
|
|
* dump_system_info
|
|
|
|
*
|
|
|
|
* Dumps into File the information about the system
|
|
|
|
*/
|
2008-01-27 19:03:57 +01:00
|
|
|
static unsigned dump_system_info(struct dump_context* dc)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
|
|
|
MINIDUMP_SYSTEM_INFO mdSysInfo;
|
|
|
|
SYSTEM_INFO sysInfo;
|
2005-03-07 12:03:21 +01:00
|
|
|
OSVERSIONINFOW osInfo;
|
2004-04-06 00:21:27 +02:00
|
|
|
DWORD written;
|
2005-03-07 12:03:21 +01:00
|
|
|
ULONG slen;
|
2012-01-23 21:36:59 +01:00
|
|
|
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;
|
2004-04-06 00:21:27 +02:00
|
|
|
|
|
|
|
GetSystemInfo(&sysInfo);
|
2005-03-07 12:03:21 +01:00
|
|
|
osInfo.dwOSVersionInfoSize = sizeof(osInfo);
|
|
|
|
GetVersionExW(&osInfo);
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2012-01-23 21:36:59 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2004-04-06 00:21:27 +02:00
|
|
|
mdSysInfo.ProcessorArchitecture = sysInfo.u.s.wProcessorArchitecture;
|
|
|
|
mdSysInfo.ProcessorLevel = sysInfo.wProcessorLevel;
|
|
|
|
mdSysInfo.ProcessorRevision = sysInfo.wProcessorRevision;
|
2005-03-07 12:03:21 +01:00
|
|
|
mdSysInfo.u.s.NumberOfProcessors = sysInfo.dwNumberOfProcessors;
|
|
|
|
mdSysInfo.u.s.ProductType = VER_NT_WORKSTATION; /* FIXME */
|
2004-04-06 00:21:27 +02:00
|
|
|
mdSysInfo.MajorVersion = osInfo.dwMajorVersion;
|
|
|
|
mdSysInfo.MinorVersion = osInfo.dwMinorVersion;
|
|
|
|
mdSysInfo.BuildNumber = osInfo.dwBuildNumber;
|
|
|
|
mdSysInfo.PlatformId = osInfo.dwPlatformId;
|
|
|
|
|
2012-01-23 21:36:59 +01:00
|
|
|
mdSysInfo.CSDVersionRva = dc->rva + sizeof(mdSysInfo) + wine_extra;
|
2005-03-07 12:03:21 +01:00
|
|
|
mdSysInfo.u1.Reserved1 = 0;
|
2008-01-17 22:59:22 +01:00
|
|
|
mdSysInfo.u1.s.SuiteMask = VER_SUITE_TERMINAL;
|
2005-03-07 12:03:21 +01:00
|
|
|
|
2008-11-10 11:27:52 +01:00
|
|
|
if (have_x86cpuid())
|
|
|
|
{
|
|
|
|
unsigned regs0[4], regs1[4];
|
|
|
|
|
|
|
|
do_x86cpuid(0, regs0);
|
|
|
|
mdSysInfo.Cpu.X86CpuInfo.VendorId[0] = regs0[1];
|
2013-03-01 16:12:10 +01:00
|
|
|
mdSysInfo.Cpu.X86CpuInfo.VendorId[1] = regs0[3];
|
|
|
|
mdSysInfo.Cpu.X86CpuInfo.VendorId[2] = regs0[2];
|
2008-11-10 11:27:52 +01:00
|
|
|
do_x86cpuid(1, regs1);
|
|
|
|
mdSysInfo.Cpu.X86CpuInfo.VersionInformation = regs1[0];
|
|
|
|
mdSysInfo.Cpu.X86CpuInfo.FeatureInformation = regs1[3];
|
|
|
|
mdSysInfo.Cpu.X86CpuInfo.AMDExtendedCpuFeatures = 0;
|
|
|
|
if (regs0[1] == 0x68747541 /* "Auth" */ &&
|
|
|
|
regs0[3] == 0x69746e65 /* "enti" */ &&
|
|
|
|
regs0[2] == 0x444d4163 /* "cAMD" */)
|
|
|
|
{
|
|
|
|
do_x86cpuid(0x80000000, regs1); /* get vendor cpuid level */
|
|
|
|
if (regs1[0] >= 0x80000001)
|
|
|
|
{
|
|
|
|
do_x86cpuid(0x80000001, regs1); /* get vendor features */
|
|
|
|
mdSysInfo.Cpu.X86CpuInfo.AMDExtendedCpuFeatures = regs1[3];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
ULONG64 one = 1;
|
2005-03-07 12:03:21 +01:00
|
|
|
|
2008-11-10 11:27:52 +01:00
|
|
|
mdSysInfo.Cpu.OtherCpuInfo.ProcessorFeatures[0] = 0;
|
|
|
|
mdSysInfo.Cpu.OtherCpuInfo.ProcessorFeatures[1] = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < sizeof(mdSysInfo.Cpu.OtherCpuInfo.ProcessorFeatures[0]) * 8; i++)
|
|
|
|
if (IsProcessorFeaturePresent(i))
|
|
|
|
mdSysInfo.Cpu.OtherCpuInfo.ProcessorFeatures[0] |= one << i;
|
|
|
|
}
|
2005-03-07 12:03:21 +01:00
|
|
|
append(dc, &mdSysInfo, sizeof(mdSysInfo));
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2012-01-23 21:36:59 +01:00
|
|
|
/* write Wine specific system information just behind the structure, and before any string */
|
|
|
|
if (wine_extra)
|
|
|
|
{
|
2018-11-12 04:51:58 +01:00
|
|
|
static const char code[] = {'W','I','N','E'};
|
2012-01-23 21:36:59 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2008-01-17 22:59:22 +01:00
|
|
|
/* write the service pack version string after this stream. It is referenced within the
|
|
|
|
stream by its RVA in the file. */
|
2005-03-07 12:03:21 +01:00
|
|
|
slen = lstrlenW(osInfo.szCSDVersion) * sizeof(WCHAR);
|
|
|
|
WriteFile(dc->hFile, &slen, sizeof(slen), &written, NULL);
|
|
|
|
WriteFile(dc->hFile, osInfo.szCSDVersion, slen, &written, NULL);
|
|
|
|
dc->rva += sizeof(ULONG) + slen;
|
2008-01-27 19:03:57 +01:00
|
|
|
|
|
|
|
return sizeof(mdSysInfo);
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* dump_threads
|
|
|
|
*
|
|
|
|
* Dumps into File the information about running threads
|
|
|
|
*/
|
2008-01-27 19:03:57 +01:00
|
|
|
static unsigned dump_threads(struct dump_context* dc,
|
|
|
|
const MINIDUMP_EXCEPTION_INFORMATION* except)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
|
|
|
MINIDUMP_THREAD mdThd;
|
|
|
|
MINIDUMP_THREAD_LIST mdThdList;
|
2009-11-13 13:18:12 +01:00
|
|
|
unsigned i, sz;
|
2005-03-07 12:03:21 +01:00
|
|
|
RVA rva_base;
|
|
|
|
DWORD flags_out;
|
|
|
|
CONTEXT ctx;
|
|
|
|
|
|
|
|
mdThdList.NumberOfThreads = 0;
|
|
|
|
|
|
|
|
rva_base = dc->rva;
|
2012-01-23 21:37:05 +01:00
|
|
|
dc->rva += sz = sizeof(mdThdList.NumberOfThreads) + dc->num_threads * sizeof(mdThd);
|
2005-03-07 12:03:21 +01:00
|
|
|
|
2012-01-23 21:37:05 +01:00
|
|
|
for (i = 0; i < dc->num_threads; i++)
|
2005-03-07 12:03:21 +01:00
|
|
|
{
|
2007-02-19 23:09:24 +01:00
|
|
|
fetch_thread_info(dc, i, except, &mdThd, &ctx);
|
2005-03-07 12:03:21 +01:00
|
|
|
|
|
|
|
flags_out = ThreadWriteThread | ThreadWriteStack | ThreadWriteContext |
|
|
|
|
ThreadWriteInstructionWindow;
|
|
|
|
if (dc->type & MiniDumpWithProcessThreadData)
|
|
|
|
flags_out |= ThreadWriteThreadData;
|
|
|
|
if (dc->type & MiniDumpWithThreadInfo)
|
|
|
|
flags_out |= ThreadWriteThreadInfo;
|
|
|
|
|
|
|
|
if (dc->cb)
|
|
|
|
{
|
|
|
|
MINIDUMP_CALLBACK_INPUT cbin;
|
|
|
|
MINIDUMP_CALLBACK_OUTPUT cbout;
|
|
|
|
|
|
|
|
cbin.ProcessId = dc->pid;
|
|
|
|
cbin.ProcessHandle = dc->hProcess;
|
|
|
|
cbin.CallbackType = ThreadCallback;
|
2012-01-23 21:37:05 +01:00
|
|
|
cbin.u.Thread.ThreadId = dc->threads[i].tid;
|
2005-03-07 12:03:21 +01:00
|
|
|
cbin.u.Thread.ThreadHandle = 0; /* FIXME */
|
2008-02-29 23:06:16 +01:00
|
|
|
cbin.u.Thread.Context = ctx;
|
2005-03-07 12:03:21 +01:00
|
|
|
cbin.u.Thread.SizeOfContext = sizeof(CONTEXT);
|
|
|
|
cbin.u.Thread.StackBase = mdThd.Stack.StartOfMemoryRange;
|
|
|
|
cbin.u.Thread.StackEnd = mdThd.Stack.StartOfMemoryRange +
|
|
|
|
mdThd.Stack.Memory.DataSize;
|
|
|
|
|
|
|
|
cbout.u.ThreadWriteFlags = flags_out;
|
|
|
|
if (!dc->cb->CallbackRoutine(dc->cb->CallbackParam, &cbin, &cbout))
|
|
|
|
continue;
|
|
|
|
flags_out &= cbout.u.ThreadWriteFlags;
|
|
|
|
}
|
|
|
|
if (flags_out & ThreadWriteThread)
|
|
|
|
{
|
|
|
|
if (ctx.ContextFlags && (flags_out & ThreadWriteContext))
|
|
|
|
{
|
|
|
|
mdThd.ThreadContext.Rva = dc->rva;
|
|
|
|
mdThd.ThreadContext.DataSize = sizeof(CONTEXT);
|
|
|
|
append(dc, &ctx, sizeof(CONTEXT));
|
|
|
|
}
|
|
|
|
if (mdThd.Stack.Memory.DataSize && (flags_out & ThreadWriteStack))
|
|
|
|
{
|
2012-01-23 21:37:10 +01:00
|
|
|
minidump_add_memory_block(dc, mdThd.Stack.StartOfMemoryRange,
|
|
|
|
mdThd.Stack.Memory.DataSize,
|
|
|
|
rva_base + sizeof(mdThdList.NumberOfThreads) +
|
|
|
|
mdThdList.NumberOfThreads * sizeof(mdThd) +
|
|
|
|
FIELD_OFFSET(MINIDUMP_THREAD, Stack.Memory.Rva));
|
2005-03-07 12:03:21 +01:00
|
|
|
}
|
|
|
|
writeat(dc,
|
|
|
|
rva_base + sizeof(mdThdList.NumberOfThreads) +
|
|
|
|
mdThdList.NumberOfThreads * sizeof(mdThd),
|
|
|
|
&mdThd, sizeof(mdThd));
|
|
|
|
mdThdList.NumberOfThreads++;
|
|
|
|
}
|
2012-01-23 21:37:10 +01:00
|
|
|
/* fetch CPU dependent thread info (like 256 bytes around program counter */
|
|
|
|
dbghelp_current_cpu->fetch_minidump_thread(dc, i, flags_out, &ctx);
|
2005-03-07 12:03:21 +01:00
|
|
|
}
|
|
|
|
writeat(dc, rva_base,
|
|
|
|
&mdThdList.NumberOfThreads, sizeof(mdThdList.NumberOfThreads));
|
2008-01-27 19:03:57 +01:00
|
|
|
|
2009-11-13 13:18:12 +01:00
|
|
|
return sz;
|
2005-03-07 12:03:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* dump_memory_info
|
|
|
|
*
|
|
|
|
* dumps information about the memory of the process (stack of the threads)
|
|
|
|
*/
|
2008-01-27 19:03:57 +01:00
|
|
|
static unsigned dump_memory_info(struct dump_context* dc)
|
2005-03-07 12:03:21 +01:00
|
|
|
{
|
|
|
|
MINIDUMP_MEMORY_LIST mdMemList;
|
|
|
|
MINIDUMP_MEMORY_DESCRIPTOR mdMem;
|
2004-04-06 00:21:27 +02:00
|
|
|
DWORD written;
|
2008-01-27 19:03:57 +01:00
|
|
|
unsigned i, pos, len, sz;
|
2005-03-07 12:03:21 +01:00
|
|
|
RVA rva_base;
|
|
|
|
char tmp[1024];
|
|
|
|
|
|
|
|
mdMemList.NumberOfMemoryRanges = dc->num_mem;
|
|
|
|
append(dc, &mdMemList.NumberOfMemoryRanges,
|
|
|
|
sizeof(mdMemList.NumberOfMemoryRanges));
|
|
|
|
rva_base = dc->rva;
|
2008-01-27 19:03:57 +01:00
|
|
|
sz = mdMemList.NumberOfMemoryRanges * sizeof(mdMem);
|
|
|
|
dc->rva += sz;
|
|
|
|
sz += sizeof(mdMemList.NumberOfMemoryRanges);
|
2005-03-07 12:03:21 +01:00
|
|
|
|
|
|
|
for (i = 0; i < dc->num_mem; i++)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2005-03-07 12:03:21 +01:00
|
|
|
mdMem.StartOfMemoryRange = dc->mem[i].base;
|
|
|
|
mdMem.Memory.Rva = dc->rva;
|
|
|
|
mdMem.Memory.DataSize = dc->mem[i].size;
|
|
|
|
SetFilePointer(dc->hFile, dc->rva, NULL, FILE_BEGIN);
|
|
|
|
for (pos = 0; pos < dc->mem[i].size; pos += sizeof(tmp))
|
|
|
|
{
|
|
|
|
len = min(dc->mem[i].size - pos, sizeof(tmp));
|
|
|
|
if (ReadProcessMemory(dc->hProcess,
|
2009-12-12 12:18:28 +01:00
|
|
|
(void*)(DWORD_PTR)(dc->mem[i].base + pos),
|
2005-03-07 12:03:21 +01:00
|
|
|
tmp, len, NULL))
|
|
|
|
WriteFile(dc->hFile, tmp, len, &written, NULL);
|
|
|
|
}
|
|
|
|
dc->rva += mdMem.Memory.DataSize;
|
|
|
|
writeat(dc, rva_base + i * sizeof(mdMem), &mdMem, sizeof(mdMem));
|
|
|
|
if (dc->mem[i].rva)
|
|
|
|
{
|
|
|
|
writeat(dc, dc->mem[i].rva, &mdMem.Memory.Rva, sizeof(mdMem.Memory.Rva));
|
|
|
|
}
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
2008-01-27 19:03:57 +01:00
|
|
|
|
|
|
|
return sz;
|
2005-03-07 12:03:21 +01:00
|
|
|
}
|
|
|
|
|
2008-01-27 19:03:57 +01:00
|
|
|
static unsigned dump_misc_info(struct dump_context* dc)
|
2005-03-07 12:03:21 +01:00
|
|
|
{
|
|
|
|
MINIDUMP_MISC_INFO mmi;
|
|
|
|
|
|
|
|
mmi.SizeOfInfo = sizeof(mmi);
|
|
|
|
mmi.Flags1 = MINIDUMP_MISC1_PROCESS_ID;
|
|
|
|
mmi.ProcessId = dc->pid;
|
|
|
|
/* FIXME: create/user/kernel time */
|
2008-01-17 22:59:22 +01:00
|
|
|
mmi.ProcessCreateTime = 0;
|
|
|
|
mmi.ProcessKernelTime = 0;
|
|
|
|
mmi.ProcessUserTime = 0;
|
|
|
|
|
2005-03-07 12:03:21 +01:00
|
|
|
append(dc, &mmi, sizeof(mmi));
|
2008-01-27 19:03:57 +01:00
|
|
|
return sizeof(mmi);
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* MiniDumpWriteDump (DEBUGHLP.@)
|
|
|
|
*
|
|
|
|
*/
|
2005-03-07 12:03:21 +01:00
|
|
|
BOOL WINAPI MiniDumpWriteDump(HANDLE hProcess, DWORD pid, HANDLE hFile,
|
2004-04-06 00:21:27 +02:00
|
|
|
MINIDUMP_TYPE DumpType,
|
|
|
|
PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam,
|
|
|
|
PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam,
|
|
|
|
PMINIDUMP_CALLBACK_INFORMATION CallbackParam)
|
|
|
|
{
|
2008-01-17 22:59:22 +01:00
|
|
|
static const MINIDUMP_DIRECTORY emptyDir = {UnusedStream, {0, 0}};
|
2004-04-06 00:21:27 +02:00
|
|
|
MINIDUMP_HEADER mdHead;
|
|
|
|
MINIDUMP_DIRECTORY mdDir;
|
2005-03-07 12:03:21 +01:00
|
|
|
DWORD i, nStreams, idx_stream;
|
|
|
|
struct dump_context dc;
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2005-03-07 12:03:21 +01:00
|
|
|
dc.hProcess = hProcess;
|
|
|
|
dc.hFile = hFile;
|
|
|
|
dc.pid = pid;
|
2008-01-13 17:02:08 +01:00
|
|
|
dc.modules = NULL;
|
|
|
|
dc.num_modules = 0;
|
2009-07-10 14:46:55 +02:00
|
|
|
dc.alloc_modules = 0;
|
2012-01-23 21:37:05 +01:00
|
|
|
dc.threads = NULL;
|
|
|
|
dc.num_threads = 0;
|
2005-03-07 12:03:21 +01:00
|
|
|
dc.cb = CallbackParam;
|
|
|
|
dc.type = DumpType;
|
|
|
|
dc.mem = NULL;
|
|
|
|
dc.num_mem = 0;
|
2009-07-10 14:46:55 +02:00
|
|
|
dc.alloc_mem = 0;
|
2005-03-07 12:03:21 +01:00
|
|
|
dc.rva = 0;
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2012-01-23 21:37:05 +01:00
|
|
|
if (!fetch_process_info(&dc)) return FALSE;
|
2008-01-13 17:02:08 +01:00
|
|
|
fetch_modules_info(&dc);
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2005-03-07 12:03:21 +01:00
|
|
|
/* 1) init */
|
|
|
|
nStreams = 6 + (ExceptionParam ? 1 : 0) +
|
|
|
|
(UserStreamParam ? UserStreamParam->UserStreamCount : 0);
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2008-01-17 22:59:22 +01:00
|
|
|
/* pad the directory size to a multiple of 4 for alignment purposes */
|
|
|
|
nStreams = (nStreams + 3) & ~3;
|
|
|
|
|
2004-04-06 00:21:27 +02:00
|
|
|
if (DumpType & MiniDumpWithDataSegs)
|
|
|
|
FIXME("NIY MiniDumpWithDataSegs\n");
|
|
|
|
if (DumpType & MiniDumpWithFullMemory)
|
|
|
|
FIXME("NIY MiniDumpWithFullMemory\n");
|
|
|
|
if (DumpType & MiniDumpWithHandleData)
|
|
|
|
FIXME("NIY MiniDumpWithHandleData\n");
|
|
|
|
if (DumpType & MiniDumpFilterMemory)
|
|
|
|
FIXME("NIY MiniDumpFilterMemory\n");
|
|
|
|
if (DumpType & MiniDumpScanMemory)
|
|
|
|
FIXME("NIY MiniDumpScanMemory\n");
|
|
|
|
|
|
|
|
/* 2) write header */
|
|
|
|
mdHead.Signature = MINIDUMP_SIGNATURE;
|
2008-01-17 22:59:22 +01:00
|
|
|
mdHead.Version = MINIDUMP_VERSION; /* NOTE: native puts in an 'implementation specific' value in the high order word of this member */
|
2005-03-07 12:03:21 +01:00
|
|
|
mdHead.NumberOfStreams = nStreams;
|
2008-01-17 22:59:22 +01:00
|
|
|
mdHead.CheckSum = 0; /* native sets a 0 checksum in its files */
|
2005-03-07 12:03:21 +01:00
|
|
|
mdHead.StreamDirectoryRva = sizeof(mdHead);
|
2004-04-06 00:21:27 +02:00
|
|
|
mdHead.u.TimeDateStamp = time(NULL);
|
|
|
|
mdHead.Flags = DumpType;
|
2005-03-07 12:03:21 +01:00
|
|
|
append(&dc, &mdHead, sizeof(mdHead));
|
|
|
|
|
2004-04-06 00:21:27 +02:00
|
|
|
/* 3) write stream directories */
|
2005-03-07 12:03:21 +01:00
|
|
|
dc.rva += nStreams * sizeof(mdDir);
|
|
|
|
idx_stream = 0;
|
|
|
|
|
2004-04-06 00:21:27 +02:00
|
|
|
/* 3.1) write data stream directories */
|
2005-03-07 12:03:21 +01:00
|
|
|
|
2007-12-22 02:21:56 +01:00
|
|
|
/* must be first in minidump */
|
|
|
|
mdDir.StreamType = SystemInfoStream;
|
|
|
|
mdDir.Location.Rva = dc.rva;
|
2008-01-27 19:03:57 +01:00
|
|
|
mdDir.Location.DataSize = dump_system_info(&dc);
|
2007-12-22 02:21:56 +01:00
|
|
|
writeat(&dc, mdHead.StreamDirectoryRva + idx_stream++ * sizeof(mdDir),
|
|
|
|
&mdDir, sizeof(mdDir));
|
|
|
|
|
2004-04-06 00:21:27 +02:00
|
|
|
mdDir.StreamType = ThreadListStream;
|
2005-03-07 12:03:21 +01:00
|
|
|
mdDir.Location.Rva = dc.rva;
|
2008-01-27 19:03:57 +01:00
|
|
|
mdDir.Location.DataSize = dump_threads(&dc, ExceptionParam);
|
2005-03-07 12:03:21 +01:00
|
|
|
writeat(&dc, mdHead.StreamDirectoryRva + idx_stream++ * sizeof(mdDir),
|
|
|
|
&mdDir, sizeof(mdDir));
|
|
|
|
|
|
|
|
mdDir.StreamType = ModuleListStream;
|
|
|
|
mdDir.Location.Rva = dc.rva;
|
2008-01-27 19:03:57 +01:00
|
|
|
mdDir.Location.DataSize = dump_modules(&dc, FALSE);
|
2005-03-07 12:03:21 +01:00
|
|
|
writeat(&dc, mdHead.StreamDirectoryRva + idx_stream++ * sizeof(mdDir),
|
|
|
|
&mdDir, sizeof(mdDir));
|
|
|
|
|
|
|
|
mdDir.StreamType = 0xfff0; /* FIXME: this is part of MS reserved streams */
|
|
|
|
mdDir.Location.Rva = dc.rva;
|
2008-01-27 19:03:57 +01:00
|
|
|
mdDir.Location.DataSize = dump_modules(&dc, TRUE);
|
2005-03-07 12:03:21 +01:00
|
|
|
writeat(&dc, mdHead.StreamDirectoryRva + idx_stream++ * sizeof(mdDir),
|
|
|
|
&mdDir, sizeof(mdDir));
|
|
|
|
|
|
|
|
mdDir.StreamType = MemoryListStream;
|
|
|
|
mdDir.Location.Rva = dc.rva;
|
2008-01-27 19:03:57 +01:00
|
|
|
mdDir.Location.DataSize = dump_memory_info(&dc);
|
2005-03-07 12:03:21 +01:00
|
|
|
writeat(&dc, mdHead.StreamDirectoryRva + idx_stream++ * sizeof(mdDir),
|
|
|
|
&mdDir, sizeof(mdDir));
|
|
|
|
|
|
|
|
mdDir.StreamType = MiscInfoStream;
|
|
|
|
mdDir.Location.Rva = dc.rva;
|
2008-01-27 19:03:57 +01:00
|
|
|
mdDir.Location.DataSize = dump_misc_info(&dc);
|
2005-03-07 12:03:21 +01:00
|
|
|
writeat(&dc, mdHead.StreamDirectoryRva + idx_stream++ * sizeof(mdDir),
|
|
|
|
&mdDir, sizeof(mdDir));
|
|
|
|
|
|
|
|
/* 3.2) write exception information (if any) */
|
|
|
|
if (ExceptionParam)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2005-03-07 12:03:21 +01:00
|
|
|
mdDir.StreamType = ExceptionStream;
|
|
|
|
mdDir.Location.Rva = dc.rva;
|
2008-01-27 19:03:57 +01:00
|
|
|
mdDir.Location.DataSize = dump_exception_info(&dc, ExceptionParam);
|
2005-03-07 12:03:21 +01:00
|
|
|
writeat(&dc, mdHead.StreamDirectoryRva + idx_stream++ * sizeof(mdDir),
|
|
|
|
&mdDir, sizeof(mdDir));
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
|
|
|
|
2005-03-07 12:03:21 +01:00
|
|
|
/* 3.3) write user defined streams (if any) */
|
|
|
|
if (UserStreamParam)
|
|
|
|
{
|
|
|
|
for (i = 0; i < UserStreamParam->UserStreamCount; i++)
|
|
|
|
{
|
|
|
|
mdDir.StreamType = UserStreamParam->UserStreamArray[i].Type;
|
|
|
|
mdDir.Location.DataSize = UserStreamParam->UserStreamArray[i].BufferSize;
|
|
|
|
mdDir.Location.Rva = dc.rva;
|
|
|
|
writeat(&dc, mdHead.StreamDirectoryRva + idx_stream++ * sizeof(mdDir),
|
|
|
|
&mdDir, sizeof(mdDir));
|
|
|
|
append(&dc, UserStreamParam->UserStreamArray[i].Buffer,
|
|
|
|
UserStreamParam->UserStreamArray[i].BufferSize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-17 22:59:22 +01:00
|
|
|
/* fill the remaining directory entries with 0's (unused stream types) */
|
|
|
|
/* NOTE: this should always come last in the dump! */
|
|
|
|
for (i = idx_stream; i < nStreams; i++)
|
|
|
|
writeat(&dc, mdHead.StreamDirectoryRva + i * sizeof(emptyDir), &emptyDir, sizeof(emptyDir));
|
|
|
|
|
2005-03-07 12:03:21 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, dc.mem);
|
2008-01-13 17:02:08 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, dc.modules);
|
2012-01-23 21:37:05 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, dc.threads);
|
2005-03-07 12:03:21 +01:00
|
|
|
|
2004-04-06 00:21:27 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2005-03-07 12:03:21 +01:00
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* MiniDumpReadDumpStream (DEBUGHLP.@)
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2007-08-03 00:51:09 +02:00
|
|
|
BOOL WINAPI MiniDumpReadDumpStream(PVOID base, ULONG str_idx,
|
2005-03-07 12:03:21 +01:00
|
|
|
PMINIDUMP_DIRECTORY* pdir,
|
2007-08-03 00:51:09 +02:00
|
|
|
PVOID* stream, ULONG* size)
|
2005-03-07 12:03:21 +01:00
|
|
|
{
|
2009-01-19 10:24:06 +01:00
|
|
|
MINIDUMP_HEADER* mdHead = base;
|
2005-03-07 12:03:21 +01:00
|
|
|
|
|
|
|
if (mdHead->Signature == MINIDUMP_SIGNATURE)
|
|
|
|
{
|
|
|
|
MINIDUMP_DIRECTORY* dir;
|
2008-09-24 21:50:05 +02:00
|
|
|
DWORD i;
|
2005-03-07 12:03:21 +01:00
|
|
|
|
|
|
|
dir = (MINIDUMP_DIRECTORY*)((char*)base + mdHead->StreamDirectoryRva);
|
|
|
|
for (i = 0; i < mdHead->NumberOfStreams; i++, dir++)
|
|
|
|
{
|
|
|
|
if (dir->StreamType == str_idx)
|
|
|
|
{
|
2009-05-21 06:31:04 +02:00
|
|
|
if (pdir) *pdir = dir;
|
|
|
|
if (stream) *stream = (char*)base + dir->Location.Rva;
|
|
|
|
if (size) *size = dir->Location.DataSize;
|
2005-03-07 12:03:21 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|