ReactOS  0.4.12-dev-43-g63b00d8
evtdetctl.c File Reference
#include "eventvwr.h"
#include "evtdetctl.h"
#include <shellapi.h>
Include dependency graph for evtdetctl.c:

Go to the source code of this file.

Classes

struct  _DETAILDATA
 

Macros

#define EVENT_MESSAGE_EVENTTEXT_BUFFER   1024*10
 

Typedefs

typedef struct _DETAILDATA DETAILDATA
 
typedef struct _DETAILDATAPDETAILDATA
 

Functions

BOOL GetEventMessage (IN LPCWSTR KeyName, IN LPCWSTR SourceName, IN PEVENTLOGRECORD pevlr, OUT PWCHAR EventText)
 
static VOID DisplayEvent (HWND hDlg, PEVENTLOGFILTER EventLogFilter)
 
static UINT PrintByteDataLine (PWCHAR pBuffer, UINT uOffset, PBYTE pData, UINT uLength)
 
static UINT PrintWordDataLine (PWCHAR pBuffer, UINT uOffset, PULONG pData, UINT uLength)
 
static VOID DisplayEventData (HWND hDlg, BOOL bDisplayWords)
 
static HFONT CreateMonospaceFont (VOID)
 
static VOID CopyEventEntry (HWND hWnd)
 
static VOID OnLink (HWND hDlg, ENLINK *penLink)
 
static VOID OnScroll (HWND hDlg, PDETAILDATA pData, INT nBar, WORD sbCode)
 
static VOID OnSize (HWND hDlg, PDETAILDATA pData, INT cx, INT cy)
 
static VOID InitDetailsDlgCtrl (HWND hDlg, PDETAILDATA pData)
 
static INT_PTR CALLBACK EventDetailsCtrl (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
HWND CreateEventDetailsCtrl (HINSTANCE hInstance, HWND hParentWnd, LPARAM lParam)
 

Variables

HWND hwndListView
 

Macro Definition Documentation

◆ EVENT_MESSAGE_EVENTTEXT_BUFFER

#define EVENT_MESSAGE_EVENTTEXT_BUFFER   1024*10

Definition at line 17 of file evtdetctl.c.

Referenced by CopyEventEntry(), and DisplayEvent().

Typedef Documentation

◆ DETAILDATA

◆ PDETAILDATA

Function Documentation

◆ CopyEventEntry()

static VOID CopyEventEntry ( HWND  hWnd)
static

Definition at line 282 of file evtdetctl.c.

Referenced by EventDetailsCtrl().

283 {
284  WCHAR tmpHeader[512];
285  WCHAR szEventType[MAX_PATH];
287  WCHAR szCategory[MAX_PATH];
288  WCHAR szEventID[MAX_PATH];
291  WCHAR szUser[MAX_PATH];
292  WCHAR szComputer[MAX_PATH];
294  ULONG size = 0;
295  LPWSTR output;
296  HGLOBAL hMem;
297 
298  /* Try to open the clipboard */
299  if (!OpenClipboard(hWnd))
300  return;
301 
302  /* Get the formatted text needed to place the content into */
303  size += LoadStringW(hInst, IDS_COPY, tmpHeader, ARRAYSIZE(tmpHeader));
304 
305  /* Grab all the information and get it ready for the clipboard */
306  size += GetDlgItemTextW(hWnd, IDC_EVENTTYPESTATIC, szEventType, ARRAYSIZE(szEventType));
307  size += GetDlgItemTextW(hWnd, IDC_EVENTSOURCESTATIC, szSource, ARRAYSIZE(szSource));
308  size += GetDlgItemTextW(hWnd, IDC_EVENTCATEGORYSTATIC, szCategory, ARRAYSIZE(szCategory));
309  size += GetDlgItemTextW(hWnd, IDC_EVENTIDSTATIC, szEventID, ARRAYSIZE(szEventID));
310  size += GetDlgItemTextW(hWnd, IDC_EVENTDATESTATIC, szDate, ARRAYSIZE(szDate));
311  size += GetDlgItemTextW(hWnd, IDC_EVENTTIMESTATIC, szTime, ARRAYSIZE(szTime));
312  size += GetDlgItemTextW(hWnd, IDC_EVENTUSERSTATIC, szUser, ARRAYSIZE(szUser));
313  size += GetDlgItemTextW(hWnd, IDC_EVENTCOMPUTERSTATIC, szComputer, ARRAYSIZE(szComputer));
314  size += GetDlgItemTextW(hWnd, IDC_EVENTTEXTEDIT, evtDesc, ARRAYSIZE(evtDesc));
315 
316  size++; /* Null-termination */
317  size *= sizeof(WCHAR);
318 
319  /*
320  * Consolidate the information into one big piece and
321  * sort out the memory needed to write to the clipboard.
322  */
323  hMem = GlobalAlloc(GMEM_MOVEABLE, size);
324  if (hMem == NULL) goto Quit;
325 
326  output = GlobalLock(hMem);
327  if (output == NULL)
328  {
329  GlobalFree(hMem);
330  goto Quit;
331  }
332 
333  StringCbPrintfW(output, size,
334  tmpHeader, szEventType, szSource, szCategory, szEventID,
335  szDate, szTime, szUser, szComputer, evtDesc);
336 
337  GlobalUnlock(hMem);
338 
339  /* We succeeded, empty the clipboard and write the data in it */
340  EmptyClipboard();
342 
343 Quit:
344  /* Close the clipboard once we are done with it */
345  CloseClipboard();
346 }
#define IDC_EVENTDATESTATIC
Definition: resource.h:30
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2195
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
static UCHAR ULONG UCHAR ULONG UCHAR * output
Definition: bcrypt.c:29
TCHAR szTime[64]
Definition: solitaire.cpp:18
#define IDC_EVENTCATEGORYSTATIC
Definition: resource.h:33
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define IDC_EVENTSOURCESTATIC
Definition: resource.h:31
#define IDC_EVENTUSERSTATIC
Definition: resource.h:36
#define WCHAR
Definition: msvc.h:43
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
HANDLE WINAPI SetClipboardData(_In_ UINT, _In_opt_ HANDLE)
#define IDC_EVENTIDSTATIC
Definition: resource.h:35
#define CF_UNICODETEXT
Definition: constants.h:408
smooth NULL
Definition: ftsmooth.c:416
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
BOOL WINAPI EmptyClipboard(void)
Definition: ntwrapper.h:190
GLsizeiptr size
Definition: glext.h:5919
#define MAX_PATH
Definition: compat.h:26
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
BOOL WINAPI CloseClipboard(void)
Definition: ntwrapper.h:178
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
static const WCHAR szDate[]
Definition: http.c:99
static const WCHAR szSource[]
Definition: automation.c:501
#define IDC_EVENTTEXTEDIT
Definition: resource.h:41
#define IDC_EVENTCOMPUTERSTATIC
Definition: resource.h:37
#define IDC_EVENTTIMESTATIC
Definition: resource.h:32
HINSTANCE hInst
Definition: dxdiag.c:13
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
unsigned int ULONG
Definition: retypes.h:1
BOOL WINAPI OpenClipboard(_In_opt_ HWND)
#define IDC_EVENTTYPESTATIC
Definition: resource.h:34
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define GMEM_MOVEABLE
Definition: winbase.h:291
#define IDS_COPY
Definition: resource.h:120
#define EVENT_MESSAGE_EVENTTEXT_BUFFER
Definition: evtdetctl.c:17

◆ CreateEventDetailsCtrl()

HWND CreateEventDetailsCtrl ( HINSTANCE  hInstance,
HWND  hParentWnd,
LPARAM  lParam 
)

Definition at line 937 of file evtdetctl.c.

Referenced by EventDetails(), and InitInstance().

940 {
941  return CreateDialogParamW(hInstance,
943  hParentWnd, EventDetailsCtrl, lParam);
944 }
#define IDD_EVENTDETAILS_CTRL
Definition: resource.h:24
static INT_PTR CALLBACK EventDetailsCtrl(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: evtdetctl.c:783
HWND WINAPI CreateDialogParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
LPARAM lParam
Definition: combotst.c:139

◆ CreateMonospaceFont()

static HFONT CreateMonospaceFont ( VOID  )
static

Definition at line 261 of file evtdetctl.c.

Referenced by EventDetailsCtrl().

262 {
263  LOGFONTW tmpFont = {0};
264  HFONT hFont;
265  HDC hDC;
266 
267  hDC = GetDC(NULL);
268 
269  tmpFont.lfHeight = -MulDiv(8, GetDeviceCaps(hDC, LOGPIXELSY), 72);
270  tmpFont.lfWeight = FW_NORMAL;
271  wcscpy(tmpFont.lfFaceName, L"Courier New");
272 
273  hFont = CreateFontIndirectW(&tmpFont);
274 
275  ReleaseDC(NULL, hDC);
276 
277  return hFont;
278 }
#define HDC
Definition: msvc.h:22
HDC WINAPI GetDC(_In_opt_ HWND)
LONG lfHeight
Definition: dimm.idl:59
HFONT hFont
Definition: main.c:53
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
smooth NULL
Definition: ftsmooth.c:416
HFONT WINAPI CreateFontIndirectW(_In_ const LOGFONTW *)
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1087
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
static HDC hDC
Definition: 3dtext.c:33
#define FW_NORMAL
Definition: wingdi.h:371
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
#define LOGPIXELSY
Definition: wingdi.h:717
LONG lfWeight
Definition: dimm.idl:63
#define MulDiv(x, y, z)
Definition: gdifloat.h:86

◆ DisplayEvent()

static VOID DisplayEvent ( HWND  hDlg,
PEVENTLOGFILTER  EventLogFilter 
)
static

Definition at line 41 of file evtdetctl.c.

Referenced by EventDetailsCtrl().

42 {
43  WCHAR szEventType[MAX_PATH];
46  WCHAR szUser[MAX_PATH];
47  WCHAR szComputer[MAX_PATH];
49  WCHAR szCategory[MAX_PATH];
50  WCHAR szEventID[MAX_PATH];
52  BOOL bEventData = FALSE;
53  LVITEMW li;
54  PEVENTLOGRECORD pevlr;
55  int iIndex;
56 
57  /* Get index of selected item */
59  if (iIndex == -1)
60  {
61  MessageBoxW(hDlg,
62  L"No Items in ListView",
63  L"Error",
65  return;
66  }
67 
68  li.mask = LVIF_PARAM;
69  li.iItem = iIndex;
70  li.iSubItem = 0;
71 
73 
74  pevlr = (PEVENTLOGRECORD)li.lParam;
75 
76  ListView_GetItemText(hwndListView, iIndex, 0, szEventType, ARRAYSIZE(szEventType));
77  ListView_GetItemText(hwndListView, iIndex, 1, szDate, ARRAYSIZE(szDate));
78  ListView_GetItemText(hwndListView, iIndex, 2, szTime, ARRAYSIZE(szTime));
79  ListView_GetItemText(hwndListView, iIndex, 3, szSource, ARRAYSIZE(szSource));
80  ListView_GetItemText(hwndListView, iIndex, 4, szCategory, ARRAYSIZE(szCategory));
81  ListView_GetItemText(hwndListView, iIndex, 5, szEventID, ARRAYSIZE(szEventID));
82  ListView_GetItemText(hwndListView, iIndex, 6, szUser, ARRAYSIZE(szUser));
83  ListView_GetItemText(hwndListView, iIndex, 7, szComputer, ARRAYSIZE(szComputer));
84 
85  SetDlgItemTextW(hDlg, IDC_EVENTDATESTATIC, szDate);
86  SetDlgItemTextW(hDlg, IDC_EVENTTIMESTATIC, szTime);
87  SetDlgItemTextW(hDlg, IDC_EVENTUSERSTATIC, szUser);
88  SetDlgItemTextW(hDlg, IDC_EVENTSOURCESTATIC, szSource);
89  SetDlgItemTextW(hDlg, IDC_EVENTCOMPUTERSTATIC, szComputer);
90  SetDlgItemTextW(hDlg, IDC_EVENTCATEGORYSTATIC, szCategory);
91  SetDlgItemTextW(hDlg, IDC_EVENTIDSTATIC, szEventID);
92  SetDlgItemTextW(hDlg, IDC_EVENTTYPESTATIC, szEventType);
93 
94  bEventData = (pevlr->DataLength > 0);
95  EnableDlgItem(hDlg, IDC_BYTESRADIO, bEventData);
96  EnableDlgItem(hDlg, IDC_WORDRADIO, bEventData);
97 
98  // FIXME: At the moment we support only one event log in the filter
99  GetEventMessage(EventLogFilter->EventLogs[0]->LogName, szSource, pevlr, szEventText);
100  SetDlgItemTextW(hDlg, IDC_EVENTTEXTEDIT, szEventText);
101 }
#define IDC_WORDRADIO
Definition: resource.h:44
#define IDC_EVENTDATESTATIC
Definition: resource.h:30
#define ListView_GetNextItem(hwnd, i, flags)
Definition: commctrl.h:2404
PEVENTLOG EventLogs[ANYSIZE_ARRAY]
Definition: eventvwr.h:135
PWSTR LogName
Definition: eventvwr.h:90
TCHAR szTime[64]
Definition: solitaire.cpp:18
#define IDC_EVENTCATEGORYSTATIC
Definition: resource.h:33
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define ListView_GetItemText(hwndLV, i, iSubItem_, pszText_, cchTextMax_)
Definition: commctrl.h:2654
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define IDC_EVENTSOURCESTATIC
Definition: resource.h:31
#define LVNI_SELECTED
Definition: commctrl.h:2394
#define IDC_EVENTUSERSTATIC
Definition: resource.h:36
BOOL GetEventMessage(IN LPCWSTR KeyName, IN LPCWSTR SourceName, IN PEVENTLOGRECORD pevlr, OUT PWCHAR EventText)
Definition: eventvwr.c:1648
#define IDC_EVENTIDSTATIC
Definition: resource.h:35
HWND hwndListView
Definition: eventvwr.c:83
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
int iSubItem
Definition: commctrl.h:2332
LPARAM lParam
Definition: commctrl.h:2338
#define LVNI_FOCUSED
Definition: commctrl.h:2393
unsigned int BOOL
Definition: ntddk_ex.h:94
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
#define MAX_PATH
Definition: compat.h:26
UINT mask
Definition: commctrl.h:2330
#define MB_ICONINFORMATION
Definition: winuser.h:796
struct _EVENTLOGRECORD * PEVENTLOGRECORD
#define IDC_BYTESRADIO
Definition: resource.h:43
static const WCHAR L[]
Definition: oid.c:1087
static const WCHAR szDate[]
Definition: http.c:99
static const WCHAR szSource[]
Definition: automation.c:501
#define IDC_EVENTTEXTEDIT
Definition: resource.h:41
#define IDC_EVENTCOMPUTERSTATIC
Definition: resource.h:37
#define IDC_EVENTTIMESTATIC
Definition: resource.h:32
#define EnableDlgItem(hDlg, nID, bEnable)
Definition: eventvwr.h:52
#define MB_OK
Definition: winuser.h:784
#define ListView_GetItem(hwnd, pitem)
Definition: commctrl.h:2364
#define LVIF_PARAM
Definition: commctrl.h:2281
#define IDC_EVENTTYPESTATIC
Definition: resource.h:34
#define EVENT_MESSAGE_EVENTTEXT_BUFFER
Definition: evtdetctl.c:17

◆ DisplayEventData()

static VOID DisplayEventData ( HWND  hDlg,
BOOL  bDisplayWords 
)
static

Definition at line 184 of file evtdetctl.c.

Referenced by EventDetailsCtrl().

185 {
186  LVITEMW li;
187  PEVENTLOGRECORD pevlr;
188  int iIndex;
189 
190  LPBYTE pData;
191  UINT i, uOffset;
192  UINT uBufferSize, uLineLength;
193  PWCHAR pTextBuffer, pLine;
194 
195  /* Get index of selected item */
197  if (iIndex == -1)
198  {
199  MessageBoxW(hDlg,
200  L"No Items in ListView",
201  L"Error",
203  return;
204  }
205 
206  li.mask = LVIF_PARAM;
207  li.iItem = iIndex;
208  li.iSubItem = 0;
209 
211 
212  pevlr = (PEVENTLOGRECORD)li.lParam;
213  if (pevlr->DataLength == 0)
214  {
216  return;
217  }
218 
219  if (bDisplayWords)
220  uBufferSize = ((pevlr->DataLength / 8) + 1) * 26 * sizeof(WCHAR);
221  else
222  uBufferSize = ((pevlr->DataLength / 8) + 1) * 43 * sizeof(WCHAR);
223 
224  pTextBuffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, uBufferSize);
225  if (!pTextBuffer)
226  return;
227 
228  pLine = pTextBuffer;
229  uOffset = 0;
230 
231  for (i = 0; i < pevlr->DataLength / 8; i++)
232  {
233  pData = (LPBYTE)((LPBYTE)pevlr + pevlr->DataOffset + uOffset);
234 
235  if (bDisplayWords)
236  uLineLength = PrintWordDataLine(pLine, uOffset, (PULONG)pData, 8);
237  else
238  uLineLength = PrintByteDataLine(pLine, uOffset, pData, 8);
239  pLine = pLine + uLineLength;
240 
241  uOffset += 8;
242  }
243 
244  if (pevlr->DataLength % 8 != 0)
245  {
246  pData = (LPBYTE)((LPBYTE)pevlr + pevlr->DataOffset + uOffset);
247 
248  if (bDisplayWords)
249  PrintWordDataLine(pLine, uOffset, (PULONG)pData, pevlr->DataLength % 8);
250  else
251  PrintByteDataLine(pLine, uOffset, pData, pevlr->DataLength % 8);
252  }
253 
254  SetDlgItemTextW(hDlg, IDC_EVENTDATAEDIT, pTextBuffer);
255 
256  HeapFree(GetProcessHeap(), 0, pTextBuffer);
257 }
#define ListView_GetNextItem(hwnd, i, flags)
Definition: commctrl.h:2404
#define IDC_EVENTDATAEDIT
Definition: resource.h:45
#define LVNI_SELECTED
Definition: commctrl.h:2394
uint16_t * PWCHAR
Definition: typedefs.h:54
#define WCHAR
Definition: msvc.h:43
HWND hwndListView
Definition: eventvwr.c:83
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
GLenum GLclampf GLint i
Definition: glfuncs.h:14
unsigned char * LPBYTE
Definition: typedefs.h:52
static UINT PrintByteDataLine(PWCHAR pBuffer, UINT uOffset, PBYTE pData, UINT uLength)
Definition: evtdetctl.c:105
int iSubItem
Definition: commctrl.h:2332
LPARAM lParam
Definition: commctrl.h:2338
#define LVNI_FOCUSED
Definition: commctrl.h:2393
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
if(!(yy_init))
Definition: macro.lex.yy.c:717
unsigned int UINT
Definition: ndis.h:50
UINT mask
Definition: commctrl.h:2330
#define MB_ICONINFORMATION
Definition: winuser.h:796
struct _EVENTLOGRECORD * PEVENTLOGRECORD
static const WCHAR L[]
Definition: oid.c:1087
unsigned int * PULONG
Definition: retypes.h:1
#define MB_OK
Definition: winuser.h:784
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define ListView_GetItem(hwnd, pitem)
Definition: commctrl.h:2364
#define LVIF_PARAM
Definition: commctrl.h:2281
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
static UINT PrintWordDataLine(PWCHAR pBuffer, UINT uOffset, PULONG pData, UINT uLength)
Definition: evtdetctl.c:148
#define HeapFree(x, y, z)
Definition: compat.h:394

◆ EventDetailsCtrl()

static INT_PTR CALLBACK EventDetailsCtrl ( HWND  hDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 783 of file evtdetctl.c.

Referenced by CreateEventDetailsCtrl().

784 {
786 
787  pData = (PDETAILDATA)GetWindowLongPtrW(hDlg, DWLP_USER);
788 
789  switch (uMsg)
790  {
791  case WM_INITDIALOG:
792  {
793  RECT rect;
794 
795  pData = (PDETAILDATA)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pData));
796  if (!pData)
797  {
798  EndDialog(hDlg, 0);
799  return (INT_PTR)TRUE;
800  }
801  SetWindowLongPtrW(hDlg, DWLP_USER, (LONG_PTR)pData);
802 
804  pData->bDisplayWords = FALSE;
806 
807  GetClientRect(hDlg, &rect);
808  pData->cxOld = pData->cxMin = rect.right - rect.left;
809  pData->cyOld = pData->cyMin = rect.bottom - rect.top;
810  pData->scPos.x = pData->scPos.y = 0;
811 
812  InitDetailsDlgCtrl(hDlg, pData);
813 
814 #if 0
815  /* Show event info on dialog box */
816  DisplayEvent(hDlg, pData->EventLogFilter);
817  DisplayEventData(hDlg, pData->bDisplayWords);
818 #endif
819 
820  // OnSize(hDlg, pData, pData->cxOld, pData->cyOld);
821  return (INT_PTR)TRUE;
822  }
823 
824  case WM_DESTROY:
825  if (pData)
826  {
827  if (pData->hMonospaceFont)
829  HeapFree(GetProcessHeap(), 0, pData);
830  }
831  return (INT_PTR)TRUE;
832 
833  case EVT_SETFILTER:
835  return (INT_PTR)TRUE;
836 
837  case EVT_DISPLAY:
838  if (pData->EventLogFilter)
839  {
840  /* Show event info on dialog box */
841  DisplayEvent(hDlg, pData->EventLogFilter);
842  DisplayEventData(hDlg, pData->bDisplayWords);
843  }
844  return (INT_PTR)TRUE;
845 
846  case WM_COMMAND:
847  switch (LOWORD(wParam))
848  {
849  case IDC_PREVIOUS:
850  {
852 
853  /* Show event info on dialog box */
854  if (pData->EventLogFilter)
855  {
856  DisplayEvent(hDlg, pData->EventLogFilter);
857  DisplayEventData(hDlg, pData->bDisplayWords);
858  }
859  return (INT_PTR)TRUE;
860  }
861 
862  case IDC_NEXT:
863  {
865 
866  /* Show event info on dialog box */
867  if (pData->EventLogFilter)
868  {
869  DisplayEvent(hDlg, pData->EventLogFilter);
870  DisplayEventData(hDlg, pData->bDisplayWords);
871  }
872  return (INT_PTR)TRUE;
873  }
874 
875  case IDC_COPY:
876  if (pData->EventLogFilter)
877  CopyEventEntry(hDlg);
878  return (INT_PTR)TRUE;
879 
880  case IDC_BYTESRADIO:
881  if (pData->EventLogFilter)
882  {
883  pData->bDisplayWords = FALSE;
884  DisplayEventData(hDlg, pData->bDisplayWords);
885  }
886  return (INT_PTR)TRUE;
887 
888  case IDC_WORDRADIO:
889  if (pData->EventLogFilter)
890  {
891  pData->bDisplayWords = TRUE;
892  DisplayEventData(hDlg, pData->bDisplayWords);
893  }
894  return (INT_PTR)TRUE;
895 
896  default:
897  break;
898  }
899  break;
900 
901  case WM_NOTIFY:
902  {
904 
905  if (hdr->idFrom == IDC_EVENTTEXTEDIT)
906  {
907  switch (hdr->code)
908  {
909  case EN_LINK:
910  OnLink(hDlg, (ENLINK*)lParam);
911  break;
912  }
913  }
914  break;
915  }
916 
917  case WM_HSCROLL:
918  OnScroll(hDlg, pData, SB_HORZ, LOWORD(wParam));
920  return (INT_PTR)TRUE;
921 
922  case WM_VSCROLL:
923  OnScroll(hDlg, pData, SB_VERT, LOWORD(wParam));
925  return (INT_PTR)TRUE;
926 
927  case WM_SIZE:
928  OnSize(hDlg, pData, LOWORD(lParam), HIWORD(lParam));
930  return (INT_PTR)TRUE;
931  }
932 
933  return (INT_PTR)FALSE;
934 }
#define IDC_WORDRADIO
Definition: resource.h:44
#define TRUE
Definition: types.h:120
char hdr[14]
Definition: iptest.cpp:33
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
#define SB_VERT
Definition: winuser.h:553
#define SB_HORZ
Definition: winuser.h:552
BOOL bDisplayWords
Definition: evtdetctl.c:30
LONG top
Definition: windef.h:297
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define IDC_NEXT
Definition: fontview.h:17
#define VK_DOWN
Definition: winuser.h:2181
#define IDC_PREVIOUS
Definition: resource.h:38
#define GetWindowLongPtrW
Definition: winuser.h:4698
LONG left
Definition: windef.h:296
int32_t INT_PTR
Definition: typedefs.h:62
HFONT hMonospaceFont
Definition: evtdetctl.c:31
LONG right
Definition: windef.h:298
& rect
Definition: startmenu.cpp:1413
WPARAM wParam
Definition: combotst.c:138
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
#define DWLP_MSGRESULT
Definition: winuser.h:864
struct tagNMHDR * LPNMHDR
HWND hwndListView
Definition: eventvwr.c:83
#define EVT_DISPLAY
Definition: evtdetctl.h:15
UINT code
Definition: winuser.h:3112
static VOID CopyEventEntry(HWND hWnd)
Definition: evtdetctl.c:282
#define VK_UP
Definition: winuser.h:2179
struct _DETAILDATA * PDETAILDATA
UINT_PTR idFrom
Definition: winuser.h:3111
PEVENTLOGFILTER EventLogFilter
Definition: evtdetctl.c:28
#define EVT_SETFILTER
Definition: evtdetctl.h:14
static HFONT CreateMonospaceFont(VOID)
Definition: evtdetctl.c:261
POINT scPos
Definition: evtdetctl.c:35
#define WM_KEYDOWN
Definition: winuser.h:1691
#define WM_DESTROY
Definition: winuser.h:1591
struct _EVENTLOGFILTER * PEVENTLOGFILTER
static VOID OnSize(HWND hDlg, PDETAILDATA pData, INT cx, INT cy)
Definition: evtdetctl.c:484
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static VOID InitDetailsDlgCtrl(HWND hDlg, PDETAILDATA pData)
Definition: evtdetctl.c:747
#define WM_SIZE
Definition: winuser.h:1593
#define IDC_COPY
Definition: resource.h:17
#define IDC_BYTESRADIO
Definition: resource.h:43
#define DWLP_USER
Definition: winuser.h:866
#define IDC_EVENTTEXTEDIT
Definition: resource.h:41
static VOID OnScroll(HWND hDlg, PDETAILDATA pData, INT nBar, WORD sbCode)
Definition: evtdetctl.c:388
#define WM_COMMAND
Definition: winuser.h:1716
static VOID DisplayEvent(HWND hDlg, PEVENTLOGFILTER EventLogFilter)
Definition: evtdetctl.c:41
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define EN_LINK
Definition: richedit.h:202
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
static VOID DisplayEventData(HWND hDlg, BOOL bDisplayWords)
Definition: evtdetctl.c:184
#define WM_HSCROLL
Definition: winuser.h:1719
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
static VOID OnLink(HWND hDlg, ENLINK *penLink)
Definition: evtdetctl.c:350
#define HIWORD(l)
Definition: typedefs.h:246
LONG bottom
Definition: windef.h:299
#define SetWindowLongPtrW
Definition: winuser.h:5215
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define HeapFree(x, y, z)
Definition: compat.h:394
#define WM_NOTIFY
Definition: richedit.h:61
#define WM_VSCROLL
Definition: winuser.h:1720

◆ GetEventMessage()

BOOL GetEventMessage ( IN LPCWSTR  KeyName,
IN LPCWSTR  SourceName,
IN PEVENTLOGRECORD  pevlr,
OUT PWCHAR  EventText 
)

Definition at line 1648 of file eventvwr.c.

Referenced by DisplayEvent().

1652 {
1653  BOOL Success = FALSE;
1654  DWORD i;
1655  size_t cch;
1656  WCHAR SourceModuleName[1024];
1657  WCHAR ParameterModuleName[1024];
1658  BOOL IsParamModNameCached = FALSE;
1659  LPWSTR lpMsgBuf = NULL;
1660  LPWSTR szStringArray, szMessage;
1661  LPWSTR *szArguments;
1662 
1663  /* Get the event string array */
1664  szStringArray = (LPWSTR)((LPBYTE)pevlr + pevlr->StringOffset);
1665 
1666  /* NOTE: GetEventMessageFileDLL can return a comma-separated list of DLLs */
1667  if (!GetEventMessageFileDLL(KeyName, SourceName, EVENT_MESSAGE_FILE, SourceModuleName))
1668  goto Quit;
1669 
1670  /* Allocate space for insertion strings */
1671  szArguments = HeapAlloc(GetProcessHeap(), 0, pevlr->NumStrings * sizeof(LPVOID));
1672  if (!szArguments)
1673  goto Quit;
1674 
1675  if (!IsParamModNameCached)
1676  {
1677  /* Now that the parameter file list is loaded, no need to reload it at the next run! */
1678  IsParamModNameCached = GetEventMessageFileDLL(KeyName, SourceName, EVENT_PARAMETER_MESSAGE_FILE, ParameterModuleName);
1679  // FIXME: If the string loading failed the first time, no need to retry it just after???
1680  }
1681 
1682  if (IsParamModNameCached)
1683  {
1684  /* Not yet support for reading messages from parameter message DLL */
1685  }
1686 
1687  szMessage = szStringArray;
1688  /*
1689  * HACK:
1690  * We do some hackish preformatting of the cached event strings...
1691  * That's because after we pass the string to FormatMessage
1692  * (via GetMessageStringFromDllList) with the FORMAT_MESSAGE_ARGUMENT_ARRAY
1693  * flag, instead of ignoring the insertion parameters and do the formatting
1694  * by ourselves. Therefore, the resulting string should have the parameter
1695  * string placeholders starting with a single '%' instead of a mix of one
1696  * and two '%'.
1697  */
1698  /* HACK part 1: Compute the full length of the string array */
1699  cch = 0;
1700  for (i = 0; i < pevlr->NumStrings; i++)
1701  {
1702  szMessage += wcslen(szMessage) + 1;
1703  }
1704  cch = szMessage - szStringArray;
1705 
1706  /* HACK part 2: Now do the HACK proper! */
1707  szMessage = szStringArray;
1708  for (i = 0; i < pevlr->NumStrings; i++)
1709  {
1710  lpMsgBuf = szMessage;
1711  while ((lpMsgBuf = wcsstr(lpMsgBuf, L"%%")))
1712  {
1713  if (iswdigit(lpMsgBuf[2]))
1714  {
1715  RtlMoveMemory(lpMsgBuf, lpMsgBuf+1, ((szStringArray + cch) - lpMsgBuf - 1) * sizeof(WCHAR));
1716  }
1717  }
1718 
1719  szArguments[i] = szMessage;
1720  szMessage += wcslen(szMessage) + 1;
1721  }
1722 
1723  /* Retrieve the message string without appending extra newlines */
1724  lpMsgBuf =
1725  GetMessageStringFromDllList(SourceModuleName,
1728  pevlr->EventID,
1729  0,
1730  (va_list*)szArguments);
1731  if (lpMsgBuf)
1732  {
1733  /* Trim the string */
1734  TrimNulls(lpMsgBuf);
1735 
1736  szMessage = NULL;
1737  Success = (ApplyParameterStringsToMessage(ParameterModuleName,
1738  TRUE,
1739  lpMsgBuf,
1740  &szMessage) == ERROR_SUCCESS);
1741  if (Success && szMessage)
1742  {
1743  /* Free the buffer allocated by FormatMessage */
1744  LocalFree(lpMsgBuf);
1745  lpMsgBuf = szMessage;
1746  }
1747 
1748  /* Copy the event text */
1749  StringCchCopyW(EventText, EVENT_MESSAGE_EVENTTEXT_BUFFER, lpMsgBuf);
1750 
1751  /* Free the buffer allocated by FormatMessage */
1752  LocalFree(lpMsgBuf);
1753  }
1754 
1755  HeapFree(GetProcessHeap(), 0, szArguments);
1756 
1757 Quit:
1758  if (!Success)
1759  {
1760  /* Get a read-only pointer to the "event-not-found" string */
1761  lpMsgBuf = HeapAlloc(GetProcessHeap(), 0, EVENT_MESSAGE_EVENTTEXT_BUFFER * sizeof(WCHAR));
1763  StringCchPrintfW(EventText, EVENT_MESSAGE_EVENTTEXT_BUFFER, lpMsgBuf, (pevlr->EventID & 0xFFFF), SourceName);
1764 
1765  /* Append the strings */
1766  szMessage = szStringArray;
1767  for (i = 0; i < pevlr->NumStrings; i++)
1768  {
1769  StringCchCatW(EventText, EVENT_MESSAGE_EVENTTEXT_BUFFER, szMessage);
1771  szMessage += wcslen(szMessage) + 1;
1772  }
1773  }
1774 
1775  return Success;
1776 }
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING KeyName
Definition: ndis.h:4693
void TrimNulls(LPWSTR s)
Definition: eventvwr.c:1450
#define TRUE
Definition: types.h:120
#define FORMAT_MESSAGE_MAX_WIDTH_MASK
Definition: winbase.h:406
#define ERROR_SUCCESS
Definition: deptool.c:10
__wchar_t WCHAR
Definition: xmlstorage.h:180
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
#define FORMAT_MESSAGE_ARGUMENT_ARRAY
Definition: winbase.h:405
#define iswdigit(_c)
Definition: ctype.h:667
#define EVENT_PARAMETER_MESSAGE_FILE
Definition: eventvwr.c:58
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
HINSTANCE hInst
Definition: eventvwr.c:65
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
GLenum GLclampf GLint i
Definition: glfuncs.h:14
unsigned char * LPBYTE
Definition: typedefs.h:52
DWORD ApplyParameterStringsToMessage(IN LPCWSTR lpMessageDllList, IN BOOL bMessagePreFormatted, IN CONST LPCWSTR pMessage, OUT LPWSTR *pFinalMessage)
Definition: eventvwr.c:916
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:400
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:201
smooth NULL
Definition: ftsmooth.c:416
char * va_list
Definition: acmsvcex.h:78
#define FORMAT_MESSAGE_FROM_HMODULE
Definition: winbase.h:403
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1087
#define EVENT_MESSAGE_EVENTTEXT_BUFFER
Definition: eventvwr.c:53
#define IDS_EVENTSTRINGIDNOTFOUND
Definition: resource.h:96
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define EVENT_MESSAGE_FILE
Definition: eventvwr.c:57
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
WCHAR SourceName[256]
Definition: arping.c:28
BOOL GetEventMessageFileDLL(IN LPCWSTR lpLogName, IN LPCWSTR SourceName, IN LPCWSTR EntryName, OUT PWCHAR lpModuleName)
Definition: eventvwr.c:1537
WCHAR * LPWSTR
Definition: xmlstorage.h:184
LPWSTR GetMessageStringFromDllList(IN LPCWSTR lpMessageDllList, IN DWORD dwFlags, IN DWORD dwMessageId, IN DWORD nSize, IN va_list *Arguments OPTIONAL)
Definition: eventvwr.c:855
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:394

◆ InitDetailsDlgCtrl()

static VOID InitDetailsDlgCtrl ( HWND  hDlg,
PDETAILDATA  pData 
)
static

Definition at line 747 of file evtdetctl.c.

Referenced by EventDetailsCtrl().

748 {
749  DWORD dwMask;
750 
754 
756  SendDlgItemMessageW(hDlg, IDC_PREVIOUS, BM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)prevIcon);
757  SendDlgItemMessageW(hDlg, IDC_COPY, BM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)copyIcon);
758 
759  /* Set the default read-only RichEdit color */
761 
762  /* Enable RichEdit coloured and underlined links */
765 
766  /*
767  * Activate automatic URL recognition by the RichEdit control. For more information, see:
768  * https://blogs.msdn.microsoft.com/murrays/2009/08/31/automatic-richedit-hyperlinks/
769  * https://blogs.msdn.microsoft.com/murrays/2009/09/24/richedit-friendly-name-hyperlinks/
770  * https://msdn.microsoft.com/en-us/library/windows/desktop/bb787991(v=vs.85).aspx
771  */
772  SendDlgItemMessageW(hDlg, IDC_EVENTTEXTEDIT, EM_AUTOURLDETECT, AURL_ENABLEURL /* | AURL_ENABLEEAURLS */, 0);
773 
774  /* Note that the RichEdit control never gets themed under WinXP+; one would have to write code to simulate Edit-control theming */
775 
778 }
#define IDC_WORDRADIO
Definition: resource.h:44
#define TRUE
Definition: types.h:120
#define IMAGE_ICON
Definition: winuser.h:212
#define EM_GETEVENTMASK
Definition: richedit.h:92
#define ENM_MOUSEEVENTS
Definition: richedit.h:476
#define IDC_EVENTDATAEDIT
Definition: resource.h:45
DWORD dwMask
Definition: msvc.h:86
BOOL bDisplayWords
Definition: evtdetctl.c:30
#define IDC_NEXT
Definition: fontview.h:17
#define IDI_PREV
Definition: resource.h:14
#define IDC_PREVIOUS
Definition: resource.h:38
HFONT hMonospaceFont
Definition: evtdetctl.c:31
#define BM_SETIMAGE
Definition: winuser.h:1883
DWORD WINAPI GetSysColor(_In_ int)
UINT_PTR WPARAM
Definition: windef.h:207
#define ENM_LINK
Definition: richedit.h:485
#define COLOR_3DFACE
Definition: winuser.h:919
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:2172
LONG_PTR LPARAM
Definition: windef.h:208
#define IDI_NEXT
Definition: resource.h:13
#define EM_SETBKGNDCOLOR
Definition: richedit.h:100
#define EM_SETEVENTMASK
Definition: richedit.h:102
#define EM_AUTOURLDETECT
Definition: richedit.h:125
#define BM_SETCHECK
Definition: winuser.h:1882
#define IDC_COPY
Definition: resource.h:17
unsigned long DWORD
Definition: ntddk_ex.h:95
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define IDC_BYTESRADIO
Definition: resource.h:43
#define IDC_EVENTTEXTEDIT
Definition: resource.h:41
HINSTANCE hInst
Definition: dxdiag.c:13
#define WM_SETFONT
Definition: winuser.h:1632
#define BST_CHECKED
Definition: winuser.h:197
#define IDI_COPY
Definition: resource.h:15
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define AURL_ENABLEURL
Definition: eventvwr.h:41
#define LR_DEFAULTCOLOR
Definition: winuser.h:1077

◆ OnLink()

static VOID OnLink ( HWND  hDlg,
ENLINK penLink 
)
static

Definition at line 350 of file evtdetctl.c.

Referenced by EventDetailsCtrl(), and CMainWindow::ProcessWindowMessage().

351 {
352  LPWSTR pLink;
353  TEXTRANGE txtRange;
354 
355  ASSERT(penLink->nmhdr.idFrom == IDC_EVENTTEXTEDIT);
356 
357  /* Only act on left button up events */
358  if (penLink->msg != WM_LBUTTONUP)
359  return;
360 
361  /* If the range is empty, do nothing */
362  if (penLink->chrg.cpMin == penLink->chrg.cpMax)
363  return;
364 
365  /* Allocate memory for the text link */
367  (max(penLink->chrg.cpMin, penLink->chrg.cpMax) -
368  min(penLink->chrg.cpMin, penLink->chrg.cpMax) + 1) * sizeof(WCHAR));
369  if (!pLink)
370  {
371  /* Not enough memory, bail out */
372  return;
373  }
374 
375  txtRange.chrg = penLink->chrg;
376  txtRange.lpstrText = pLink;
378 
379  /* Open the link */
380  ShellExecuteW(hDlg, L"open", pLink, NULL, NULL, SW_SHOWNOACTIVATE);
381 
382  /* Free the buffer */
383  HeapFree(GetProcessHeap(), 0, pLink);
384 }
#define max(a, b)
Definition: svc.c:63
#define SW_SHOWNOACTIVATE
Definition: winuser.h:768
#define EM_GETTEXTRANGE
Definition: richedit.h:108
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG cpMax
Definition: richedit.h:501
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR idFrom
Definition: winuser.h:3111
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static const WCHAR L[]
Definition: oid.c:1087
#define IDC_EVENTTEXTEDIT
Definition: resource.h:41
#define WM_LBUTTONUP
Definition: winuser.h:1753
#define min(a, b)
Definition: monoChain.cc:55
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
Definition: shlexec.cpp:2236
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:394
LONG cpMin
Definition: richedit.h:500

◆ OnScroll()

static VOID OnScroll ( HWND  hDlg,
PDETAILDATA  pData,
INT  nBar,
WORD  sbCode 
)
static

Definition at line 388 of file evtdetctl.c.

Referenced by EventDetailsCtrl().

389 {
390  RECT rect;
391 
392  SCROLLINFO sInfo;
393  INT oldPos, Maximum;
394  PLONG pOriginXY;
395 
396  ASSERT(nBar == SB_HORZ || nBar == SB_VERT);
397 
398  GetClientRect(hDlg, &rect);
399 
400  if (nBar == SB_HORZ)
401  {
402  Maximum = pData->cxMin - (rect.right-rect.left) /* pData->cxOld */;
403  pOriginXY = &pData->scPos.x;
404  }
405  else // if (nBar == SB_VERT)
406  {
407  Maximum = pData->cyMin - (rect.bottom-rect.top) /* pData->cyOld */;
408  pOriginXY = &pData->scPos.y;
409  }
410 
411  /* Set scrollbar sizes */
412  sInfo.cbSize = sizeof(sInfo);
414 
415  if (!GetScrollInfo(hDlg, nBar, &sInfo))
416  return;
417 
418  oldPos = sInfo.nPos;
419 
420  switch (sbCode)
421  {
422  case SB_LINEUP: // SB_LINELEFT:
423  sInfo.nPos--;
424  break;
425 
426  case SB_LINEDOWN: // SB_LINERIGHT:
427  sInfo.nPos++;
428  break;
429 
430  case SB_PAGEUP: // SB_PAGELEFT:
431  sInfo.nPos -= sInfo.nPage;
432  break;
433 
434  case SB_PAGEDOWN: // SB_PAGERIGHT:
435  sInfo.nPos += sInfo.nPage;
436  break;
437 
438  case SB_THUMBTRACK:
439  sInfo.nPos = sInfo.nTrackPos;
440  break;
441 
442  case SB_THUMBPOSITION:
443  sInfo.nPos = sInfo.nTrackPos;
444  break;
445 
446  case SB_TOP: // SB_LEFT:
447  sInfo.nPos = sInfo.nMin;
448  break;
449 
450  case SB_BOTTOM: // SB_RIGHT:
451  sInfo.nPos = sInfo.nMax;
452  break;
453 
454  default:
455  break;
456  }
457 
458  sInfo.nPos = min(max(sInfo.nPos, 0), Maximum);
459 
460  if (oldPos != sInfo.nPos)
461  {
462  POINT scOldPos = pData->scPos;
463 
464  /* We now modify pData->scPos */
465  *pOriginXY = sInfo.nPos;
466 
467  ScrollWindowEx(hDlg,
468  (scOldPos.x - pData->scPos.x),
469  (scOldPos.y - pData->scPos.y),
470  NULL,
471  NULL,
472  NULL,
473  NULL,
475 
476  sInfo.fMask = SIF_POS;
477  SetScrollInfo(hDlg, nBar, &sInfo, TRUE);
478 
479  // UpdateWindow(hDlg);
480  }
481 }
#define SB_PAGEDOWN
Definition: winuser.h:569
#define SB_PAGEUP
Definition: winuser.h:568
#define max(a, b)
Definition: svc.c:63
#define TRUE
Definition: types.h:120
#define SIF_RANGE
Definition: winuser.h:1221
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
#define SB_VERT
Definition: winuser.h:553
#define SB_HORZ
Definition: winuser.h:552
LONG top
Definition: windef.h:297
LONG left
Definition: windef.h:296
LONG right
Definition: windef.h:298
int32_t INT
Definition: typedefs.h:56
#define SIF_PAGE
Definition: winuser.h:1219
& rect
Definition: startmenu.cpp:1413
#define SW_ERASE
Definition: winuser.h:2534
smooth NULL
Definition: ftsmooth.c:416
POINT scPos
Definition: evtdetctl.c:35
#define SB_THUMBPOSITION
Definition: winuser.h:572
int WINAPI ScrollWindowEx(_In_ HWND, _In_ int, _In_ int, _In_opt_ LPCRECT, _In_opt_ LPCRECT, _In_opt_ HRGN, _Out_opt_ LPRECT, _In_ UINT)
#define SB_THUMBTRACK
Definition: winuser.h:573
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
BOOL WINAPI GetScrollInfo(_In_ HWND, _In_ int, _Inout_ LPSCROLLINFO)
#define SW_INVALIDATE
Definition: winuser.h:2533
#define SIF_POS
Definition: winuser.h:1220
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define SB_TOP
Definition: winuser.h:578
#define SIF_TRACKPOS
Definition: winuser.h:1223
#define min(a, b)
Definition: monoChain.cc:55
#define SB_LINEDOWN
Definition: winuser.h:565
#define SB_LINEUP
Definition: winuser.h:564
#define SB_BOTTOM
Definition: winuser.h:577
#define SW_SCROLLCHILDREN
Definition: winuser.h:2532
LONG bottom
Definition: windef.h:299
signed int * PLONG
Definition: retypes.h:5
int WINAPI SetScrollInfo(_In_ HWND, _In_ int, _In_ LPCSCROLLINFO, _In_ BOOL)

◆ OnSize()

static VOID OnSize ( HWND  hDlg,
PDETAILDATA  pData,
INT  cx,
INT  cy 
)
static

y += (cy - pData->cyOld) / 2 ; // + (cy - pData->cyOld) % 2;

SWP_NOMOVE |

Definition at line 484 of file evtdetctl.c.

Referenced by CSysPagerWnd::ContextSensitiveHelp(), CTaskSwitchWnd::ContextSensitiveHelp(), EventDetailsCtrl(), CGridView::GetHwnd(), CShellBrowser::GetWindowProc(), and CMainWindow::ProcessWindowMessage().

485 {
486  LONG_PTR dwStyle;
487  INT sbVXSize, sbHYSize;
488  SCROLLINFO sInfo;
489  POINT scOldPos;
490  HDWP hdwp;
491  HWND hItemWnd;
492  RECT rect;
493  INT y = 0;
494 
495  if (!pData)
496  return;
497 
498  dwStyle = GetWindowLongPtrW(hDlg, GWL_STYLE);
499  sbVXSize = GetSystemMetrics(SM_CXVSCROLL);
500  sbHYSize = GetSystemMetrics(SM_CYHSCROLL);
501 
502  /* Compensate for existing scroll bars (because lParam values do not accommodate scroll bar) */
503  if (dwStyle & WS_HSCROLL) cy += sbHYSize; // Window currently has a horizontal scrollbar
504  if (dwStyle & WS_VSCROLL) cx += sbVXSize; // Window currently has a vertical scrollbar
505 
506  /* Compensate for added scroll bars in window */
507  if (cx < pData->cxMin) cy -= sbHYSize; // Window will have a horizontal scroll bar
508  if (cy < pData->cyMin) cx -= sbVXSize; // Window will have a vertical scroll bar
509 
510  /* Set scrollbar sizes */
511  sInfo.cbSize = sizeof(sInfo);
512 
513  sInfo.fMask = SIF_POS;
514  if (GetScrollInfo(hDlg, SB_VERT, &sInfo))
515  scOldPos.y = sInfo.nPos;
516  else
517  scOldPos.y = pData->scPos.y;
518 
519  sInfo.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
520  sInfo.nMin = 0;
521  if (pData->cyMin > cy)
522  {
523  sInfo.nMax = pData->cyMin - 1;
524  sInfo.nPage = cy;
525  sInfo.nPos = pData->scPos.y;
526  SetScrollInfo(hDlg, SB_VERT, &sInfo, TRUE);
527 
528  /* Display the scrollbar if needed */
529  if (!(dwStyle & WS_VSCROLL))
530  ShowScrollBar(hDlg, SB_VERT, TRUE);
531  }
532  else
533  {
534  scOldPos.y = 0;
535 
536  sInfo.nMax = pData->cyMin - 1;
537  sInfo.nPage = cy;
538  sInfo.nPos = pData->scPos.y;
539  sInfo.nPos = scOldPos.y;
540  SetScrollInfo(hDlg, SB_VERT, &sInfo, TRUE);
541 
542  ShowScrollBar(hDlg, SB_VERT, FALSE);
543 
544  rect.left = cx - sbVXSize;
545  rect.right = cx;
546  rect.top = 0;
547  rect.bottom = cy;
548  InvalidateRect(hDlg, &rect, TRUE);
549  }
550 
551  sInfo.fMask = SIF_POS;
552  if (GetScrollInfo(hDlg, SB_HORZ, &sInfo))
553  scOldPos.x = sInfo.nPos;
554  else
555  scOldPos.x = pData->scPos.x;
556 
557  sInfo.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
558  sInfo.nMin = 0;
559  if (pData->cxMin > cx)
560  {
561  sInfo.nMax = pData->cxMin - 1;
562  sInfo.nPage = cx;
563  sInfo.nPos = pData->scPos.x;
564  SetScrollInfo(hDlg, SB_HORZ, &sInfo, TRUE);
565 
566  /* Display the scrollbar if needed */
567  if (!(dwStyle & WS_HSCROLL))
568  ShowScrollBar(hDlg, SB_HORZ, TRUE);
569  }
570  else
571  {
572  scOldPos.x = 0;
573 
574  sInfo.nMax = pData->cxMin - 1;
575  sInfo.nPage = cx;
576  sInfo.nPos = pData->scPos.x;
577  sInfo.nPos = scOldPos.x;
578  SetScrollInfo(hDlg, SB_HORZ, &sInfo, TRUE);
579 
580  ShowScrollBar(hDlg, SB_HORZ, FALSE);
581 
582  rect.left = 0;
583  rect.right = cx;
584  rect.top = cy - sbHYSize;
585  rect.bottom = cy;
586  InvalidateRect(hDlg, &rect, TRUE);
587  }
588 
589  if ((scOldPos.x != pData->scPos.x) || (scOldPos.y != pData->scPos.y))
590  {
591  ScrollWindowEx(hDlg,
592  // (scOldPos.x - pData->scPos.x),
593  (pData->scPos.x - scOldPos.x),
594  // (scOldPos.y - pData->scPos.y),
595  (pData->scPos.y - scOldPos.y),
596  NULL,
597  NULL,
598  NULL,
599  NULL,
601 
602  pData->scPos = scOldPos;
603  }
604 
605  // /* Adjust the start of the visible area if we are attempting to show nonexistent areas */
606  // if ((pData->cxMin - pData->scPos.x) < cx) pData->scPos.x = pData->cxMin - cx;
607  // if ((pData->cyMin - pData->scPos.y) < cy) pData->scPos.y = pData->cyMin - cy;
608  // // InvalidateRect(GuiData->hWindow, NULL, TRUE);
609 
610  /* Forbid resizing the control smaller than its minimal size */
611  if (cx < pData->cxMin) cx = pData->cxMin;
612  if (cy < pData->cyMin) cy = pData->cyMin;
613 
614  if ((cx != pData->cxOld) || (cy != pData->cyOld))
615  {
616  hdwp = BeginDeferWindowPos(8);
617 
618  /* Move the edit boxes */
619 
620  GetWindowRect(hDlg, &rect);
621 
622  hItemWnd = GetDlgItem(hDlg, IDC_EVENTTEXTEDIT);
623  GetWindowRect(hItemWnd, &rect);
624  MapWindowPoints(HWND_DESKTOP /*NULL*/, hDlg, (LPPOINT)&rect, sizeof(RECT)/sizeof(POINT));
625  // OffsetRect(&rect, 0, y);
626  // y += (cy - pData->cyOld) / 2 ; // + (cy - pData->cyOld) % 2;
628  if (cy >= pData->cyOld)
629  y += (cy - pData->cyOld) / 2 + (cy - pData->cyOld) % 2;
630  else
631  y -= (pData->cyOld - cy) / 2 + (pData->cyOld - cy) % 2;
632 
633  if (hdwp)
634  hdwp = DeferWindowPos(hdwp,
635  hItemWnd,
636  0,
637  rect.left, rect.top,
638  (rect.right - rect.left) + (cx - pData->cxOld),
639  (rect.bottom - rect.top) + y, SWP_NOZORDER | SWP_NOACTIVATE);
641 
642  hItemWnd = GetDlgItem(hDlg, IDC_DETAILS_STATIC);
643  GetWindowRect(hItemWnd, &rect);
644  MapWindowPoints(HWND_DESKTOP /*NULL*/, hDlg, (LPPOINT)&rect, sizeof(RECT)/sizeof(POINT));
645  // OffsetRect(&rect, 0, y);
646 
647  if (hdwp)
648  hdwp = DeferWindowPos(hdwp,
649  hItemWnd,
650  0,
651  rect.left, rect.top + y,
652  0, 0,
654 
655  hItemWnd = GetDlgItem(hDlg, IDC_BYTESRADIO);
656  GetWindowRect(hItemWnd, &rect);
657  MapWindowPoints(HWND_DESKTOP /*NULL*/, hDlg, (LPPOINT)&rect, sizeof(RECT)/sizeof(POINT));
658  // OffsetRect(&rect, 0, y);
659 
660  if (hdwp)
661  hdwp = DeferWindowPos(hdwp,
662  hItemWnd,
663  0,
664  rect.left, rect.top + y,
665  0, 0,
667 
668  hItemWnd = GetDlgItem(hDlg, IDC_WORDRADIO);
669  GetWindowRect(hItemWnd, &rect);
670  MapWindowPoints(HWND_DESKTOP /*NULL*/, hDlg, (LPPOINT)&rect, sizeof(RECT)/sizeof(POINT));
671  // OffsetRect(&rect, 0, y);
672 
673  if (hdwp)
674  hdwp = DeferWindowPos(hdwp,
675  hItemWnd,
676  0,
677  rect.left, rect.top + y,
678  0, 0,
680 
681  hItemWnd = GetDlgItem(hDlg, IDC_EVENTDATAEDIT);
682  GetWindowRect(hItemWnd, &rect);
683  MapWindowPoints(HWND_DESKTOP /*NULL*/, hDlg, (LPPOINT)&rect, sizeof(RECT)/sizeof(POINT));
684  // OffsetRect(&rect, 0, y);
685  // // y -= (cy - pData->cyOld) % 2;
686 
687  if (hdwp)
688  hdwp = DeferWindowPos(hdwp,
689  hItemWnd,
690  0,
691  rect.left, rect.top + y,
692  (rect.right - rect.left) + (cx - pData->cxOld),
693  (rect.bottom - rect.top) + y,
695 
696  /* Move the buttons */
697 
698  hItemWnd = GetDlgItem(hDlg, IDC_PREVIOUS);
699  GetWindowRect(hItemWnd, &rect);
700  MapWindowPoints(HWND_DESKTOP /*NULL*/, hDlg, (LPPOINT)&rect, sizeof(RECT)/sizeof(POINT));
701 
702  if (hdwp)
703  hdwp = DeferWindowPos(hdwp,
704  hItemWnd,
705  0,
706  rect.left + (cx - pData->cxOld),
707  rect.top,
708  0, 0,
710 
711  hItemWnd = GetDlgItem(hDlg, IDC_NEXT);
712  GetWindowRect(hItemWnd, &rect);
713  MapWindowPoints(HWND_DESKTOP /*NULL*/, hDlg, (LPPOINT)&rect, sizeof(RECT)/sizeof(POINT));
714 
715  if (hdwp)
716  hdwp = DeferWindowPos(hdwp,
717  hItemWnd,
718  0,
719  rect.left + (cx - pData->cxOld),
720  rect.top,
721  0, 0,
723 
724  hItemWnd = GetDlgItem(hDlg, IDC_COPY);
725  GetWindowRect(hItemWnd, &rect);
726  MapWindowPoints(HWND_DESKTOP /*NULL*/, hDlg, (LPPOINT)&rect, sizeof(RECT)/sizeof(POINT));
727 
728  if (hdwp)
729  hdwp = DeferWindowPos(hdwp,
730  hItemWnd,
731  0,
732  rect.left + (cx - pData->cxOld),
733  rect.top,
734  0, 0,
736 
737  if (hdwp)
738  EndDeferWindowPos(hdwp);
739 
740  pData->cxOld = cx;
741  pData->cyOld = cy;
742  }
743 }
#define IDC_WORDRADIO
Definition: resource.h:44
HDWP WINAPI BeginDeferWindowPos(_In_ int)
#define SM_CYHSCROLL
Definition: winuser.h:952
#define TRUE
Definition: types.h:120
#define SIF_RANGE
Definition: winuser.h:1221
long y
Definition: polytest.cpp:48
static INT cyMin
Definition: eventvwr.c:4141
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
long x
Definition: polytest.cpp:48
#define SB_VERT
Definition: winuser.h:553
#define IDC_EVENTDATAEDIT
Definition: resource.h:45
static INT cxMin
Definition: eventvwr.c:4141
#define SB_HORZ
Definition: winuser.h:552
BOOL WINAPI ShowScrollBar(_In_ HWND, _In_ int, _In_ BOOL)
LONG top
Definition: windef.h:297
#define IDC_NEXT
Definition: fontview.h:17
#define IDC_PREVIOUS
Definition: resource.h:38
#define GetWindowLongPtrW
Definition: winuser.h:4698
LONG left
Definition: windef.h:296
#define SWP_NOZORDER
Definition: winuser.h:1232
LONG right
Definition: windef.h:298
int32_t INT
Definition: typedefs.h:56
#define SIF_PAGE
Definition: winuser.h:1219
& rect
Definition: startmenu.cpp:1413
INT INT y
Definition: msvc.h:62
#define IDC_DETAILS_STATIC
Definition: resource.h:42
BOOL WINAPI EndDeferWindowPos(_In_ HDWP)
#define SW_ERASE
Definition: winuser.h:2534
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:570
smooth NULL
Definition: ftsmooth.c:416
POINT scPos
Definition: evtdetctl.c:35
int WINAPI ScrollWindowEx(_In_ HWND, _In_ int, _In_ int, _In_opt_ LPCRECT, _In_opt_ LPCRECT, _In_opt_ HRGN, _Out_opt_ LPRECT, _In_ UINT)
HDWP WINAPI DeferWindowPos(_In_ HDWP, _In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
if(!(yy_init))
Definition: macro.lex.yy.c:717
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define SWP_NOACTIVATE
Definition: winuser.h:1227
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define IDC_COPY
Definition: resource.h:17
int WINAPI GetSystemMetrics(_In_ int)
#define WS_HSCROLL
Definition: pedump.c:628
BOOL WINAPI GetScrollInfo(_In_ HWND, _In_ int, _Inout_ LPSCROLLINFO)
#define IDC_BYTESRADIO
Definition: resource.h:43
#define IDC_EVENTTEXTEDIT
Definition: resource.h:41
#define SW_INVALIDATE
Definition: winuser.h:2533
#define SIF_POS
Definition: winuser.h:1220
#define SWP_NOSIZE
Definition: winuser.h:1230
#define GWL_STYLE
Definition: winuser.h:846
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define HWND_DESKTOP
Definition: winuser.h:1195
#define WS_VSCROLL
Definition: pedump.c:627
#define SW_SCROLLCHILDREN
Definition: winuser.h:2532
#define SM_CXVSCROLL
Definition: winuser.h:951
_Out_opt_ int * cx
Definition: commctrl.h:570
LONG bottom
Definition: windef.h:299
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
int WINAPI SetScrollInfo(_In_ HWND, _In_ int, _In_ LPCSCROLLINFO, _In_ BOOL)

◆ PrintByteDataLine()

static UINT PrintByteDataLine ( PWCHAR  pBuffer,
UINT  uOffset,
PBYTE  pData,
UINT  uLength 
)
static

Definition at line 105 of file evtdetctl.c.

Referenced by DisplayEventData().

106 {
107  PWCHAR p = pBuffer;
108  UINT n, i, r = 0;
109 
110  if (uOffset != 0)
111  {
112  n = swprintf(p, L"\r\n");
113  p += n;
114  r += n;
115  }
116 
117  n = swprintf(p, L"%04lx:", uOffset);
118  p += n;
119  r += n;
120 
121  for (i = 0; i < uLength; i++)
122  {
123  n = swprintf(p, L" %02x", pData[i]);
124  p += n;
125  r += n;
126  }
127 
128  for (i = 0; i < 9 - uLength; i++)
129  {
130  n = swprintf(p, L" ");
131  p += n;
132  r += n;
133  }
134 
135  for (i = 0; i < uLength; i++)
136  {
137  // NOTE: Normally iswprint should return FALSE for tabs...
138  n = swprintf(p, L"%c", (iswprint(pData[i]) && (pData[i] != L'\t')) ? pData[i] : L'.');
139  p += n;
140  r += n;
141  }
142 
143  return r;
144 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
uint16_t * PWCHAR
Definition: typedefs.h:54
GLuint n
Definition: s_context.h:57
GLenum GLclampf GLint i
Definition: glfuncs.h:14
PVOID pBuffer
#define swprintf(buf, format,...)
Definition: sprintf.c:56
unsigned int UINT
Definition: ndis.h:50
static const WCHAR L[]
Definition: oid.c:1087
#define iswprint(_c)
Definition: ctype.h:672
GLfloat GLfloat p
Definition: glext.h:8902
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827

◆ PrintWordDataLine()

static UINT PrintWordDataLine ( PWCHAR  pBuffer,
UINT  uOffset,
PULONG  pData,
UINT  uLength 
)
static

Definition at line 148 of file evtdetctl.c.

Referenced by DisplayEventData().

149 {
150  PWCHAR p = pBuffer;
151  UINT n, i, r = 0;
152 
153  if (uOffset != 0)
154  {
155  n = swprintf(p, L"\r\n");
156  p += n;
157  r += n;
158  }
159 
160  n = swprintf(p, L"%04lx:", uOffset);
161  p += n;
162  r += n;
163 
164  for (i = 0; i < uLength / sizeof(ULONG); i++)
165  {
166  n = swprintf(p, L" %08lx", pData[i]);
167  p += n;
168  r += n;
169  }
170 
171  /* Display the remaining bytes if uLength was not a multiple of sizeof(ULONG) */
172  for (i = (uLength / sizeof(ULONG)) * sizeof(ULONG); i < uLength; i++)
173  {
174  n = swprintf(p, L" %02x", ((PBYTE)pData)[i]);
175  p += n;
176  r += n;
177  }
178 
179  return r;
180 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
uint16_t * PWCHAR
Definition: typedefs.h:54
GLuint n
Definition: s_context.h:57
GLenum GLclampf GLint i
Definition: glfuncs.h:14
PVOID pBuffer
#define swprintf(buf, format,...)
Definition: sprintf.c:56
unsigned int UINT
Definition: ndis.h:50
static const WCHAR L[]
Definition: oid.c:1087
unsigned int ULONG
Definition: retypes.h:1
GLfloat GLfloat p
Definition: glext.h:8902
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
BYTE * PBYTE
Definition: pedump.c:66

Variable Documentation

◆ hwndListView