-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
1,195 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "Deviare-InProc"] | ||
path = Deviare-InProc | ||
url = https://github.com/nektra/Deviare-InProc.git |
Submodule Deviare-InProc
added at
ef115d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,13 @@ | ||
# WingDbg | ||
Friends don't let friends debug alone | ||
Friends don't let friends debug alone. | ||
|
||
|
||
## !regfix | ||
Fixes that nasty bug in WinDbg that makes it not show any | ||
registers when performing kernel debugging on targets older | ||
than Windows 8 (approximately). Present since around WinDbg version 6.2. | ||
|
||
For more information, see [here][1]. | ||
|
||
|
||
[1]: http://stackoverflow.com/q/35961246/851560 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 14 | ||
VisualStudioVersion = 14.0.24720.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WingDbg", "WingDbg\WingDbg.vcxproj", "{FB9DB05A-769F-47BA-B115-9DDA49F82197}" | ||
ProjectSection(ProjectDependencies) = postProject | ||
{7DE03078-DA93-4D66-8164-76277522D3F6} = {7DE03078-DA93-4D66-8164-76277522D3F6} | ||
EndProjectSection | ||
EndProject | ||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NktHookLib", "Deviare-InProc\Src\vs2015\NktHookLib.vcxproj", "{7DE03078-DA93-4D66-8164-76277522D3F6}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|x64 = Debug|x64 | ||
Debug|x86 = Debug|x86 | ||
Release|x64 = Release|x64 | ||
Release|x86 = Release|x86 | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{FB9DB05A-769F-47BA-B115-9DDA49F82197}.Debug|x64.ActiveCfg = Debug|x64 | ||
{FB9DB05A-769F-47BA-B115-9DDA49F82197}.Debug|x64.Build.0 = Debug|x64 | ||
{FB9DB05A-769F-47BA-B115-9DDA49F82197}.Debug|x86.ActiveCfg = Debug|Win32 | ||
{FB9DB05A-769F-47BA-B115-9DDA49F82197}.Debug|x86.Build.0 = Debug|Win32 | ||
{FB9DB05A-769F-47BA-B115-9DDA49F82197}.Release|x64.ActiveCfg = Release|x64 | ||
{FB9DB05A-769F-47BA-B115-9DDA49F82197}.Release|x64.Build.0 = Release|x64 | ||
{FB9DB05A-769F-47BA-B115-9DDA49F82197}.Release|x86.ActiveCfg = Release|Win32 | ||
{FB9DB05A-769F-47BA-B115-9DDA49F82197}.Release|x86.Build.0 = Release|Win32 | ||
{7DE03078-DA93-4D66-8164-76277522D3F6}.Debug|x64.ActiveCfg = Debug|x64 | ||
{7DE03078-DA93-4D66-8164-76277522D3F6}.Debug|x64.Build.0 = Debug|x64 | ||
{7DE03078-DA93-4D66-8164-76277522D3F6}.Debug|x86.ActiveCfg = Debug|Win32 | ||
{7DE03078-DA93-4D66-8164-76277522D3F6}.Debug|x86.Build.0 = Debug|Win32 | ||
{7DE03078-DA93-4D66-8164-76277522D3F6}.Release|x64.ActiveCfg = Release|x64 | ||
{7DE03078-DA93-4D66-8164-76277522D3F6}.Release|x64.Build.0 = Release|x64 | ||
{7DE03078-DA93-4D66-8164-76277522D3F6}.Release|x86.ActiveCfg = Release|Win32 | ||
{7DE03078-DA93-4D66-8164-76277522D3F6}.Release|x86.Build.0 = Release|Win32 | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#define INITGUID | ||
#include <DbgEng.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#include "StdAfx.hpp" | ||
|
||
#include "Exceptions.hpp" | ||
|
||
|
||
namespace WingDbg { | ||
namespace Exceptions { | ||
|
||
|
||
namespace { | ||
|
||
std::string FormatSystemMessage(DWORD message_id) | ||
{ | ||
// ntdll should always be loaded for the lifetime | ||
// of the process. No need to bump the reference count. | ||
HMODULE ntdll_handle = ::GetModuleHandleW(L"ntdll.dll"); | ||
if (NULL == ntdll_handle) | ||
{ | ||
THROW_WIN32_EXCEPTION(GetLastError()); | ||
} | ||
|
||
PSTR message_unsafe_ptr = nullptr; | ||
DWORD result = ::FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_IGNORE_INSERTS, | ||
ntdll_handle, | ||
message_id, | ||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), | ||
reinterpret_cast<PSTR>(&message_unsafe_ptr), | ||
0, | ||
nullptr); | ||
std::unique_ptr<CHAR, HLOCAL(WINAPI *)(HLOCAL)> message_ptr(message_unsafe_ptr, &::LocalFree); | ||
if (0 == result) | ||
{ | ||
return std::string(); | ||
} | ||
|
||
std::string message(message_ptr.get()); | ||
boost::trim(message); | ||
|
||
return message; | ||
} | ||
|
||
} | ||
|
||
|
||
|
||
std::string to_string(const ComErrorInfo & com_error_info) | ||
{ | ||
std::ostringstream temp; | ||
|
||
temp << "COM error: 0x" << std::hex << com_error_info.value(); | ||
|
||
auto message = FormatSystemMessage(com_error_info.value()); | ||
if (!message.empty()) | ||
{ | ||
temp << ", \"" << message << "\""; | ||
} | ||
|
||
temp << std::endl; | ||
|
||
return temp.str(); | ||
} | ||
|
||
std::string to_string(const Win32ErrorInfo & win32_error_info) | ||
{ | ||
std::ostringstream temp; | ||
|
||
temp << "Win32 error: " << win32_error_info.value(); | ||
|
||
auto message = FormatSystemMessage(win32_error_info.value()); | ||
if (!message.empty()) | ||
{ | ||
temp << ", \"" << message << "\""; | ||
} | ||
|
||
temp << std::endl; | ||
|
||
return temp.str(); | ||
} | ||
|
||
std::string to_string(const NtErrorInfo & nt_error_info) | ||
{ | ||
std::ostringstream temp; | ||
|
||
temp << "NTSTATUS: 0x" << std::hex << nt_error_info.value(); | ||
|
||
auto message = FormatSystemMessage(nt_error_info.value()); | ||
if (!message.empty()) | ||
{ | ||
temp << ", \"" << message << "\""; | ||
} | ||
|
||
temp << std::endl; | ||
|
||
return temp.str(); | ||
} | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#pragma once | ||
|
||
#include "StdAfx.hpp" | ||
|
||
|
||
#define THROW_COM_EXCEPTION(hrResult) \ | ||
BOOST_THROW_EXCEPTION(Exceptions::WingDbgException() << Exceptions::ComErrorInfo(hrResult)) | ||
|
||
#define THROW_WIN32_EXCEPTION(dwError) \ | ||
BOOST_THROW_EXCEPTION(Exceptions::WingDbgException() << Exceptions::Win32ErrorInfo(dwError)) | ||
|
||
#define THROW_NT_EXCEPTION(eNtStatus) \ | ||
BOOST_THROW_EXCEPTION(Exceptions::WingDbgException() << Exceptions::NtErrorInfo(eNtStatus)) | ||
|
||
#define CHECK_HRESULT_AND_THROW(hrResult) \ | ||
do \ | ||
{ \ | ||
HRESULT hrResultTemp = (hrResult); \ | ||
if (FAILED(hrResultTemp)) \ | ||
{ \ | ||
THROW_COM_EXCEPTION(hrResultTemp); \ | ||
} \ | ||
} while (0) | ||
|
||
|
||
namespace WingDbg { | ||
namespace Exceptions { | ||
|
||
|
||
|
||
typedef boost::error_info<struct ComErrorInfo_, HRESULT> ComErrorInfo; | ||
std::string to_string(const ComErrorInfo & com_error_info); | ||
|
||
typedef boost::error_info<struct Win32ErrorInfo_, DWORD> Win32ErrorInfo; | ||
std::string to_string(const Win32ErrorInfo & win32_error_info); | ||
|
||
typedef boost::error_info<struct NtErrorInfo_, NTSTATUS> NtErrorInfo; | ||
std::string to_string(const NtErrorInfo & nt_error_info); | ||
|
||
typedef boost::error_info<struct ErrorMessage_, const char *> ErrorMessage; | ||
|
||
struct WingDbgException : virtual boost::exception, virtual std::exception | ||
{ | ||
}; | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include "StdAfx.hpp" | ||
|
||
#include "Utils.h" | ||
#include "RegFix.hpp" | ||
|
||
|
||
HRESULT CALLBACK DebugExtensionInitialize( | ||
_Out_ PULONG pnVersion, | ||
_Out_ PULONG pfFlags | ||
) | ||
{ | ||
UNREFERENCED_PARAMETER(pfFlags); | ||
|
||
if (NULL == pnVersion) | ||
{ | ||
return E_INVALIDARG; | ||
} | ||
|
||
*pnVersion = DEBUG_EXTENSION_VERSION(1, 0); | ||
|
||
return S_OK; | ||
} | ||
|
||
HRESULT CALLBACK regfix( | ||
_In_ PDEBUG_CLIENT piClient, | ||
_In_opt_ PCSTR pszArgs | ||
) | ||
{ | ||
try | ||
{ | ||
WingDbg::Extensions::RegFix(piClient, pszArgs); | ||
} | ||
catch (...) | ||
{ | ||
(void)::UTILS_OutputString(piClient, | ||
DEBUG_OUTPUT_ERROR, | ||
boost::current_exception_diagnostic_information().c_str()); | ||
return E_FAIL; | ||
} | ||
|
||
return S_OK; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
LIBRARY WingDbg | ||
EXPORTS | ||
DebugExtensionInitialize | ||
regfix |
Oops, something went wrong.