ultimatepp/uppsrc/plugin/ndisasm/ndisupp.cpp
cxl 43f750cf91 ide: 64-bit pdb debugging
git-svn-id: svn://ultimatepp.org/upp/trunk@7581 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2014-08-10 17:33:31 +00:00

39 lines
769 B
C++

#include <Core/Core.h>
#include "ndisasm.h"
extern "C" {
#undef INT64_MIN
#undef INT64_MAX
#undef UINT64_MAX
#include "lib/compiler.h"
#include "lib/inttypes.h"
#include "lib/disasm.h"
}
NAMESPACE_UPP
int NDisassemble(char *output, const byte *data, uint64 offset, bool x64)// returns instruction length
{
int len = disasm(const_cast<unsigned char *>(data), output, 256, x64 ? 64 : 32, offset, false, 0);
if(len <= 0) {
eatbyte(const_cast<unsigned char *>(data), output, 256, x64 ? 64 : 32);
len = 1;
}
return len;
}
#ifdef flagMAIN
CONSOLE_APP_MAIN
{
long start = 0x4012f8, end = start + 256;
while(start < end) {
char line[NDISASM_OUTBUF_SIZE];
start += NDisassemble(line, (const byte *)start, start);
puts(line);
}
}
#endif
END_UPP_NAMESPACE