String getGUIVersion() { #define XSTR_DEF(s) #s #define STR_DEF(s) XSTR_DEF(s) return STR_DEF(JUCE_APP_VERSION); }
LRESULT CALLBACK _AboutWnd_WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static HINSTANCE g_hInstance ; static HWND g_hwndRichEdit ; static HWND g_hbtnReadme ; static HWND g_hbtnChangelog ; static HWND g_hbtnFaq ; static HWND g_hbtnLicense ; static HWND g_hbtnDonation ; TCHAR szBuffer[1024] ; switch (message) { case WM_CREATE: g_hInstance = ((CREATESTRUCT*)lParam)->hInstance ; g_hbtnReadme = CreateWindow (WC_BUTTON, NULL, WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|BS_FLAT, 0, 0, 0, 0, hwnd, (HMENU)IDC_VIEW_README, g_hInstance, NULL) ; g_hbtnChangelog = CreateWindow (WC_BUTTON, NULL, WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|BS_FLAT, 0, 0, 0, 0, hwnd, (HMENU)IDC_VIEW_CHANGELOG, g_hInstance, NULL) ; g_hbtnFaq = CreateWindow (WC_BUTTON, NULL, WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|BS_FLAT, 0, 0, 0, 0, hwnd, (HMENU)IDC_VIEW_FAQ, g_hInstance, NULL) ; g_hbtnLicense = CreateWindow (WC_BUTTON, NULL, WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|BS_FLAT, 0, 0, 0, 0, hwnd, (HMENU)IDC_VIEW_LICENSE, g_hInstance, NULL) ; g_hbtnDonation = CreateWindow (WC_BUTTON, NULL, WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|BS_FLAT, 0, 0, 0, 0, hwnd, (HMENU)IDC_MAKE_DONATION, g_hInstance, NULL) ; g_hwndRichEdit = CreateWindow (RICHEDIT_CLASS, NULL, WS_CHILD|WS_VISIBLE|ES_MULTILINE|ES_READONLY, 0, 0, 0, 0, hwnd, NULL, g_hInstance, NULL) ; SendMessage (g_hwndRichEdit, EM_AUTOURLDETECT, TRUE, 0) ; SendMessage (g_hwndRichEdit, EM_SETEVENTMASK, 0, ENM_LINK) ; case WM_LANGUAGECHANGED: SetWindowText (g_hbtnReadme, STR_DEF(_VIEW_README,g_szViewReadme)) ; SetWindowText (g_hbtnChangelog, STR_DEF(_VIEW_CHANGELOG,g_szViewChangelog)) ; SetWindowText (g_hbtnFaq, STR_DEF(_VIEW_FAQ,g_szViewFaq)) ; SetWindowText (g_hbtnLicense, STR_DEF(_VIEW_LICENSE,g_szViewLicense)) ; SetWindowText (g_hbtnDonation, STR_DEF(_MAKE_DONATION,g_szMakeDonation)) ; SetWindowText (g_hwndRichEdit, TEXT("")) ; if( Language_IsLoaded() ) wsprintf (szBuffer, STR(_VERSION_S), TEXT(APPLICATION_VERSION_STRING)) ; else wsprintf (szBuffer, g_szVersion, TEXT(APPLICATION_VERSION_STRING)) ; SendMessage (g_hwndRichEdit, EM_REPLACESEL, FALSE, (LPARAM)szBuffer) ; SendMessage (g_hwndRichEdit, EM_REPLACESEL, FALSE, (LPARAM)TEXT("\n\n")) ; _tcscpy (szBuffer, STR_DEF(_ABOUT_DRAWING,g_szDrawings)) ; SendMessage (g_hwndRichEdit, EM_REPLACESEL, FALSE, (LPARAM)szBuffer) ; if( Language_IsLoaded() ) { SendMessage (g_hwndRichEdit, EM_REPLACESEL, FALSE, (LPARAM)TEXT("\n\n")) ; _tcscpy (szBuffer, STR(_TRANSLATION_BY)) ; SendMessage (g_hwndRichEdit, EM_REPLACESEL, FALSE, (LPARAM)szBuffer) ; } _tcscpy (szBuffer, STR_DEF(_LICENSE, g_szLicense)) ; SendMessage (g_hwndRichEdit, EM_REPLACESEL, FALSE, (LPARAM)TEXT("\n\n")) ; SendMessage (g_hwndRichEdit, EM_REPLACESEL, FALSE, (LPARAM)szBuffer) ; _tcscpy (szBuffer, STR_DEF(_ABOUT_FREEIMAGE, g_szFreeImageLicense)) ; SendMessage (g_hwndRichEdit, EM_REPLACESEL, FALSE, (LPARAM)TEXT("\n\n")) ; SendMessage (g_hwndRichEdit, EM_REPLACESEL, FALSE, (LPARAM)szBuffer) ; _tcscpy (szBuffer, STR_DEF(_ABOUT_LIBCLAMAV, g_szLibclamavLicense)) ; SendMessage (g_hwndRichEdit, EM_REPLACESEL, FALSE, (LPARAM)TEXT("\n\n")) ; SendMessage (g_hwndRichEdit, EM_REPLACESEL, FALSE, (LPARAM)szBuffer) ; if( Language_IsLoaded() ) { _tcscpy (szBuffer, STR(_ABOUT_SITE)) ; SendMessage (g_hwndRichEdit, EM_REPLACESEL, FALSE, (LPARAM)TEXT("\n\n")) ; SendMessage (g_hwndRichEdit, EM_REPLACESEL, FALSE, (LPARAM)szBuffer) ; } return 0 ; case WM_SIZE: MoveWindow (g_hwndRichEdit, CX_SPACE, CY_SPACE, LOWORD(lParam)-3*CX_SPACE-CX_BUTTON, HIWORD(lParam)-2*CY_SPACE, TRUE) ; MoveWindow (g_hbtnReadme, LOWORD(lParam)-2*CX_SPACE-CX_BUTTON, CY_SPACE, CX_BUTTON, CY_BUTTON, TRUE) ; MoveWindow (g_hbtnChangelog, LOWORD(lParam)-2*CX_SPACE-CX_BUTTON, 2*CY_SPACE+CY_BUTTON, CX_BUTTON, CY_BUTTON, TRUE) ; MoveWindow (g_hbtnFaq, LOWORD(lParam)-2*CX_SPACE-CX_BUTTON, 3*CY_SPACE+2*CY_BUTTON, CX_BUTTON, CY_BUTTON, TRUE) ; MoveWindow (g_hbtnLicense, LOWORD(lParam)-2*CX_SPACE-CX_BUTTON, 4*CY_SPACE+3*CY_BUTTON, CX_BUTTON, CY_BUTTON, TRUE) ; MoveWindow (g_hbtnDonation, LOWORD(lParam)-2*CX_SPACE-CX_BUTTON, 6*CY_SPACE+5*CY_BUTTON, CX_BUTTON, CY_BUTTON, TRUE) ; return 0 ; case WM_NOTIFY: { union { NMHDR *pnmh ; ENLINK *plink ; } nmu ; nmu.pnmh = (NMHDR*) lParam ; switch( nmu.pnmh->code ) { case EN_LINK: { TCHAR szBuffer[256] ; TEXTRANGE tr ; if( nmu.plink->msg!=WM_LBUTTONDOWN ) return 0 ; tr.lpstrText = szBuffer ; tr.chrg = nmu.plink->chrg ; SendMessage (g_hwndRichEdit, EM_GETTEXTRANGE, 0, (LPARAM)&tr) ; ShellExecute (hwnd, NULL, szBuffer, NULL, NULL, SW_SHOW) ; } return 0 ; } } return 0 ; // case WM_NOTIFY: case WM_COMMAND: switch( LOWORD(wParam) ) { case IDC_VIEW_README: _AboutWnd_GetAbsolutePath (szBuffer, NULL, g_szReadmeFileName) ; ShellExecute (hwnd, NULL, g_szNotepadExe, szBuffer, NULL, SW_SHOW) ; return 0 ; case IDC_VIEW_CHANGELOG: _AboutWnd_GetAbsolutePath (szBuffer, NULL, g_szChangeLogFileName) ; ShellExecute (hwnd, NULL, g_szNotepadExe, szBuffer, NULL, SW_SHOW) ; return 0 ; case IDC_VIEW_FAQ: _AboutWnd_GetAbsolutePath (szBuffer, NULL, g_szFaqFileName) ; ShellExecute (hwnd, NULL, g_szNotepadExe, szBuffer, NULL, SW_SHOW) ; return 0 ; case IDC_VIEW_LICENSE: if( Language_IsLoaded() ) _AboutWnd_GetAbsolutePath (szBuffer, g_szLanguageDir, STR(_LICENSE_FILE)) ; else _AboutWnd_GetAbsolutePath (szBuffer, NULL, g_szLicenseFileName) ; ShellExecute (hwnd, NULL, g_szNotepadExe, szBuffer, NULL, SW_SHOW) ; return 0 ; case IDC_MAKE_DONATION: ShellExecute (hwnd, NULL, TEXT(DONATION_PAGE), NULL, NULL, SW_SHOW) ; return 0 ; } break ; // case WM_COMMAND: } return DefWindowProc (hwnd, message, wParam, lParam) ; }
DWORD _SpySrv_Ask (PROCADDR nProcessAddress, UINT nDefReaction, PFILTCOND pCond) { TCHAR szProcess[MAX_PATH] = TEXT("???") ; UINT nProcessId ; int nResult ; TRACE ; // get process name { PROCSTRUCT * pProc ; ProcList_Lock () ; pProc = ProcList_Get (nProcessAddress) ; nProcessId = pProc->nProcessId ; if( pProc ) { wcslcpy (szProcess, pProc->szPath, MAX_PATH) ; } else { wsprintf (szProcess, TEXT("Process %d"), nProcessId) ; TRACE_WARNING (TEXT("Process %d not in list (addr=0x%08X\n"), nProcessId, nProcessAddress) ; } ProcList_Unlock () ; } Sounds_Play (SOUND_ASK) ; TRACE_INFO (TEXT(" /----ASK----\\\n")) ; askdlg: nResult = AskDlg_DialogBox (g_hInstance, g_hwndMain, szProcess, nProcessId, nDefReaction, pCond) ; if( nResult==ASKDLG_CREATEFILTER ) { FILTRULE * pRule ; // alloc new rule pRule = (FILTRULE*) calloc (1, sizeof(FILTRULE)) ; // fill params as they appear in the ask dialog pRule->nReaction = nDefReaction ; pRule->nVerbosity = RULE_LOG ; pRule->nOptions = 0 ; FiltCond_Dup (&pRule->condition, pCond) ; // show rule dialog if( IDOK!=RuleDlg_DialogBox (g_hInstance, g_hwndMain, szProcess, pRule, FALSE) ) { free (pRule) ; goto askdlg ; } // verify that this rule matches the current event if( ! FiltCond_Check(&pRule->condition,pCond) ) { MessageBox (g_hwndMain, STR_DEF(_RULE_DOESNT_MATCH, TEXT("The rule you defined doesn't match current event")), TEXT(APPLICATION_NAME), MB_ICONERROR) ; free (pRule) ; goto askdlg ; } SpySrv_AddRuleForProgram (pRule, szProcess) ; nResult = pRule->nReaction ; } if( nResult==ASKDLG_UNHOOK ) { SpySrv_IgnoreProcess (nProcessAddress, TRUE) ; nResult = RULE_ACCEPT ; } TRACE_INFO (TEXT(" \\----ASK-%d--/\n"), nResult) ; return nResult ; }
char *Str_rtrim(char *s) { if (STR_DEF(s)) for (size_t j = strlen(s) - 1; isspace(s[j]); j--) s[j] = 0; return s; }