Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用WinDbg将托管字节[]的内容写入文件_Windbg_Sos - Fatal编程技术网

使用WinDbg将托管字节[]的内容写入文件

使用WinDbg将托管字节[]的内容写入文件,windbg,sos,Windbg,Sos,我有一个来自生产服务器的崩溃转储,显示OutOfMemoryException。例外情况本身与此无关 我碰巧跑了一辆自行车!dso要查看堆栈对象,请执行以下操作: 0:042> !dso OS Thread Id: 0x1014 (42) ESP/REG Object Name 246eeb24 109a21bc System.UnhandledExceptionEventHandler 246eeb2c 39083998 System.Runtime.Remoting.Proxie

我有一个来自生产服务器的崩溃转储,显示OutOfMemoryException。例外情况本身与此无关

我碰巧跑了一辆自行车!dso要查看堆栈对象,请执行以下操作:

0:042> !dso
OS Thread Id: 0x1014 (42)
ESP/REG  Object   Name
246eeb24 109a21bc System.UnhandledExceptionEventHandler
246eeb2c 39083998 System.Runtime.Remoting.Proxies.__TransparentProxy
246eeb34 39083b5c System.UnhandledExceptionEventArgs
246eeb48 39073280 System.Byte[]
246eec10 2e720050 System.OutOfMemoryException
[snip]
246ef250 0ac1c4d0 System.IO.MemoryStream <-- interesting
数组的前10个元素如下:

0:042> !dumparray -start 0 -length 10 50710038 
Name: System.Byte[]
MethodTable: 79333470
EEClass: 790eeb6c
Size: 67108876(0x400000c) bytes
Array: Rank 1, Number of elements 67108864, Type Byte
Element Methodtable: 79333520
[0] 50710040
[1] 50710041
[2] 50710042
[3] 50710043
[4] 50710044
[5] 50710045
[6] 50710046
[7] 50710047
[8] 50710048
[9] 50710049
这是一个巨大的阵列。我宁愿不要!把整件事都搞定了。我想查看文件中的输出

问题

是否可以将此字节[]的内容转储到文件中

我熟悉.writemem命令,但似乎无法使其正常工作。我试着写了全文,但WinDbg不喜欢这样:

0:042> .writemem C:\LargeBuffer.bin 50710040 L56071048
                                                     ^ Range error in '.writemem C:\LargeBuffer.bin 50710040 l56071048'

我是否设置了.writemem命令的格式不正确?

范围的
L
修饰符大小有限。如果要绕过限制,请使用
L?
范围修饰符。以下命令对我有效:

0:000> !do 0x04cc1000
Name:        System.Byte[]
MethodTable: 68374944
EEClass:     680aaf1c
Size:        67108876(0x400000c) bytes
Array:       Rank 1, Number of elements 67108864, Type Byte
Element Type:System.Byte
Content:     ................................................................................................................................
Fields:
None
0:000> .writemem c:\temp\array.bin 0x04cc1000 L?0x400000c
Writing 400000c bytes
.foreach($str {!DumpHeap /d -mt 00007ff890e96948 -min 0n126500 -short}){r@$t0=  dwo(${$str}+8)*2;.writemem e:\temp\str\${$str}.txt ${$str}+c L? @$t0} 

这就是我的工作原理:

0:000> !do 0x04cc1000
Name:        System.Byte[]
MethodTable: 68374944
EEClass:     680aaf1c
Size:        67108876(0x400000c) bytes
Array:       Rank 1, Number of elements 67108864, Type Byte
Element Type:System.Byte
Content:     ................................................................................................................................
Fields:
None
0:000> .writemem c:\temp\array.bin 0x04cc1000 L?0x400000c
Writing 400000c bytes
.foreach($str {!DumpHeap /d -mt 00007ff890e96948 -min 0n126500 -short}){r@$t0=  dwo(${$str}+8)*2;.writemem e:\temp\str\${$str}.txt ${$str}+c L? @$t0} 

我只是想指出,您需要向初始地址添加16个字节,否则您将在二进制文件中包含方法表。遗憾的是,这也会阻止您从范围大于1MB的两个地址之间写入数据
.writemem blah.dat 0x05da0063 0x5ea1245
也会失败。