DBG: fixed a bug in 'getstr' + added function 'strcpy'
This commit is contained in:
parent
67e2544259
commit
cd4e07597f
|
@ -899,13 +899,13 @@ CMDRESULT cbInstrGetstr(int argc, char* argv[])
|
|||
dputs("not enough arguments!");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
VAR_TYPE vartype;
|
||||
if(!vargettype(argv[1], &vartype))
|
||||
VAR_VALUE_TYPE valtype;
|
||||
if(!vargettype(argv[1], 0, &valtype))
|
||||
{
|
||||
dprintf("no such variable \"%s\"!\n", argv[1]);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
if(vartype!=VAR_STRING)
|
||||
if(valtype!=VAR_STRING)
|
||||
{
|
||||
dprintf("variable \"%s\" is not a string!\n", argv[1]);
|
||||
return STATUS_ERROR;
|
||||
|
@ -920,6 +920,7 @@ CMDRESULT cbInstrGetstr(int argc, char* argv[])
|
|||
memset(string, 0, size+1);
|
||||
if(!varget(argv[1], string, &size, 0))
|
||||
{
|
||||
efree(string, "cbInstrGetstr:string");
|
||||
dprintf("failed to get variable data \"%s\"!\n", argv[1]);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
@ -928,6 +929,57 @@ CMDRESULT cbInstrGetstr(int argc, char* argv[])
|
|||
return STATUS_CONTINUE;
|
||||
}
|
||||
|
||||
CMDRESULT cbInstrCopystr(int argc, char* argv[])
|
||||
{
|
||||
if(argc<3)
|
||||
{
|
||||
dputs("not enough arguments!");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
VAR_VALUE_TYPE valtype;
|
||||
if(!vargettype(argv[2], 0, &valtype))
|
||||
{
|
||||
dprintf("no such variable \"%s\"!\n", argv[2]);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
if(valtype!=VAR_STRING)
|
||||
{
|
||||
dprintf("variable \"%s\" is not a string!\n", argv[2]);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
int size;
|
||||
if(!varget(argv[2], (char*)0, &size, 0) or !size)
|
||||
{
|
||||
dprintf("failed to get variable size \"%s\"!\n", argv[2]);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
char* string=(char*)emalloc(size+1, "cbInstrGetstr:string");
|
||||
memset(string, 0, size+1);
|
||||
if(!varget(argv[2], string, &size, 0))
|
||||
{
|
||||
efree(string, "cbInstrCopystr:string");
|
||||
dprintf("failed to get variable data \"%s\"!\n", argv[2]);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
uint addr;
|
||||
if(!valfromstring(argv[1], &addr))
|
||||
{
|
||||
efree(string, "cbInstrCopystr:string");
|
||||
dprintf("invalid address \"%s\"!\n", argv[1]);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
if(!memwrite(fdProcessInfo->hProcess, (void*)addr, string, strlen(string), 0))
|
||||
{
|
||||
efree(string, "cbInstrCopystr:string");
|
||||
dputs("memwrite failed!");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
efree(string, "cbInstrCopystr:string");
|
||||
dputs("string written!");
|
||||
GuiUpdateAllViews();
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
|
||||
CMDRESULT cbInstrFind(int argc, char* argv[])
|
||||
{
|
||||
if(argc<3)
|
||||
|
|
|
@ -49,6 +49,7 @@ CMDRESULT cbInstrRefStr(int argc, char* argv[]);
|
|||
|
||||
CMDRESULT cbInstrSetstr(int argc, char* argv[]);
|
||||
CMDRESULT cbInstrGetstr(int argc, char* argv[]);
|
||||
CMDRESULT cbInstrCopystr(int argc, char* argv[]);
|
||||
|
||||
CMDRESULT cbInstrFind(int argc, char* argv[]);
|
||||
CMDRESULT cbInstrModCallFind(int argc, char* argv[]);
|
||||
|
|
|
@ -263,7 +263,7 @@ bool vardel(const char* name, bool delsystem)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool vargettype(const char* name, VAR_TYPE* type)
|
||||
bool vargettype(const char* name, VAR_TYPE* type, VAR_VALUE_TYPE* valtype)
|
||||
{
|
||||
char newname[deflen]="$";
|
||||
int add=0;
|
||||
|
@ -273,6 +273,8 @@ bool vargettype(const char* name, VAR_TYPE* type)
|
|||
VAR* found=varfind(newname, 0);
|
||||
if(!found)
|
||||
return false;
|
||||
if(valtype)
|
||||
*valtype=found->value.type;
|
||||
if(type)
|
||||
*type=found->type;
|
||||
return true;
|
||||
|
|
|
@ -48,6 +48,6 @@ bool varget(const char* name, char* string, int* size, VAR_TYPE* type);
|
|||
bool varset(const char* name, uint value, bool setreadonly);
|
||||
bool varset(const char* name, const char* string, bool setreadonly);
|
||||
bool vardel(const char* name, bool delsystem);
|
||||
bool vargettype(const char* name, VAR_TYPE* type);
|
||||
bool vargettype(const char* name, VAR_TYPE* type = 0, VAR_VALUE_TYPE* valtype = 0);
|
||||
|
||||
#endif // _VARIABLE_H
|
||||
|
|
|
@ -179,6 +179,7 @@ static void registercommands()
|
|||
dbgcmdnew("refadd", cbInstrRefadd, false);
|
||||
dbgcmdnew("setstr\1strset", cbInstrSetstr, false); //set a string variable
|
||||
dbgcmdnew("getstr\1strget", cbInstrGetstr, false); //get a string variable
|
||||
dbgcmdnew("copystr\1strcpy", cbInstrCopystr, true); //write a string variable to memory
|
||||
dbgcmdnew("DebugContinue\1con", cbDebugContinue, true); //set continue status
|
||||
dbgcmdnew("bpdll", cbBpDll, true); //set dll breakpoint
|
||||
dbgcmdnew("bcdll", cbBcDll, true); //remove dll breakpoint
|
||||
|
|
Loading…
Reference in New Issue