Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Bazhan committed Jun 19, 2015
1 parent e3b787d commit 0dd340b
Show file tree
Hide file tree
Showing 18 changed files with 1,026 additions and 0 deletions.
30 changes: 30 additions & 0 deletions KD.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "kd", "KD\kd.vcxproj", "{5BBD5478-483A-4DB0-855A-74187E629C1A}"
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
{5BBD5478-483A-4DB0-855A-74187E629C1A}.Debug|x64.ActiveCfg = Debug|x64
{5BBD5478-483A-4DB0-855A-74187E629C1A}.Debug|x64.Build.0 = Debug|x64
{5BBD5478-483A-4DB0-855A-74187E629C1A}.Debug|x86.ActiveCfg = Debug|Win32
{5BBD5478-483A-4DB0-855A-74187E629C1A}.Debug|x86.Build.0 = Debug|Win32
{5BBD5478-483A-4DB0-855A-74187E629C1A}.Debug|x86.Deploy.0 = Debug|Win32
{5BBD5478-483A-4DB0-855A-74187E629C1A}.Release|x64.ActiveCfg = Release|x64
{5BBD5478-483A-4DB0-855A-74187E629C1A}.Release|x64.Build.0 = Release|x64
{5BBD5478-483A-4DB0-855A-74187E629C1A}.Release|x86.ActiveCfg = Release|Win32
{5BBD5478-483A-4DB0-855A-74187E629C1A}.Release|x86.Build.0 = Release|Win32
{5BBD5478-483A-4DB0-855A-74187E629C1A}.Release|x86.Deploy.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Binary file added KD/Version.rc
Binary file not shown.
3 changes: 3 additions & 0 deletions KD/Version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#define BINVERSION 1,1,0,0
#define STRVERSION "1.1"
#define YEAR "2014"
119 changes: 119 additions & 0 deletions KD/dllmain.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/*++
Copyright (c) Andrey Bazhan
--*/

#include "stdafx.h"


PDEBUG_CONTROL DebugControl;
PDEBUG_SYMBOLS DebugSymbols;
PDEBUG_DATA_SPACES DebugDataSpaces;
PDEBUG_REGISTERS DebugRegisters;


HRESULT
QueryInterfaces(
_In_ PDEBUG_CLIENT DebugClient
)
{
HRESULT Result;

if ((Result = DebugClient->QueryInterface(__uuidof(IDebugControl), (PVOID *)&DebugControl)) != S_OK) {

return Result;
}

if ((Result = DebugClient->QueryInterface(__uuidof(IDebugSymbols), (PVOID *)&DebugSymbols)) != S_OK) {

return Result;
}

if ((Result = DebugClient->QueryInterface(__uuidof(IDebugDataSpaces), (PVOID *)&DebugDataSpaces)) != S_OK) {

return Result;
}

if ((Result = DebugClient->QueryInterface(__uuidof(IDebugRegisters), (PVOID *)&DebugRegisters)) != S_OK) {

return Result;
}

return S_OK;
}

VOID
ReleaseInterfaces(
VOID
)
{
if (DebugRegisters) {

DebugRegisters->Release();
DebugRegisters = NULL;
}

if (DebugDataSpaces) {

DebugDataSpaces->Release();
DebugDataSpaces = NULL;
}

if (DebugSymbols) {

DebugSymbols->Release();
DebugSymbols = NULL;
}

if (DebugControl) {

DebugControl->Release();
DebugControl = NULL;
}
}

VOID
CALLBACK
DebugExtensionUninitialize(
VOID
)
{
return;
}

HRESULT
CALLBACK
DebugExtensionInitialize(
_Out_ PULONG Version,
_Out_ PULONG Flags
)
{
*Version = DEBUG_EXTENSION_VERSION(1, 0);
*Flags = 0;

return S_OK;
}

BOOL
WINAPI
DllMain(
_In_ HINSTANCE hInstance,
_In_ DWORD Reason,
_In_ LPVOID Reserved
)
{
UNREFERENCED_PARAMETER(hInstance);
UNREFERENCED_PARAMETER(Reserved);

switch (Reason) {

case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}

return TRUE;
}
20 changes: 20 additions & 0 deletions KD/dllmain.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once

#include "stdafx.h"


extern PDEBUG_CONTROL DebugControl;
extern PDEBUG_SYMBOLS DebugSymbols;
extern PDEBUG_DATA_SPACES DebugDataSpaces;
extern PDEBUG_REGISTERS DebugRegisters;


HRESULT
QueryInterfaces(
_In_ PDEBUG_CLIENT DebugClient
);

VOID
ReleaseInterfaces(
VOID
);
84 changes: 84 additions & 0 deletions KD/help.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*++
Copyright (c) Andrey Bazhan
--*/

#include "stdafx.h"

#define APPNAME _T("KD")


HRESULT
CALLBACK
help(
_In_ PDEBUG_CLIENT DebugClient,
_In_opt_ PCSTR args
)
{
PDEBUG_CONTROL4 DebugControl;

UNREFERENCED_PARAMETER(args);

if (DebugClient->QueryInterface(__uuidof(IDebugControl), (PVOID *)&DebugControl) == S_OK) {

HMODULE hModule = GetModuleHandle(APPNAME);

if (hModule) {

TCHAR FileName[MAX_PATH];
TCHAR Text[MAX_PATH] = APPNAME _T(" ");
DWORD Handle;
PVOID Block;
DWORD BlockSize;
PVOID String;
UINT Length;

DebugControl->OutputWide(DEBUG_OUTPUT_NORMAL, _T("\n"));

if (GetModuleFileName(hModule, FileName, _countof(FileName))) {

BlockSize = GetFileVersionInfoSize(FileName, &Handle);

if (BlockSize) {

Block = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, BlockSize);

if (Block) {

GetFileVersionInfo(FileName, 0, BlockSize, Block);

if (VerQueryValue(Block, _T("\\StringFileInfo\\040904b0\\FileVersion"), &String, &Length)) {

_tcsncpy_s(&Text[_tcslen(Text)], _countof(Text) - _tcslen(Text), (PCTSTR)String, Length);

DebugControl->OutputWide(DEBUG_OUTPUT_NORMAL, Text);
DebugControl->OutputWide(DEBUG_OUTPUT_NORMAL, _T("\n"));
}

if (VerQueryValue(Block, _T("\\StringFileInfo\\040904b0\\LegalCopyright"), &String, &Length)) {

_tcsncpy_s(Text, _countof(Text), (PCTSTR)String, Length);

DebugControl->OutputWide(DEBUG_OUTPUT_NORMAL, Text);
DebugControl->OutputWide(DEBUG_OUTPUT_NORMAL, _T("\n"));
}

HeapFree(GetProcessHeap(), 0, Block);
}
}
}

DebugControl->ControlledOutputWide(DEBUG_OUTCTL_ALL_CLIENTS | DEBUG_OUTCTL_DML,
DEBUG_OUTPUT_NORMAL,
_T("<link cmd=\".shell -x start http:https://www.andreybazhan.com\">http:https://www.andreybazhan.com</link>\n\n")
_T("help - Displays this list\n")
_T("st - Displays system service table\n")
_T("idt - Displays interrupt descriptor table\n\n"));
}

DebugControl->Release();
}

return S_OK;
}
Loading

0 comments on commit 0dd340b

Please sign in to comment.