DBG: automatically add plugin callbacks on certain export names +updated help

This commit is contained in:
Mr. eXoDia 2014-07-07 19:38:23 +02:00
parent 250271ed03
commit cf404b9273
5 changed files with 89 additions and 21 deletions

View File

@ -21,6 +21,9 @@ command window and the result will be displayed in the console. Apart from
calculations, it allows quick&nbsp;variable changes using a C-like syntax.</P>
<P><STRONG>Operators</STRONG><BR> You can use the
following operators in your expression. They are processed in the following order:</P>
<P><U>0:negative</U>
: Negative numbers can be prefixed by a
'-' sign.</P>
<P><U>1:</U><U>brackets</U>: '(' and ')' Brackets are
resolved first, there is no need for a terminating bracket, unless you want to
use one.</P>
@ -30,8 +33,7 @@ number of a variable, like in C.</P>
multiplication (signed/unsigned), '$' = get the higher part of the
multiplication, '/' = regular devision (signed/unsigned, devide by zero=error)
and '%' = get the modulo (remainder) of the devision.</P>
<P><U>4:addition/substraction</U>
: '+' and '-'</P>
<P><U>4:addition/substraction</U>: '+' and '-'</P>
<P><U>5:shift</U>: '&lt;' = shift left (shl for unsigned,
sal for signed), '&gt;' = shift right (shr for unsigned, sar for signed).</P>
<P><U>6:and</U>: '&amp;' Just the regular AND operation like
@ -47,4 +49,4 @@ syntax:</P>
can be any register, flag, variable or memory location. 'b' can be anything that is recognized as a mathmatical
input.</P>
<P><U>a++/a--</U>: 'a' can be any register, flag, variable or memory
location.</P></BODY></HTML>
location.</P></body>

View File

@ -47,7 +47,7 @@ above.<BR><EM>n</EM>:[addr]&nbsp;&nbsp;- read <EM>n</EM>
class=rvts9><BR>
@<EM>n</EM>:addr&nbsp;&nbsp; - same as
above.<BR><STRONG>REMARKS</STRONG>:<BR>- <EM>n</EM> is the amount of bytes to
read, this can be anything smaller then 4 on x32 and smaller then 8 on x64 when
read, this can be anything smaller than 4 on x32 and smaller than 8 on x64 when
specified, otherwise there will be an error.<BR>- addr is directly interpreted
as a value, when you want to read [addr+1] you should use
brackets:<BR>
@ -63,15 +63,15 @@ class=rvts9>
</SPAN><SPAN
class=rvts9><U>flags</U>: Debug flags (interpreted as integer) can be used
as input. Flags are prefixed with a '!' following the flag name or the bit number their on.
class=rvts9><U>flags</U> : Debug flags
(interpreted as integer) can be used as input. Flags are prefixed with a '!' following the flag name.
Valid flags are: !cf, !pf, !af, !zf, !sf, !tf, !if, !df, !of, !rf, !vm, !ac, !vif, !vip and !id.</SPAN><SPAN class=rvts9></P></SPAN>
<P class=rvps3><SPAN class=rvts11><U>numbers</U></SPAN><SPAN class=rvts9>: All
numbers are interpreted as hex by default. If you want to be sure, you can use
the "x" prefix. Decimal numbers can be used by prefixing the number with a "."
<P class=rvps3><SPAN class=rvts11><U>numbers</U></SPAN><SPAN class=rvts9>:
All numbers are interpreted as
hex by default. If you want to be sure, you can use the "x" prefix or
the "0x" prefix. Decimal numbers can be used by prefixing the number with a "."
(.123=7B).</SPAN></P>
<P class=rvps3><SPAN class=rvts9><U>basic calculations</U> :
<P class=rvps3><SPAN class=rvts9><U>basic calculations</U>:
See "Calculations" for more
information.</SPAN></P>
<P class=rvps3><SPAN class=rvts9><U>DLL exports</U>: Type 'GetProcAddress' and it will
@ -87,9 +87,10 @@ base of a module. Try
and symbols&nbsp;are a valid
expressions.</SPAN></P>
<P class=rvps3><SPAN class=rvts9>
<P class=rvps3><SPAN class=rvts9><STRONG>Input for arguments can always be done in any of
the above forms, except if stated otherwise.</STRONG>
Input
for arguments can always be done in any of the above forms, except if stated
otherwise.</SPAN></P></body>
</SPAN></P></BODY></HTML>

View File

@ -17,17 +17,16 @@ html,body {
<body>
<P><STRONG>Introduction</STRONG><BR>This is a x64/x32 debugger that is currently
in active development.</P>
<P>The debugger has (currently) three parts:<BR>- DBG<BR>-
<P>The debugger (currently) has three parts:<BR>- DBG<BR>-
GUI<BR>
- Bridge</P>
<P>DBG is the debugging part of the debugger. It handles
debugging (using<BR> TitanEngine) and will provide data
for the GUI.</P>
<P>GUI is the graphical part of the debugger. It is built
on top of Qt and it<BR>provides the user interaction, the dump window (not yet
implemented), the<BR>disassembly, the register window, the memory map view, the
log view etc.</P>
on top of Qt and it<BR> provides
the user interaction.</P>
<P>Bridge is the communication library for the DBG and GUI
part (and maybe in<BR>the future more parts). The bridge can be used to work on
new features,<BR> without having to update the code of
the other parts.</P></body>
the other parts.</P></head>

View File

@ -14,6 +14,7 @@ html,body {
</head>
<body>
<P><STRONG>The basics</STRONG><BR>This page covers the
basic principles of plugin development for x64_dbg.</P>
@ -26,4 +27,10 @@ unloaded. Remove all registered commands and
callbacks here. Also clean up plugin data.</P>
<P><U>plugsetup</U>: Called when the plugin initialization
was successful, here you
can register menus and other GUI-related things.</P></body>
can register menus and other GUI-related things.</P>
<P><U>CB*</U>: Instead of calling _plugin_registercallback,
you can create a CDECL export which has the name of the callback. For example
when you create an export called "CBMENUENTRY", this will be registered as your
callback for the event CB_MENUENTRY. Notice that you should <STRONG>not</STRONG>
use an underscore in the export name.</P></body>

View File

@ -51,6 +51,65 @@ void pluginload(const char* pluginDir)
}
pluginData.plugstop=(PLUGSTOP)GetProcAddress(pluginData.hPlugin, "plugstop");
pluginData.plugsetup=(PLUGSETUP)GetProcAddress(pluginData.hPlugin, "plugsetup");
//auto-register callbacks for certain export names
CBPLUGIN cbPlugin;
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBINITDEBUG");
if(cbPlugin)
pluginregistercallback(curPluginHandle, CB_INITDEBUG, cbPlugin);
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBSTOPDEBUG");
if(cbPlugin)
pluginregistercallback(curPluginHandle, CB_STOPDEBUG, cbPlugin);
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBCREATEPROCESS");
if(cbPlugin)
pluginregistercallback(curPluginHandle, CB_CREATEPROCESS, cbPlugin);
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBEXITPROCESS");
if(cbPlugin)
pluginregistercallback(curPluginHandle, CB_EXITPROCESS, cbPlugin);
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBCREATETHREAD");
if(cbPlugin)
pluginregistercallback(curPluginHandle, CB_CREATETHREAD, cbPlugin);
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBEXITTHREAD");
if(cbPlugin)
pluginregistercallback(curPluginHandle, CB_EXITTHREAD, cbPlugin);
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBSYSTEMBREAKPOINT");
if(cbPlugin)
pluginregistercallback(curPluginHandle, CB_SYSTEMBREAKPOINT, cbPlugin);
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBLOADDLL");
if(cbPlugin)
pluginregistercallback(curPluginHandle, CB_LOADDLL, cbPlugin);
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBUNLOADDLL");
if(cbPlugin)
pluginregistercallback(curPluginHandle, CB_UNLOADDLL, cbPlugin);
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBOUTPUTDEBUGSTRING");
if(cbPlugin)
pluginregistercallback(curPluginHandle, CB_OUTPUTDEBUGSTRING, cbPlugin);
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBEXCEPTION");
if(cbPlugin)
pluginregistercallback(curPluginHandle, CB_EXCEPTION, cbPlugin);
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBBREAKPOINT");
if(cbPlugin)
pluginregistercallback(curPluginHandle, CB_BREAKPOINT, cbPlugin);
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBPAUSEDEBUG");
if(cbPlugin)
pluginregistercallback(curPluginHandle, CB_PAUSEDEBUG, cbPlugin);
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBRESUMEDEBUG");
if(cbPlugin)
pluginregistercallback(curPluginHandle, CB_RESUMEDEBUG, cbPlugin);
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBSTEPPED");
if(cbPlugin)
pluginregistercallback(curPluginHandle, CB_STEPPED, cbPlugin);
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBATTACH");
if(cbPlugin)
pluginregistercallback(curPluginHandle, CB_ATTACH, cbPlugin);
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBDETACH");
if(cbPlugin)
pluginregistercallback(curPluginHandle, CB_DETACH, cbPlugin);
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBDEBUGEVENT");
if(cbPlugin)
pluginregistercallback(curPluginHandle, CB_DEBUGEVENT, cbPlugin);
cbPlugin=(CBPLUGIN)GetProcAddress(pluginData.hPlugin, "CBMENUENTRY");
if(cbPlugin)
pluginregistercallback(curPluginHandle, CB_MENUENTRY, cbPlugin);
//init plugin
//TODO: handle exceptions
if(!pluginData.pluginit(&pluginData.initStruct))