Skip to content

Commit ce335aa

Browse files
committed
implemented detailed parser error information, added c++ allocation tracker to the memory allocation tracker, fixed a bug in UI manager and fixed a few memory leak issue. Now its memory leak free.
1 parent 53d9dde commit ce335aa

File tree

13 files changed

+204
-72
lines changed

13 files changed

+204
-72
lines changed

x64dbgApiBreak/res.aps

80 Bytes
Binary file not shown.

x64dbgApiBreak/res.rc

130 Bytes
Binary file not shown.

x64dbgApiBreak/resource.h

92 Bytes
Binary file not shown.

x64dbgApiBreak/src/apibreak.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,25 +151,24 @@ bool AbpDeregisterModule(ModuleApiInfo *mai)
151151
{
152152
apilist::iterator apit;
153153
modlist::iterator modit;
154-
ApiFunctionInfo *afi;
154+
ApiFunctionInfo *afi;
155155

156156
if (!mai)
157157
return false;
158158

159159

160160
for (apit = mai->apiList->begin(); apit != mai->apiList->end(); apit++)
161161
{
162-
afi = apit->second;
162+
afi = apit->second;
163163

164164
if (afi->callInfo.calls)
165165
FREEOBJECT(afi->callInfo.calls);
166166

167167
FREEOBJECT(afi);
168168
}
169169

170-
mai->listCount = 0;
170+
mai->listCount = 0;
171171
mai->apiList->clear();
172-
173172
delete mai->apiList;
174173

175174
for (modit = AbpModuleList.begin(); modit != AbpModuleList.end(); modit++)

x64dbgApiBreak/src/incl/corelib.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ bool AbMemReadGuaranteed(duint va, void *dest, duint size);
2222
#define TRACK_MEMORY_ALLOCATIONS
2323

2424
#ifdef TRACK_MEMORY_ALLOCATIONS
25+
2526
void *AbMemoryAlloc_DBG(int size,const char *file, const char *func, const int line);
2627
void *AbMemoryRealloc_DBG(void *memPtr, int newSize, const char *file, const char *func, const int line);
2728
void AbMemoryFree_DBG(void *memPtr);
@@ -32,6 +33,19 @@ void AbTrackMemory_DBG(void *memPtr);
3233
#define AbMemoryFree(memPtr) AbMemoryFree_DBG((memPtr))
3334
#define AbTrackMemory(memPtr) AbTrackMemory_DBG((memPtr))
3435

36+
#ifdef __cplusplus
37+
38+
void *operator new(size_t size, char *func, char *file, int line);
39+
40+
//this just for compiler warning. it will forward to standart delete call
41+
void operator delete(void *memory, char *func, char *file, int line);
42+
43+
void operator delete(void *memory);
44+
45+
#define new new(__FUNCTION__, __FILE__, __LINE__)
46+
47+
#endif
48+
3549
#else
3650
#define AbMemoryAlloc(size) _AbMemoryAlloc((size))
3751
#define AbMemoryRealloc(memPtr, newSize) _AbMemoryRealloc((memPtr),(newSize))

x64dbgApiBreak/src/incl/defs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ typedef unsigned char uchar;
5252

5353
#define AB_VERSION_MAJOR 0
5454
#define AB_VERSION_MINOR 5
55-
#define AB_VERSION_BUILD 38
55+
#define AB_VERSION_BUILD 39
5656

5757
#if _WIN64
5858
#define AB_PLATFORM "x64"

x64dbgApiBreak/src/incl/dlgs/ApiCallMapForm.hpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,22 @@ class ApiCallMapForm : public UiWrapper
6666
FREESTRING(mapContent);
6767
}
6868

69+
void OnCommand(WPARAM wp, LPARAM lp)
70+
{
71+
switch (LOWORD(wp))
72+
{
73+
case IDC_MAPDLG_BTNCONT:
74+
AbDebuggerRun();
75+
Close();
76+
break;
77+
}
78+
}
79+
6980
void OnInit()
7081
{
7182
EDITSTREAM es;
7283

73-
es.dwCookie = (DWORD_PTR)this;
84+
es.dwCookie = (DWORD_PTR)this;
7485
es.dwError = 0;
7586
es.pfnCallback = EditStreamCallback;
7687

x64dbgApiBreak/src/incl/ui/ctrl/uicontrolbase.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,8 @@ class UiControlBase
4242

4343
reqLen++; //Include null term
4444

45-
if ((ULONG)reqLen > size)
46-
{
47-
return 0;
48-
}
49-
else if (size == 0)
45+
46+
if (size == 0)
5047
{
5148
if (IsWindowUnicode(MyHandle()))
5249
*pValue = (BYTE *)ALLOCSTRINGW(reqLen);
@@ -56,6 +53,10 @@ class UiControlBase
5653
if (*pValue == NULL)
5754
return 0;
5855
}
56+
else if ((ULONG)reqLen > size)
57+
{
58+
return 0;
59+
}
5960

6061

6162
readLen = SendControlMsg(WM_GETTEXT, (WPARAM)reqLen, (LPARAM)*pValue);

x64dbgApiBreak/src/incl/ui/uiwrapper.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ class UiWrapper
157157
~UiWrapper(void)
158158
{
159159
DestroyControlResources();
160+
161+
if (this->wci.pci != NULL)
162+
FREEOBJECT(this->wci.pci);
163+
160164
CloseHandle(this->initCompletedEvent);
161165

162166
if (!this->killingSelf)

x64dbgApiBreak/src/plugin.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,18 +217,18 @@ void __AbpInitMenu()
217217

218218
DBG_LIBEXPORT bool pluginit(PLUG_INITSTRUCT* initStruct)
219219
{
220-
initStruct->sdkVersion = PLUG_SDKVERSION;
221-
initStruct->pluginVersion = MAKEWORD(AB_VERSION_MAJOR, AB_VERSION_MINOR);
222-
strcpy_s(initStruct->pluginName, 256, "Api Break");
223-
AbPluginHandle = initStruct->pluginHandle;
224-
225220
#if _DEBUG
226221
if (MessageBoxA(NULL, "Wanna break into debugger?", "Dive-in", MB_YESNO | MB_ICONQUESTION) == IDYES)
227222
{
228223
__debugbreak();
229224
}
230225
#endif
231226

227+
initStruct->sdkVersion = PLUG_SDKVERSION;
228+
initStruct->pluginVersion = (AB_VERSION_MAJOR * 10) + AB_VERSION_MINOR;
229+
strcpy_s(initStruct->pluginName, 256, "Api Break");
230+
AbPluginHandle = initStruct->pluginHandle;
231+
232232
if (AbpNeedsNewerx64Dbg())
233233
{
234234
MessageBoxA(NULL,
@@ -378,7 +378,7 @@ LONG WINAPI AbpShowOutputArgumentQuestion(LPVOID p)
378378
BASIC_INSTRUCTION_INFO instr;
379379
duint addr;
380380
char msgBuf[512];
381-
LPSTR mapResult;
381+
LPSTR mapResult;
382382

383383
BpCallbackContext *bpcb = (BpCallbackContext *)p;
384384

0 commit comments

Comments
 (0)