IsFileBeingDebugged problem
This commit is contained in:
parent
b4ffffdbe9
commit
22e78f5a8d
|
@ -80,7 +80,9 @@ extern "C" DLL_EXPORT bool _dbg_valfromstring(const char* string, duint* value)
|
||||||
|
|
||||||
extern "C" DLL_EXPORT bool _dbg_isdebugging()
|
extern "C" DLL_EXPORT bool _dbg_isdebugging()
|
||||||
{
|
{
|
||||||
return IsFileBeingDebugged();
|
if(IsFileBeingDebugged())
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" DLL_EXPORT bool _dbg_isjumpgoingtoexecute(duint addr)
|
extern "C" DLL_EXPORT bool _dbg_isjumpgoingtoexecute(duint addr)
|
||||||
|
@ -99,7 +101,7 @@ extern "C" DLL_EXPORT bool _dbg_isjumpgoingtoexecute(duint addr)
|
||||||
|
|
||||||
extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDRINFO* addrinfo)
|
extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDRINFO* addrinfo)
|
||||||
{
|
{
|
||||||
if(!IsFileBeingDebugged())
|
if(!DbgIsDebugging())
|
||||||
return false;
|
return false;
|
||||||
bool retval=false;
|
bool retval=false;
|
||||||
if(addrinfo->flags&flagmodule) //get module
|
if(addrinfo->flags&flagmodule) //get module
|
||||||
|
@ -310,7 +312,7 @@ extern "C" DLL_EXPORT int _dbg_bpgettypeat(duint addr)
|
||||||
|
|
||||||
extern "C" DLL_EXPORT bool _dbg_getregdump(REGDUMP* regdump)
|
extern "C" DLL_EXPORT bool _dbg_getregdump(REGDUMP* regdump)
|
||||||
{
|
{
|
||||||
if(!IsFileBeingDebugged())
|
if(!DbgIsDebugging())
|
||||||
{
|
{
|
||||||
memset(regdump, 0, sizeof(REGDUMP));
|
memset(regdump, 0, sizeof(REGDUMP));
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -259,7 +259,7 @@ bool apienumexports(uint base, EXPORTENUMCALLBACK cbEnum)
|
||||||
///comment functions
|
///comment functions
|
||||||
bool commentset(uint addr, const char* text)
|
bool commentset(uint addr, const char* text)
|
||||||
{
|
{
|
||||||
if(!IsFileBeingDebugged() or !memisvalidreadptr(fdProcessInfo->hProcess, addr) or !text or strlen(text)>=MAX_COMMENT_SIZE-1)
|
if(!DbgIsDebugging() or !memisvalidreadptr(fdProcessInfo->hProcess, addr) or !text or strlen(text)>=MAX_COMMENT_SIZE-1)
|
||||||
return false;
|
return false;
|
||||||
if(!*text) //NOTE: delete when there is no text
|
if(!*text) //NOTE: delete when there is no text
|
||||||
return commentdel(addr);
|
return commentdel(addr);
|
||||||
|
@ -297,7 +297,7 @@ bool commentset(uint addr, const char* text)
|
||||||
|
|
||||||
bool commentget(uint addr, char* text)
|
bool commentget(uint addr, char* text)
|
||||||
{
|
{
|
||||||
if(!IsFileBeingDebugged() or !memisvalidreadptr(fdProcessInfo->hProcess, addr) or !text)
|
if(!DbgIsDebugging() or !memisvalidreadptr(fdProcessInfo->hProcess, addr) or !text)
|
||||||
return false;
|
return false;
|
||||||
char modname[MAX_MODULE_SIZE]="";
|
char modname[MAX_MODULE_SIZE]="";
|
||||||
char sql[deflen]="";
|
char sql[deflen]="";
|
||||||
|
@ -310,7 +310,7 @@ bool commentget(uint addr, char* text)
|
||||||
|
|
||||||
bool commentdel(uint addr)
|
bool commentdel(uint addr)
|
||||||
{
|
{
|
||||||
if(!IsFileBeingDebugged() or !memisvalidreadptr(fdProcessInfo->hProcess, addr))
|
if(!DbgIsDebugging() or !memisvalidreadptr(fdProcessInfo->hProcess, addr))
|
||||||
return false;
|
return false;
|
||||||
char modname[MAX_MODULE_SIZE]="";
|
char modname[MAX_MODULE_SIZE]="";
|
||||||
char sql[deflen]="";
|
char sql[deflen]="";
|
||||||
|
@ -339,7 +339,7 @@ bool commentdel(uint addr)
|
||||||
///label functions
|
///label functions
|
||||||
bool labelset(uint addr, const char* text)
|
bool labelset(uint addr, const char* text)
|
||||||
{
|
{
|
||||||
if(!IsFileBeingDebugged() or !memisvalidreadptr(fdProcessInfo->hProcess, addr) or !text or strlen(text)>=MAX_LABEL_SIZE-1)
|
if(!DbgIsDebugging() or !memisvalidreadptr(fdProcessInfo->hProcess, addr) or !text or strlen(text)>=MAX_LABEL_SIZE-1)
|
||||||
return false;
|
return false;
|
||||||
if(!*text) //NOTE: delete when there is no text
|
if(!*text) //NOTE: delete when there is no text
|
||||||
return labeldel(addr);
|
return labeldel(addr);
|
||||||
|
@ -418,7 +418,7 @@ bool labelfromstring(const char* text, uint* addr)
|
||||||
|
|
||||||
bool labelget(uint addr, char* text)
|
bool labelget(uint addr, char* text)
|
||||||
{
|
{
|
||||||
if(!IsFileBeingDebugged() or !memisvalidreadptr(fdProcessInfo->hProcess, addr) or !text)
|
if(!DbgIsDebugging() or !memisvalidreadptr(fdProcessInfo->hProcess, addr) or !text)
|
||||||
return false;
|
return false;
|
||||||
char modname[MAX_MODULE_SIZE]="";
|
char modname[MAX_MODULE_SIZE]="";
|
||||||
char sql[deflen]="";
|
char sql[deflen]="";
|
||||||
|
@ -431,7 +431,7 @@ bool labelget(uint addr, char* text)
|
||||||
|
|
||||||
bool labeldel(uint addr)
|
bool labeldel(uint addr)
|
||||||
{
|
{
|
||||||
if(!IsFileBeingDebugged() or !memisvalidreadptr(fdProcessInfo->hProcess, addr))
|
if(!DbgIsDebugging() or !memisvalidreadptr(fdProcessInfo->hProcess, addr))
|
||||||
return false;
|
return false;
|
||||||
char modname[MAX_MODULE_SIZE]="";
|
char modname[MAX_MODULE_SIZE]="";
|
||||||
char sql[deflen]="";
|
char sql[deflen]="";
|
||||||
|
@ -460,7 +460,7 @@ bool labeldel(uint addr)
|
||||||
///bookmark functions
|
///bookmark functions
|
||||||
bool bookmarkset(uint addr)
|
bool bookmarkset(uint addr)
|
||||||
{
|
{
|
||||||
if(!IsFileBeingDebugged() or !memisvalidreadptr(fdProcessInfo->hProcess, addr))
|
if(!DbgIsDebugging() or !memisvalidreadptr(fdProcessInfo->hProcess, addr))
|
||||||
return false;
|
return false;
|
||||||
char modname[MAX_MODULE_SIZE]="";
|
char modname[MAX_MODULE_SIZE]="";
|
||||||
char sql[deflen]="";
|
char sql[deflen]="";
|
||||||
|
@ -494,7 +494,7 @@ bool bookmarkset(uint addr)
|
||||||
|
|
||||||
bool bookmarkget(uint addr)
|
bool bookmarkget(uint addr)
|
||||||
{
|
{
|
||||||
if(!IsFileBeingDebugged() or !memisvalidreadptr(fdProcessInfo->hProcess, addr))
|
if(!DbgIsDebugging() or !memisvalidreadptr(fdProcessInfo->hProcess, addr))
|
||||||
return false;
|
return false;
|
||||||
char modname[MAX_MODULE_SIZE]="";
|
char modname[MAX_MODULE_SIZE]="";
|
||||||
char sql[deflen]="";
|
char sql[deflen]="";
|
||||||
|
@ -507,7 +507,7 @@ bool bookmarkget(uint addr)
|
||||||
|
|
||||||
bool bookmarkdel(uint addr)
|
bool bookmarkdel(uint addr)
|
||||||
{
|
{
|
||||||
if(!IsFileBeingDebugged() or !memisvalidreadptr(fdProcessInfo->hProcess, addr))
|
if(!DbgIsDebugging() or !memisvalidreadptr(fdProcessInfo->hProcess, addr))
|
||||||
return false;
|
return false;
|
||||||
char modname[MAX_MODULE_SIZE]="";
|
char modname[MAX_MODULE_SIZE]="";
|
||||||
char sql[deflen]="";
|
char sql[deflen]="";
|
||||||
|
@ -536,7 +536,7 @@ bool bookmarkdel(uint addr)
|
||||||
///function database
|
///function database
|
||||||
bool functionget(duint addr, duint* start, duint* end)
|
bool functionget(duint addr, duint* start, duint* end)
|
||||||
{
|
{
|
||||||
if(!IsFileBeingDebugged() or !memisvalidreadptr(fdProcessInfo->hProcess, addr))
|
if(!DbgIsDebugging() or !memisvalidreadptr(fdProcessInfo->hProcess, addr))
|
||||||
return false;
|
return false;
|
||||||
char modname[MAX_MODULE_SIZE]="";
|
char modname[MAX_MODULE_SIZE]="";
|
||||||
char sql[deflen]="";
|
char sql[deflen]="";
|
||||||
|
@ -598,7 +598,7 @@ bool functionoverlaps(uint start, uint end)
|
||||||
|
|
||||||
bool functionadd(uint start, uint end, bool manual)
|
bool functionadd(uint start, uint end, bool manual)
|
||||||
{
|
{
|
||||||
if(!IsFileBeingDebugged() or end<start or memfindbaseaddr(fdProcessInfo->hProcess, start, 0)!=memfindbaseaddr(fdProcessInfo->hProcess, end, 0)) //the function boundaries are not in the same mem page
|
if(!DbgIsDebugging() or end<start or memfindbaseaddr(fdProcessInfo->hProcess, start, 0)!=memfindbaseaddr(fdProcessInfo->hProcess, end, 0)) //the function boundaries are not in the same mem page
|
||||||
return false;
|
return false;
|
||||||
char sql[deflen]="";
|
char sql[deflen]="";
|
||||||
char modname[MAX_MODULE_SIZE]="";
|
char modname[MAX_MODULE_SIZE]="";
|
||||||
|
@ -629,7 +629,7 @@ bool functionadd(uint start, uint end, bool manual)
|
||||||
|
|
||||||
bool functiondel(uint addr)
|
bool functiondel(uint addr)
|
||||||
{
|
{
|
||||||
if(!IsFileBeingDebugged() or !functionget(addr, 0, 0))
|
if(!DbgIsDebugging() or !functionget(addr, 0, 0))
|
||||||
return false;
|
return false;
|
||||||
char modname[MAX_MODULE_SIZE]="";
|
char modname[MAX_MODULE_SIZE]="";
|
||||||
char sql[deflen]="";
|
char sql[deflen]="";
|
||||||
|
|
|
@ -162,7 +162,7 @@ CMDRESULT cmdloop(COMMAND* command_list, CBCOMMAND cbUnknownCommand, CBCOMMANDPR
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(cmd->debugonly and !IsFileBeingDebugged())
|
if(cmd->debugonly and !DbgIsDebugging())
|
||||||
{
|
{
|
||||||
dputs("this command is debug-only");
|
dputs("this command is debug-only");
|
||||||
if(error_is_fatal)
|
if(error_is_fatal)
|
||||||
|
@ -266,7 +266,7 @@ CMDRESULT cmddirectexec(COMMAND* cmd_list, const char* cmd)
|
||||||
COMMAND* found=cmdfindmain(cmd_list, command);
|
COMMAND* found=cmdfindmain(cmd_list, command);
|
||||||
if(!found or !found->cbCommand)
|
if(!found or !found->cbCommand)
|
||||||
return STATUS_ERROR;
|
return STATUS_ERROR;
|
||||||
if(found->debugonly and !IsFileBeingDebugged())
|
if(found->debugonly and !DbgIsDebugging())
|
||||||
return STATUS_ERROR;
|
return STATUS_ERROR;
|
||||||
int argcount=arggetcount(command);
|
int argcount=arggetcount(command);
|
||||||
char** argv=(char**)emalloc((argcount+1)*sizeof(char*), "cmddirectexec:argv");
|
char** argv=(char**)emalloc((argcount+1)*sizeof(char*), "cmddirectexec:argv");
|
||||||
|
|
|
@ -953,7 +953,7 @@ static DWORD WINAPI threadDebugLoop(void* lpParameter)
|
||||||
|
|
||||||
CMDRESULT cbDebugInit(int argc, char* argv[])
|
CMDRESULT cbDebugInit(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
if(IsFileBeingDebugged())
|
if(DbgIsDebugging())
|
||||||
{
|
{
|
||||||
dputs("already debugging!");
|
dputs("already debugging!");
|
||||||
return STATUS_ERROR;
|
return STATUS_ERROR;
|
||||||
|
@ -1906,7 +1906,7 @@ CMDRESULT cbDebugAttach(int argc, char* argv[])
|
||||||
dprintf("invalid expression \"%s\"!\n", argv[1]);
|
dprintf("invalid expression \"%s\"!\n", argv[1]);
|
||||||
return STATUS_ERROR;
|
return STATUS_ERROR;
|
||||||
}
|
}
|
||||||
if(IsFileBeingDebugged())
|
if(DbgIsDebugging())
|
||||||
{
|
{
|
||||||
//TODO: do stuff
|
//TODO: do stuff
|
||||||
dputs("terminate the current session!");
|
dputs("terminate the current session!");
|
||||||
|
|
|
@ -303,7 +303,7 @@ static CMDRESULT scriptinternalcmdexec(const char* cmd)
|
||||||
return STATUS_CONTINUE;
|
return STATUS_CONTINUE;
|
||||||
}
|
}
|
||||||
CMDRESULT res=cmddirectexec(dbggetcommandlist(), command);
|
CMDRESULT res=cmddirectexec(dbggetcommandlist(), command);
|
||||||
if(IsFileBeingDebugged())
|
if(DbgIsDebugging())
|
||||||
{
|
{
|
||||||
while(!waitislocked(WAITID_RUN)) //while not locked (NOTE: possible deadlock)
|
while(!waitislocked(WAITID_RUN)) //while not locked (NOTE: possible deadlock)
|
||||||
Sleep(10);
|
Sleep(10);
|
||||||
|
|
|
@ -978,7 +978,7 @@ static bool setregister(const char* string, uint value)
|
||||||
|
|
||||||
bool valapifromstring(const char* name, uint* value, int* value_size, bool printall, bool silent, bool* hexonly)
|
bool valapifromstring(const char* name, uint* value, int* value_size, bool printall, bool silent, bool* hexonly)
|
||||||
{
|
{
|
||||||
if(!value or !IsFileBeingDebugged())
|
if(!value or !DbgIsDebugging())
|
||||||
return false;
|
return false;
|
||||||
//explicit API handling
|
//explicit API handling
|
||||||
const char* apiname=strstr(name, ":");
|
const char* apiname=strstr(name, ":");
|
||||||
|
@ -1206,7 +1206,7 @@ bool valfromstring(const char* string, uint* value, bool silent, bool baseonly,
|
||||||
}
|
}
|
||||||
else if(*string=='@' or strstr(string, "[")) //memory location
|
else if(*string=='@' or strstr(string, "[")) //memory location
|
||||||
{
|
{
|
||||||
if(!IsFileBeingDebugged())
|
if(!DbgIsDebugging())
|
||||||
{
|
{
|
||||||
if(!silent)
|
if(!silent)
|
||||||
dputs("not debugging");
|
dputs("not debugging");
|
||||||
|
@ -1269,7 +1269,7 @@ bool valfromstring(const char* string, uint* value, bool silent, bool baseonly,
|
||||||
}
|
}
|
||||||
else if(isregister(string)) //register
|
else if(isregister(string)) //register
|
||||||
{
|
{
|
||||||
if(!IsFileBeingDebugged())
|
if(!DbgIsDebugging())
|
||||||
{
|
{
|
||||||
if(!silent)
|
if(!silent)
|
||||||
dputs("not debugging!");
|
dputs("not debugging!");
|
||||||
|
@ -1287,7 +1287,7 @@ bool valfromstring(const char* string, uint* value, bool silent, bool baseonly,
|
||||||
}
|
}
|
||||||
else if(*string=='!' and isflag(string+1)) //flag
|
else if(*string=='!' and isflag(string+1)) //flag
|
||||||
{
|
{
|
||||||
if(!IsFileBeingDebugged())
|
if(!DbgIsDebugging())
|
||||||
{
|
{
|
||||||
if(!silent)
|
if(!silent)
|
||||||
dputs("not debugging");
|
dputs("not debugging");
|
||||||
|
@ -1372,7 +1372,7 @@ bool valtostring(const char* string, uint* value, bool silent)
|
||||||
return false;
|
return false;
|
||||||
else if(*string=='@' or strstr(string, "[")) //memory location
|
else if(*string=='@' or strstr(string, "[")) //memory location
|
||||||
{
|
{
|
||||||
if(!IsFileBeingDebugged())
|
if(!DbgIsDebugging())
|
||||||
{
|
{
|
||||||
if(!silent)
|
if(!silent)
|
||||||
dputs("not debugging");
|
dputs("not debugging");
|
||||||
|
@ -1427,7 +1427,7 @@ bool valtostring(const char* string, uint* value, bool silent)
|
||||||
}
|
}
|
||||||
else if(isregister(string)) //register
|
else if(isregister(string)) //register
|
||||||
{
|
{
|
||||||
if(!IsFileBeingDebugged())
|
if(!DbgIsDebugging())
|
||||||
{
|
{
|
||||||
if(!silent)
|
if(!silent)
|
||||||
dputs("not debugging!");
|
dputs("not debugging!");
|
||||||
|
@ -1447,7 +1447,7 @@ bool valtostring(const char* string, uint* value, bool silent)
|
||||||
}
|
}
|
||||||
else if(*string=='!' and isflag(string+1)) //flag
|
else if(*string=='!' and isflag(string+1)) //flag
|
||||||
{
|
{
|
||||||
if(!IsFileBeingDebugged())
|
if(!DbgIsDebugging())
|
||||||
{
|
{
|
||||||
if(!silent)
|
if(!silent)
|
||||||
dputs("not debugging");
|
dputs("not debugging");
|
||||||
|
|
Loading…
Reference in New Issue