Skip to content

Instantly share code, notes, and snippets.

@toptensoftware
Last active October 8, 2016 23:56
Show Gist options
  • Select an option

  • Save toptensoftware/a2ed963920524c06592696191f90de92 to your computer and use it in GitHub Desktop.

Select an option

Save toptensoftware/a2ed963920524c06592696191f90de92 to your computer and use it in GitHub Desktop.
public void CallVM(uint lpfnProc)
{
// Save the old IP
var oldCS = cs;
var oldIP = ip;
// Setup the new IP
cs = lpfnProc.Hiword();
ip = lpfnProc.Loword();
// Push address of the system return thunk
this.PushDWord(_sysRetThunk);
// Handle re-entrancy
_sysRetDepth++;
uint sysCallDepthAtCall= _sysRetDepth;
// Process until the sys return thunk is invoked
while (_sysRetDepth >= sysCallDepthAtCall)
{
Step();
}
// Restore instruction pointer
cs = oldCS;
ip = oldIP;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment