diff --git a/help/pop.htm b/help/pop.htm new file mode 100644 index 00000000..faf747e9 --- /dev/null +++ b/help/pop.htm @@ -0,0 +1,25 @@ + + + +pop + + + + + + + +

push
Pop a value from the stack.

+

+arguments
[arg1]: The destination.

+

+ +result
This command does not set any +result variables.

+ \ No newline at end of file diff --git a/help/push.htm b/help/push.htm new file mode 100644 index 00000000..9d6fd7ff --- /dev/null +++ b/help/push.htm @@ -0,0 +1,26 @@ + + + +push + + + + + + + +

push
Push a value on the stack.

+

+arguments
  arg1: The value to push on the stack. +

+

+ +result
This command does not set any +result variables.

+ \ No newline at end of file diff --git a/help/x64_dbg.wcp b/help/x64_dbg.wcp index be0d070b..885895ea 100644 Binary files a/help/x64_dbg.wcp and b/help/x64_dbg.wcp differ diff --git a/x64_dbg_dbg/instruction.cpp b/x64_dbg_dbg/instruction.cpp index 32b5c18a..b6679154 100644 --- a/x64_dbg_dbg/instruction.cpp +++ b/x64_dbg_dbg/instruction.cpp @@ -30,6 +30,7 @@ #include "controlflowanalysis.h" #include "analysis_nukem.h" #include "exceptiondirectoryanalysis.h" +#include "_scriptapi_stack.h" static bool bRefinit = false; @@ -778,6 +779,40 @@ CMDRESULT cbInstrXor(int argc, char* argv[]) return cmddirectexec(dbggetcommandlist(), newcmd); } +CMDRESULT cbInstrPush(int argc, char* argv[]) +{ + if(argc < 2) + { + dputs("not enough arguments!"); + return STATUS_ERROR; + } + duint value; + if(!valfromstring(argv[1], &value)) + { + dprintf("invalid argument \"%s\"!\n", argv[1]); + return STATUS_ERROR; + } + Script::Stack::Push(value); + uint csp = GetContextDataEx(hActiveThread, UE_CSP); + GuiStackDumpAt(csp, csp); + GuiUpdateRegisterView(); + return STATUS_CONTINUE; +} + +CMDRESULT cbInstrPop(int argc, char* argv[]) +{ + duint value = Script::Stack::Pop(); + uint csp = GetContextDataEx(hActiveThread, UE_CSP); + GuiStackDumpAt(csp, csp); + GuiUpdateRegisterView(); + if(argc > 1) + { + if(!valtostring(argv[1], value, false)) + return STATUS_ERROR; + } + return STATUS_CONTINUE; +} + CMDRESULT cbInstrRefinit(int argc, char* argv[]) { GuiReferenceInitialize("Script"); diff --git a/x64_dbg_dbg/instruction.h b/x64_dbg_dbg/instruction.h index b398dc32..1166a07c 100644 --- a/x64_dbg_dbg/instruction.h +++ b/x64_dbg_dbg/instruction.h @@ -40,6 +40,8 @@ CMDRESULT cbInstrShr(int argc, char* argv[]); CMDRESULT cbInstrSub(int argc, char* argv[]); CMDRESULT cbInstrTest(int argc, char* argv[]); CMDRESULT cbInstrXor(int argc, char* argv[]); +CMDRESULT cbInstrPush(int argc, char* argv[]); +CMDRESULT cbInstrPop(int argc, char* argv[]); CMDRESULT cbInstrRefinit(int argc, char* argv[]); CMDRESULT cbInstrRefadd(int argc, char* argv[]); diff --git a/x64_dbg_dbg/x64_dbg.cpp b/x64_dbg_dbg/x64_dbg.cpp index 94a483f2..a1582dc1 100644 --- a/x64_dbg_dbg/x64_dbg.cpp +++ b/x64_dbg_dbg/x64_dbg.cpp @@ -173,6 +173,8 @@ static void registercommands() dbgcmdnew("sub", cbInstrSub, false); dbgcmdnew("test", cbInstrTest, false); dbgcmdnew("xor", cbInstrXor, false); + dbgcmdnew("push", cbInstrPush, true); + dbgcmdnew("pop", cbInstrPop, true); //script dbgcmdnew("scriptload", cbScriptLoad, false);