Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DbgGetRegDumpEx() return success but get nothing. #2248

Open
StarsunYzL opened this issue Nov 12, 2019 · 0 comments

Comments

@StarsunYzL
Copy link
Contributor

@StarsunYzL StarsunYzL commented Nov 12, 2019

I am developing a plugin using pluginsdk from snapshot_2019-11-10_23-25, I found that sometimes DbgGetRegDumpEx() return true but all registers get zero, here is the code:

#include <mutex>
#include <windows.h>

#include "_plugins.h"
#include "bridgemain.h"

std::mutex g_step_mutex;

extern "C" __declspec(dllexport) bool pluginit(PLUG_INITSTRUCT * init) {
  init->sdkVersion = PLUG_SDKVERSION;
  init->pluginVersion = 1;
  strcpy_s(init->pluginName, "Test");
  return true;
}

extern "C" __declspec(dllexport) void CBSTEPPED(CBTYPE type, PLUG_CB_STEPPED * info) {
  std::lock_guard lock(g_step_mutex);
  REGDUMP regs;
  if (!DbgGetRegDumpEx(&regs, sizeof(regs))) {
    _plugin_logprintf("Read registers failed!");
    return;
  }

  // !!! Sometimes all registers get zero.
  if (!regs.regcontext.cip)
    _plugin_debugpause();
}

extern "C" __declspec(dllexport) void CBTRACEEXECUTE(CBTYPE type, PLUG_CB_TRACEEXECUTE * info) {
  std::lock_guard lock(g_step_mutex);
  REGDUMP regs;
  if (!DbgGetRegDumpEx(&regs, sizeof(regs))) {
    _plugin_logprintf("Read registers failed!");
    return;
  }

  // !!! Sometimes all registers get zero.
  if (!regs.regcontext.cip)
    _plugin_debugpause();
}

BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved) {
  return TRUE;
}

Load any exe to x32dbg such as calc.exe, do a "Animate into" or "Trace into", _plugin_debugpause() will be called sooner or later. See attachment:

2019-11-12_095849

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.