Exemplo n.º 1
0
void LoggerWin::platformShut()
{
  if(hWnd != NULL)
  {
    char szLog[] = "--- GOING AWAY... PRESS SPACE BAR TO CONTINUE ---";
    HWND hWndOutput = GetDlgItem(hWnd, IDC_MAIN_OUTPUT);
    ListBox_AddString(hWndOutput, "");
    ListBox_AddString(hWndOutput, szLog);
    int count = ListBox_GetCount(hWndOutput);
    ListBox_SetCaretIndex(hWndOutput, count - 1);
    UpdateWindow(hWndOutput);

    DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG_PAUSE), hWnd, (DLGPROC)PauseDlgProc);

    ProfileWin profile;

    RECT rc;
    if(GetWindowRect(hWnd, &rc))
      profile.setSizeAndPosition(rc.right - rc.left, rc.bottom - rc.top, rc.left, rc.top);

    DestroyWindow(hWnd);
    hWnd = NULL;
  }

  UnregisterClass(szClassName, hInst);
}
Exemplo n.º 2
0
BOOL LoggerWin::platformInit()
{
  WNDCLASS wc;
  wc.style         = 0; 
  wc.lpfnWndProc   = DefDlgProc; 
  wc.cbClsExtra    = 0; 
  wc.cbWndExtra    = DLGWINDOWEXTRA; 
  wc.hInstance     = hInst; 
  wc.hIcon         = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON_APP)); 
  wc.hCursor       = LoadCursor(0, IDC_ARROW); 
  wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
  wc.lpszMenuName  = NULL; 
  wc.lpszClassName = szClassName;

  if(!RegisterClass(&wc))
    return FALSE;

  // restore prefs
  ProfileWin profile;

  profile.getBool(NPSPY_REG_KEY_ONTOP, &bOnTop);
  profile.getBool(NPSPY_REG_KEY_LOGTOWINDOW, &bToWindow);
  profile.getBool(NPSPY_REG_KEY_LOGTOCONSOLE, &bToConsole);
  profile.getBool(NPSPY_REG_KEY_LOGTOFILE, &bToFile);
  profile.getBool(NPSPY_REG_KEY_SPALID, &bSPALID);
  profile.getString(NPSPY_REG_KEY_LOGFILENAME, szFile, strlen(szFile));

  for(int i = 1; i < TOTAL_NUMBER_OF_API_CALLS; i++)
  {
    BOOL selected = TRUE;
    if(profile.getBool(ActionName[i], &selected))
      bMutedCalls[i] = !selected;
  }
  
  if(!profile.getSizeAndPosition(&width, &height, &x, &y))
  {
    width = 0;
    height = 0;
    x = 0;
    y = 0;
  }

  hWnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_DIALOG_MAIN), GetDesktopWindow(), (DLGPROC)MainDlgProc, (LPARAM)this);
  if(hWnd == NULL)
  {
    UnregisterClass(szClassName, hInst);
    return FALSE;
  }

  if(bOnTop)
    SetWindowPos(hWnd, bOnTop ? HWND_TOPMOST : HWND_NOTOPMOST, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE);

  return TRUE;
}
Exemplo n.º 3
0
// This is exported function which allows to access Settings GUI from other applications
void WINAPI SPY_Setup()
{
  LoggerWin logger;
  ProfileWin profile;

  profile.getBool(NPSPY_REG_KEY_ONTOP, &logger.bOnTop);
  profile.getBool(NPSPY_REG_KEY_LOGTOWINDOW, &logger.bToWindow);
  profile.getBool(NPSPY_REG_KEY_LOGTOCONSOLE, &logger.bToConsole);
  profile.getBool(NPSPY_REG_KEY_LOGTOFILE, &logger.bToFile);
  profile.getBool(NPSPY_REG_KEY_SPALID, &logger.bSPALID);
  profile.getString(NPSPY_REG_KEY_LOGFILENAME, logger.szFile, strlen(logger.szFile));

  for(int i = 1; i < TOTAL_NUMBER_OF_API_CALLS; i++)
  {
    BOOL selected = TRUE;
    if(profile.getBool(ActionName[i], &selected))
      logger.bMutedCalls[i] = !selected;
  }

  onOptions(NULL, &logger);
}
Exemplo n.º 4
0
static void onOptions(HWND hWnd, Logger * logger)
{
  if(!logger)
    return;

  PROPSHEETPAGE psp[4];

  psp[0].dwSize = sizeof(psp[0]);
  psp[0].dwFlags = PSP_DEFAULT;
  psp[0].hInstance = hInst;
  psp[0].pszTemplate = MAKEINTRESOURCE(IDD_PAGE_GENERAL);
  psp[0].pszIcon = 0;
  psp[0].pfnDlgProc = GeneralPageProc;
  psp[0].pszTitle = 0;
  psp[0].lParam = (LPARAM)logger;
  psp[0].pfnCallback = NULL;

  psp[1].dwSize = sizeof(psp[1]);
  psp[1].dwFlags = PSP_DEFAULT;
  psp[1].hInstance = hInst;
  psp[1].pszTemplate = MAKEINTRESOURCE(IDD_PAGE_LOG);
  psp[1].pszIcon = 0;
  psp[1].pfnDlgProc = LogPageProc;
  psp[1].pszTitle = 0;
  psp[1].lParam = (LPARAM)logger;
  psp[1].pfnCallback = NULL;

  psp[2].dwSize = sizeof(psp[2]);
  psp[2].dwFlags = PSP_DEFAULT;
  psp[2].hInstance = hInst;
  psp[2].pszTemplate = MAKEINTRESOURCE(IDD_PAGE_FILTER);
  psp[2].pszIcon = 0;
  psp[2].pfnDlgProc = FilterPageProc;
  psp[2].pszTitle = 0;
  psp[2].lParam = (LPARAM)logger;
  psp[2].pfnCallback = NULL;

  psp[3].dwSize = sizeof(psp[3]);
  psp[3].dwFlags = PSP_DEFAULT;
  psp[3].hInstance = hInst;
  psp[3].pszTemplate = MAKEINTRESOURCE(IDD_PAGE_ADVANCED);
  psp[3].pszIcon = 0;
  psp[3].pfnDlgProc = AdvancedPageProc;
  psp[3].pszTitle = 0;
  psp[3].lParam = (LPARAM)logger;
  psp[3].pfnCallback = NULL;

  PROPSHEETHEADER psh;
  psh.dwSize = sizeof(PROPSHEETHEADER);
  psh.dwFlags = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW;
  psh.hwndParent = hWnd;
  psh.hInstance = hInst;
  psh.pszIcon = 0;
  psh.pszCaption = "Settings";
  psh.nPages = sizeof(psp) / sizeof(psp[0]);
  psh.nStartPage = 0;
  psh.ppsp = psp;
  psh.pfnCallback = NULL;

  logger->bSaveSettings = FALSE;

  int rv = PropertySheet(&psh);
  if(rv == -1)
    return;

  if(logger->bSaveSettings)
  {
    ProfileWin profile;

    if(hWnd != NULL)
    {
      RECT rc;
      if(GetWindowRect(hWnd, &rc))
        profile.setSizeAndPosition(rc.right - rc.left, rc.bottom - rc.top, rc.left, rc.top);
    }

    profile.setBool(NPSPY_REG_KEY_ONTOP, logger->bOnTop);
    profile.setBool(NPSPY_REG_KEY_LOGTOWINDOW, logger->bToWindow);
    profile.setBool(NPSPY_REG_KEY_LOGTOCONSOLE, logger->bToConsole);
    profile.setBool(NPSPY_REG_KEY_LOGTOFILE, logger->bToFile);
    profile.setBool(NPSPY_REG_KEY_SPALID, logger->bSPALID);
    profile.setString(NPSPY_REG_KEY_LOGFILENAME, logger->szFile);

    for(int i = 1; i < TOTAL_NUMBER_OF_API_CALLS; i++)
      profile.setBool(ActionName[i], !logger->bMutedCalls[i]);

    SetWindowPos(hWnd, logger->bOnTop ? HWND_TOPMOST : HWND_NOTOPMOST, 0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
  }

  logger->bSaveSettings = FALSE;
}