1
0
Fork 0

Refactor breakpoint.cpp/.h

This commit is contained in:
Nukem 2015-03-17 21:24:24 -04:00
parent 61c731693c
commit ebb46e67a0
7 changed files with 390 additions and 282 deletions

View File

@ -318,20 +318,20 @@ extern "C" DLL_EXPORT int _dbg_bpgettypeat(duint addr)
static uint cacheAddr;
static int cacheBpCount;
static int cacheResult;
int bpcount = bpgetlist(0);
int bpcount = BpGetList(nullptr);
if(cacheAddr != addr or cacheBpCount != bpcount)
{
BREAKPOINT bp;
cacheAddr = addr;
cacheResult = 0;
cacheBpCount = bpcount;
if(bpget(addr, BPNORMAL, 0, &bp))
if(BpGet(addr, BPNORMAL, 0, &bp))
if(bp.enabled)
cacheResult |= bp_normal;
if(bpget(addr, BPHARDWARE, 0, &bp))
if(BpGet(addr, BPHARDWARE, 0, &bp))
if(bp.enabled)
cacheResult |= bp_hardware;
if(bpget(addr, BPMEMORY, 0, &bp))
if(BpGet(addr, BPMEMORY, 0, &bp))
if(bp.enabled)
cacheResult |= bp_memory;
}
@ -504,7 +504,7 @@ extern "C" DLL_EXPORT int _dbg_getbplist(BPXTYPE type, BPMAP* bpmap)
if(!bpmap)
return 0;
std::vector<BREAKPOINT> list;
int bpcount = bpgetlist(&list);
int bpcount = BpGetList(&list);
if(bpcount == 0)
{
bpmap->count = 0;
@ -867,7 +867,7 @@ extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* par
case DBG_IS_BP_DISABLED:
{
BREAKPOINT bp;
if(bpget((uint)param1, BPNORMAL, 0, &bp))
if(BpGet((uint)param1, BPNORMAL, 0, &bp))
return !(uint)bp.enabled;
return (uint)false;
}

View File

@ -26,7 +26,7 @@ void dbsave()
bookmarkcachesave(root);
functioncachesave(root);
loopcachesave(root);
bpcachesave(root);
BpCacheSave(root);
WString wdbpath = StringUtils::Utf8ToUtf16(dbpath);
if(json_object_size(root))
{
@ -87,7 +87,7 @@ void dbload()
bookmarkcacheload(root);
functioncacheload(root);
loopcacheload(root);
bpcacheload(root);
BpCacheLoad(root);
json_decref(root); //free root
dprintf("%ums\n", GetTickCount() - ticks);
}
@ -100,7 +100,7 @@ void dbclose()
bookmarkclear();
functionclear();
loopclear();
bpclear();
BpClear();
patchclear();
}

View File

@ -11,266 +11,386 @@ typedef std::map<BreakpointKey, BREAKPOINT> BreakpointsInfo;
static BreakpointsInfo breakpoints;
int bpgetlist(std::vector<BREAKPOINT>* list)
BREAKPOINT* BpInfoFromAddr(BP_TYPE Type, uint Address)
{
if(!DbgIsDebugging())
return false;
BREAKPOINT curBp;
int count = 0;
CriticalSectionLocker locker(LockBreakpoints);
for(BreakpointsInfo::iterator i = breakpoints.begin(); i != breakpoints.end(); ++i)
{
curBp = i->second;
curBp.addr += ModBaseFromName(curBp.mod);
curBp.active = memisvalidreadptr(fdProcessInfo->hProcess, curBp.addr);
count++;
if(list)
list->push_back(curBp);
}
return count;
//
// NOTE: THIS DOES _NOT_ USE LOCKS
//
auto found = breakpoints.find(BreakpointKey(Type, ModHashFromAddr(Address)));
// Was the module found with this address?
if(found == breakpoints.end())
return nullptr;
return &found->second;
}
bool bpnew(uint addr, bool enabled, bool singleshoot, short oldbytes, BP_TYPE type, DWORD titantype, const char* name)
int BpGetList(std::vector<BREAKPOINT>* List)
{
if(!DbgIsDebugging() or !memisvalidreadptr(fdProcessInfo->hProcess, addr) or bpget(addr, type, name, 0))
// CHECK: Exported function
if(!DbgIsDebugging())
return false;
SHARED_ACQUIRE(LockBreakpoints);
// Did the caller request an output?
if(List)
{
// Enumerate all breakpoints in the global list, fixing the relative
// offset to a virtual address
for(auto & i : breakpoints)
{
BREAKPOINT currentBp = i.second;
currentBp.addr += ModBaseFromName(currentBp.mod);
currentBp.active = memisvalidreadptr(fdProcessInfo->hProcess, currentBp.addr);
List->push_back(currentBp);
}
}
return breakpoints.size();
}
bool BpNew(uint Address, bool Enable, bool Singleshot, short OldBytes, BP_TYPE Type, DWORD TitanType, const char* Name)
{
// CHECK: Command function
if(!DbgIsDebugging())
return false;
// Fail if the address is a bad memory region
if(!memisvalidreadptr(fdProcessInfo->hProcess, Address))
return false;
// Fail if the breakpoint already exists
if(BpGet(Address, Type, Name, nullptr))
return false;
// Default to an empty name if one wasn't supplied
if(!Name)
Name = "";
BREAKPOINT bp;
ModNameFromAddr(addr, bp.mod, true);
uint modbase = ModBaseFromAddr(addr);
bp.active = true;
bp.addr = addr - modbase;
bp.enabled = enabled;
if(name and * name)
strcpy_s(bp.name, name);
else
*bp.name = '\0';
bp.oldbytes = oldbytes;
bp.singleshoot = singleshoot;
bp.titantype = titantype;
bp.type = type;
CriticalSectionLocker locker(LockBreakpoints);
breakpoints.insert(std::make_pair(BreakpointKey(type, ModHashFromAddr(addr)), bp));
memset(&bp, 0, sizeof(BREAKPOINT));
ModNameFromAddr(Address, bp.mod, true);
strcpy_s(bp.name, Name);
bp.active = true;
bp.addr = Address - ModBaseFromAddr(Address);
bp.enabled = Enable;
bp.oldbytes = OldBytes;
bp.singleshoot = Singleshot;
bp.titantype = TitanType;
bp.type = Type;
// Insert new entry to the global list
EXCLUSIVE_ACQUIRE(LockBreakpoints);
breakpoints.insert(std::make_pair(BreakpointKey(Type, ModHashFromAddr(Address)), bp));
return true;
}
bool bpget(uint addr, BP_TYPE type, const char* name, BREAKPOINT* bp)
bool BpGet(uint Address, BP_TYPE Type, const char* Name, BREAKPOINT* Bp)
{
// CHECK: Export/Command function
if(!DbgIsDebugging())
return false;
BREAKPOINT curBp;
CriticalSectionLocker locker(LockBreakpoints);
if(!name)
SHARED_ACQUIRE(LockBreakpoints);
// Name is optional
if(!Name || Name[0] == '\0')
{
BreakpointsInfo::iterator found = breakpoints.find(BreakpointKey(type, ModHashFromAddr(addr)));
if(found == breakpoints.end()) //not found
// Perform a lookup by an address only
BREAKPOINT* bpInfo = BpInfoFromAddr(Type, Address);
if(!bpInfo)
return false;
if(!bp)
// Succeed even if the user didn't request anything
if(!Bp)
return true;
curBp = found->second;
curBp.addr += ModBaseFromAddr(addr);
curBp.active = memisvalidreadptr(fdProcessInfo->hProcess, curBp.addr);
*bp = curBp;
*Bp = *bpInfo;
Bp->addr += ModBaseFromAddr(Address);
Bp->active = memisvalidreadptr(fdProcessInfo->hProcess, Bp->addr);
return true;
}
for(BreakpointsInfo::iterator i = breakpoints.begin(); i != breakpoints.end(); ++i)
// Do a lookup by breakpoint name
for(auto & i : breakpoints)
{
curBp = i->second;
if(name and * name)
// Do the names match?
if(strcmp(Name, i.second.name) != 0)
continue;
// Fill out the optional user buffer
if(Bp)
{
if(!strcmp(name, curBp.name))
{
if(bp)
{
curBp.addr += ModBaseFromName(curBp.mod);
curBp.active = memisvalidreadptr(fdProcessInfo->hProcess, curBp.addr);
*bp = curBp;
}
return true;
}
*Bp = i.second;
Bp->addr += ModBaseFromAddr(Address);
Bp->active = memisvalidreadptr(fdProcessInfo->hProcess, Bp->addr);
}
// Return true if the name was found at all
return true;
}
return false;
}
bool bpdel(uint addr, BP_TYPE type)
bool BpDelete(uint Address, BP_TYPE Type)
{
// CHECK: Command function
if(!DbgIsDebugging())
return false;
CriticalSectionLocker locker(LockBreakpoints);
return (breakpoints.erase(BreakpointKey(type, ModHashFromAddr(addr))) > 0);
// Erase the index from the global list
EXCLUSIVE_ACQUIRE(LockBreakpoints);
return (breakpoints.erase(BreakpointKey(Type, ModHashFromAddr(Address))) > 0);
}
bool bpenable(uint addr, BP_TYPE type, bool enable)
bool BpEnable(uint Address, BP_TYPE Type, bool Enable)
{
// CHECK: Command function
if(!DbgIsDebugging())
return false;
CriticalSectionLocker locker(LockBreakpoints);
BreakpointsInfo::iterator found = breakpoints.find(BreakpointKey(type, ModHashFromAddr(addr)));
if(found == breakpoints.end()) //not found
EXCLUSIVE_ACQUIRE(LockBreakpoints);
// Check if the breakpoint exists first
BREAKPOINT* bpInfo = BpInfoFromAddr(Type, Address);
if(!bpInfo)
return false;
breakpoints[found->first].enabled = enable;
bpInfo->enabled = Enable;
return true;
}
bool bpsetname(uint addr, BP_TYPE type, const char* name)
bool BpSetName(uint Address, BP_TYPE Type, const char* Name)
{
if(!DbgIsDebugging() or !name or !*name)
// CHECK: Future(?); This is not used anywhere
if(!DbgIsDebugging())
return false;
CriticalSectionLocker locker(LockBreakpoints);
BreakpointsInfo::iterator found = breakpoints.find(BreakpointKey(type, ModHashFromAddr(addr)));
if(found == breakpoints.end()) //not found
// If a name wasn't supplied, set to nothing
if(!Name)
Name = "";
EXCLUSIVE_ACQUIRE(LockBreakpoints);
// Check if the breakpoint exists first
BREAKPOINT* bpInfo = BpInfoFromAddr(Type, Address);
if(!bpInfo)
return false;
strcpy_s(breakpoints[found->first].name, name);
strcpy_s(bpInfo->name, Name);
return true;
}
bool bpsettitantype(uint addr, BP_TYPE type, int titantype)
bool BpSetTitanType(uint Address, BP_TYPE Type, int TitanType)
{
// CHECK: Command function
if(!DbgIsDebugging())
return false;
CriticalSectionLocker locker(LockBreakpoints);
BreakpointsInfo::iterator found = breakpoints.find(BreakpointKey(type, ModHashFromAddr(addr)));
if(found == breakpoints.end()) //not found
EXCLUSIVE_ACQUIRE(LockBreakpoints);
// Set the TitanEngine type, separate from BP_TYPE
BREAKPOINT* bpInfo = BpInfoFromAddr(Type, Address);
if(!bpInfo)
return false;
breakpoints[found->first].titantype = titantype;
bpInfo->titantype = TitanType;
return true;
}
bool bpenumall(BPENUMCALLBACK cbEnum, const char* module)
bool BpEnumAll(BPENUMCALLBACK EnumCallback, const char* Module)
{
if(!DbgIsDebugging())
return false;
bool retval = true;
BREAKPOINT curBp;
CriticalSectionLocker locker(LockBreakpoints);
BreakpointsInfo::iterator i = breakpoints.begin();
while(i != breakpoints.end())
SHARED_ACQUIRE(LockBreakpoints);
// Loop each entry, executing the user's callback
bool callbackStatus = false;
for(auto & i : breakpoints)
{
BreakpointsInfo::iterator j = i;
++i;
curBp = j->second;
curBp.addr += ModBaseFromName(curBp.mod); //RVA to VA
curBp.active = memisvalidreadptr(fdProcessInfo->hProcess, curBp.addr); //TODO: wtf am I doing?
if(module and * module)
BREAKPOINT bpInfo = i.second;
bpInfo.addr += ModBaseFromName(bpInfo.mod);
bpInfo.active = memisvalidreadptr(fdProcessInfo->hProcess, bpInfo.addr);
// If a module name was sent, check it
if(Module && Module[0] != '\0')
{
if(!strcmp(curBp.mod, module))
{
if(!cbEnum(&curBp))
retval = false;
}
}
else
{
if(!cbEnum(&curBp))
retval = false;
if(strcmp(bpInfo.mod, Module) != 0)
continue;
}
// Execute the callback
if(!EnumCallback(&bpInfo))
callbackStatus = false;
}
return retval;
return callbackStatus;
}
bool bpenumall(BPENUMCALLBACK cbEnum)
bool BpEnumAll(BPENUMCALLBACK EnumCallback)
{
return bpenumall(cbEnum, 0);
return BpEnumAll(EnumCallback, nullptr);
}
int bpgetcount(BP_TYPE type, bool enabledonly)
int BpGetCount(BP_TYPE Type, bool EnabledOnly)
{
SHARED_ACQUIRE(LockBreakpoints);
// Count the number of enabled/disabled breakpoint types
int count = 0;
CriticalSectionLocker locker(LockBreakpoints);
for(BreakpointsInfo::iterator i = breakpoints.begin(); i != breakpoints.end(); ++i)
for(auto & i : breakpoints)
{
if(i->first.first == type && (!enabledonly || i->second.enabled))
count++;
// Check if the type matches
if(i.first.first != Type)
continue;
// If it's not enabled, skip it
if(EnabledOnly && !i.second.enabled)
continue;
count++;
}
return count;
}
void bptobridge(const BREAKPOINT* bp, BRIDGEBP* bridge)
void BpToBridge(const BREAKPOINT* Bp, BRIDGEBP* BridgeBp)
{
if(!bp or !bridge)
//
// Convert a debugger breakpoint to an open/exported
// bridge breakpoint
//
// TOOD: ASSERT(?) These should never be null
if(!Bp or !BridgeBp)
return;
memset(bridge, 0, sizeof(BRIDGEBP));
bridge->active = bp->active;
bridge->addr = bp->addr;
bridge->enabled = bp->enabled;
strcpy_s(bridge->mod, bp->mod);
strcpy_s(bridge->name, bp->name);
bridge->singleshoot = bp->singleshoot;
switch(bp->type)
memset(BridgeBp, 0, sizeof(BRIDGEBP));
strcpy_s(BridgeBp->mod, Bp->mod);
strcpy_s(BridgeBp->name, Bp->name);
BridgeBp->active = Bp->active;
BridgeBp->addr = Bp->addr;
BridgeBp->enabled = Bp->enabled;
BridgeBp->singleshoot = Bp->singleshoot;
switch(Bp->type)
{
case BPNORMAL:
bridge->type = bp_normal;
BridgeBp->type = bp_normal;
break;
case BPHARDWARE:
bridge->type = bp_hardware;
BridgeBp->type = bp_hardware;
break;
case BPMEMORY:
bridge->type = bp_memory;
break; //so that's why it didn't show in the gui.
BridgeBp->type = bp_memory;
break;
default:
bridge->type = bp_none;
BridgeBp->type = bp_none;
break;
}
}
void bpcachesave(JSON root)
void BpCacheSave(JSON Root)
{
CriticalSectionLocker locker(LockBreakpoints);
EXCLUSIVE_ACQUIRE(LockBreakpoints);
// Create a JSON array to store each sub-object with a breakpoint
const JSON jsonbreakpoints = json_array();
for(BreakpointsInfo::iterator i = breakpoints.begin(); i != breakpoints.end(); ++i)
// Loop all breakpoints
for(auto & i : breakpoints)
{
const BREAKPOINT curBreakpoint = i->second;
if(curBreakpoint.singleshoot)
continue; //skip
JSON curjsonbreakpoint = json_object();
json_object_set_new(curjsonbreakpoint, "address", json_hex(curBreakpoint.addr));
json_object_set_new(curjsonbreakpoint, "enabled", json_boolean(curBreakpoint.enabled));
if(curBreakpoint.type == BPNORMAL)
json_object_set_new(curjsonbreakpoint, "oldbytes", json_hex(curBreakpoint.oldbytes));
json_object_set_new(curjsonbreakpoint, "type", json_integer(curBreakpoint.type));
json_object_set_new(curjsonbreakpoint, "titantype", json_hex(curBreakpoint.titantype));
json_object_set_new(curjsonbreakpoint, "name", json_string(curBreakpoint.name));
json_object_set_new(curjsonbreakpoint, "module", json_string(curBreakpoint.mod));
json_array_append_new(jsonbreakpoints, curjsonbreakpoint);
auto & breakpoint = i.second;
// Ignore single-shot breakpoints
if(breakpoint.singleshoot)
continue;
JSON jsonObj = json_object();
json_object_set_new(jsonObj, "address", json_hex(breakpoint.addr));
json_object_set_new(jsonObj, "enabled", json_boolean(breakpoint.enabled));
// "Normal" breakpoints save the old data
if(breakpoint.type == BPNORMAL)
json_object_set_new(jsonObj, "oldbytes", json_hex(breakpoint.oldbytes));
json_object_set_new(jsonObj, "type", json_integer(breakpoint.type));
json_object_set_new(jsonObj, "titantype", json_hex(breakpoint.titantype));
json_object_set_new(jsonObj, "name", json_string(breakpoint.name));
json_object_set_new(jsonObj, "module", json_string(breakpoint.mod));
json_array_append_new(jsonbreakpoints, jsonObj);
}
if(json_array_size(jsonbreakpoints))
json_object_set(root, "breakpoints", jsonbreakpoints);
json_object_set(Root, "breakpoints", jsonbreakpoints);
// Notify garbage collector
json_decref(jsonbreakpoints);
}
void bpcacheload(JSON root)
void BpCacheLoad(JSON Root)
{
CriticalSectionLocker locker(LockBreakpoints);
EXCLUSIVE_ACQUIRE(LockBreakpoints);
// Remove all existing elements
breakpoints.clear();
const JSON jsonbreakpoints = json_object_get(root, "breakpoints");
if(jsonbreakpoints)
// Get a handle to the root object -> breakpoints subtree
const JSON jsonbreakpoints = json_object_get(Root, "breakpoints");
// Return if there was nothing to load
if(!jsonbreakpoints)
return;
size_t i;
JSON value;
json_array_foreach(jsonbreakpoints, i, value)
{
size_t i;
JSON value;
json_array_foreach(jsonbreakpoints, i, value)
{
BREAKPOINT curBreakpoint;
memset(&curBreakpoint, 0, sizeof(BREAKPOINT));
curBreakpoint.type = (BP_TYPE)json_integer_value(json_object_get(value, "type"));
if(curBreakpoint.type == BPNORMAL)
curBreakpoint.oldbytes = (short)json_hex_value(json_object_get(value, "oldbytes"));
curBreakpoint.addr = (uint)json_hex_value(json_object_get(value, "address"));
curBreakpoint.enabled = json_boolean_value(json_object_get(value, "enabled"));
curBreakpoint.titantype = (DWORD)json_hex_value(json_object_get(value, "titantype"));
const char* name = json_string_value(json_object_get(value, "name"));
if(name)
strcpy_s(curBreakpoint.name, name);
const char* mod = json_string_value(json_object_get(value, "module"));
if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE)
strcpy_s(curBreakpoint.mod, mod);
const uint key = ModHashFromName(curBreakpoint.mod) + curBreakpoint.addr;
breakpoints.insert(std::make_pair(BreakpointKey(curBreakpoint.type, key), curBreakpoint));
}
BREAKPOINT breakpoint;
memset(&breakpoint, 0, sizeof(BREAKPOINT));
if(breakpoint.type == BPNORMAL)
breakpoint.oldbytes = (short)json_hex_value(json_object_get(value, "oldbytes"));
breakpoint.type = (BP_TYPE)json_integer_value(json_object_get(value, "type"));
breakpoint.addr = (uint)json_hex_value(json_object_get(value, "address"));
breakpoint.enabled = json_boolean_value(json_object_get(value, "enabled"));
breakpoint.titantype = (DWORD)json_hex_value(json_object_get(value, "titantype"));
// Name
const char* name = json_string_value(json_object_get(value, "name"));
if(name)
strcpy_s(breakpoint.name, name);
// Module
const char* mod = json_string_value(json_object_get(value, "module"));
if(mod && *mod && strlen(mod) < MAX_MODULE_SIZE)
strcpy_s(breakpoint.mod, mod);
// Build the hash map key: MOD_HASH + ADDRESS
const uint key = ModHashFromName(breakpoint.mod) + breakpoint.addr;
breakpoints.insert(std::make_pair(BreakpointKey(breakpoint.type, key), breakpoint));
}
}
void bpclear()
void BpClear()
{
CriticalSectionLocker locker(LockBreakpoints);
BreakpointsInfo().swap(breakpoints);
EXCLUSIVE_ACQUIRE(LockBreakpoints);
breakpoints.clear();
EXCLUSIVE_RELEASE();
}

View File

@ -1,10 +1,8 @@
#ifndef _BREAKPOINT_H
#define _BREAKPOINT_H
#pragma once
#include "_global.h"
#include "TitanEngine\TitanEngine.h"
//macros
#define TITANSETDRX(titantype, drx) titantype &= 0x0FF; titantype |= (drx<<8)
#define TITANGETDRX(titantype) (titantype >> 8) & 0xF
#define TITANSETTYPE(titantype, type) titantype &= 0xF0F; titantype |= (type<<4)
@ -12,7 +10,6 @@
#define TITANSETSIZE(titantype, size) titantype &= 0xFF0; titantype |= size;
#define TITANGETSIZE(titantype) titantype & 0xF
//enums
enum BP_TYPE
{
BPNORMAL = 0,
@ -20,7 +17,6 @@ enum BP_TYPE
BPMEMORY = 2
};
//structs
struct BREAKPOINT
{
uint addr;
@ -34,23 +30,21 @@ struct BREAKPOINT
char mod[MAX_MODULE_SIZE];
};
//typedefs
// Breakpoint enumeration callback
typedef bool (*BPENUMCALLBACK)(const BREAKPOINT* bp);
//functions
int bpgetlist(std::vector<BREAKPOINT>* list);
bool bpnew(uint addr, bool enabled, bool singleshoot, short oldbytes, BP_TYPE type, DWORD titantype, const char* name);
bool bpget(uint addr, BP_TYPE type, const char* name, BREAKPOINT* bp);
bool bpdel(uint addr, BP_TYPE type);
bool bpenable(uint addr, BP_TYPE type, bool enable);
bool bpsetname(uint addr, BP_TYPE type, const char* name);
bool bpsettitantype(uint addr, BP_TYPE type, int titantype);
bool bpenumall(BPENUMCALLBACK cbEnum);
bool bpenumall(BPENUMCALLBACK cbEnum, const char* module);
int bpgetcount(BP_TYPE type, bool enabledonly = false);
void bptobridge(const BREAKPOINT* bp, BRIDGEBP* bridge);
void bpcachesave(JSON root);
void bpcacheload(JSON root);
void bpclear();
#endif // _BREAKPOINT_H
BREAKPOINT* BpInfoFromAddr(BP_TYPE Type, uint Address);
int BpGetList(std::vector<BREAKPOINT>* List);
bool BpNew(uint Address, bool Enable, bool Singleshot, short OldBytes, BP_TYPE Type, DWORD TitanType, const char* Name);
bool BpGet(uint Address, BP_TYPE Type, const char* Name, BREAKPOINT* Bp);
bool BpDelete(uint Address, BP_TYPE Type);
bool BpEnable(uint Address, BP_TYPE Type, bool Enable);
bool BpSetName(uint Address, BP_TYPE Type, const char* Name);
bool BpSetTitanType(uint Address, BP_TYPE Type, int TitanType);
bool BpEnumAll(BPENUMCALLBACK EnumCallback, const char* Module);
bool BpEnumAll(BPENUMCALLBACK EnumCallback);
int BpGetCount(BP_TYPE Type, bool EnabledOnly);
void BpToBridge(const BREAKPOINT* Bp, BRIDGEBP* BridgeBp);
void BpCacheSave(JSON Root);
void BpCacheLoad(JSON Root);
void BpClear();

View File

@ -82,7 +82,7 @@ uint dbgdebuggedbase()
void dbgdisablebpx()
{
std::vector<BREAKPOINT> list;
int bpcount = bpgetlist(&list);
int bpcount = BpGetList(&list);
for(int i = 0; i < bpcount; i++)
{
if(list[i].type == BPNORMAL and IsBPXEnabled(list[i].addr))
@ -93,7 +93,7 @@ void dbgdisablebpx()
void dbgenablebpx()
{
std::vector<BREAKPOINT> list;
int bpcount = bpgetlist(&list);
int bpcount = BpGetList(&list);
for(int i = 0; i < bpcount; i++)
{
if(list[i].type == BPNORMAL and !IsBPXEnabled(list[i].addr) and list[i].enabled)
@ -215,7 +215,7 @@ void cbUserBreakpoint()
BRIDGEBP pluginBp;
PLUG_CB_BREAKPOINT bpInfo;
bpInfo.breakpoint = 0;
if(!bpget(GetContextDataEx(hActiveThread, UE_CIP), BPNORMAL, 0, &bp) and bp.enabled)
if(!BpGet(GetContextDataEx(hActiveThread, UE_CIP), BPNORMAL, 0, &bp) and bp.enabled)
dputs("Breakpoint reached not in list!");
else
{
@ -241,8 +241,8 @@ void cbUserBreakpoint()
dprintf("%s breakpoint at "fhex"!\n", bptype, bp.addr);
}
if(bp.singleshoot)
bpdel(bp.addr, BPNORMAL);
bptobridge(&bp, &pluginBp);
BpDelete(bp.addr, BPNORMAL);
BpToBridge(&bp, &pluginBp);
bpInfo.breakpoint = &pluginBp;
}
GuiSetDebugState(paused);
@ -266,7 +266,7 @@ void cbHardwareBreakpoint(void* ExceptionAddress)
BRIDGEBP pluginBp;
PLUG_CB_BREAKPOINT bpInfo;
bpInfo.breakpoint = 0;
if(!bpget((uint)ExceptionAddress, BPHARDWARE, 0, &bp))
if(!BpGet((uint)ExceptionAddress, BPHARDWARE, 0, &bp))
dputs("Hardware breakpoint reached not in list!");
else
{
@ -317,7 +317,7 @@ void cbHardwareBreakpoint(void* ExceptionAddress)
else
dprintf("Hardware breakpoint (%s%s) at "fhex"!\n", bpsize, bptype, bp.addr);
}
bptobridge(&bp, &pluginBp);
BpToBridge(&bp, &pluginBp);
bpInfo.breakpoint = &pluginBp;
}
GuiSetDebugState(paused);
@ -343,7 +343,7 @@ void cbMemoryBreakpoint(void* ExceptionAddress)
BRIDGEBP pluginBp;
PLUG_CB_BREAKPOINT bpInfo;
bpInfo.breakpoint = 0;
if(!bpget(base, BPMEMORY, 0, &bp))
if(!BpGet(base, BPMEMORY, 0, &bp))
dputs("Memory breakpoint reached not in list!");
else
{
@ -378,11 +378,11 @@ void cbMemoryBreakpoint(void* ExceptionAddress)
else
dprintf("Memory breakpoint%s at "fhex" ("fhex")!\n", bptype, bp.addr, ExceptionAddress);
}
bptobridge(&bp, &pluginBp);
BpToBridge(&bp, &pluginBp);
bpInfo.breakpoint = &pluginBp;
}
if(bp.singleshoot)
bpdel(bp.addr, BPMEMORY); //delete from breakpoint list
BpDelete(bp.addr, BPMEMORY); //delete from breakpoint list
GuiSetDebugState(paused);
DebugUpdateGui(cip, true);
//lock
@ -503,7 +503,7 @@ static bool cbSetModuleBreakpoints(const BREAKPOINT* bp)
}
int titantype = bp->titantype;
TITANSETDRX(titantype, drx);
bpsettitantype(bp->addr, BPHARDWARE, titantype);
BpSetTitanType(bp->addr, BPHARDWARE, titantype);
if(!SetHardwareBreakPoint(bp->addr, drx, TITANGETTYPE(bp->titantype), TITANGETSIZE(bp->titantype), (void*)cbHardwareBreakpoint))
dprintf("Could not set hardware breakpoint "fhex"!\n", bp->addr);
}
@ -638,7 +638,7 @@ static void cbCreateProcess(CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo)
memupdatemap(fdProcessInfo->hProcess); //update memory map
char modname[256] = "";
if(ModNameFromAddr((uint)base, modname, true))
bpenumall(cbSetModuleBreakpoints, modname);
BpEnumAll(cbSetModuleBreakpoints, modname);
GuiUpdateBreakpointsView();
if(!bFileIsDll and !bIsAttached) //Set entry breakpoint
{
@ -818,7 +818,7 @@ static void cbLoadDll(LOAD_DLL_DEBUG_INFO* LoadDll)
memupdatemap(fdProcessInfo->hProcess); //update memory map
char modname[256] = "";
if(ModNameFromAddr((uint)base, modname, true))
bpenumall(cbSetModuleBreakpoints, modname);
BpEnumAll(cbSetModuleBreakpoints, modname);
GuiUpdateBreakpointsView();
bool bAlreadySetEntry = false;
@ -908,7 +908,7 @@ static void cbUnloadDll(UNLOAD_DLL_DEBUG_INFO* UnloadDll)
void* base = UnloadDll->lpBaseOfDll;
char modname[256] = "???";
if(ModNameFromAddr((uint)base, modname, true))
bpenumall(cbRemoveModuleBreakpoints, modname);
BpEnumAll(cbRemoveModuleBreakpoints, modname);
GuiUpdateBreakpointsView();
SymUnloadModule64(fdProcessInfo->hProcess, (DWORD64)base);
dprintf("DLL Unloaded: "fhex" %s\n", base, modname);
@ -1163,7 +1163,7 @@ DWORD WINAPI threadDebugLoop(void* lpParameter)
bool cbDeleteAllBreakpoints(const BREAKPOINT* bp)
{
if(bpdel(bp->addr, BPNORMAL) and (!bp->enabled or DeleteBPX(bp->addr)))
if(BpDelete(bp->addr, BPNORMAL) and (!bp->enabled or DeleteBPX(bp->addr)))
return true;
dprintf("Delete breakpoint failed: "fhex"\n", bp->addr);
@ -1175,7 +1175,7 @@ bool cbEnableAllBreakpoints(const BREAKPOINT* bp)
if(bp->type != BPNORMAL or bp->enabled)
return true;
if(!bpenable(bp->addr, BPNORMAL, true) or !SetBPX(bp->addr, bp->titantype, (void*)cbUserBreakpoint))
if(!BpEnable(bp->addr, BPNORMAL, true) or !SetBPX(bp->addr, bp->titantype, (void*)cbUserBreakpoint))
{
dprintf("Could not enable breakpoint "fhex"\n", bp->addr);
return false;
@ -1188,7 +1188,7 @@ bool cbDisableAllBreakpoints(const BREAKPOINT* bp)
if(bp->type != BPNORMAL or !bp->enabled)
return true;
if(!bpenable(bp->addr, BPNORMAL, false) or !DeleteBPX(bp->addr))
if(!BpEnable(bp->addr, BPNORMAL, false) or !DeleteBPX(bp->addr))
{
dprintf("Could not disable breakpoint "fhex"\n", bp->addr);
return false;
@ -1208,8 +1208,8 @@ bool cbEnableAllHardwareBreakpoints(const BREAKPOINT* bp)
}
int titantype = bp->titantype;
TITANSETDRX(titantype, drx);
bpsettitantype(bp->addr, BPHARDWARE, titantype);
if(!bpenable(bp->addr, BPHARDWARE, true) or !SetHardwareBreakPoint(bp->addr, drx, TITANGETTYPE(bp->titantype), TITANGETSIZE(bp->titantype), (void*)cbHardwareBreakpoint))
BpSetTitanType(bp->addr, BPHARDWARE, titantype);
if(!BpEnable(bp->addr, BPHARDWARE, true) or !SetHardwareBreakPoint(bp->addr, drx, TITANGETTYPE(bp->titantype), TITANGETSIZE(bp->titantype), (void*)cbHardwareBreakpoint))
{
dprintf("could not enable hardware breakpoint "fhex"\n", bp->addr);
return false;
@ -1221,7 +1221,7 @@ bool cbDisableAllHardwareBreakpoints(const BREAKPOINT* bp)
{
if(bp->type != BPHARDWARE or !bp->enabled)
return true;
if(!bpenable(bp->addr, BPHARDWARE, false) or !DeleteHardwareBreakPoint(TITANGETDRX(bp->titantype)))
if(!BpEnable(bp->addr, BPHARDWARE, false) or !DeleteHardwareBreakPoint(TITANGETDRX(bp->titantype)))
{
dprintf("Could not disable hardware breakpoint "fhex"\n", bp->addr);
return false;
@ -1235,7 +1235,7 @@ bool cbEnableAllMemoryBreakpoints(const BREAKPOINT* bp)
return true;
uint size = 0;
memfindbaseaddr(bp->addr, &size);
if(!bpenable(bp->addr, BPMEMORY, true) or !SetMemoryBPXEx(bp->addr, size, bp->titantype, !bp->singleshoot, (void*)cbMemoryBreakpoint))
if(!BpEnable(bp->addr, BPMEMORY, true) or !SetMemoryBPXEx(bp->addr, size, bp->titantype, !bp->singleshoot, (void*)cbMemoryBreakpoint))
{
dprintf("Could not enable memory breakpoint "fhex"\n", bp->addr);
return false;
@ -1247,7 +1247,7 @@ bool cbDisableAllMemoryBreakpoints(const BREAKPOINT* bp)
{
if(bp->type != BPMEMORY or !bp->enabled)
return true;
if(!bpenable(bp->addr, BPMEMORY, false) or !DeleteHardwareBreakPoint(TITANGETDRX(bp->titantype)))
if(!BpEnable(bp->addr, BPMEMORY, false) or !DeleteHardwareBreakPoint(TITANGETDRX(bp->titantype)))
{
dprintf("Could not disable memory breakpoint "fhex"\n", bp->addr);
return false;
@ -1283,7 +1283,7 @@ bool cbDeleteAllMemoryBreakpoints(const BREAKPOINT* bp)
return true;
uint size;
memfindbaseaddr(bp->addr, &size);
if(!bpdel(bp->addr, BPMEMORY) or !RemoveMemoryBPX(bp->addr, size))
if(!BpDelete(bp->addr, BPMEMORY) or !RemoveMemoryBPX(bp->addr, size))
{
dprintf("Delete memory breakpoint failed: "fhex"\n", bp->addr);
return STATUS_ERROR;
@ -1295,7 +1295,7 @@ bool cbDeleteAllHardwareBreakpoints(const BREAKPOINT* bp)
{
if(!bp->enabled)
return true;
if(!bpdel(bp->addr, BPHARDWARE) or !DeleteHardwareBreakPoint(TITANGETDRX(bp->titantype)))
if(!BpDelete(bp->addr, BPHARDWARE) or !DeleteHardwareBreakPoint(TITANGETDRX(bp->titantype)))
{
dprintf("Delete hardware breakpoint failed: "fhex"\n", bp->addr);
return STATUS_ERROR;

View File

@ -209,7 +209,7 @@ CMDRESULT cbDebugSetBPX(int argc, char* argv[]) //bp addr [,name [,type]]
const char* bpname = 0;
if(*argname)
bpname = argname;
if(bpget(addr, BPNORMAL, bpname, 0))
if(BpGet(addr, BPNORMAL, bpname, 0))
{
dputs("Breakpoint already set!");
return STATUS_CONTINUE;
@ -224,7 +224,7 @@ CMDRESULT cbDebugSetBPX(int argc, char* argv[]) //bp addr [,name [,type]]
dprintf("Error setting breakpoint at "fhex"! (memread)\n", addr);
return STATUS_ERROR;
}
else if(!bpnew(addr, true, singleshoot, oldbytes, BPNORMAL, type, bpname))
else if(!BpNew(addr, true, singleshoot, oldbytes, BPNORMAL, type, bpname))
{
dprintf("Error setting breakpoint at "fhex"! (bpnew)\n", addr);
return STATUS_ERROR;
@ -244,21 +244,21 @@ CMDRESULT cbDebugDeleteBPX(int argc, char* argv[])
char arg1[deflen] = "";
if(!argget(*argv, arg1, 0, true)) //delete all breakpoints
{
if(!bpgetcount(BPNORMAL))
if(!BpGetCount(BPNORMAL))
{
dputs("No breakpoints to delete!");
return STATUS_CONTINUE;
}
if(!bpenumall(cbDeleteAllBreakpoints)) //at least one deletion failed
if(!BpEnumAll(cbDeleteAllBreakpoints)) //at least one deletion failed
return STATUS_ERROR;
dputs("All breakpoints deleted!");
GuiUpdateAllViews();
return STATUS_CONTINUE;
}
BREAKPOINT found;
if(bpget(0, BPNORMAL, arg1, &found)) //found a breakpoint with name
if(BpGet(0, BPNORMAL, arg1, &found)) //found a breakpoint with name
{
if(!bpdel(found.addr, BPNORMAL))
if(!BpDelete(found.addr, BPNORMAL))
{
dprintf("Delete breakpoint failed (bpdel): "fhex"\n", found.addr);
return STATUS_ERROR;
@ -272,12 +272,12 @@ CMDRESULT cbDebugDeleteBPX(int argc, char* argv[])
return STATUS_CONTINUE;
}
uint addr = 0;
if(!valfromstring(arg1, &addr) or !bpget(addr, BPNORMAL, 0, &found)) //invalid breakpoint
if(!valfromstring(arg1, &addr) or !BpGet(addr, BPNORMAL, 0, &found)) //invalid breakpoint
{
dprintf("No such breakpoint \"%s\"\n", arg1);
return STATUS_ERROR;
}
if(!bpdel(found.addr, BPNORMAL))
if(!BpDelete(found.addr, BPNORMAL))
{
dprintf("Delete breakpoint failed (bpdel): "fhex"\n", found.addr);
return STATUS_ERROR;
@ -298,21 +298,21 @@ CMDRESULT cbDebugEnableBPX(int argc, char* argv[])
char arg1[deflen] = "";
if(!argget(*argv, arg1, 0, true)) //enable all breakpoints
{
if(!bpgetcount(BPNORMAL))
if(!BpGetCount(BPNORMAL))
{
dputs("No breakpoints to enable!");
return STATUS_CONTINUE;
}
if(!bpenumall(cbEnableAllBreakpoints)) //at least one enable failed
if(!BpEnumAll(cbEnableAllBreakpoints)) //at least one enable failed
return STATUS_ERROR;
dputs("All breakpoints enabled!");
GuiUpdateAllViews();
return STATUS_CONTINUE;
}
BREAKPOINT found;
if(bpget(0, BPNORMAL, arg1, &found)) //found a breakpoint with name
if(BpGet(0, BPNORMAL, arg1, &found)) //found a breakpoint with name
{
if(!bpenable(found.addr, BPNORMAL, true) or !SetBPX(found.addr, found.titantype, (void*)cbUserBreakpoint))
if(!BpEnable(found.addr, BPNORMAL, true) or !SetBPX(found.addr, found.titantype, (void*)cbUserBreakpoint))
{
dprintf("Could not enable breakpoint "fhex"\n", found.addr);
return STATUS_ERROR;
@ -321,7 +321,7 @@ CMDRESULT cbDebugEnableBPX(int argc, char* argv[])
return STATUS_CONTINUE;
}
uint addr = 0;
if(!valfromstring(arg1, &addr) or !bpget(addr, BPNORMAL, 0, &found)) //invalid breakpoint
if(!valfromstring(arg1, &addr) or !BpGet(addr, BPNORMAL, 0, &found)) //invalid breakpoint
{
dprintf("No such breakpoint \"%s\"\n", arg1);
return STATUS_ERROR;
@ -332,7 +332,7 @@ CMDRESULT cbDebugEnableBPX(int argc, char* argv[])
GuiUpdateAllViews();
return STATUS_CONTINUE;
}
if(!bpenable(found.addr, BPNORMAL, true) or !SetBPX(found.addr, found.titantype, (void*)cbUserBreakpoint))
if(!BpEnable(found.addr, BPNORMAL, true) or !SetBPX(found.addr, found.titantype, (void*)cbUserBreakpoint))
{
dprintf("Could not enable breakpoint "fhex"\n", found.addr);
return STATUS_ERROR;
@ -347,21 +347,21 @@ CMDRESULT cbDebugDisableBPX(int argc, char* argv[])
char arg1[deflen] = "";
if(!argget(*argv, arg1, 0, true)) //delete all breakpoints
{
if(!bpgetcount(BPNORMAL))
if(!BpGetCount(BPNORMAL))
{
dputs("No breakpoints to disable!");
return STATUS_CONTINUE;
}
if(!bpenumall(cbDisableAllBreakpoints)) //at least one deletion failed
if(!BpEnumAll(cbDisableAllBreakpoints)) //at least one deletion failed
return STATUS_ERROR;
dputs("All breakpoints disabled!");
GuiUpdateAllViews();
return STATUS_CONTINUE;
}
BREAKPOINT found;
if(bpget(0, BPNORMAL, arg1, &found)) //found a breakpoint with name
if(BpGet(0, BPNORMAL, arg1, &found)) //found a breakpoint with name
{
if(!bpenable(found.addr, BPNORMAL, false) or !DeleteBPX(found.addr))
if(!BpEnable(found.addr, BPNORMAL, false) or !DeleteBPX(found.addr))
{
dprintf("Could not disable breakpoint "fhex"\n", found.addr);
return STATUS_ERROR;
@ -370,7 +370,7 @@ CMDRESULT cbDebugDisableBPX(int argc, char* argv[])
return STATUS_CONTINUE;
}
uint addr = 0;
if(!valfromstring(arg1, &addr) or !bpget(addr, BPNORMAL, 0, &found)) //invalid breakpoint
if(!valfromstring(arg1, &addr) or !BpGet(addr, BPNORMAL, 0, &found)) //invalid breakpoint
{
dprintf("No such breakpoint \"%s\"\n", arg1);
return STATUS_ERROR;
@ -380,7 +380,7 @@ CMDRESULT cbDebugDisableBPX(int argc, char* argv[])
dputs("Breakpoint already disabled!");
return STATUS_CONTINUE;
}
if(!bpenable(found.addr, BPNORMAL, false) or !DeleteBPX(found.addr))
if(!BpEnable(found.addr, BPNORMAL, false) or !DeleteBPX(found.addr))
{
dprintf("Could not disable breakpoint "fhex"\n", found.addr);
return STATUS_ERROR;
@ -392,7 +392,7 @@ CMDRESULT cbDebugDisableBPX(int argc, char* argv[])
CMDRESULT cbDebugBplist(int argc, char* argv[])
{
bpenumall(cbBreakpointList);
BpEnumAll(cbBreakpointList);
return STATUS_CONTINUE;
}
@ -509,12 +509,12 @@ CMDRESULT cbDebugSetMemoryBpx(int argc, char* argv[])
bool singleshoot = false;
if(!restore)
singleshoot = true;
if(bpget(base, BPMEMORY, 0, 0))
if(BpGet(base, BPMEMORY, 0, 0))
{
dputs("Hardware breakpoint already set!");
return STATUS_CONTINUE;
}
if(!bpnew(base, true, singleshoot, 0, BPMEMORY, type, 0) or !SetMemoryBPXEx(base, size, type, restore, (void*)cbMemoryBreakpoint))
if(!BpNew(base, true, singleshoot, 0, BPMEMORY, type, 0) or !SetMemoryBPXEx(base, size, type, restore, (void*)cbMemoryBreakpoint))
{
dputs("Error setting memory breakpoint!");
return STATUS_ERROR;
@ -529,23 +529,23 @@ CMDRESULT cbDebugDeleteMemoryBreakpoint(int argc, char* argv[])
char arg1[deflen] = "";
if(!argget(*argv, arg1, 0, true)) //delete all breakpoints
{
if(!bpgetcount(BPMEMORY))
if(!BpGetCount(BPMEMORY))
{
dputs("no memory breakpoints to delete!");
return STATUS_CONTINUE;
}
if(!bpenumall(cbDeleteAllMemoryBreakpoints)) //at least one deletion failed
if(!BpEnumAll(cbDeleteAllMemoryBreakpoints)) //at least one deletion failed
return STATUS_ERROR;
dputs("All memory breakpoints deleted!");
GuiUpdateAllViews();
return STATUS_CONTINUE;
}
BREAKPOINT found;
if(bpget(0, BPMEMORY, arg1, &found)) //found a breakpoint with name
if(BpGet(0, BPMEMORY, arg1, &found)) //found a breakpoint with name
{
uint size;
memfindbaseaddr(found.addr, &size);
if(!bpdel(found.addr, BPMEMORY) or !RemoveMemoryBPX(found.addr, size))
if(!BpDelete(found.addr, BPMEMORY) or !RemoveMemoryBPX(found.addr, size))
{
dprintf("Delete memory breakpoint failed: "fhex"\n", found.addr);
return STATUS_ERROR;
@ -553,14 +553,14 @@ CMDRESULT cbDebugDeleteMemoryBreakpoint(int argc, char* argv[])
return STATUS_CONTINUE;
}
uint addr = 0;
if(!valfromstring(arg1, &addr) or !bpget(addr, BPMEMORY, 0, &found)) //invalid breakpoint
if(!valfromstring(arg1, &addr) or !BpGet(addr, BPMEMORY, 0, &found)) //invalid breakpoint
{
dprintf("No such memory breakpoint \"%s\"\n", arg1);
return STATUS_ERROR;
}
uint size;
memfindbaseaddr(found.addr, &size);
if(!bpdel(found.addr, BPMEMORY) or !RemoveMemoryBPX(found.addr, size))
if(!BpDelete(found.addr, BPMEMORY) or !RemoveMemoryBPX(found.addr, size))
{
dprintf("Delete memory breakpoint failed: "fhex"\n", found.addr);
return STATUS_ERROR;
@ -655,12 +655,12 @@ CMDRESULT cbDebugSetHardwareBreakpoint(int argc, char* argv[])
TITANSETTYPE(titantype, type);
TITANSETSIZE(titantype, titsize);
//TODO: hwbp in multiple threads TEST
if(bpget(addr, BPHARDWARE, 0, 0))
if(BpGet(addr, BPHARDWARE, 0, 0))
{
dputs("Hardware breakpoint already set!");
return STATUS_CONTINUE;
}
if(!bpnew(addr, true, false, 0, BPHARDWARE, titantype, 0))
if(!BpNew(addr, true, false, 0, BPHARDWARE, titantype, 0))
{
dputs("error setting hardware breakpoint (bpnew)!");
return STATUS_ERROR;
@ -680,21 +680,21 @@ CMDRESULT cbDebugDeleteHardwareBreakpoint(int argc, char* argv[])
char arg1[deflen] = "";
if(!argget(*argv, arg1, 0, true)) //delete all breakpoints
{
if(!bpgetcount(BPHARDWARE))
if(!BpGetCount(BPHARDWARE))
{
dputs("No hardware breakpoints to delete!");
return STATUS_CONTINUE;
}
if(!bpenumall(cbDeleteAllHardwareBreakpoints)) //at least one deletion failed
if(!BpEnumAll(cbDeleteAllHardwareBreakpoints)) //at least one deletion failed
return STATUS_ERROR;
dputs("All hardware breakpoints deleted!");
GuiUpdateAllViews();
return STATUS_CONTINUE;
}
BREAKPOINT found;
if(bpget(0, BPHARDWARE, arg1, &found)) //found a breakpoint with name
if(BpGet(0, BPHARDWARE, arg1, &found)) //found a breakpoint with name
{
if(!bpdel(found.addr, BPHARDWARE) or !DeleteHardwareBreakPoint(TITANGETDRX(found.titantype)))
if(!BpDelete(found.addr, BPHARDWARE) or !DeleteHardwareBreakPoint(TITANGETDRX(found.titantype)))
{
dprintf("Delete hardware breakpoint failed: "fhex"\n", found.addr);
return STATUS_ERROR;
@ -702,12 +702,12 @@ CMDRESULT cbDebugDeleteHardwareBreakpoint(int argc, char* argv[])
return STATUS_CONTINUE;
}
uint addr = 0;
if(!valfromstring(arg1, &addr) or !bpget(addr, BPHARDWARE, 0, &found)) //invalid breakpoint
if(!valfromstring(arg1, &addr) or !BpGet(addr, BPHARDWARE, 0, &found)) //invalid breakpoint
{
dprintf("No such hardware breakpoint \"%s\"\n", arg1);
return STATUS_ERROR;
}
if(!bpdel(found.addr, BPHARDWARE) or !DeleteHardwareBreakPoint(TITANGETDRX(found.titantype)))
if(!BpDelete(found.addr, BPHARDWARE) or !DeleteHardwareBreakPoint(TITANGETDRX(found.titantype)))
{
dprintf("Delete hardware breakpoint failed: "fhex"\n", found.addr);
return STATUS_ERROR;
@ -1210,12 +1210,12 @@ CMDRESULT cbDebugEnableHardwareBreakpoint(int argc, char* argv[])
}
if(!argget(*argv, arg1, 0, true)) //enable all hardware breakpoints
{
if(!bpgetcount(BPHARDWARE))
if(!BpGetCount(BPHARDWARE))
{
dputs("No hardware breakpoints to enable!");
return STATUS_CONTINUE;
}
if(!bpenumall(cbEnableAllHardwareBreakpoints)) //at least one enable failed
if(!BpEnumAll(cbEnableAllHardwareBreakpoints)) //at least one enable failed
return STATUS_ERROR;
dputs("All hardware breakpoints enabled!");
GuiUpdateAllViews();
@ -1223,7 +1223,7 @@ CMDRESULT cbDebugEnableHardwareBreakpoint(int argc, char* argv[])
}
BREAKPOINT found;
uint addr = 0;
if(!valfromstring(arg1, &addr) or !bpget(addr, BPHARDWARE, 0, &found)) //invalid hardware breakpoint
if(!valfromstring(arg1, &addr) or !BpGet(addr, BPHARDWARE, 0, &found)) //invalid hardware breakpoint
{
dprintf("No such hardware breakpoint \"%s\"\n", arg1);
return STATUS_ERROR;
@ -1235,8 +1235,8 @@ CMDRESULT cbDebugEnableHardwareBreakpoint(int argc, char* argv[])
return STATUS_CONTINUE;
}
TITANSETDRX(found.titantype, drx);
bpsettitantype(found.addr, BPHARDWARE, found.titantype);
if(!bpenable(found.addr, BPHARDWARE, true) or !SetHardwareBreakPoint(found.addr, drx, TITANGETTYPE(found.titantype), TITANGETSIZE(found.titantype), (void*)cbHardwareBreakpoint))
BpSetTitanType(found.addr, BPHARDWARE, found.titantype);
if(!BpEnable(found.addr, BPHARDWARE, true) or !SetHardwareBreakPoint(found.addr, drx, TITANGETTYPE(found.titantype), TITANGETSIZE(found.titantype), (void*)cbHardwareBreakpoint))
{
dprintf("Could not enable hardware breakpoint "fhex"\n", found.addr);
return STATUS_ERROR;
@ -1251,12 +1251,12 @@ CMDRESULT cbDebugDisableHardwareBreakpoint(int argc, char* argv[])
char arg1[deflen] = "";
if(!argget(*argv, arg1, 0, true)) //delete all hardware breakpoints
{
if(!bpgetcount(BPHARDWARE))
if(!BpGetCount(BPHARDWARE))
{
dputs("No hardware breakpoints to disable!");
return STATUS_CONTINUE;
}
if(!bpenumall(cbDisableAllHardwareBreakpoints)) //at least one deletion failed
if(!BpEnumAll(cbDisableAllHardwareBreakpoints)) //at least one deletion failed
return STATUS_ERROR;
dputs("All hardware breakpoints disabled!");
GuiUpdateAllViews();
@ -1264,7 +1264,7 @@ CMDRESULT cbDebugDisableHardwareBreakpoint(int argc, char* argv[])
}
BREAKPOINT found;
uint addr = 0;
if(!valfromstring(arg1, &addr) or !bpget(addr, BPHARDWARE, 0, &found)) //invalid hardware breakpoint
if(!valfromstring(arg1, &addr) or !BpGet(addr, BPHARDWARE, 0, &found)) //invalid hardware breakpoint
{
dprintf("No such hardware breakpoint \"%s\"\n", arg1);
return STATUS_ERROR;
@ -1274,7 +1274,7 @@ CMDRESULT cbDebugDisableHardwareBreakpoint(int argc, char* argv[])
dputs("Hardware breakpoint already disabled!");
return STATUS_CONTINUE;
}
if(!bpenable(found.addr, BPHARDWARE, false) or !DeleteHardwareBreakPoint(TITANGETDRX(found.titantype)))
if(!BpEnable(found.addr, BPHARDWARE, false) or !DeleteHardwareBreakPoint(TITANGETDRX(found.titantype)))
{
dprintf("Could not disable hardware breakpoint "fhex"\n", found.addr);
return STATUS_ERROR;
@ -1295,12 +1295,12 @@ CMDRESULT cbDebugEnableMemoryBreakpoint(int argc, char* argv[])
}
if(!argget(*argv, arg1, 0, true)) //enable all memory breakpoints
{
if(!bpgetcount(BPMEMORY))
if(!BpGetCount(BPMEMORY))
{
dputs("No hardware breakpoints to enable!");
return STATUS_CONTINUE;
}
if(!bpenumall(cbEnableAllHardwareBreakpoints)) //at least one enable failed
if(!BpEnumAll(cbEnableAllHardwareBreakpoints)) //at least one enable failed
return STATUS_ERROR;
dputs("All memory breakpoints enabled!");
GuiUpdateAllViews();
@ -1308,7 +1308,7 @@ CMDRESULT cbDebugEnableMemoryBreakpoint(int argc, char* argv[])
}
BREAKPOINT found;
uint addr = 0;
if(!valfromstring(arg1, &addr) or !bpget(addr, BPMEMORY, 0, &found)) //invalid memory breakpoint
if(!valfromstring(arg1, &addr) or !BpGet(addr, BPMEMORY, 0, &found)) //invalid memory breakpoint
{
dprintf("No such memory breakpoint \"%s\"\n", arg1);
return STATUS_ERROR;
@ -1321,7 +1321,7 @@ CMDRESULT cbDebugEnableMemoryBreakpoint(int argc, char* argv[])
}
uint size = 0;
memfindbaseaddr(found.addr, &size);
if(!bpenable(found.addr, BPMEMORY, true) or !SetMemoryBPXEx(found.addr, size, found.titantype, !found.singleshoot, (void*)cbMemoryBreakpoint))
if(!BpEnable(found.addr, BPMEMORY, true) or !SetMemoryBPXEx(found.addr, size, found.titantype, !found.singleshoot, (void*)cbMemoryBreakpoint))
{
dprintf("Could not enable memory breakpoint "fhex"\n", found.addr);
return STATUS_ERROR;
@ -1336,12 +1336,12 @@ CMDRESULT cbDebugDisableMemoryBreakpoint(int argc, char* argv[])
char arg1[deflen] = "";
if(!argget(*argv, arg1, 0, true)) //delete all memory breakpoints
{
if(!bpgetcount(BPMEMORY))
if(!BpGetCount(BPMEMORY))
{
dputs("No memory breakpoints to disable!");
return STATUS_CONTINUE;
}
if(!bpenumall(cbDisableAllMemoryBreakpoints)) //at least one deletion failed
if(!BpEnumAll(cbDisableAllMemoryBreakpoints)) //at least one deletion failed
return STATUS_ERROR;
dputs("All memory breakpoints disabled!");
GuiUpdateAllViews();
@ -1349,7 +1349,7 @@ CMDRESULT cbDebugDisableMemoryBreakpoint(int argc, char* argv[])
}
BREAKPOINT found;
uint addr = 0;
if(!valfromstring(arg1, &addr) or !bpget(addr, BPMEMORY, 0, &found)) //invalid memory breakpoint
if(!valfromstring(arg1, &addr) or !BpGet(addr, BPMEMORY, 0, &found)) //invalid memory breakpoint
{
dprintf("No such memory breakpoint \"%s\"\n", arg1);
return STATUS_ERROR;
@ -1361,7 +1361,7 @@ CMDRESULT cbDebugDisableMemoryBreakpoint(int argc, char* argv[])
}
uint size = 0;
memfindbaseaddr(found.addr, &size);
if(!bpenable(found.addr, BPMEMORY, false) or !RemoveMemoryBPX(found.addr, size))
if(!BpEnable(found.addr, BPMEMORY, false) or !RemoveMemoryBPX(found.addr, size))
{
dprintf("Could not disable memory breakpoint "fhex"\n", found.addr);
return STATUS_ERROR;

View File

@ -17,9 +17,7 @@ bool ModLoad(uint base, uint size, const char* fullpath)
MODINFO info;
//
// Break the module path into a directory and file name
//
char dir[deflen];
char* file;
@ -42,16 +40,12 @@ bool ModLoad(uint base, uint size, const char* fullpath)
// Copy the name to the module struct
strcpy_s(info.name, file);
//
// Module base address/size/hash index
//
info.hash = ModHashFromName(info.name);
info.base = base;
info.size = size;
//
// Process module sections
//
info.sections.clear();
WString wszFullPath = StringUtils::Utf8ToUtf16(fullpath);