blob: fbc96f085ed4cd100aea118d087a2e400b90652f [file] [log] [blame]
Adrian McCarthyc96516f2015-08-03 23:01:51 +00001//===-- ProcessWinMiniDump.cpp ----------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "ProcessWinMiniDump.h"
11
12#include "lldb/Host/windows/windows.h"
13#include <DbgHelp.h>
14
15#include <assert.h>
16#include <stdlib.h>
Adrian McCarthyd9fa2b52015-11-12 21:16:15 +000017#include <memory>
Adrian McCarthyc96516f2015-08-03 23:01:51 +000018#include <mutex>
19
Adrian McCarthy0c35cde2015-12-04 22:22:15 +000020#include "Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h"
Adrian McCarthyc96516f2015-08-03 23:01:51 +000021#include "lldb/Core/DataBufferHeap.h"
22#include "lldb/Core/Log.h"
Adrian McCarthy0c35cde2015-12-04 22:22:15 +000023#include "lldb/Core/Module.h"
24#include "lldb/Core/ModuleSpec.h"
25#include "lldb/Core/PluginManager.h"
26#include "lldb/Core/Section.h"
27#include "lldb/Core/State.h"
28#include "lldb/Target/DynamicLoader.h"
29#include "lldb/Target/MemoryRegionInfo.h"
Adrian McCarthy61ede152015-08-19 20:43:22 +000030#include "lldb/Target/StopInfo.h"
Adrian McCarthyc96516f2015-08-03 23:01:51 +000031#include "lldb/Target/Target.h"
Adrian McCarthyc96516f2015-08-03 23:01:51 +000032#include "lldb/Target/UnixSignals.h"
Adrian McCarthy278a6c92015-12-09 00:29:38 +000033#include "lldb/Utility/LLDBAssert.h"
Adrian McCarthy0c35cde2015-12-04 22:22:15 +000034#include "llvm/Support/ConvertUTF.h"
Adrian McCarthy61ede152015-08-19 20:43:22 +000035#include "llvm/Support/Format.h"
36#include "llvm/Support/raw_ostream.h"
Adrian McCarthyc96516f2015-08-03 23:01:51 +000037
Adrian McCarthy27785dd2015-08-24 16:00:51 +000038#include "ExceptionRecord.h"
Adrian McCarthyc96516f2015-08-03 23:01:51 +000039#include "ThreadWinMiniDump.h"
40
41using namespace lldb_private;
42
Adrian McCarthy23d14b62015-08-28 14:42:03 +000043namespace
44{
45
46// Getting a string out of a mini dump is a chore. You're usually given a
47// relative virtual address (RVA), which points to a counted string that's in
48// Windows Unicode (UTF-16). This wrapper handles all the redirection and
49// returns a UTF-8 copy of the string.
50std::string
51GetMiniDumpString(const void *base_addr, const RVA rva)
52{
53 std::string result;
54 if (!base_addr)
55 {
56 return result;
57 }
58 auto md_string = reinterpret_cast<const MINIDUMP_STRING *>(static_cast<const char *>(base_addr) + rva);
59 auto source_start = reinterpret_cast<const UTF16 *>(md_string->Buffer);
60 const auto source_length = ::wcslen(md_string->Buffer);
61 const auto source_end = source_start + source_length;
62 result.resize(4*source_length); // worst case length
63 auto result_start = reinterpret_cast<UTF8 *>(&result[0]);
64 const auto result_end = result_start + result.size();
65 ConvertUTF16toUTF8(&source_start, source_end, &result_start, result_end, strictConversion);
66 const auto result_size = std::distance(reinterpret_cast<UTF8 *>(&result[0]), result_start);
67 result.resize(result_size); // shrink to actual length
68 return result;
69}
70
71} // anonymous namespace
72
Adrian McCarthyc96516f2015-08-03 23:01:51 +000073// Encapsulates the private data for ProcessWinMiniDump.
74// TODO(amccarth): Determine if we need a mutex for access.
75class ProcessWinMiniDump::Data
76{
77public:
78 Data();
79 ~Data();
80
81 FileSpec m_core_file;
82 HANDLE m_dump_file; // handle to the open minidump file
83 HANDLE m_mapping; // handle to the file mapping for the minidump file
84 void * m_base_addr; // base memory address of the minidump
Adrian McCarthy61ede152015-08-19 20:43:22 +000085 std::shared_ptr<ExceptionRecord> m_exception_sp;
Adrian McCarthyc96516f2015-08-03 23:01:51 +000086};
87
88ConstString
89ProcessWinMiniDump::GetPluginNameStatic()
90{
91 static ConstString g_name("win-minidump");
92 return g_name;
93}
94
95const char *
96ProcessWinMiniDump::GetPluginDescriptionStatic()
97{
98 return "Windows minidump plug-in.";
99}
100
101void
102ProcessWinMiniDump::Terminate()
103{
104 PluginManager::UnregisterPlugin(ProcessWinMiniDump::CreateInstance);
105}
106
107
108lldb::ProcessSP
Zachary Turner7529df92015-09-01 20:02:29 +0000109ProcessWinMiniDump::CreateInstance(lldb::TargetSP target_sp, Listener &listener, const FileSpec *crash_file)
Adrian McCarthyc96516f2015-08-03 23:01:51 +0000110{
111 lldb::ProcessSP process_sp;
112 if (crash_file)
113 {
Zachary Turner7529df92015-09-01 20:02:29 +0000114 process_sp.reset(new ProcessWinMiniDump(target_sp, listener, *crash_file));
Adrian McCarthyc96516f2015-08-03 23:01:51 +0000115 }
116 return process_sp;
117}
118
119bool
Zachary Turner7529df92015-09-01 20:02:29 +0000120ProcessWinMiniDump::CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name)
Adrian McCarthyc96516f2015-08-03 23:01:51 +0000121{
122 // TODO(amccarth): Eventually, this needs some actual logic.
123 return true;
124}
125
Zachary Turner7529df92015-09-01 20:02:29 +0000126ProcessWinMiniDump::ProcessWinMiniDump(lldb::TargetSP target_sp, Listener &listener,
Adrian McCarthyc96516f2015-08-03 23:01:51 +0000127 const FileSpec &core_file) :
Adrian McCarthy18a9135d2015-10-28 18:21:45 +0000128 ProcessWindows(target_sp, listener),
Adrian McCarthyc96516f2015-08-03 23:01:51 +0000129 m_data_up(new Data)
130{
131 m_data_up->m_core_file = core_file;
132}
133
134ProcessWinMiniDump::~ProcessWinMiniDump()
135{
136 Clear();
137 // We need to call finalize on the process before destroying ourselves
138 // to make sure all of the broadcaster cleanup goes as planned. If we
139 // destruct this class, then Process::~Process() might have problems
140 // trying to fully destroy the broadcaster.
141 Finalize();
142}
143
144ConstString
145ProcessWinMiniDump::GetPluginName()
146{
147 return GetPluginNameStatic();
148}
149
150uint32_t
151ProcessWinMiniDump::GetPluginVersion()
152{
153 return 1;
154}
155
156
157Error
158ProcessWinMiniDump::DoLoadCore()
159{
160 Error error;
161
162 error = MapMiniDumpIntoMemory(m_data_up->m_core_file.GetCString());
163 if (error.Fail())
164 {
165 return error;
166 }
167
Zachary Turner7529df92015-09-01 20:02:29 +0000168 GetTarget().SetArchitecture(DetermineArchitecture());
Adrian McCarthyab59a0f2015-09-17 20:52:29 +0000169 ReadMiscInfo(); // notably for process ID
Adrian McCarthy23d14b62015-08-28 14:42:03 +0000170 ReadModuleList();
Adrian McCarthy61ede152015-08-19 20:43:22 +0000171 ReadExceptionRecord();
Adrian McCarthyc96516f2015-08-03 23:01:51 +0000172
173 return error;
174
175}
176
177DynamicLoader *
178ProcessWinMiniDump::GetDynamicLoader()
179{
180 if (m_dyld_ap.get() == NULL)
181 m_dyld_ap.reset (DynamicLoader::FindPlugin(this, DynamicLoaderWindowsDYLD::GetPluginNameStatic().GetCString()));
182 return m_dyld_ap.get();
183}
184
185bool
186ProcessWinMiniDump::UpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list)
187{
Adrian McCarthy61ede152015-08-19 20:43:22 +0000188 size_t size = 0;
189 auto thread_list_ptr = static_cast<const MINIDUMP_THREAD_LIST *>(FindDumpStream(ThreadListStream, &size));
190 if (thread_list_ptr)
Adrian McCarthyc96516f2015-08-03 23:01:51 +0000191 {
Adrian McCarthyc96516f2015-08-03 23:01:51 +0000192 const ULONG32 thread_count = thread_list_ptr->NumberOfThreads;
Adrian McCarthy61ede152015-08-19 20:43:22 +0000193 for (ULONG32 i = 0; i < thread_count; ++i) {
Adrian McCarthyd9fa2b52015-11-12 21:16:15 +0000194 const auto &mini_dump_thread = thread_list_ptr->Threads[i];
195 auto thread_sp = std::make_shared<ThreadWinMiniDump>(*this, mini_dump_thread.ThreadId);
196 if (mini_dump_thread.ThreadContext.DataSize >= sizeof(CONTEXT))
197 {
198 const CONTEXT *context = reinterpret_cast<const CONTEXT *>(static_cast<const char *>(m_data_up->m_base_addr) + mini_dump_thread.ThreadContext.Rva);
199 thread_sp->SetContext(context);
200 }
Adrian McCarthyc96516f2015-08-03 23:01:51 +0000201 new_thread_list.AddThread(thread_sp);
202 }
203 }
204
205 return new_thread_list.GetSize(false) > 0;
206}
207
208void
209ProcessWinMiniDump::RefreshStateAfterStop()
210{
Adrian McCarthy61ede152015-08-19 20:43:22 +0000211 if (!m_data_up) return;
212 if (!m_data_up->m_exception_sp) return;
213
214 auto active_exception = m_data_up->m_exception_sp;
215 std::string desc;
216 llvm::raw_string_ostream desc_stream(desc);
217 desc_stream << "Exception "
218 << llvm::format_hex(active_exception->GetExceptionCode(), 8)
219 << " encountered at address "
220 << llvm::format_hex(active_exception->GetExceptionAddress(), 8);
221 m_thread_list.SetSelectedThreadByID(active_exception->GetThreadID());
222 auto stop_thread = m_thread_list.GetSelectedThread();
223 auto stop_info = StopInfo::CreateStopReasonWithException(*stop_thread, desc_stream.str().c_str());
224 stop_thread->SetStopInfo(stop_info);
Adrian McCarthyc96516f2015-08-03 23:01:51 +0000225}
226
227Error
228ProcessWinMiniDump::DoDestroy()
229{
230 return Error();
231}
232
233bool
234ProcessWinMiniDump::IsAlive()
235{
236 return true;
237}
238
Adrian McCarthy6c3d03c2015-09-01 16:59:31 +0000239bool
240ProcessWinMiniDump::WarnBeforeDetach () const
241{
242 // Since this is post-mortem debugging, there's no need to warn the user
243 // that quitting the debugger will terminate the process.
244 return false;
245}
246
Adrian McCarthyc96516f2015-08-03 23:01:51 +0000247size_t
248ProcessWinMiniDump::ReadMemory(lldb::addr_t addr, void *buf, size_t size, Error &error)
249{
250 // Don't allow the caching that lldb_private::Process::ReadMemory does
Adrian McCarthy6c3d03c2015-09-01 16:59:31 +0000251 // since we have it all cached our our dump file anyway.
Adrian McCarthyc96516f2015-08-03 23:01:51 +0000252 return DoReadMemory(addr, buf, size, error);
253}
254
255size_t
256ProcessWinMiniDump::DoReadMemory(lldb::addr_t addr, void *buf, size_t size, Error &error)
257{
Adrian McCarthy6c3d03c2015-09-01 16:59:31 +0000258 // I don't have a sense of how frequently this is called or how many memory
259 // ranges a mini dump typically has, so I'm not sure if searching for the
260 // appropriate range linearly each time is stupid. Perhaps we should build
261 // an index for faster lookups.
262 Range range = {0};
263 if (!FindMemoryRange(addr, &range))
264 {
265 return 0;
266 }
267
268 // There's at least some overlap between the beginning of the desired range
269 // (addr) and the current range. Figure out where the overlap begins and
270 // how much overlap there is, then copy it to the destination buffer.
Adrian McCarthy278a6c92015-12-09 00:29:38 +0000271 lldbassert(range.start <= addr);
272 const size_t offset = addr - range.start;
273 lldbassert(offset < range.size);
Adrian McCarthy6c3d03c2015-09-01 16:59:31 +0000274 const size_t overlap = std::min(size, range.size - offset);
275 std::memcpy(buf, range.ptr + offset, overlap);
276 return overlap;
Adrian McCarthyc96516f2015-08-03 23:01:51 +0000277}
278
Adrian McCarthy0c35cde2015-12-04 22:22:15 +0000279Error
280ProcessWinMiniDump::GetMemoryRegionInfo(lldb::addr_t load_addr, lldb_private::MemoryRegionInfo &info)
281{
282 Error error;
283 size_t size;
284 const auto list = reinterpret_cast<const MINIDUMP_MEMORY_INFO_LIST *>(FindDumpStream(MemoryInfoListStream, &size));
285 if (list == nullptr || size < sizeof(MINIDUMP_MEMORY_INFO_LIST))
286 {
287 error.SetErrorString("the mini dump contains no memory range information");
288 return error;
289 }
290
291 if (list->SizeOfEntry < sizeof(MINIDUMP_MEMORY_INFO))
292 {
293 error.SetErrorString("the entries in the mini dump memory info list are smaller than expected");
294 return error;
295 }
296
297 if (size < list->SizeOfHeader + list->SizeOfEntry * list->NumberOfEntries)
298 {
299 error.SetErrorString("the mini dump memory info list is incomplete");
300 return error;
301 }
302
303 for (int i = 0; i < list->NumberOfEntries; ++i)
304 {
305 const auto entry = reinterpret_cast<const MINIDUMP_MEMORY_INFO *>(reinterpret_cast<const char *>(list) +
306 list->SizeOfHeader + i * list->SizeOfEntry);
307 const auto head = entry->BaseAddress;
308 const auto tail = head + entry->RegionSize;
309 if (head <= load_addr && load_addr < tail)
310 {
311 info.SetReadable(IsPageReadable(entry->Protect) ? MemoryRegionInfo::eYes : MemoryRegionInfo::eNo);
312 info.SetWritable(IsPageWritable(entry->Protect) ? MemoryRegionInfo::eYes : MemoryRegionInfo::eNo);
313 info.SetExecutable(IsPageExecutable(entry->Protect) ? MemoryRegionInfo::eYes : MemoryRegionInfo::eNo);
314 return error;
315 }
316 }
317 // Note that the memory info list doesn't seem to contain ranges in kernel space,
318 // so if you're walking a stack that has kernel frames, the stack may appear
319 // truncated.
320 error.SetErrorString("address is not in a known range");
321 return error;
322}
323
Adrian McCarthyc96516f2015-08-03 23:01:51 +0000324void
325ProcessWinMiniDump::Clear()
326{
327 m_thread_list.Clear();
328}
329
330void
331ProcessWinMiniDump::Initialize()
332{
333 static std::once_flag g_once_flag;
334
335 std::call_once(g_once_flag, []()
336 {
337 PluginManager::RegisterPlugin(GetPluginNameStatic(),
338 GetPluginDescriptionStatic(),
339 CreateInstance);
340 });
341}
342
Adrian McCarthyc96516f2015-08-03 23:01:51 +0000343ArchSpec
344ProcessWinMiniDump::GetArchitecture()
345{
346 // TODO
347 return ArchSpec();
348}
349
350
351ProcessWinMiniDump::Data::Data() :
352 m_dump_file(INVALID_HANDLE_VALUE),
353 m_mapping(NULL),
354 m_base_addr(nullptr)
355{
356}
357
358ProcessWinMiniDump::Data::~Data()
359{
360 if (m_base_addr)
361 {
362 ::UnmapViewOfFile(m_base_addr);
363 m_base_addr = nullptr;
364 }
365 if (m_mapping)
366 {
367 ::CloseHandle(m_mapping);
368 m_mapping = NULL;
369 }
370 if (m_dump_file != INVALID_HANDLE_VALUE)
371 {
372 ::CloseHandle(m_dump_file);
373 m_dump_file = INVALID_HANDLE_VALUE;
374 }
375}
376
Adrian McCarthy6c3d03c2015-09-01 16:59:31 +0000377bool
378ProcessWinMiniDump::FindMemoryRange(lldb::addr_t addr, Range *range_out) const
379{
380 size_t stream_size = 0;
381 auto mem_list_stream = static_cast<const MINIDUMP_MEMORY_LIST *>(FindDumpStream(MemoryListStream, &stream_size));
382 if (mem_list_stream)
383 {
384 for (ULONG32 i = 0; i < mem_list_stream->NumberOfMemoryRanges; ++i) {
385 const MINIDUMP_MEMORY_DESCRIPTOR &mem_desc = mem_list_stream->MemoryRanges[i];
386 const MINIDUMP_LOCATION_DESCRIPTOR &loc_desc = mem_desc.Memory;
387 const lldb::addr_t range_start = mem_desc.StartOfMemoryRange;
388 const size_t range_size = loc_desc.DataSize;
389 if (range_start <= addr && addr < range_start + range_size)
390 {
391 range_out->start = range_start;
392 range_out->size = range_size;
393 range_out->ptr = reinterpret_cast<const uint8_t *>(m_data_up->m_base_addr) + loc_desc.Rva;
394 return true;
395 }
396 }
397 }
398
399 // Some mini dumps have a Memory64ListStream that captures all the heap
400 // memory. We can't exactly use the same loop as above, because the mini
401 // dump uses slightly different data structures to describe those.
402 auto mem_list64_stream = static_cast<const MINIDUMP_MEMORY64_LIST *>(FindDumpStream(Memory64ListStream, &stream_size));
403 if (mem_list64_stream)
404 {
405 size_t base_rva = mem_list64_stream->BaseRva;
406 for (ULONG32 i = 0; i < mem_list64_stream->NumberOfMemoryRanges; ++i) {
407 const MINIDUMP_MEMORY_DESCRIPTOR64 &mem_desc = mem_list64_stream->MemoryRanges[i];
408 const lldb::addr_t range_start = mem_desc.StartOfMemoryRange;
409 const size_t range_size = mem_desc.DataSize;
410 if (range_start <= addr && addr < range_start + range_size)
411 {
412 range_out->start = range_start;
413 range_out->size = range_size;
414 range_out->ptr = reinterpret_cast<const uint8_t *>(m_data_up->m_base_addr) + base_rva;
415 return true;
416 }
417 base_rva += range_size;
418 }
419 }
420
421 return false;
422}
423
424
Adrian McCarthyc96516f2015-08-03 23:01:51 +0000425Error
426ProcessWinMiniDump::MapMiniDumpIntoMemory(const char *file)
427{
428 Error error;
429
430 m_data_up->m_dump_file = ::CreateFile(file, GENERIC_READ, FILE_SHARE_READ,
431 NULL, OPEN_EXISTING,
432 FILE_ATTRIBUTE_NORMAL, NULL);
433 if (m_data_up->m_dump_file == INVALID_HANDLE_VALUE)
434 {
435 error.SetError(::GetLastError(), lldb::eErrorTypeWin32);
436 return error;
437 }
438
439 m_data_up->m_mapping = ::CreateFileMapping(m_data_up->m_dump_file, NULL,
440 PAGE_READONLY, 0, 0, NULL);
441 if (m_data_up->m_mapping == NULL)
442 {
443 error.SetError(::GetLastError(), lldb::eErrorTypeWin32);
444 return error;
445 }
446
447 m_data_up->m_base_addr = ::MapViewOfFile(m_data_up->m_mapping, FILE_MAP_READ, 0, 0, 0);
448 if (m_data_up->m_base_addr == NULL)
449 {
450 error.SetError(::GetLastError(), lldb::eErrorTypeWin32);
451 return error;
452 }
453
454 return error;
455}
456
457
458ArchSpec
459ProcessWinMiniDump::DetermineArchitecture()
460{
Adrian McCarthy61ede152015-08-19 20:43:22 +0000461 size_t size = 0;
462 auto system_info_ptr = static_cast<const MINIDUMP_SYSTEM_INFO *>(FindDumpStream(SystemInfoStream, &size));
463 if (system_info_ptr)
Adrian McCarthyc96516f2015-08-03 23:01:51 +0000464 {
Adrian McCarthyc96516f2015-08-03 23:01:51 +0000465 switch (system_info_ptr->ProcessorArchitecture)
466 {
467 case PROCESSOR_ARCHITECTURE_INTEL:
468 return ArchSpec(eArchTypeCOFF, IMAGE_FILE_MACHINE_I386, LLDB_INVALID_CPUTYPE);
469 case PROCESSOR_ARCHITECTURE_AMD64:
470 return ArchSpec(eArchTypeCOFF, IMAGE_FILE_MACHINE_AMD64, LLDB_INVALID_CPUTYPE);
471 default:
472 break;
473 }
474 }
475
476 return ArchSpec(); // invalid or unknown
477}
Adrian McCarthy61ede152015-08-19 20:43:22 +0000478
479void
Adrian McCarthyab59a0f2015-09-17 20:52:29 +0000480ProcessWinMiniDump::ReadExceptionRecord()
481{
Adrian McCarthy61ede152015-08-19 20:43:22 +0000482 size_t size = 0;
483 auto exception_stream_ptr = static_cast<MINIDUMP_EXCEPTION_STREAM*>(FindDumpStream(ExceptionStream, &size));
484 if (exception_stream_ptr)
485 {
486 m_data_up->m_exception_sp.reset(new ExceptionRecord(exception_stream_ptr->ExceptionRecord, exception_stream_ptr->ThreadId));
487 }
488}
489
Adrian McCarthy23d14b62015-08-28 14:42:03 +0000490void
Adrian McCarthyab59a0f2015-09-17 20:52:29 +0000491ProcessWinMiniDump::ReadMiscInfo()
492{
493 size_t size = 0;
494 const auto misc_info_ptr = static_cast<MINIDUMP_MISC_INFO*>(FindDumpStream(MiscInfoStream, &size));
495 if (!misc_info_ptr || size < sizeof(MINIDUMP_MISC_INFO)) {
496 return;
497 }
498
499 if ((misc_info_ptr->Flags1 & MINIDUMP_MISC1_PROCESS_ID) != 0) {
500 // This misc info record has the process ID.
501 SetID(misc_info_ptr->ProcessId);
502 }
503}
504
505void
506ProcessWinMiniDump::ReadModuleList()
507{
Adrian McCarthy23d14b62015-08-28 14:42:03 +0000508 size_t size = 0;
509 auto module_list_ptr = static_cast<MINIDUMP_MODULE_LIST*>(FindDumpStream(ModuleListStream, &size));
510 if (!module_list_ptr || module_list_ptr->NumberOfModules == 0)
511 {
512 return;
513 }
514
515 for (ULONG32 i = 0; i < module_list_ptr->NumberOfModules; ++i)
516 {
517 const auto &module = module_list_ptr->Modules[i];
518 const auto file_name = GetMiniDumpString(m_data_up->m_base_addr, module.ModuleNameRva);
519 ModuleSpec module_spec = FileSpec(file_name, true);
520
521 lldb::ModuleSP module_sp = GetTarget().GetSharedModule(module_spec);
522 if (!module_sp)
523 {
524 continue;
525 }
526 bool load_addr_changed = false;
527 module_sp->SetLoadAddress(GetTarget(), module.BaseOfImage, false, load_addr_changed);
528 }
529}
530
Adrian McCarthy61ede152015-08-19 20:43:22 +0000531void *
Adrian McCarthy6c3d03c2015-09-01 16:59:31 +0000532ProcessWinMiniDump::FindDumpStream(unsigned stream_number, size_t *size_out) const
533{
Adrian McCarthy61ede152015-08-19 20:43:22 +0000534 void *stream = nullptr;
535 *size_out = 0;
536
537 assert(m_data_up != nullptr);
538 assert(m_data_up->m_base_addr != 0);
539
540 MINIDUMP_DIRECTORY *dir = nullptr;
541 if (::MiniDumpReadDumpStream(m_data_up->m_base_addr, stream_number, &dir, nullptr, nullptr) &&
542 dir != nullptr && dir->Location.DataSize > 0)
543 {
544 assert(dir->StreamType == stream_number);
545 *size_out = dir->Location.DataSize;
546 stream = static_cast<void*>(static_cast<char*>(m_data_up->m_base_addr) + dir->Location.Rva);
547 }
548
549 return stream;
550}