/*
 *  ExceptionTracer
 *      Contructs a exception trace object, responssible for tracing informations about an exception
 */
ExceptionTracer::ExceptionTracer(char* buffer, size_t max, LPEXCEPTION_POINTERS pException) :
    buffer(buffer), exception(*pException), record(*pException->ExceptionRecord), context(*pException->ContextRecord)
{
    this->buffer = buffer;
    this->buffer[this->len = 0] = 0;
    this->spc[this->nspc = 0] = 0;
    this->max = max;

    // Acquiere common information that we'll access
    this->module = GetModuleFromAddress(record.ExceptionAddress);
}
Esempio n. 2
0
void App::InitMessageWndClass()
{
    WNDCLASSEX wc = { 0 };
    wc.cbSize = sizeof(wc);
    wc.lpfnWndProc = WndProcThunk;
    wc.hInstance = GetModuleFromAddress(wc.lpfnWndProc);
    wc.lpszClassName = kMessageWndClass;
    instance_ = wc.hInstance;
    RegisterClassEx(&wc);

    message_hwnd_ =
        ::CreateWindow(kMessageWndClass, 0, 0, 0, 0, 0, 0, HWND_MESSAGE, 0, instance_, 0);
}
/*
 *   StackTracer::Walk
 *      Walks on the stack, each walk is one frame of backtrace
 *      Returns a frame or null if the walk on the park is not possible anymore
 */
StackTracer::Trace* StackTracer::Walk()
{
    if (StackWalk64(IMAGE_FILE_MACHINE_I386, GetCurrentProcess(), GetCurrentThread(),
        &frame, &context, NULL, NULL, NULL, NULL))
    {
        trace.module = GetModuleFromAddress((void*)frame.AddrPC.Offset);
        trace.frame = (void*)frame.AddrFrame.Offset;
        trace.stack = (void*)frame.AddrStack.Offset;
        trace.pc = (void*)frame.AddrPC.Offset;
        trace.ret = (void*)frame.AddrReturn.Offset;
        return &trace;
    }
    return nullptr;
}
Esempio n. 4
0
bool BSPanel::Initialize()
{
    HMODULE module = GetModuleFromAddress(&BSPanelProc);
    WNDCLASSEX wndcls = { 0 };
    wndcls.cbSize = sizeof(wndcls);
    wndcls.style = CS_HREDRAW | CS_VREDRAW;
    wndcls.lpfnWndProc = BSPanelProc;
    wndcls.cbClsExtra = 0;
    wndcls.cbWndExtra = 0;
    wndcls.hInstance = module;
    wndcls.hIcon = 0;
    wndcls.hCursor = ::LoadCursor(NULL, IDC_HELP);
    wndcls.hbrBackground = 0;
    wndcls.lpszMenuName = 0;
    wndcls.lpszClassName = kClassName;
    wndcls.hIconSm = 0;
    return !!::RegisterClassEx(&wndcls);
}
Esempio n. 5
0
bool BSPanel::Uninitialize()
{
    HMODULE module = GetModuleFromAddress(&BSPanelProc);
    return !!::UnregisterClass(kClassName, module);
}