Back to index

lightning-sunbird  0.9+nobinonly
windbgdlg.cpp File Reference
#include <windows.h>
#include <stdlib.h>

Go to the source code of this file.


int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)

Function Documentation

int WINAPI WinMain ( HINSTANCE  hInstance,
HINSTANCE  hPrevInstance,
LPSTR  lpszCmdLine,
int  nCmdShow 

Definition at line 47 of file windbgdlg.cpp.

    /* support for auto answering based on words in the assertion.
     * the assertion message is sent as a series of arguements (words) to the commandline.
     * set a "word" to 0xffffffff to let the word not affect this code.
     * set a "word" to 0xfffffffe to show the dialog.
     * set a "word" to 0x5 to ignore (program should continue).
     * set a "word" to 0x4 to retry (should fall into debugger).
     * set a "word" to 0x3 to abort (die).
    DWORD regType;
    DWORD regValue = -1;
    DWORD regLength = sizeof regValue;
    HKEY hkeyCU, hkeyLM;
    RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\\\windbgdlg", 0, KEY_READ, &hkeyCU);
    RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\\\windbgdlg", 0, KEY_READ, &hkeyLM);
    const char * const * argv = __argv;
    for (int i = __argc - 1; regValue == (DWORD)-1 && i; --i) {
        bool ok = false;
        if (hkeyCU)
            ok = RegQueryValueEx(hkeyCU, argv[i], 0, &regType, (LPBYTE)&regValue, &regLength) == ERROR_SUCCESS;
        if (!ok && hkeyLM)
            ok = RegQueryValueEx(hkeyLM, argv[i], 0, &regType, (LPBYTE)&regValue, &regLength) == ERROR_SUCCESS;
        if (!ok)
            regValue = -1;
    if (hkeyCU)
    if (hkeyLM)
    if (regValue != (DWORD)-1 && regValue != (DWORD)-2)
        return regValue;
    static char msg[4048];

             "%s\n\nClick Abort to exit the Application.\n"
             "Click Retry to Debug the Application..\n"
             "Click Ignore to continue running the Application.", 
    return MessageBox(NULL, msg, "NSGlue_Assertion",
                      MB_ICONSTOP | MB_SYSTEMMODAL| 
                      MB_ABORTRETRYIGNORE | MB_DEFBUTTON3);