~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/programs/winedbg/tgt_minidump.c

Version: ~ [ wine-1.5.30 ] ~ [ wine-1.5.29 ] ~ [ wine-1.5.28 ] ~ [ wine-1.5.27 ] ~ [ wine-1.5.26 ] ~ [ wine-1.5.25 ] ~ [ wine-1.5.24 ] ~ [ wine-1.5.23 ] ~ [ wine-1.5.22 ] ~ [ wine-1.5.21 ] ~ [ wine-1.5.20 ] ~ [ wine-1.5.19 ] ~ [ wine-1.5.18 ] ~ [ wine-1.5.17 ] ~ [ wine-1.5.16 ] ~ [ wine-1.5.15 ] ~ [ wine-1.5.14 ] ~ [ wine-1.5.13 ] ~ [ wine-1.5.12 ] ~ [ wine-1.5.11 ] ~ [ wine-1.5.10 ] ~ [ wine-1.5.9 ] ~ [ wine-1.5.8 ] ~ [ wine-1.5.7 ] ~ [ wine-1.4.1 ] ~ [ wine-1.5.6 ] ~ [ wine-1.5.5 ] ~ [ wine-1.5.4 ] ~ [ wine-1.5.3 ] ~ [ wine-1.5.2 ] ~ [ wine-1.5.1 ] ~ [ wine-1.5.0 ] ~ [ wine-1.4 ] ~ [ wine-1.4-rc6 ] ~ [ wine-1.4-rc5 ] ~ [ wine-1.4-rc4 ] ~ [ wine-1.4-rc3 ] ~ [ wine-1.4-rc2 ] ~ [ wine-1.4-rc1 ] ~ [ wine-1.3.37 ] ~ [ wine-1.3.36 ] ~ [ wine-1.3.35 ] ~ [ wine-1.3.34 ] ~ [ wine-1.3.33 ] ~ [ wine-1.3.32 ] ~ [ wine-1.3.31 ] ~ [ wine-1.3.30 ] ~ [ wine-1.3.29 ] ~ [ wine-1.3.28 ] ~ [ wine-1.3.27 ] ~ [ wine-1.3.26 ] ~ [ wine-1.3.25 ] ~ [ wine-1.3.24 ] ~ [ wine-1.3.23 ] ~ [ wine-1.3.22 ] ~ [ wine-1.3.21 ] ~ [ wine-1.3.20 ] ~ [ wine-1.3.19 ] ~ [ wine-1.3.18 ] ~ [ wine-1.2.3 ] ~ [ wine-1.3.17 ] ~ [ wine-1.3.16 ] ~ [ wine-1.3.15 ] ~ [ wine-1.3.14 ] ~ [ wine-1.3.13 ] ~ [ wine-1.3.12 ] ~ [ wine-1.3.11 ] ~ [ wine-1.3.10 ] ~ [ wine-1.3.9 ] ~ [ wine-1.2.2 ] ~ [ wine-1.3.8 ] ~ [ wine-1.3.7 ] ~ [ wine-1.3.6 ] ~ [ wine-1.3.5 ] ~ [ wine-1.2.1 ] ~ [ wine-1.3.4 ] ~ [ wine-1.3.3 ] ~ [ wine-1.3.2 ] ~ [ wine-1.3.1 ] ~ [ wine-1.3.0 ] ~ [ wine-1.2 ] ~ [ wine-1.2-rc7 ] ~ [ wine-1.2-rc6 ] ~ [ wine-1.2-rc5 ] ~ [ wine-1.2-rc4 ] ~ [ wine-1.2-rc3 ] ~ [ wine-1.2-rc2 ] ~ [ wine-1.2-rc1 ] ~ [ wine-1.1.44 ] ~ [ wine-1.1.43 ] ~ [ wine-1.1.42 ] ~ [ wine-1.1.41 ] ~ [ wine-1.1.40 ] ~ [ wine-1.1.39 ] ~ [ wine-1.1.38 ] ~ [ wine-1.1.37 ] ~ [ wine-1.1.36 ] ~ [ wine-1.1.35 ] ~ [ wine-1.1.34 ] ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

  1 /*
  2  * Wine debugger - minidump handling
  3  *
  4  * Copyright 2005 Eric Pouech
  5  *
  6  * This library is free software; you can redistribute it and/or
  7  * modify it under the terms of the GNU Lesser General Public
  8  * License as published by the Free Software Foundation; either
  9  * version 2.1 of the License, or (at your option) any later version.
 10  *
 11  * This library is distributed in the hope that it will be useful,
 12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 14  * Lesser General Public License for more details.
 15  *
 16  * You should have received a copy of the GNU Lesser General Public
 17  * License along with this library; if not, write to the Free Software
 18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 19  */
 20 
 21 #define NONAMELESSUNION
 22 #define NONAMELESSSTRUCT
 23 
 24 #include "config.h"
 25 #include "wine/port.h"
 26 
 27 #include <stdlib.h>
 28 #include <stdio.h>
 29 #include <string.h>
 30 #include <stdarg.h>
 31 
 32 #include "debugger.h"
 33 #include "wingdi.h"
 34 #include "winuser.h"
 35 #include "tlhelp32.h"
 36 #include "wine/debug.h"
 37 #include "wine/exception.h"
 38 
 39 WINE_DEFAULT_DEBUG_CHANNEL(winedbg);
 40 
 41 static struct be_process_io be_process_minidump_io;
 42 
 43 /* we need this function on 32bit hosts to ensure we zero out the higher DWORD
 44  * stored in the minidump file (sometimes it's not cleared, or the conversion from
 45  * 32bit to 64bit wide integers is done as signed, which is wrong)
 46  * So we clamp on 32bit CPUs (as stored in minidump information) all addresses to
 47  * keep only the lower 32 bits.
 48  * FIXME: as of today, since we don't support a backend CPU which is different from
 49  * CPU this process is running on, casting to (DWORD_PTR) will do just fine.
 50  */
 51 static inline DWORD64  get_addr64(DWORD64 addr)
 52 {
 53     return (DWORD_PTR)addr;
 54 }
 55 
 56 void minidump_write(const char* file, const EXCEPTION_RECORD* rec)
 57 {
 58     HANDLE                              hFile;
 59     MINIDUMP_EXCEPTION_INFORMATION      mei;
 60     EXCEPTION_POINTERS                  ep;
 61 
 62     hFile = CreateFileA(file, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
 63                         FILE_ATTRIBUTE_NORMAL, NULL);
 64 
 65     if (hFile == INVALID_HANDLE_VALUE) return;
 66 
 67     if (rec)
 68     {
 69         mei.ThreadId = dbg_curr_thread->tid;
 70         mei.ExceptionPointers = &ep;
 71         ep.ExceptionRecord = (EXCEPTION_RECORD*)rec;
 72         ep.ContextRecord = &dbg_context;
 73         mei.ClientPointers = FALSE;
 74     }
 75     MiniDumpWriteDump(dbg_curr_process->handle, dbg_curr_process->pid,
 76                       hFile, MiniDumpNormal/*|MiniDumpWithDataSegs*/,
 77                       rec ? &mei : NULL, NULL, NULL);
 78     CloseHandle(hFile);
 79 }
 80 
 81 #define Wine_ElfModuleListStream        0xFFF0
 82 
 83 struct tgt_process_minidump_data
 84 {
 85     void*       mapping;
 86     HANDLE      hFile;
 87     HANDLE      hMap;
 88 };
 89 
 90 static inline struct tgt_process_minidump_data* private_data(struct dbg_process* pcs)
 91 {
 92     return pcs->pio_data;
 93 }
 94 
 95 static BOOL tgt_process_minidump_read(HANDLE hProcess, const void* addr,
 96                                       void* buffer, SIZE_T len, SIZE_T* rlen)
 97 {
 98     void*               stream;
 99 
100     if (!private_data(dbg_curr_process)->mapping) return FALSE;
101     if (MiniDumpReadDumpStream(private_data(dbg_curr_process)->mapping,
102                                MemoryListStream, NULL, &stream, NULL))
103     {
104         MINIDUMP_MEMORY_LIST*   mml = stream;
105         MINIDUMP_MEMORY_DESCRIPTOR* mmd = &mml->MemoryRanges[0];
106         int                     i;
107 
108         for (i = 0; i < mml->NumberOfMemoryRanges; i++, mmd++)
109         {
110             if (get_addr64(mmd->StartOfMemoryRange) <= (DWORD_PTR)addr &&
111                 (DWORD_PTR)addr < get_addr64(mmd->StartOfMemoryRange) + mmd->Memory.DataSize)
112             {
113                 len = min(len,
114                           get_addr64(mmd->StartOfMemoryRange) + mmd->Memory.DataSize - (DWORD_PTR)addr);
115                 memcpy(buffer,
116                        (char*)private_data(dbg_curr_process)->mapping + mmd->Memory.Rva + (DWORD_PTR)addr - get_addr64(mmd->StartOfMemoryRange),
117                        len);
118                 if (rlen) *rlen = len;
119                 return TRUE;
120             }
121         }
122     }
123     /* FIXME: this is a dirty hack to let the last frame in a bt to work
124      * However, we need to check who's to blame, this code or the current 
125      * dbghelp!StackWalk implementation
126      */
127     if ((DWORD_PTR)addr < 32)
128     {
129         memset(buffer, 0, len); 
130         if (rlen) *rlen = len;
131         return TRUE;
132     }
133     return FALSE;
134 }
135 
136 static BOOL tgt_process_minidump_write(HANDLE hProcess, void* addr,
137                                        const void* buffer, SIZE_T len, SIZE_T* wlen)
138 {
139     return FALSE;
140 }
141 
142 static BOOL CALLBACK validate_file(PCWSTR name, void* user)
143 {
144     return FALSE; /* get the first file we find !! */
145 }
146 
147 static BOOL is_pe_module_embedded(struct tgt_process_minidump_data* data,
148                                   MINIDUMP_MODULE* pe_mm)
149 {
150     MINIDUMP_MODULE_LIST*       mml;
151 
152     if (MiniDumpReadDumpStream(data->mapping, Wine_ElfModuleListStream, NULL,
153                                (void**)&mml, NULL))
154     {
155         MINIDUMP_MODULE*        mm;
156         unsigned                i;
157 
158         for (i = 0, mm = &mml->Modules[0]; i < mml->NumberOfModules; i++, mm++)
159         {
160             if (get_addr64(mm->BaseOfImage) <= get_addr64(pe_mm->BaseOfImage) &&
161                 get_addr64(mm->BaseOfImage) + mm->SizeOfImage >= get_addr64(pe_mm->BaseOfImage) + pe_mm->SizeOfImage)
162                 return TRUE;
163         }
164     }
165     return FALSE;
166 }
167 
168 static enum dbg_start minidump_do_reload(struct tgt_process_minidump_data* data)
169 {
170     void*                       stream;
171     DWORD                       pid = 1; /* by default */
172     HANDLE                      hProc = (HANDLE)0x900DBAAD;
173     int                         i;
174     MINIDUMP_MODULE_LIST*       mml;
175     MINIDUMP_MODULE*            mm;
176     MINIDUMP_STRING*            mds;
177     WCHAR                       exec_name[1024];
178     WCHAR                       nameW[1024];
179     unsigned                    len;
180     static WCHAR                default_exec_name[] = {'<','m','i','n','i','d','u','m','p','-','e','x','e','c','>',0};
181 
182     /* fetch PID */
183     if (MiniDumpReadDumpStream(data->mapping, MiscInfoStream, NULL, &stream, NULL))
184     {
185         MINIDUMP_MISC_INFO* mmi = stream;
186         if (mmi->Flags1 & MINIDUMP_MISC1_PROCESS_ID)
187             pid = mmi->ProcessId;
188     }
189 
190     /* fetch executable name (it's normally the first one in module list) */
191     lstrcpyW(exec_name, default_exec_name);
192     if (MiniDumpReadDumpStream(data->mapping, ModuleListStream, NULL, &stream, NULL))
193     {
194         mml = stream;
195         if (mml->NumberOfModules)
196         {
197             WCHAR*      ptr;
198 
199             mm = &mml->Modules[0];
200             mds = (MINIDUMP_STRING*)((char*)data->mapping + mm->ModuleNameRva);
201             len = mds->Length / 2;
202             memcpy(exec_name, mds->Buffer, mds->Length);
203             exec_name[len] = 0;
204             for (ptr = exec_name + len - 1; ptr >= exec_name; ptr--)
205             {
206                 if (*ptr == '/' || *ptr == '\\')
207                 {
208                     memmove(exec_name, ptr + 1, (lstrlenW(ptr + 1) + 1) * sizeof(WCHAR));
209                     break;
210                 }
211             }
212         }
213     }
214 
215     if (MiniDumpReadDumpStream(data->mapping, SystemInfoStream, NULL, &stream, NULL))
216     {
217         MINIDUMP_SYSTEM_INFO*   msi = stream;
218         const char *str;
219         char tmp[128];
220 
221         dbg_printf("WineDbg starting on minidump on pid %04x\n", pid);
222         switch (msi->ProcessorArchitecture)
223         {
224         case PROCESSOR_ARCHITECTURE_UNKNOWN:
225             str = "Unknown";
226             break;
227         case PROCESSOR_ARCHITECTURE_INTEL:
228             strcpy(tmp, "Intel ");
229             switch (msi->ProcessorLevel)
230             {
231             case  3: str = "80386"; break;
232             case  4: str = "80486"; break;
233             case  5: str = "Pentium"; break;
234             case  6: str = "Pentium Pro/II or AMD Athlon"; break;
235             case 15: str = "Pentium 4 or AMD Athlon64"; break;
236             default: str = "???"; break;
237             }
238             strcat(tmp, str);
239             if (msi->ProcessorLevel == 3 || msi->ProcessorLevel == 4)
240             {
241                 if (HIBYTE(msi->ProcessorRevision) == 0xFF)
242                     sprintf(tmp + strlen(tmp), " (%c%d)",
243                             'A' + ((msi->ProcessorRevision>>4)&0xf)-0x0a,
244                             ((msi->ProcessorRevision&0xf)));
245                 else
246                     sprintf(tmp + strlen(tmp), " (%c%d)",
247                             'A' + HIBYTE(msi->ProcessorRevision),
248                             LOBYTE(msi->ProcessorRevision));
249             }
250             else sprintf(tmp + strlen(tmp), " (%d.%d)",
251                          HIBYTE(msi->ProcessorRevision),
252                          LOBYTE(msi->ProcessorRevision));
253             str = tmp;
254             break;
255         case PROCESSOR_ARCHITECTURE_MIPS:
256             str = "Mips";
257             break;
258         case PROCESSOR_ARCHITECTURE_ALPHA:
259             str = "Alpha";
260             break;
261         case PROCESSOR_ARCHITECTURE_PPC:
262             str = "PowerPC";
263             break;
264         case PROCESSOR_ARCHITECTURE_AMD64:
265             str = "X86_64";
266             break;
267         case PROCESSOR_ARCHITECTURE_ARM:
268             str = "ARM";
269             break;
270         default:
271             str = "???";
272             break;
273         }
274         dbg_printf("  %s was running on #%d %s CPU%s",
275                    dbg_W2A(exec_name, -1), msi->u.s.NumberOfProcessors, str,
276                    msi->u.s.NumberOfProcessors < 2 ? "" : "s");
277         switch (msi->MajorVersion)
278         {
279         case 3:
280             switch (msi->MinorVersion)
281             {
282             case 51: str = "NT 3.51"; break;
283             default: str = "3-????"; break;
284             }
285             break;
286         case 4:
287             switch (msi->MinorVersion)
288             {
289             case 0: str = (msi->PlatformId == VER_PLATFORM_WIN32_NT) ? "NT 4.0" : "95"; break;
290             case 10: str = "98"; break;
291             case 90: str = "ME"; break;
292             default: str = "5-????"; break;
293             }
294             break;
295         case 5:
296             switch (msi->MinorVersion)
297             {
298             case 0: str = "2000"; break;
299             case 1: str = "XP"; break;
300             case 2: str = "Server 2003"; break;
301             default: str = "5-????"; break;
302             }
303             break;
304         default: str = "???"; break;
305         }
306         dbg_printf(" on Windows %s (%u)\n", str, msi->BuildNumber);
307         /* FIXME CSD: msi->CSDVersionRva */
308     }
309 
310     dbg_curr_process = dbg_add_process(&be_process_minidump_io, pid, hProc);
311     dbg_curr_pid = pid;
312     dbg_curr_process->pio_data = data;
313     dbg_set_process_name(dbg_curr_process, exec_name);
314 
315     dbg_init(hProc, NULL, FALSE);
316 
317     if (MiniDumpReadDumpStream(data->mapping, ThreadListStream, NULL, &stream, NULL))
318     {
319         MINIDUMP_THREAD_LIST*   mtl = stream;
320         ULONG                   i;
321 
322         for (i = 0; i < mtl->NumberOfThreads; i++)
323         {
324             dbg_add_thread(dbg_curr_process, mtl->Threads[i].ThreadId, NULL,
325                            (void*)(DWORD_PTR)get_addr64(mtl->Threads[i].Teb));
326         }
327     }
328     /* first load ELF modules, then do the PE ones */
329     if (MiniDumpReadDumpStream(data->mapping, Wine_ElfModuleListStream, NULL,
330                                &stream, NULL))
331     {
332         WCHAR   buffer[MAX_PATH];
333 
334         mml = stream;
335         for (i = 0, mm = &mml->Modules[0]; i < mml->NumberOfModules; i++, mm++)
336         {
337             mds = (MINIDUMP_STRING*)((char*)data->mapping + mm->ModuleNameRva);
338             memcpy(nameW, mds->Buffer, mds->Length);
339             nameW[mds->Length / sizeof(WCHAR)] = 0;
340             if (SymFindFileInPathW(hProc, NULL, nameW, (void*)(DWORD_PTR)mm->CheckSum,
341                                    0, 0, SSRVOPT_DWORD, buffer, validate_file, NULL))
342                 dbg_load_module(hProc, NULL, buffer, get_addr64(mm->BaseOfImage),
343                                  mm->SizeOfImage);
344             else
345                 SymLoadModuleExW(hProc, NULL, nameW, NULL, get_addr64(mm->BaseOfImage),
346                                  mm->SizeOfImage, NULL, SLMFLAG_VIRTUAL);
347         }
348     }
349     if (MiniDumpReadDumpStream(data->mapping, ModuleListStream, NULL, &stream, NULL))
350     {
351         WCHAR   buffer[MAX_PATH];
352 
353         mml = stream;
354         for (i = 0, mm = &mml->Modules[0]; i < mml->NumberOfModules; i++, mm++)
355         {
356             mds = (MINIDUMP_STRING*)((char*)data->mapping + mm->ModuleNameRva);
357             memcpy(nameW, mds->Buffer, mds->Length);
358             nameW[mds->Length / sizeof(WCHAR)] = 0;
359             if (SymFindFileInPathW(hProc, NULL, nameW, (void*)(DWORD_PTR)mm->TimeDateStamp,
360                                    mm->SizeOfImage, 0, SSRVOPT_DWORD, buffer, validate_file, NULL))
361                 dbg_load_module(hProc, NULL, buffer, get_addr64(mm->BaseOfImage),
362                                  mm->SizeOfImage);
363             else if (is_pe_module_embedded(data, mm))
364                 dbg_load_module(hProc, NULL, nameW, get_addr64(mm->BaseOfImage),
365                                  mm->SizeOfImage);
366             else
367                 SymLoadModuleExW(hProc, NULL, nameW, NULL, get_addr64(mm->BaseOfImage),
368                                  mm->SizeOfImage, NULL, SLMFLAG_VIRTUAL);
369         }
370     }
371     if (MiniDumpReadDumpStream(data->mapping, ExceptionStream, NULL, &stream, NULL))
372     {
373         MINIDUMP_EXCEPTION_STREAM*      mes = stream;
374 
375         if ((dbg_curr_thread = dbg_get_thread(dbg_curr_process, mes->ThreadId)))
376         {
377             ADDRESS64   addr;
378 
379             dbg_curr_tid = mes->ThreadId;
380             dbg_curr_thread->in_exception = TRUE;
381             dbg_curr_thread->excpt_record.ExceptionCode = mes->ExceptionRecord.ExceptionCode;
382             dbg_curr_thread->excpt_record.ExceptionFlags = mes->ExceptionRecord.ExceptionFlags;
383             dbg_curr_thread->excpt_record.ExceptionRecord = (void*)(DWORD_PTR)get_addr64(mes->ExceptionRecord.ExceptionRecord);
384             dbg_curr_thread->excpt_record.ExceptionAddress = (void*)(DWORD_PTR)get_addr64(mes->ExceptionRecord.ExceptionAddress);
385             dbg_curr_thread->excpt_record.NumberParameters = mes->ExceptionRecord.NumberParameters;
386             for (i = 0; i < dbg_curr_thread->excpt_record.NumberParameters; i++)
387             {
388                 dbg_curr_thread->excpt_record.ExceptionInformation[i] = mes->ExceptionRecord.ExceptionInformation[i];
389             }
390             memcpy(&dbg_context, (char*)data->mapping + mes->ThreadContext.Rva,
391                    min(sizeof(dbg_context), mes->ThreadContext.DataSize));
392             memory_get_current_pc(&addr);
393             stack_fetch_frames(&dbg_context);
394             be_cpu->print_context(dbg_curr_thread->handle, &dbg_context, 0);
395             stack_info(-1);
396             be_cpu->print_segment_info(dbg_curr_thread->handle, &dbg_context);
397             stack_backtrace(mes->ThreadId);
398             source_list_from_addr(&addr, 0);
399         }
400     }
401     return start_ok;
402 }
403 
404 static void cleanup(struct tgt_process_minidump_data* data)
405 {
406     if (data->mapping)                          UnmapViewOfFile(data->mapping);
407     if (data->hMap)                             CloseHandle(data->hMap);
408     if (data->hFile != INVALID_HANDLE_VALUE)    CloseHandle(data->hFile);
409     HeapFree(GetProcessHeap(), 0, data);
410 }
411 
412 static struct be_process_io be_process_minidump_io;
413 
414 enum dbg_start minidump_reload(int argc, char* argv[])
415 {
416     struct tgt_process_minidump_data*   data;
417     enum dbg_start                      ret = start_error_parse;
418 
419     /* try the form <myself> minidump-file */
420     if (argc != 1) return start_error_parse;
421     
422     WINE_TRACE("Processing Minidump file %s\n", argv[0]);
423 
424     data = HeapAlloc(GetProcessHeap(), 0, sizeof(struct tgt_process_minidump_data));
425     if (!data) return start_error_init;
426     data->mapping = NULL;
427     data->hMap    = NULL;
428     data->hFile   = INVALID_HANDLE_VALUE;
429 
430     if ((data->hFile = CreateFileA(argv[0], GENERIC_READ, FILE_SHARE_READ, NULL, 
431                                    OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) != INVALID_HANDLE_VALUE &&
432         ((data->hMap = CreateFileMappingA(data->hFile, NULL, PAGE_READONLY, 0, 0, NULL)) != 0) &&
433         ((data->mapping = MapViewOfFile(data->hMap, FILE_MAP_READ, 0, 0, 0)) != NULL))
434     {
435         __TRY
436         {
437             if (((MINIDUMP_HEADER*)data->mapping)->Signature == MINIDUMP_SIGNATURE)
438             {
439                 ret = minidump_do_reload(data);
440             }
441         }
442         __EXCEPT_PAGE_FAULT
443         {
444             dbg_printf("Unexpected fault while reading minidump %s\n", argv[0]);
445             dbg_curr_pid = 0;
446         }
447         __ENDTRY;
448     }
449     if (ret != start_ok) cleanup(data);
450     return ret;
451 }
452 
453 static BOOL tgt_process_minidump_close_process(struct dbg_process* pcs, BOOL kill)
454 {
455     struct tgt_process_minidump_data*    data = private_data(pcs);
456 
457     cleanup(data);
458     pcs->pio_data = NULL;
459     SymCleanup(pcs->handle);
460     dbg_del_process(pcs);
461     return TRUE;
462 }
463 
464 static BOOL tgt_process_minidump_get_selector(HANDLE hThread, DWORD sel, LDT_ENTRY* le)
465 {
466     /* so far, pretend all selectors are valid, and mapped to a 32bit flat address space */
467     memset(le, 0, sizeof(*le));
468     le->HighWord.Bits.Default_Big = 1;
469     return TRUE;
470 }
471 
472 static struct be_process_io be_process_minidump_io =
473 {
474     tgt_process_minidump_close_process,
475     tgt_process_minidump_read,
476     tgt_process_minidump_write,
477     tgt_process_minidump_get_selector,
478 };
479 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.