Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
alastorid authored Aug 14, 2020
1 parent a639cbb commit 4a28af4
Show file tree
Hide file tree
Showing 2 changed files with 732 additions and 0 deletions.
111 changes: 111 additions & 0 deletions WindbgEx.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
// ReSharper disable StringLiteralTypo

namespace WindbgEx
{
enum ARCH
{
AMD64,
WOW64,
X86
};
class WindbgEx
{
static void windbg(string dumpfile)
{
Console.Write($"Loading {dumpfile}...");
using (var dbg = new dbgeng())
{
var result = dbg.OpenDumpFile(dumpfile);
if (null != result)
{
Console.WriteLine($"{result}");
return;
}

ARCH arch;

var lm = dbg.Execute("lm");
var vertarget = dbg.Execute("vertarget");

if (lm.Contains("wow64cpu") && lm.Contains("ntdll_"))
{
arch = ARCH.WOW64;
}
else if(vertarget.Contains(".amd64"))
{
arch = ARCH.AMD64;
}
else
{
arch = ARCH.X86;
}

if (arch == ARCH.WOW64)
{
Console.WriteLine(dbg.Execute(@"!wow64exts.sw;"));
}
//===================================

var line = "=w=";
while (false == line?.StartsWith("q"))
{
var mre = new ManualResetEvent(false);
Console.Write("> ");
line = Console.ReadLine();

var tt = new Thread(() =>
{
var bb = new[]
{
"\r-BUSY-",
"\r/BUSY/",
"\r-BUSY-",
"\r\\BUSY\\",
};
var i = 0;
while (false == mre.WaitOne(333))
{
Console.Write(bb[i]);
i++;
if (i == bb.Length)
{
i = 0;
}
}
Console.Write("\r \r");
}) { IsBackground = true};
tt.Start();
result = dbg.Execute(line, (m, t) =>
{
mre.Set();
tt.Join();
Console.Write(t);
return 0;
});

Console.WriteLine($"{result}");
}
//===================================
}
Console.WriteLine("bye");
}
static void Main(string[] args)
{
byte[] inputBuffer = new byte[65535];
Stream inputStream = Console.OpenStandardInput(inputBuffer.Length);
Console.SetIn(new StreamReader(inputStream, Console.InputEncoding, false, inputBuffer.Length));

if (args.Length == 1)
{
windbg(args[0]);
}
}
}
}
Loading

0 comments on commit 4a28af4

Please sign in to comment.