Skip to content

Commit

Permalink
再次修复无法下载符号文件导致卡死
Browse files Browse the repository at this point in the history
  • Loading branch information
wwh1004 committed Jan 18, 2021
1 parent 92ca437 commit c22c459
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ csharp_style_expression_bodied_properties = true:suggestion
# Pattern matching preferences
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
csharp_style_prefer_switch_expression = true:suggestion
csharp_style_prefer_switch_expression = false:suggestion

# Null-checking preferences
csharp_style_conditional_delegate_call = true:suggestion
Expand Down
8 changes: 8 additions & 0 deletions ExtremeDumper-x86/ExtremeDumper-x86.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,13 @@
<PropertyGroup>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<Target Name="ClearReferenceCopyLocalPaths" AfterTargets="ResolveAssemblyReferences">
<ItemGroup>
<ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)" />
</ItemGroup>
</Target>
<Import Project="..\ExtremeDumper.Common.props" />
<ItemGroup>
<ProjectReference Include="..\ExtremeDumper\ExtremeDumper.csproj" />
</ItemGroup>
</Project>
4 changes: 1 addition & 3 deletions ExtremeDumper-x86/Program.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using System;
using System.IO;
using System.Reflection;

namespace ExtremeDumper_x86 {
internal static class Program {
[STAThread]
private static void Main() {
Assembly.LoadFile(Path.GetFullPath("ExtremeDumper.exe")).EntryPoint.Invoke(null, null);
ExtremeDumper.Program.Main();
}
}
}
4 changes: 2 additions & 2 deletions ExtremeDumper.Common.props
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project>
<PropertyGroup>
<Title>ExtremeDumper</Title>
<Version>3.0.0.1</Version>
<Copyright>Copyright © 2018-2020 Wwh</Copyright>
<Version>3.0.0.2</Version>
<Copyright>Copyright © 2018-2021 Wwh</Copyright>
<Description>.NET Assemblies Dumper</Description>
<ApplicationIcon>..\ExtremeDumper\Images\ExtremeDumper.ico</ApplicationIcon>
</PropertyGroup>
Expand Down
30 changes: 30 additions & 0 deletions ExtremeDumper/Forms/ModulesForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
using System.Reflection;
using System.Resources;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ExtremeDumper.Dumping;
using Microsoft.Diagnostics.Runtime;
using Microsoft.Diagnostics.Runtime.Utilities;
using NativeSharp;
using static ExtremeDumper.Forms.NativeMethods;
using ImageLayout = dnlib.PE.ImageLayout;
Expand Down Expand Up @@ -114,6 +116,7 @@ private void RefreshModuleList() {
if (_isDotNetProcess) {
try {
using (var dataTarget = DataTarget.AttachToProcess((int)_process.Id, 1000, AttachFlag.Passive)) {
dataTarget.SymbolLocator = DummySymbolLocator.Instance;
foreach (var clrModule in dataTarget.ClrVersions.Select(t => t.CreateRuntime()).SelectMany(t => t.AppDomains).SelectMany(t => t.Modules)) {
string name = clrModule.Name;
bool inMemory;
Expand Down Expand Up @@ -179,5 +182,32 @@ protected override void Dispose(bool disposing) {
}
base.Dispose(disposing);
}

private sealed class DummySymbolLocator : SymbolLocator {
public static DummySymbolLocator Instance { get; } = new DummySymbolLocator();

private DummySymbolLocator() {
}

public override string FindBinary(string fileName, int buildTimeStamp, int imageSize, bool checkProperties = true) {
return string.Empty;
}

public override Task<string> FindBinaryAsync(string fileName, int buildTimeStamp, int imageSize, bool checkProperties = true) {
return Task.FromResult(string.Empty);
}

public override string FindPdb(string pdbName, Guid pdbIndexGuid, int pdbIndexAge) {
return string.Empty;
}

public override Task<string> FindPdbAsync(string pdbName, Guid pdbIndexGuid, int pdbIndexAge) {
return Task.FromResult(string.Empty);
}

protected override Task CopyStreamToFileAsync(Stream input, string fullSrcPath, string fullDestPath, long size) {
throw new NotImplementedException();
}
}
}
}
2 changes: 0 additions & 2 deletions ExtremeDumper/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ namespace ExtremeDumper {
public static class Program {
[STAThread]
public static void Main() {
Environment.SetEnvironmentVariable("_NT_SYMBOL_PATH", string.Empty);
// 禁止在线搜索PDB文件
GlobalExceptionCatcher.Catch();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ build:
project: ExtremeDumper.sln
verbosity: normal
artifacts:
- path: bin\Release\
- path: bin\Release
name: ExtremeDumper
deploy:
- provider: GitHub
Expand Down

0 comments on commit c22c459

Please sign in to comment.