Create an Empty Visual C++ Project and save the solution as sampext. Add
sampext.cpp
to the project with the following content.
#include "sampext.h"
EXT_DECLARE_GLOBALS();
EXT_CLASS::EXT_CLASS()
{
}
Add sampext.h
to the project with the following content.
#pragma once
#include "engextcpp.hpp"
class EXT_CLASS : public ExtExtension
{
protected:
public:
EXT_CLASS();
EXT_COMMAND_METHOD(ver);
};
Add ver.cpp
to the project file with the following content. This file contains the implementation of the sample command.
#include "ver.h"
EXT_COMMAND(ver,
"Shows version number of the extension.\n",
""
)
{
g_Ext->Out("Sample Windbg Extension in Visual Studio v0.1\n");
}
Add
ver.h
, too.
#pragma once
#include "sampext.h"
Add sampext.def
that is the definition file.
EXPORTS
;--------------------------------------------------------------------
; Core exports provided by the ExtCpp framework.
;--------------------------------------------------------------------
DebugExtensionInitialize
DebugExtensionUninitialize
DebugExtensionNotify
help
;--------------------------------------------------------------------
; Extension commands.
;--------------------------------------------------------------------
ver
Create a folder called sdk
in the solution folder.Copy the
inc
and lib
folders from the sdk folder of Windbg to the sdk
folder of the solution.Set the configuration type of the project to
Dynamic Library DLL.
Add
$(SolutionDir)sdk\inc
to the additional include directories.Add
$(SolutionDir)sdk\lib\i386
to the additional library dependencies.Add
engextcpp.lib
to the additional dependencies in the linker input.Set up the module definition file to
samplext.def
in the linker input.The extension is now ready to be built.