1
0
Fork 0

DBG: Capitalize status messages

This commit is contained in:
Nukem 2015-01-02 13:01:45 -05:00
parent 45393bda75
commit ff2b7422c7
2 changed files with 163 additions and 161 deletions

View File

@ -273,7 +273,7 @@ void cbUserBreakpoint()
PLUG_CB_BREAKPOINT bpInfo; PLUG_CB_BREAKPOINT bpInfo;
bpInfo.breakpoint = 0; 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!"); dputs("Breakpoint reached not in list!");
else else
{ {
const char* bptype = "INT3"; const char* bptype = "INT3";
@ -324,7 +324,7 @@ void cbHardwareBreakpoint(void* ExceptionAddress)
PLUG_CB_BREAKPOINT bpInfo; PLUG_CB_BREAKPOINT bpInfo;
bpInfo.breakpoint = 0; bpInfo.breakpoint = 0;
if(!bpget((uint)ExceptionAddress, BPHARDWARE, 0, &bp)) if(!bpget((uint)ExceptionAddress, BPHARDWARE, 0, &bp))
dputs("hardware breakpoint reached not in list!"); dputs("Hardware breakpoint reached not in list!");
else else
{ {
const char* bpsize = ""; const char* bpsize = "";
@ -363,16 +363,16 @@ void cbHardwareBreakpoint(void* ExceptionAddress)
if(symbolicname) if(symbolicname)
{ {
if(*bp.name) if(*bp.name)
dprintf("hardware breakpoint (%s%s) \"%s\" at %s ("fhex")!\n", bpsize, bptype, bp.name, symbolicname, bp.addr); dprintf("Hardware breakpoint (%s%s) \"%s\" at %s ("fhex")!\n", bpsize, bptype, bp.name, symbolicname, bp.addr);
else else
dprintf("hardware breakpoint (%s%s) at %s ("fhex")!\n", bpsize, bptype, symbolicname, bp.addr); dprintf("Hardware breakpoint (%s%s) at %s ("fhex")!\n", bpsize, bptype, symbolicname, bp.addr);
} }
else else
{ {
if(*bp.name) if(*bp.name)
dprintf("hardware breakpoint (%s%s) \"%s\" at "fhex"!\n", bpsize, bptype, bp.name, bp.addr); dprintf("Hardware breakpoint (%s%s) \"%s\" at "fhex"!\n", bpsize, bptype, bp.name, bp.addr);
else else
dprintf("hardware breakpoint (%s%s) at "fhex"!\n", bpsize, bptype, bp.addr); dprintf("Hardware breakpoint (%s%s) at "fhex"!\n", bpsize, bptype, bp.addr);
} }
bptobridge(&bp, &pluginBp); bptobridge(&bp, &pluginBp);
bpInfo.breakpoint = &pluginBp; bpInfo.breakpoint = &pluginBp;
@ -401,7 +401,7 @@ void cbMemoryBreakpoint(void* ExceptionAddress)
PLUG_CB_BREAKPOINT bpInfo; PLUG_CB_BREAKPOINT bpInfo;
bpInfo.breakpoint = 0; bpInfo.breakpoint = 0;
if(!bpget(base, BPMEMORY, 0, &bp)) if(!bpget(base, BPMEMORY, 0, &bp))
dputs("memory breakpoint reached not in list!"); dputs("Memory breakpoint reached not in list!");
else else
{ {
const char* bptype = ""; const char* bptype = "";
@ -424,16 +424,16 @@ void cbMemoryBreakpoint(void* ExceptionAddress)
if(symbolicname) if(symbolicname)
{ {
if(*bp.name) if(*bp.name)
dprintf("memory breakpoint%s \"%s\" at %s ("fhex", "fhex")!\n", bptype, bp.name, symbolicname, bp.addr, ExceptionAddress); dprintf("Memory breakpoint%s \"%s\" at %s ("fhex", "fhex")!\n", bptype, bp.name, symbolicname, bp.addr, ExceptionAddress);
else else
dprintf("memory breakpoint%s at %s ("fhex", "fhex")!\n", bptype, symbolicname, bp.addr, ExceptionAddress); dprintf("Memory breakpoint%s at %s ("fhex", "fhex")!\n", bptype, symbolicname, bp.addr, ExceptionAddress);
} }
else else
{ {
if(*bp.name) if(*bp.name)
dprintf("memory breakpoint%s \"%s\" at "fhex" ("fhex")!\n", bptype, bp.name, bp.addr, ExceptionAddress); dprintf("Memory breakpoint%s \"%s\" at "fhex" ("fhex")!\n", bptype, bp.name, bp.addr, ExceptionAddress);
else else
dprintf("memory breakpoint%s at "fhex" ("fhex")!\n", bptype, bp.addr, ExceptionAddress); dprintf("Memory breakpoint%s at "fhex" ("fhex")!\n", bptype, bp.addr, ExceptionAddress);
} }
bptobridge(&bp, &pluginBp); bptobridge(&bp, &pluginBp);
bpInfo.breakpoint = &pluginBp; bpInfo.breakpoint = &pluginBp;
@ -537,7 +537,7 @@ static bool cbSetModuleBreakpoints(const BREAKPOINT* bp)
case BPNORMAL: case BPNORMAL:
{ {
if(!SetBPX(bp->addr, bp->titantype, (void*)cbUserBreakpoint)) if(!SetBPX(bp->addr, bp->titantype, (void*)cbUserBreakpoint))
dprintf("could not set breakpoint "fhex"!\n", bp->addr); dprintf("Could not set breakpoint "fhex"!\n", bp->addr);
} }
break; break;
@ -546,7 +546,7 @@ static bool cbSetModuleBreakpoints(const BREAKPOINT* bp)
uint size = 0; uint size = 0;
memfindbaseaddr(bp->addr, &size); memfindbaseaddr(bp->addr, &size);
if(!SetMemoryBPXEx(bp->addr, size, bp->titantype, !bp->singleshoot, (void*)cbMemoryBreakpoint)) if(!SetMemoryBPXEx(bp->addr, size, bp->titantype, !bp->singleshoot, (void*)cbMemoryBreakpoint))
dprintf("could not set memory breakpoint "fhex"!\n", bp->addr); dprintf("Could not set memory breakpoint "fhex"!\n", bp->addr);
} }
break; break;
@ -555,14 +555,14 @@ static bool cbSetModuleBreakpoints(const BREAKPOINT* bp)
DWORD drx = 0; DWORD drx = 0;
if(!GetUnusedHardwareBreakPointRegister(&drx)) if(!GetUnusedHardwareBreakPointRegister(&drx))
{ {
dputs("you can only set 4 hardware breakpoints"); dputs("You can only set 4 hardware breakpoints");
return false; return false;
} }
int titantype = bp->titantype; int titantype = bp->titantype;
TITANSETDRX(titantype, drx); 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)) if(!SetHardwareBreakPoint(bp->addr, drx, TITANGETTYPE(bp->titantype), TITANGETSIZE(bp->titantype), (void*)cbHardwareBreakpoint))
dprintf("could not set hardware breakpoint "fhex"!\n", bp->addr); dprintf("Could not set hardware breakpoint "fhex"!\n", bp->addr);
} }
break; break;
@ -708,7 +708,7 @@ static void cbCreateProcess(CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo)
dprintf("TLS Callbacks: %d\n", NumberOfCallBacks); dprintf("TLS Callbacks: %d\n", NumberOfCallBacks);
Memory<uint*> TLSCallBacks(NumberOfCallBacks * sizeof(uint), "cbCreateProcess:TLSCallBacks"); Memory<uint*> TLSCallBacks(NumberOfCallBacks * sizeof(uint), "cbCreateProcess:TLSCallBacks");
if(!TLSGrabCallBackDataW(StringUtils::Utf8ToUtf16(DebugFileName).c_str(), TLSCallBacks, &NumberOfCallBacks)) if(!TLSGrabCallBackDataW(StringUtils::Utf8ToUtf16(DebugFileName).c_str(), TLSCallBacks, &NumberOfCallBacks))
dputs("failed to get TLS callback addresses!"); dputs("Failed to get TLS callback addresses!");
else else
{ {
for(unsigned int i = 0; i < NumberOfCallBacks; i++) for(unsigned int i = 0; i < NumberOfCallBacks; i++)
@ -821,9 +821,9 @@ static void cbSystemBreakpoint(void* ExceptionData)
hActiveThread = threadgethandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); hActiveThread = threadgethandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId);
//log message //log message
if(bIsAttached) if(bIsAttached)
dputs("attach breakpoint reached!"); dputs("Attach breakpoint reached!");
else else
dputs("system breakpoint reached!"); dputs("System breakpoint reached!");
bSkipExceptions = false; //we are not skipping first-chance exceptions bSkipExceptions = false; //we are not skipping first-chance exceptions
uint cip = GetContextDataEx(hActiveThread, UE_CIP); uint cip = GetContextDataEx(hActiveThread, UE_CIP);
GuiDumpAt(memfindbaseaddr(cip, 0, true)); //dump somewhere GuiDumpAt(memfindbaseaddr(cip, 0, true)); //dump somewhere
@ -1015,7 +1015,7 @@ static void cbException(EXCEPTION_DEBUG_INFO* ExceptionData)
if(!DetachDebuggerEx(fdProcessInfo->dwProcessId)) if(!DetachDebuggerEx(fdProcessInfo->dwProcessId))
dputs("DetachDebuggerEx failed..."); dputs("DetachDebuggerEx failed...");
else else
dputs("detached!"); dputs("Detached!");
isDetachedByUser = false; isDetachedByUser = false;
return; return;
} }
@ -1061,9 +1061,9 @@ static void cbException(EXCEPTION_DEBUG_INFO* ExceptionData)
if(ExceptionData->dwFirstChance) //first chance exception if(ExceptionData->dwFirstChance) //first chance exception
{ {
if(exceptionName) if(exceptionName)
dprintf("first chance exception on "fhex" (%.8X, %s)!\n", addr, ExceptionCode, exceptionName); dprintf("First chance exception on "fhex" (%.8X, %s)!\n", addr, ExceptionCode, exceptionName);
else else
dprintf("first chance exception on "fhex" (%.8X)!\n", addr, ExceptionCode); dprintf("First chance exception on "fhex" (%.8X)!\n", addr, ExceptionCode);
SetNextDbgContinueStatus(DBG_EXCEPTION_NOT_HANDLED); SetNextDbgContinueStatus(DBG_EXCEPTION_NOT_HANDLED);
if(bSkipExceptions || dbgisignoredexception(ExceptionCode)) if(bSkipExceptions || dbgisignoredexception(ExceptionCode))
return; return;
@ -1071,9 +1071,9 @@ static void cbException(EXCEPTION_DEBUG_INFO* ExceptionData)
else //lock the exception else //lock the exception
{ {
if(exceptionName) if(exceptionName)
dprintf("last chance exception on "fhex" (%.8X, %s)!\n", addr, ExceptionCode, exceptionName); dprintf("Last chance exception on "fhex" (%.8X, %s)!\n", addr, ExceptionCode, exceptionName);
else else
dprintf("last chance exception on "fhex" (%.8X)!\n", addr, ExceptionCode); dprintf("Last chance exception on "fhex" (%.8X)!\n", addr, ExceptionCode);
SetNextDbgContinueStatus(DBG_CONTINUE); SetNextDbgContinueStatus(DBG_CONTINUE);
} }
@ -1115,7 +1115,7 @@ DWORD WINAPI threadDebugLoop(void* lpParameter)
if(!fdProcessInfo) if(!fdProcessInfo)
{ {
fdProcessInfo = &g_pi; fdProcessInfo = &g_pi;
dputs("error starting process (invalid pe?)!"); dputs("Error starting process (invalid pe?)!");
unlock(WAITID_STOP); unlock(WAITID_STOP);
return 0; return 0;
} }
@ -1192,7 +1192,8 @@ bool cbDeleteAllBreakpoints(const BREAKPOINT* bp)
{ {
if(bpdel(bp->addr, BPNORMAL) and (!bp->enabled or DeleteBPX(bp->addr))) if(bpdel(bp->addr, BPNORMAL) and (!bp->enabled or DeleteBPX(bp->addr)))
return true; return true;
dprintf("delete breakpoint failed: "fhex"\n", bp->addr);
dprintf("Delete breakpoint failed: "fhex"\n", bp->addr);
return false; return false;
} }
@ -1200,9 +1201,10 @@ bool cbEnableAllBreakpoints(const BREAKPOINT* bp)
{ {
if(bp->type != BPNORMAL or bp->enabled) if(bp->type != BPNORMAL or bp->enabled)
return true; 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); dprintf("Could not enable breakpoint "fhex"\n", bp->addr);
return false; return false;
} }
return true; return true;
@ -1212,9 +1214,10 @@ bool cbDisableAllBreakpoints(const BREAKPOINT* bp)
{ {
if(bp->type != BPNORMAL or !bp->enabled) if(bp->type != BPNORMAL or !bp->enabled)
return true; 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); dprintf("Could not disable breakpoint "fhex"\n", bp->addr);
return false; return false;
} }
return true; return true;
@ -1227,7 +1230,7 @@ bool cbEnableAllHardwareBreakpoints(const BREAKPOINT* bp)
DWORD drx = 0; DWORD drx = 0;
if(!GetUnusedHardwareBreakPointRegister(&drx)) if(!GetUnusedHardwareBreakPointRegister(&drx))
{ {
dprintf("did not enable hardware breakpoint "fhex" (all slots full)\n", bp->addr); dprintf("Did not enable hardware breakpoint "fhex" (all slots full)\n", bp->addr);
return true; return true;
} }
int titantype = bp->titantype; int titantype = bp->titantype;
@ -1247,7 +1250,7 @@ bool cbDisableAllHardwareBreakpoints(const BREAKPOINT* bp)
return true; 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); dprintf("Could not disable hardware breakpoint "fhex"\n", bp->addr);
return false; return false;
} }
return true; return true;
@ -1261,7 +1264,7 @@ bool cbEnableAllMemoryBreakpoints(const BREAKPOINT* bp)
memfindbaseaddr(bp->addr, &size); 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); dprintf("Could not enable memory breakpoint "fhex"\n", bp->addr);
return false; return false;
} }
return true; return true;
@ -1273,7 +1276,7 @@ bool cbDisableAllMemoryBreakpoints(const BREAKPOINT* bp)
return true; 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); dprintf("Could not disable memory breakpoint "fhex"\n", bp->addr);
return false; return false;
} }
return true; return true;
@ -1309,7 +1312,7 @@ bool cbDeleteAllMemoryBreakpoints(const BREAKPOINT* bp)
memfindbaseaddr(bp->addr, &size); memfindbaseaddr(bp->addr, &size);
if(!bpdel(bp->addr, BPMEMORY) or !RemoveMemoryBPX(bp->addr, size)) if(!bpdel(bp->addr, BPMEMORY) or !RemoveMemoryBPX(bp->addr, size))
{ {
dprintf("delete memory breakpoint failed: "fhex"\n", bp->addr); dprintf("Delete memory breakpoint failed: "fhex"\n", bp->addr);
return STATUS_ERROR; return STATUS_ERROR;
} }
return true; return true;
@ -1321,7 +1324,7 @@ bool cbDeleteAllHardwareBreakpoints(const BREAKPOINT* bp)
return true; return true;
if(!bpdel(bp->addr, BPHARDWARE) or !DeleteHardwareBreakPoint(TITANGETDRX(bp->titantype))) if(!bpdel(bp->addr, BPHARDWARE) or !DeleteHardwareBreakPoint(TITANGETDRX(bp->titantype)))
{ {
dprintf("delete hardware breakpoint failed: "fhex"\n", bp->addr); dprintf("Delete hardware breakpoint failed: "fhex"\n", bp->addr);
return STATUS_ERROR; return STATUS_ERROR;
} }
return true; return true;
@ -1412,7 +1415,7 @@ void cbDetach()
if(!DetachDebuggerEx(fdProcessInfo->dwProcessId)) if(!DetachDebuggerEx(fdProcessInfo->dwProcessId))
dputs("DetachDebuggerEx failed..."); dputs("DetachDebuggerEx failed...");
else else
dputs("detached!"); dputs("Detached!");
return; return;
} }

View File

@ -29,18 +29,18 @@ CMDRESULT cbDebugInit(int argc, char* argv[])
char szResolvedPath[MAX_PATH] = ""; char szResolvedPath[MAX_PATH] = "";
if(ResolveShortcut(GuiGetWindowHandle(), StringUtils::Utf8ToUtf16(arg1).c_str(), szResolvedPath, _countof(szResolvedPath))) if(ResolveShortcut(GuiGetWindowHandle(), StringUtils::Utf8ToUtf16(arg1).c_str(), szResolvedPath, _countof(szResolvedPath)))
{ {
dprintf("resolved shortcut \"%s\"->\"%s\"\n", arg1, szResolvedPath); dprintf("Resolved shortcut \"%s\"->\"%s\"\n", arg1, szResolvedPath);
strcpy_s(arg1, szResolvedPath); strcpy_s(arg1, szResolvedPath);
} }
if(!FileExists(arg1)) if(!FileExists(arg1))
{ {
dputs("file does not exist!"); dputs("File does not exist!");
return STATUS_ERROR; return STATUS_ERROR;
} }
HANDLE hFile = CreateFileW(StringUtils::Utf8ToUtf16(arg1).c_str(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0); HANDLE hFile = CreateFileW(StringUtils::Utf8ToUtf16(arg1).c_str(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
if(hFile == INVALID_HANDLE_VALUE) if(hFile == INVALID_HANDLE_VALUE)
{ {
dputs("could not open file!"); dputs("Could not open file!");
return STATUS_ERROR; return STATUS_ERROR;
} }
GetFileNameFromHandle(hFile, arg1); //get full path of the file GetFileNameFromHandle(hFile, arg1); //get full path of the file
@ -50,14 +50,14 @@ CMDRESULT cbDebugInit(int argc, char* argv[])
switch(GetFileArchitecture(arg1)) switch(GetFileArchitecture(arg1))
{ {
case invalid: case invalid:
dputs("invalid PE file!"); dputs("Invalid PE file!");
return STATUS_ERROR; return STATUS_ERROR;
#ifdef _WIN64 #ifdef _WIN64
case x32: case x32:
dputs("use x32_dbg to debug this file!"); dputs("Use x32_dbg to debug this file!");
#else //x86 #else //x86
case x64: case x64:
dputs("use x64_dbg to debug this file!"); dputs("Use x64_dbg to debug this file!");
#endif //_WIN64 #endif //_WIN64
return STATUS_ERROR; return STATUS_ERROR;
default: default:
@ -109,7 +109,7 @@ CMDRESULT cbDebugRun(int argc, char* argv[])
{ {
if(!waitislocked(WAITID_RUN)) if(!waitislocked(WAITID_RUN))
{ {
dputs("program is already running"); dputs("Program is already running");
return STATUS_ERROR; return STATUS_ERROR;
} }
GuiSetDebugState(running); GuiSetDebugState(running);
@ -155,12 +155,12 @@ CMDRESULT cbDebugSetBPXOptions(int argc, char* argv[])
} }
else else
{ {
dputs("invalid type specified!"); dputs("Invalid type specified!");
return STATUS_ERROR; return STATUS_ERROR;
} }
SetBPXOptions(type); SetBPXOptions(type);
BridgeSettingSetUint("Engine", "BreakpointType", setting_type); BridgeSettingSetUint("Engine", "BreakpointType", setting_type);
dprintf("default breakpoint type set to: %s\n", a); dprintf("Default breakpoint type set to: %s\n", a);
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
@ -182,7 +182,7 @@ CMDRESULT cbDebugSetBPX(int argc, char* argv[]) //bp addr [,name [,type]]
uint addr = 0; uint addr = 0;
if(!valfromstring(argaddr, &addr)) if(!valfromstring(argaddr, &addr))
{ {
dprintf("invalid addr: \"%s\"\n", argaddr); dprintf("Invalid addr: \"%s\"\n", argaddr);
return STATUS_ERROR; return STATUS_ERROR;
} }
int type = 0; int type = 0;
@ -206,30 +206,30 @@ CMDRESULT cbDebugSetBPX(int argc, char* argv[]) //bp addr [,name [,type]]
bpname = argname; bpname = argname;
if(bpget(addr, BPNORMAL, bpname, 0)) if(bpget(addr, BPNORMAL, bpname, 0))
{ {
dputs("breakpoint already set!"); dputs("Breakpoint already set!");
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
if(IsBPXEnabled(addr)) if(IsBPXEnabled(addr))
{ {
dprintf("error setting breakpoint at "fhex"! (IsBPXEnabled)\n", addr); dprintf("Error setting breakpoint at "fhex"! (IsBPXEnabled)\n", addr);
return STATUS_ERROR; return STATUS_ERROR;
} }
else if(!memread(fdProcessInfo->hProcess, (void*)addr, &oldbytes, sizeof(short), 0)) else if(!memread(fdProcessInfo->hProcess, (void*)addr, &oldbytes, sizeof(short), 0))
{ {
dprintf("error setting breakpoint at "fhex"! (memread)\n", addr); dprintf("Error setting breakpoint at "fhex"! (memread)\n", addr);
return STATUS_ERROR; 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); dprintf("Error setting breakpoint at "fhex"! (bpnew)\n", addr);
return STATUS_ERROR; return STATUS_ERROR;
} }
else if(!SetBPX(addr, type, (void*)cbUserBreakpoint)) else if(!SetBPX(addr, type, (void*)cbUserBreakpoint))
{ {
dprintf("error setting breakpoint at "fhex"! (SetBPX)\n", addr); dprintf("Error setting breakpoint at "fhex"! (SetBPX)\n", addr);
return STATUS_ERROR; return STATUS_ERROR;
} }
dprintf("breakpoint at "fhex" set!\n", addr); dprintf("Breakpoint at "fhex" set!\n", addr);
GuiUpdateAllViews(); GuiUpdateAllViews();
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
@ -241,12 +241,12 @@ CMDRESULT cbDebugDeleteBPX(int argc, char* argv[])
{ {
if(!bpgetcount(BPNORMAL)) if(!bpgetcount(BPNORMAL))
{ {
dputs("no breakpoints to delete!"); dputs("No breakpoints to delete!");
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
if(!bpenumall(cbDeleteAllBreakpoints)) //at least one deletion failed if(!bpenumall(cbDeleteAllBreakpoints)) //at least one deletion failed
return STATUS_ERROR; return STATUS_ERROR;
dputs("all breakpoints deleted!"); dputs("All breakpoints deleted!");
GuiUpdateAllViews(); GuiUpdateAllViews();
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
@ -255,12 +255,12 @@ CMDRESULT cbDebugDeleteBPX(int argc, char* argv[])
{ {
if(!bpdel(found.addr, BPNORMAL)) if(!bpdel(found.addr, BPNORMAL))
{ {
dprintf("delete breakpoint failed (bpdel): "fhex"\n", found.addr); dprintf("Delete breakpoint failed (bpdel): "fhex"\n", found.addr);
return STATUS_ERROR; return STATUS_ERROR;
} }
else if(found.enabled && !DeleteBPX(found.addr)) else if(found.enabled && !DeleteBPX(found.addr))
{ {
dprintf("delete breakpoint failed (DeleteBPX): "fhex"\n", found.addr); dprintf("Delete breakpoint failed (DeleteBPX): "fhex"\n", found.addr);
GuiUpdateAllViews(); GuiUpdateAllViews();
return STATUS_ERROR; return STATUS_ERROR;
} }
@ -269,21 +269,21 @@ CMDRESULT cbDebugDeleteBPX(int argc, char* argv[])
uint addr = 0; 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); dprintf("No such breakpoint \"%s\"\n", arg1);
return STATUS_ERROR; return STATUS_ERROR;
} }
if(!bpdel(found.addr, BPNORMAL)) if(!bpdel(found.addr, BPNORMAL))
{ {
dprintf("delete breakpoint failed (bpdel): "fhex"\n", found.addr); dprintf("Delete breakpoint failed (bpdel): "fhex"\n", found.addr);
return STATUS_ERROR; return STATUS_ERROR;
} }
else if(found.enabled && !DeleteBPX(found.addr)) else if(found.enabled && !DeleteBPX(found.addr))
{ {
dprintf("delete breakpoint failed (DeleteBPX): "fhex"\n", found.addr); dprintf("Delete breakpoint failed (DeleteBPX): "fhex"\n", found.addr);
GuiUpdateAllViews(); GuiUpdateAllViews();
return STATUS_ERROR; return STATUS_ERROR;
} }
dputs("breakpoint deleted!"); dputs("Breakpoint deleted!");
GuiUpdateAllViews(); GuiUpdateAllViews();
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
@ -295,12 +295,12 @@ CMDRESULT cbDebugEnableBPX(int argc, char* argv[])
{ {
if(!bpgetcount(BPNORMAL)) if(!bpgetcount(BPNORMAL))
{ {
dputs("no breakpoints to enable!"); dputs("No breakpoints to enable!");
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
if(!bpenumall(cbEnableAllBreakpoints)) //at least one enable failed if(!bpenumall(cbEnableAllBreakpoints)) //at least one enable failed
return STATUS_ERROR; return STATUS_ERROR;
dputs("all breakpoints enabled!"); dputs("All breakpoints enabled!");
GuiUpdateAllViews(); GuiUpdateAllViews();
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
@ -309,7 +309,7 @@ CMDRESULT cbDebugEnableBPX(int argc, char* argv[])
{ {
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); dprintf("Could not enable breakpoint "fhex"\n", found.addr);
return STATUS_ERROR; return STATUS_ERROR;
} }
GuiUpdateAllViews(); GuiUpdateAllViews();
@ -318,21 +318,21 @@ CMDRESULT cbDebugEnableBPX(int argc, char* argv[])
uint addr = 0; 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); dprintf("No such breakpoint \"%s\"\n", arg1);
return STATUS_ERROR; return STATUS_ERROR;
} }
if(found.enabled) if(found.enabled)
{ {
dputs("breakpoint already enabled!"); dputs("Breakpoint already enabled!");
GuiUpdateAllViews(); GuiUpdateAllViews();
return STATUS_CONTINUE; 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); dprintf("Could not enable breakpoint "fhex"\n", found.addr);
return STATUS_ERROR; return STATUS_ERROR;
} }
dputs("breakpoint enabled!"); dputs("Breakpoint enabled!");
GuiUpdateAllViews(); GuiUpdateAllViews();
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
@ -344,12 +344,12 @@ CMDRESULT cbDebugDisableBPX(int argc, char* argv[])
{ {
if(!bpgetcount(BPNORMAL)) if(!bpgetcount(BPNORMAL))
{ {
dputs("no breakpoints to disable!"); dputs("No breakpoints to disable!");
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
if(!bpenumall(cbDisableAllBreakpoints)) //at least one deletion failed if(!bpenumall(cbDisableAllBreakpoints)) //at least one deletion failed
return STATUS_ERROR; return STATUS_ERROR;
dputs("all breakpoints disabled!"); dputs("All breakpoints disabled!");
GuiUpdateAllViews(); GuiUpdateAllViews();
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
@ -358,7 +358,7 @@ CMDRESULT cbDebugDisableBPX(int argc, char* argv[])
{ {
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); dprintf("Could not disable breakpoint "fhex"\n", found.addr);
return STATUS_ERROR; return STATUS_ERROR;
} }
GuiUpdateAllViews(); GuiUpdateAllViews();
@ -367,20 +367,20 @@ CMDRESULT cbDebugDisableBPX(int argc, char* argv[])
uint addr = 0; 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); dprintf("No such breakpoint \"%s\"\n", arg1);
return STATUS_ERROR; return STATUS_ERROR;
} }
if(!found.enabled) if(!found.enabled)
{ {
dputs("breakpoint already disabled!"); dputs("Breakpoint already disabled!");
return STATUS_CONTINUE; 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); dprintf("Could not disable breakpoint "fhex"\n", found.addr);
return STATUS_ERROR; return STATUS_ERROR;
} }
dputs("breakpoint disabled!"); dputs("Breakpoint disabled!");
GuiUpdateAllViews(); GuiUpdateAllViews();
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
@ -440,9 +440,9 @@ CMDRESULT cbDebugeSingleStep(int argc, char* argv[])
CMDRESULT cbDebugHide(int argc, char* argv[]) CMDRESULT cbDebugHide(int argc, char* argv[])
{ {
if(HideDebugger(fdProcessInfo->hProcess, UE_HIDE_PEBONLY)) if(HideDebugger(fdProcessInfo->hProcess, UE_HIDE_PEBONLY))
dputs("debugger hidden"); dputs("Debugger hidden");
else else
dputs("something went wrong"); dputs("Something went wrong");
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
@ -495,7 +495,7 @@ CMDRESULT cbDebugSetMemoryBpx(int argc, char* argv[])
type = UE_MEMORY_EXECUTE; //EXECUTE type = UE_MEMORY_EXECUTE; //EXECUTE
break; break;
default: default:
dputs("invalid type (argument ignored)"); dputs("Invalid type (argument ignored)");
break; break;
} }
} }
@ -506,15 +506,15 @@ CMDRESULT cbDebugSetMemoryBpx(int argc, char* argv[])
singleshoot = true; singleshoot = true;
if(bpget(base, BPMEMORY, 0, 0)) if(bpget(base, BPMEMORY, 0, 0))
{ {
dputs("hardware breakpoint already set!"); dputs("Hardware breakpoint already set!");
return STATUS_CONTINUE; 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!"); dputs("Error setting memory breakpoint!");
return STATUS_ERROR; return STATUS_ERROR;
} }
dprintf("memory breakpoint at "fhex" set!\n", addr); dprintf("Memory breakpoint at "fhex" set!\n", addr);
GuiUpdateAllViews(); GuiUpdateAllViews();
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
@ -531,7 +531,7 @@ CMDRESULT cbDebugDeleteMemoryBreakpoint(int argc, char* argv[])
} }
if(!bpenumall(cbDeleteAllMemoryBreakpoints)) //at least one deletion failed if(!bpenumall(cbDeleteAllMemoryBreakpoints)) //at least one deletion failed
return STATUS_ERROR; return STATUS_ERROR;
dputs("all memory breakpoints deleted!"); dputs("All memory breakpoints deleted!");
GuiUpdateAllViews(); GuiUpdateAllViews();
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
@ -542,7 +542,7 @@ CMDRESULT cbDebugDeleteMemoryBreakpoint(int argc, char* argv[])
memfindbaseaddr(found.addr, &size); memfindbaseaddr(found.addr, &size);
if(!bpdel(found.addr, BPMEMORY) or !RemoveMemoryBPX(found.addr, size)) if(!bpdel(found.addr, BPMEMORY) or !RemoveMemoryBPX(found.addr, size))
{ {
dprintf("delete memory breakpoint failed: "fhex"\n", found.addr); dprintf("Delete memory breakpoint failed: "fhex"\n", found.addr);
return STATUS_ERROR; return STATUS_ERROR;
} }
return STATUS_CONTINUE; return STATUS_CONTINUE;
@ -550,17 +550,17 @@ CMDRESULT cbDebugDeleteMemoryBreakpoint(int argc, char* argv[])
uint addr = 0; 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); dprintf("No such memory breakpoint \"%s\"\n", arg1);
return STATUS_ERROR; return STATUS_ERROR;
} }
uint size; uint size;
memfindbaseaddr(found.addr, &size); memfindbaseaddr(found.addr, &size);
if(!bpdel(found.addr, BPMEMORY) or !RemoveMemoryBPX(found.addr, size)) if(!bpdel(found.addr, BPMEMORY) or !RemoveMemoryBPX(found.addr, size))
{ {
dprintf("delete memory breakpoint failed: "fhex"\n", found.addr); dprintf("Delete memory breakpoint failed: "fhex"\n", found.addr);
return STATUS_ERROR; return STATUS_ERROR;
} }
dputs("memory breakpoint deleted!"); dputs("Memory breakpoint deleted!");
GuiUpdateAllViews(); GuiUpdateAllViews();
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
@ -625,19 +625,19 @@ CMDRESULT cbDebugSetHardwareBreakpoint(int argc, char* argv[])
break; break;
#endif // _WIN64 #endif // _WIN64
default: default:
dputs("invalid size, using 1"); dputs("Invalid size, using 1");
break; break;
} }
if((addr % size) != 0) if((addr % size) != 0)
{ {
dprintf("address not aligned to %d\n", size); dprintf("Address not aligned to %d\n", size);
return STATUS_ERROR; return STATUS_ERROR;
} }
} }
DWORD drx = 0; DWORD drx = 0;
if(!GetUnusedHardwareBreakPointRegister(&drx)) if(!GetUnusedHardwareBreakPointRegister(&drx))
{ {
dputs("you can only set 4 hardware breakpoints"); dputs("You can only set 4 hardware breakpoints");
return STATUS_ERROR; return STATUS_ERROR;
} }
int titantype = 0; int titantype = 0;
@ -647,15 +647,15 @@ CMDRESULT cbDebugSetHardwareBreakpoint(int argc, char* argv[])
//TODO: hwbp in multiple threads TEST //TODO: hwbp in multiple threads TEST
if(bpget(addr, BPHARDWARE, 0, 0)) if(bpget(addr, BPHARDWARE, 0, 0))
{ {
dputs("hardware breakpoint already set!"); dputs("Hardware breakpoint already set!");
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
if(!bpnew(addr, true, false, 0, BPHARDWARE, titantype, 0) or !SetHardwareBreakPoint(addr, drx, type, (DWORD)size, (void*)cbHardwareBreakpoint)) if(!bpnew(addr, true, false, 0, BPHARDWARE, titantype, 0) or !SetHardwareBreakPoint(addr, drx, type, (DWORD)size, (void*)cbHardwareBreakpoint))
{ {
dputs("error setting hardware breakpoint!"); dputs("Error setting hardware breakpoint!");
return STATUS_ERROR; return STATUS_ERROR;
} }
dprintf("hardware breakpoint at "fhex" set!\n", addr); dprintf("Hardware breakpoint at "fhex" set!\n", addr);
GuiUpdateAllViews(); GuiUpdateAllViews();
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
@ -667,12 +667,12 @@ CMDRESULT cbDebugDeleteHardwareBreakpoint(int argc, char* argv[])
{ {
if(!bpgetcount(BPHARDWARE)) if(!bpgetcount(BPHARDWARE))
{ {
dputs("no hardware breakpoints to delete!"); dputs("No hardware breakpoints to delete!");
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
if(!bpenumall(cbDeleteAllHardwareBreakpoints)) //at least one deletion failed if(!bpenumall(cbDeleteAllHardwareBreakpoints)) //at least one deletion failed
return STATUS_ERROR; return STATUS_ERROR;
dputs("all hardware breakpoints deleted!"); dputs("All hardware breakpoints deleted!");
GuiUpdateAllViews(); GuiUpdateAllViews();
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
@ -681,7 +681,7 @@ CMDRESULT cbDebugDeleteHardwareBreakpoint(int argc, char* argv[])
{ {
if(!bpdel(found.addr, BPHARDWARE) or !DeleteHardwareBreakPoint(TITANGETDRX(found.titantype))) if(!bpdel(found.addr, BPHARDWARE) or !DeleteHardwareBreakPoint(TITANGETDRX(found.titantype)))
{ {
dprintf("delete hardware breakpoint failed: "fhex"\n", found.addr); dprintf("Delete hardware breakpoint failed: "fhex"\n", found.addr);
return STATUS_ERROR; return STATUS_ERROR;
} }
return STATUS_CONTINUE; return STATUS_CONTINUE;
@ -689,15 +689,15 @@ CMDRESULT cbDebugDeleteHardwareBreakpoint(int argc, char* argv[])
uint addr = 0; 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); dprintf("No such hardware breakpoint \"%s\"\n", arg1);
return STATUS_ERROR; return STATUS_ERROR;
} }
if(!bpdel(found.addr, BPHARDWARE) or !DeleteHardwareBreakPoint(TITANGETDRX(found.titantype))) if(!bpdel(found.addr, BPHARDWARE) or !DeleteHardwareBreakPoint(TITANGETDRX(found.titantype)))
{ {
dprintf("delete hardware breakpoint failed: "fhex"\n", found.addr); dprintf("Delete hardware breakpoint failed: "fhex"\n", found.addr);
return STATUS_ERROR; return STATUS_ERROR;
} }
dputs("hardware breakpoint deleted!"); dputs("Hardware breakpoint deleted!");
GuiUpdateAllViews(); GuiUpdateAllViews();
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
@ -736,7 +736,7 @@ CMDRESULT cbDebugFree(int argc, char* argv[])
} }
else if(!lastalloc) else if(!lastalloc)
{ {
dputs("lastalloc is zero, provide a page address"); dputs("$lastalloc is zero, provide a page address");
return STATUS_ERROR; return STATUS_ERROR;
} }
if(addr == lastalloc) if(addr == lastalloc)
@ -759,7 +759,7 @@ CMDRESULT cbDebugMemset(int argc, char* argv[])
uint size; uint size;
if(argc < 3) if(argc < 3)
{ {
dputs("not enough arguments"); dputs("Not enough arguments");
return STATUS_ERROR; return STATUS_ERROR;
} }
if(!valfromstring(argv[1], &addr, false) or !valfromstring(argv[2], &value, false)) if(!valfromstring(argv[1], &addr, false) or !valfromstring(argv[2], &value, false))
@ -783,9 +783,9 @@ CMDRESULT cbDebugMemset(int argc, char* argv[])
} }
BYTE fi = value & 0xFF; BYTE fi = value & 0xFF;
if(!Fill((void*)addr, size & 0xFFFFFFFF, &fi)) if(!Fill((void*)addr, size & 0xFFFFFFFF, &fi))
dputs("memset failed"); dputs("Memset failed");
else else
dprintf("memory "fhex" (size: %.8X) set to %.2X\n", addr, size & 0xFFFFFFFF, value & 0xFF); dprintf("Memory "fhex" (size: %.8X) set to %.2X\n", addr, size & 0xFFFFFFFF, value & 0xFF);
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
@ -809,7 +809,7 @@ CMDRESULT cbDebugPause(int argc, char* argv[])
{ {
if(waitislocked(WAITID_RUN)) if(waitislocked(WAITID_RUN))
{ {
dputs("program is not running"); dputs("Program is not running");
return STATUS_ERROR; return STATUS_ERROR;
} }
dbgsetispausedbyuser(true); dbgsetispausedbyuser(true);
@ -824,7 +824,7 @@ static DWORD WINAPI scyllaThread(void* lpParam)
HINSTANCE hScylla = LoadLibraryW(L"Scylla.dll"); HINSTANCE hScylla = LoadLibraryW(L"Scylla.dll");
if(!hScylla) if(!hScylla)
{ {
dputs("error loading Scylla.dll!"); dputs("Error loading Scylla.dll!");
bScyllaLoaded = false; bScyllaLoaded = false;
FreeLibrary(hScylla); FreeLibrary(hScylla);
return 0; return 0;
@ -832,7 +832,7 @@ static DWORD WINAPI scyllaThread(void* lpParam)
ScyllaStartGui = (SCYLLASTARTGUI)GetProcAddress(hScylla, "ScyllaStartGui"); ScyllaStartGui = (SCYLLASTARTGUI)GetProcAddress(hScylla, "ScyllaStartGui");
if(!ScyllaStartGui) if(!ScyllaStartGui)
{ {
dputs("could not find export 'ScyllaStartGui' inside Scylla.dll"); dputs("Could not find export 'ScyllaStartGui' inside Scylla.dll");
bScyllaLoaded = false; bScyllaLoaded = false;
FreeLibrary(hScylla); FreeLibrary(hScylla);
return 0; return 0;
@ -862,7 +862,7 @@ CMDRESULT cbDebugAttach(int argc, char* argv[])
{ {
if(argc < 2) if(argc < 2)
{ {
dputs("not enough arguments!"); dputs("Not enough arguments!");
return STATUS_ERROR; return STATUS_ERROR;
} }
uint pid = 0; uint pid = 0;
@ -880,7 +880,7 @@ CMDRESULT cbDebugAttach(int argc, char* argv[])
Handle hProcess = TitanOpenProcess(PROCESS_ALL_ACCESS, false, (DWORD)pid); Handle hProcess = TitanOpenProcess(PROCESS_ALL_ACCESS, false, (DWORD)pid);
if(!hProcess) if(!hProcess)
{ {
dprintf("could not open process %X!\n", pid); dprintf("Could not open process %X!\n", pid);
return STATUS_ERROR; return STATUS_ERROR;
} }
BOOL wow64 = false, mewow64 = false; BOOL wow64 = false, mewow64 = false;
@ -901,7 +901,7 @@ CMDRESULT cbDebugAttach(int argc, char* argv[])
wchar_t wszFileName[MAX_PATH] = L""; wchar_t wszFileName[MAX_PATH] = L"";
if(!GetModuleFileNameExW(hProcess, 0, wszFileName, MAX_PATH)) if(!GetModuleFileNameExW(hProcess, 0, wszFileName, MAX_PATH))
{ {
dprintf("could not get module filename %X!\n", pid); dprintf("Could not get module filename %X!\n", pid);
return STATUS_ERROR; return STATUS_ERROR;
} }
strcpy_s(szFileName, StringUtils::Utf16ToUtf8(wszFileName).c_str()); strcpy_s(szFileName, StringUtils::Utf16ToUtf8(wszFileName).c_str());
@ -928,7 +928,7 @@ CMDRESULT cbDebugDump(int argc, char* argv[])
duint addr = 0; duint addr = 0;
if(!valfromstring(argv[1], &addr)) if(!valfromstring(argv[1], &addr))
{ {
dprintf("invalid address \"%s\"!\n", argv[1]); dprintf("Invalid address \"%s\"!\n", argv[1]);
return STATUS_ERROR; return STATUS_ERROR;
} }
GuiDumpAt(addr); GuiDumpAt(addr);
@ -942,7 +942,7 @@ CMDRESULT cbDebugStackDump(int argc, char* argv[])
addr = GetContextDataEx(hActiveThread, UE_CSP); addr = GetContextDataEx(hActiveThread, UE_CSP);
else if(!valfromstring(argv[1], &addr)) else if(!valfromstring(argv[1], &addr))
{ {
dprintf("invalid address \"%s\"!\n", argv[1]); dprintf("Invalid address \"%s\"!\n", argv[1]);
return STATUS_ERROR; return STATUS_ERROR;
} }
duint csp = GetContextDataEx(hActiveThread, UE_CSP); duint csp = GetContextDataEx(hActiveThread, UE_CSP);
@ -951,7 +951,7 @@ CMDRESULT cbDebugStackDump(int argc, char* argv[])
if(base && addr >= base && addr < (base + size)) if(base && addr >= base && addr < (base + size))
GuiStackDumpAt(addr, csp); GuiStackDumpAt(addr, csp);
else else
dputs("invalid stack address!"); dputs("Invalid stack address!");
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
@ -960,12 +960,12 @@ CMDRESULT cbDebugContinue(int argc, char* argv[])
if(argc < 2) if(argc < 2)
{ {
SetNextDbgContinueStatus(DBG_CONTINUE); SetNextDbgContinueStatus(DBG_CONTINUE);
dputs("exception will be swallowed"); dputs("Exception will be swallowed");
} }
else else
{ {
SetNextDbgContinueStatus(DBG_EXCEPTION_NOT_HANDLED); SetNextDbgContinueStatus(DBG_EXCEPTION_NOT_HANDLED);
dputs("exception will be thrown in the program"); dputs("Exception will be thrown in the program");
} }
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
@ -994,7 +994,7 @@ CMDRESULT cbDebugBpDll(int argc, char* argv[])
if(argc > 3) if(argc > 3)
singleshoot = false; singleshoot = false;
LibrarianSetBreakPoint(argv[1], type, singleshoot, (void*)cbLibrarianBreakpoint); LibrarianSetBreakPoint(argv[1], type, singleshoot, (void*)cbLibrarianBreakpoint);
dprintf("dll breakpoint set on \"%s\"!\n", argv[1]); dprintf("Dll breakpoint set on \"%s\"!\n", argv[1]);
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
@ -1002,15 +1002,15 @@ CMDRESULT cbDebugBcDll(int argc, char* argv[])
{ {
if(argc < 2) if(argc < 2)
{ {
dputs("not enough arguments"); dputs("Not enough arguments");
return STATUS_ERROR; return STATUS_ERROR;
} }
if(!LibrarianRemoveBreakPoint(argv[1], UE_ON_LIB_ALL)) if(!LibrarianRemoveBreakPoint(argv[1], UE_ON_LIB_ALL))
{ {
dputs("failed to remove dll breakpoint..."); dputs("Failed to remove DLL breakpoint...");
return STATUS_ERROR; return STATUS_ERROR;
} }
dputs("dll breakpoint removed!"); dputs("DLL breakpoint removed!");
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
@ -1022,13 +1022,13 @@ CMDRESULT cbDebugSwitchthread(int argc, char* argv[])
return STATUS_ERROR; return STATUS_ERROR;
if(!threadisvalid((DWORD)threadid)) //check if the thread is valid if(!threadisvalid((DWORD)threadid)) //check if the thread is valid
{ {
dprintf("invalid thread %X\n", threadid); dprintf("Invalid thread %X\n", threadid);
return STATUS_ERROR; return STATUS_ERROR;
} }
//switch thread //switch thread
hActiveThread = threadgethandle((DWORD)threadid); hActiveThread = threadgethandle((DWORD)threadid);
DebugUpdateGui(GetContextDataEx(hActiveThread, UE_CIP), true); DebugUpdateGui(GetContextDataEx(hActiveThread, UE_CIP), true);
dputs("thread switched!"); dputs("Thread switched!");
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
@ -1040,16 +1040,16 @@ CMDRESULT cbDebugSuspendthread(int argc, char* argv[])
return STATUS_ERROR; return STATUS_ERROR;
if(!threadisvalid((DWORD)threadid)) //check if the thread is valid if(!threadisvalid((DWORD)threadid)) //check if the thread is valid
{ {
dprintf("invalid thread %X\n", threadid); dprintf("Invalid thread %X\n", threadid);
return STATUS_ERROR; return STATUS_ERROR;
} }
//suspend thread //suspend thread
if(SuspendThread(threadgethandle((DWORD)threadid)) == -1) if(SuspendThread(threadgethandle((DWORD)threadid)) == -1)
{ {
dputs("error suspending thread"); dputs("Error suspending thread");
return STATUS_ERROR; return STATUS_ERROR;
} }
dputs("thread suspended"); dputs("Thread suspended");
GuiUpdateAllViews(); GuiUpdateAllViews();
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
@ -1062,16 +1062,16 @@ CMDRESULT cbDebugResumethread(int argc, char* argv[])
return STATUS_ERROR; return STATUS_ERROR;
if(!threadisvalid((DWORD)threadid)) //check if the thread is valid if(!threadisvalid((DWORD)threadid)) //check if the thread is valid
{ {
dprintf("invalid thread %X\n", threadid); dprintf("Invalid thread %X\n", threadid);
return STATUS_ERROR; return STATUS_ERROR;
} }
//resume thread //resume thread
if(ResumeThread(threadgethandle((DWORD)threadid)) == -1) if(ResumeThread(threadgethandle((DWORD)threadid)) == -1)
{ {
dputs("error resuming thread"); dputs("Error resuming thread");
return STATUS_ERROR; return STATUS_ERROR;
} }
dputs("thread resumed!"); dputs("Thread resumed!");
GuiUpdateAllViews(); GuiUpdateAllViews();
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
@ -1088,17 +1088,17 @@ CMDRESULT cbDebugKillthread(int argc, char* argv[])
return STATUS_ERROR; return STATUS_ERROR;
if(!threadisvalid((DWORD)threadid)) //check if the thread is valid if(!threadisvalid((DWORD)threadid)) //check if the thread is valid
{ {
dprintf("invalid thread %X\n", threadid); dprintf("Invalid thread %X\n", threadid);
return STATUS_ERROR; return STATUS_ERROR;
} }
//terminate thread //terminate thread
if(TerminateThread(threadgethandle((DWORD)threadid), (DWORD)exitcode) != 0) if(TerminateThread(threadgethandle((DWORD)threadid), (DWORD)exitcode) != 0)
{ {
GuiUpdateAllViews(); GuiUpdateAllViews();
dputs("thread terminated"); dputs("Thread terminated");
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
dputs("error terminating thread!"); dputs("Error terminating thread!");
return STATUS_ERROR; return STATUS_ERROR;
} }
@ -1124,7 +1124,7 @@ CMDRESULT cbDebugSetPriority(int argc, char* argv[])
{ {
if(argc < 3) if(argc < 3)
{ {
dputs("not enough arguments!"); dputs("Not enough arguments!");
return STATUS_ERROR; return STATUS_ERROR;
} }
uint threadid; uint threadid;
@ -1149,7 +1149,7 @@ CMDRESULT cbDebugSetPriority(int argc, char* argv[])
priority = THREAD_PRIORITY_LOWEST; priority = THREAD_PRIORITY_LOWEST;
else else
{ {
dputs("unknown priority value, read the help!"); dputs("Unknown priority value, read the help!");
return STATUS_ERROR; return STATUS_ERROR;
} }
} }
@ -1166,22 +1166,22 @@ CMDRESULT cbDebugSetPriority(int argc, char* argv[])
case THREAD_PRIORITY_LOWEST: case THREAD_PRIORITY_LOWEST:
break; break;
default: default:
dputs("unknown priority value, read the help!"); dputs("Unknown priority value, read the help!");
return STATUS_ERROR; return STATUS_ERROR;
} }
} }
if(!threadisvalid((DWORD)threadid)) //check if the thread is valid if(!threadisvalid((DWORD)threadid)) //check if the thread is valid
{ {
dprintf("invalid thread %X\n", threadid); dprintf("Invalid thread %X\n", threadid);
return STATUS_ERROR; return STATUS_ERROR;
} }
//set thread priority //set thread priority
if(SetThreadPriority(threadgethandle((DWORD)threadid), (int)priority) == 0) if(SetThreadPriority(threadgethandle((DWORD)threadid), (int)priority) == 0)
{ {
dputs("error setting thread priority"); dputs("Error setting thread priority");
return STATUS_ERROR; return STATUS_ERROR;
} }
dputs("thread priority changed!"); dputs("Thread priority changed!");
GuiUpdateAllViews(); GuiUpdateAllViews();
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
@ -1192,19 +1192,19 @@ CMDRESULT cbDebugEnableHardwareBreakpoint(int argc, char* argv[])
DWORD drx = 0; DWORD drx = 0;
if(!GetUnusedHardwareBreakPointRegister(&drx)) if(!GetUnusedHardwareBreakPointRegister(&drx))
{ {
dputs("you can only set 4 hardware breakpoints"); dputs("You can only set 4 hardware breakpoints");
return STATUS_ERROR; return STATUS_ERROR;
} }
if(!argget(*argv, arg1, 0, true)) //enable all hardware breakpoints if(!argget(*argv, arg1, 0, true)) //enable all hardware breakpoints
{ {
if(!bpgetcount(BPHARDWARE)) if(!bpgetcount(BPHARDWARE))
{ {
dputs("no hardware breakpoints to enable!"); dputs("No hardware breakpoints to enable!");
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
if(!bpenumall(cbEnableAllHardwareBreakpoints)) //at least one enable failed if(!bpenumall(cbEnableAllHardwareBreakpoints)) //at least one enable failed
return STATUS_ERROR; return STATUS_ERROR;
dputs("all hardware breakpoints enabled!"); dputs("All hardware breakpoints enabled!");
GuiUpdateAllViews(); GuiUpdateAllViews();
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
@ -1212,12 +1212,12 @@ CMDRESULT cbDebugEnableHardwareBreakpoint(int argc, char* argv[])
uint addr = 0; 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); dprintf("No such hardware breakpoint \"%s\"\n", arg1);
return STATUS_ERROR; return STATUS_ERROR;
} }
if(found.enabled) if(found.enabled)
{ {
dputs("hardware breakpoint already enabled!"); dputs("Hardware breakpoint already enabled!");
GuiUpdateAllViews(); GuiUpdateAllViews();
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
@ -1225,10 +1225,10 @@ CMDRESULT cbDebugEnableHardwareBreakpoint(int argc, char* argv[])
bpsettitantype(found.addr, BPHARDWARE, found.titantype); 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)) 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); dprintf("Could not enable hardware breakpoint "fhex"\n", found.addr);
return STATUS_ERROR; return STATUS_ERROR;
} }
dputs("hardware breakpoint enabled!"); dputs("Hardware breakpoint enabled!");
GuiUpdateAllViews(); GuiUpdateAllViews();
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
@ -1240,12 +1240,12 @@ CMDRESULT cbDebugDisableHardwareBreakpoint(int argc, char* argv[])
{ {
if(!bpgetcount(BPHARDWARE)) if(!bpgetcount(BPHARDWARE))
{ {
dputs("no hardware breakpoints to disable!"); dputs("No hardware breakpoints to disable!");
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
if(!bpenumall(cbDisableAllHardwareBreakpoints)) //at least one deletion failed if(!bpenumall(cbDisableAllHardwareBreakpoints)) //at least one deletion failed
return STATUS_ERROR; return STATUS_ERROR;
dputs("all hardware breakpoints disabled!"); dputs("All hardware breakpoints disabled!");
GuiUpdateAllViews(); GuiUpdateAllViews();
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
@ -1253,20 +1253,20 @@ CMDRESULT cbDebugDisableHardwareBreakpoint(int argc, char* argv[])
uint addr = 0; 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); dprintf("No such hardware breakpoint \"%s\"\n", arg1);
return STATUS_ERROR; return STATUS_ERROR;
} }
if(!found.enabled) if(!found.enabled)
{ {
dputs("hardware breakpoint already disabled!"); dputs("Hardware breakpoint already disabled!");
return STATUS_CONTINUE; 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); dprintf("Could not disable hardware breakpoint "fhex"\n", found.addr);
return STATUS_ERROR; return STATUS_ERROR;
} }
dputs("hardware breakpoint disabled!"); dputs("Hardware breakpoint disabled!");
GuiUpdateAllViews(); GuiUpdateAllViews();
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
@ -1277,19 +1277,19 @@ CMDRESULT cbDebugEnableMemoryBreakpoint(int argc, char* argv[])
DWORD drx = 0; DWORD drx = 0;
if(!GetUnusedHardwareBreakPointRegister(0)) if(!GetUnusedHardwareBreakPointRegister(0))
{ {
dputs("you can only set 4 hardware breakpoints"); dputs("You can only set 4 hardware breakpoints");
return STATUS_ERROR; return STATUS_ERROR;
} }
if(!argget(*argv, arg1, 0, true)) //enable all memory breakpoints if(!argget(*argv, arg1, 0, true)) //enable all memory breakpoints
{ {
if(!bpgetcount(BPMEMORY)) if(!bpgetcount(BPMEMORY))
{ {
dputs("no hardware breakpoints to enable!"); dputs("No hardware breakpoints to enable!");
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
if(!bpenumall(cbEnableAllHardwareBreakpoints)) //at least one enable failed if(!bpenumall(cbEnableAllHardwareBreakpoints)) //at least one enable failed
return STATUS_ERROR; return STATUS_ERROR;
dputs("all memory breakpoints enabled!"); dputs("All memory breakpoints enabled!");
GuiUpdateAllViews(); GuiUpdateAllViews();
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
@ -1297,12 +1297,12 @@ CMDRESULT cbDebugEnableMemoryBreakpoint(int argc, char* argv[])
uint addr = 0; 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); dprintf("No such memory breakpoint \"%s\"\n", arg1);
return STATUS_ERROR; return STATUS_ERROR;
} }
if(found.enabled) if(found.enabled)
{ {
dputs("hardware memory already enabled!"); dputs("Hardware memory already enabled!");
GuiUpdateAllViews(); GuiUpdateAllViews();
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
@ -1310,10 +1310,10 @@ CMDRESULT cbDebugEnableMemoryBreakpoint(int argc, char* argv[])
memfindbaseaddr(found.addr, &size); 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); dprintf("Could not enable memory breakpoint "fhex"\n", found.addr);
return STATUS_ERROR; return STATUS_ERROR;
} }
dputs("memory breakpoint enabled!"); dputs("Memory breakpoint enabled!");
GuiUpdateAllViews(); GuiUpdateAllViews();
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
@ -1325,12 +1325,12 @@ CMDRESULT cbDebugDisableMemoryBreakpoint(int argc, char* argv[])
{ {
if(!bpgetcount(BPMEMORY)) if(!bpgetcount(BPMEMORY))
{ {
dputs("no memory breakpoints to disable!"); dputs("No memory breakpoints to disable!");
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
if(!bpenumall(cbDisableAllMemoryBreakpoints)) //at least one deletion failed if(!bpenumall(cbDisableAllMemoryBreakpoints)) //at least one deletion failed
return STATUS_ERROR; return STATUS_ERROR;
dputs("all memory breakpoints disabled!"); dputs("All memory breakpoints disabled!");
GuiUpdateAllViews(); GuiUpdateAllViews();
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
@ -1338,22 +1338,22 @@ CMDRESULT cbDebugDisableMemoryBreakpoint(int argc, char* argv[])
uint addr = 0; 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); dprintf("No such memory breakpoint \"%s\"\n", arg1);
return STATUS_ERROR; return STATUS_ERROR;
} }
if(!found.enabled) if(!found.enabled)
{ {
dputs("memory breakpoint already disabled!"); dputs("Memory breakpoint already disabled!");
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
uint size = 0; uint size = 0;
memfindbaseaddr(found.addr, &size); 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); dprintf("Could not disable memory breakpoint "fhex"\n", found.addr);
return STATUS_ERROR; return STATUS_ERROR;
} }
dputs("memory breakpoint disabled!"); dputs("Memory breakpoint disabled!");
GuiUpdateAllViews(); GuiUpdateAllViews();
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
@ -1371,14 +1371,14 @@ CMDRESULT cbDebugDownloadSymbol(int argc, char* argv[])
{ {
symdownloadallsymbols(szSymbolStore); //download symbols for all modules symdownloadallsymbols(szSymbolStore); //download symbols for all modules
GuiSymbolRefreshCurrent(); GuiSymbolRefreshCurrent();
dputs("done! See symbol log for more information"); dputs("Done! See symbol log for more information");
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
//get some module information //get some module information
uint modbase = modbasefromname(argv[1]); uint modbase = modbasefromname(argv[1]);
if(!modbase) if(!modbase)
{ {
dprintf("invalid module \"%s\"!\n", argv[1]); dprintf("Invalid module \"%s\"!\n", argv[1]);
return STATUS_ERROR; return STATUS_ERROR;
} }
wchar_t wszModulePath[MAX_PATH] = L""; wchar_t wszModulePath[MAX_PATH] = L"";
@ -1422,7 +1422,7 @@ CMDRESULT cbDebugDownloadSymbol(int argc, char* argv[])
return STATUS_ERROR; return STATUS_ERROR;
} }
GuiSymbolRefreshCurrent(); GuiSymbolRefreshCurrent();
dputs("done! See symbol log for more information"); dputs("Done! See symbol log for more information");
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
@ -1549,7 +1549,6 @@ CMDRESULT cbDebugSetJITAuto(int argc, char* argv[])
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
CMDRESULT cbDebugSetJIT(int argc, char* argv[]) CMDRESULT cbDebugSetJIT(int argc, char* argv[])
{ {
arch actual_arch = invalid; arch actual_arch = invalid;