ReactOS 0.4.16-dev-1067-ge98bba2
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 DisplayEventData (_In_ HWND hDlg, _In_ PDETAILDATA pDetailData)
 
static VOID DisplayEvent (_In_ HWND hDlg, _In_ PDETAILDATA pDetailData)
 
static UINT PrintByteDataLine (PWCHAR pBuffer, UINT uOffset, PBYTE pData, UINT uLength)
 
static UINT PrintWordDataLine (PWCHAR pBuffer, UINT uOffset, PULONG pData, UINT uLength)
 
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 EnableNavigationArrows (_In_ HWND hDlg, _In_ BOOL bEnable)
 
static VOID ClearContents (_In_ HWND hDlg)
 
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

WCHAR szTitle []
 
HWND hwndListView
 

Macro Definition Documentation

◆ EVENT_MESSAGE_EVENTTEXT_BUFFER

#define EVENT_MESSAGE_EVENTTEXT_BUFFER   (1024*10)

Definition at line 16 of file evtdetctl.c.

Typedef Documentation

◆ DETAILDATA

◆ PDETAILDATA

Function Documentation

◆ ClearContents()

static VOID ClearContents ( _In_ HWND  hDlg)
static

Definition at line 753 of file evtdetctl.c.

755{
756 /* Disable the Previous/Next and Copy buttons */
759
760 /* Disable the Bytes/Words mode buttons */
763
764 /* Clear the data fields */
773
776}
#define IDC_COPY
Definition: resource.h:17
#define IDC_EVENTCOMPUTERSTATIC
Definition: resource.h:46
#define IDC_EVENTDATESTATIC
Definition: resource.h:39
#define IDC_WORDSRADIO
Definition: resource.h:53
#define IDC_EVENTUSERSTATIC
Definition: resource.h:45
#define IDC_EVENTTYPESTATIC
Definition: resource.h:43
#define IDC_BYTESRADIO
Definition: resource.h:52
#define IDC_EVENTTIMESTATIC
Definition: resource.h:41
#define IDC_EVENTDATAEDIT
Definition: resource.h:54
#define IDC_EVENTSOURCESTATIC
Definition: resource.h:40
#define IDC_EVENTCATEGORYSTATIC
Definition: resource.h:42
#define IDC_EVENTTEXTEDIT
Definition: resource.h:50
#define IDC_EVENTIDSTATIC
Definition: resource.h:44
#define FALSE
Definition: types.h:117
#define EnableDlgItem(hDlg, nID, bEnable)
Definition: eventvwr.h:55
static VOID EnableNavigationArrows(_In_ HWND hDlg, _In_ BOOL bEnable)
Definition: evtdetctl.c:740
#define L(x)
Definition: ntvdm.h:50
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)

Referenced by EventDetailsCtrl().

◆ CopyEventEntry()

static VOID CopyEventEntry ( HWND  hWnd)
static

Definition at line 274 of file evtdetctl.c.

275{
276 WCHAR tmpHeader[512];
277 WCHAR szEventType[MAX_PATH];
278 WCHAR szSource[MAX_PATH];
279 WCHAR szCategory[MAX_PATH];
280 WCHAR szEventID[MAX_PATH];
281 WCHAR szDate[MAX_PATH];
283 WCHAR szUser[MAX_PATH];
284 WCHAR szComputer[MAX_PATH];
286 ULONG size = 0;
287 LPWSTR output;
288 HGLOBAL hMem;
289
290 /* Try to open the clipboard */
291 if (!OpenClipboard(hWnd))
292 return;
293
294 /* Get the formatted text needed to place the content into */
295 size += LoadStringW(hInst, IDS_COPY, tmpHeader, ARRAYSIZE(tmpHeader));
296
297 /* Grab all the information and get it ready for the clipboard */
298 size += GetDlgItemTextW(hWnd, IDC_EVENTTYPESTATIC, szEventType, ARRAYSIZE(szEventType));
299 size += GetDlgItemTextW(hWnd, IDC_EVENTSOURCESTATIC, szSource, ARRAYSIZE(szSource));
300 size += GetDlgItemTextW(hWnd, IDC_EVENTCATEGORYSTATIC, szCategory, ARRAYSIZE(szCategory));
301 size += GetDlgItemTextW(hWnd, IDC_EVENTIDSTATIC, szEventID, ARRAYSIZE(szEventID));
305 size += GetDlgItemTextW(hWnd, IDC_EVENTCOMPUTERSTATIC, szComputer, ARRAYSIZE(szComputer));
306 size += GetDlgItemTextW(hWnd, IDC_EVENTTEXTEDIT, evtDesc, ARRAYSIZE(evtDesc));
307
308 size++; /* Null-termination */
309 size *= sizeof(WCHAR);
310
311 /*
312 * Consolidate the information into one big piece and
313 * sort out the memory needed to write to the clipboard.
314 */
316 if (hMem == NULL) goto Quit;
317
318 output = GlobalLock(hMem);
319 if (output == NULL)
320 {
321 GlobalFree(hMem);
322 goto Quit;
323 }
324
325 StringCbPrintfW(output, size,
326 tmpHeader, szEventType, szSource, szCategory, szEventID,
327 szDate, szTime, szUser, szComputer, evtDesc);
328
329 GlobalUnlock(hMem);
330
331 /* We succeeded, empty the clipboard and write the data in it */
334
335Quit:
336 /* Close the clipboard once we are done with it */
338}
HWND hWnd
Definition: settings.c:17
#define IDS_COPY
Definition: resource.h:133
#define CF_UNICODETEXT
Definition: constants.h:408
#define NULL
Definition: types.h:112
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define MAX_PATH
Definition: compat.h:34
HINSTANCE hInst
Definition: dxdiag.c:13
#define EVENT_MESSAGE_EVENTTEXT_BUFFER
Definition: evtdetctl.c:16
GLsizeiptr size
Definition: glext.h:5919
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
TCHAR szTime[64]
Definition: solitaire.cpp:20
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
uint32_t ULONG
Definition: typedefs.h:59
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2263
#define GMEM_MOVEABLE
Definition: winbase.h:320
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)
BOOL WINAPI CloseClipboard(void)
Definition: ntwrapper.h:178
BOOL WINAPI OpenClipboard(_In_opt_ HWND)
BOOL WINAPI EmptyClipboard(void)
Definition: ntwrapper.h:190
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by EventDetailsCtrl().

◆ CreateEventDetailsCtrl()

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

Definition at line 1060 of file evtdetctl.c.

1063{
1066 hParentWnd, EventDetailsCtrl, lParam);
1067}
#define IDD_EVENTDETAILS_CTRL
Definition: resource.h:33
HINSTANCE hInstance
Definition: charmap.c:19
LPARAM lParam
Definition: combotst.c:139
static INT_PTR CALLBACK EventDetailsCtrl(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: evtdetctl.c:830
HWND WINAPI CreateDialogParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582

Referenced by EventDetails(), and InitInstance().

◆ CreateMonospaceFont()

static HFONT CreateMonospaceFont ( VOID  )
static

Definition at line 253 of file evtdetctl.c.

254{
255 LOGFONTW tmpFont = {0};
256 HFONT hFont;
257 HDC hDC;
258
259 hDC = GetDC(NULL);
260
261 tmpFont.lfHeight = -MulDiv(8, GetDeviceCaps(hDC, LOGPIXELSY), 72);
262 tmpFont.lfWeight = FW_NORMAL;
263 wcscpy(tmpFont.lfFaceName, L"Courier New");
264
265 hFont = CreateFontIndirectW(&tmpFont);
266
268
269 return hFont;
270}
static HDC hDC
Definition: 3dtext.c:33
HFONT hFont
Definition: main.c:53
wcscpy
static HDC
Definition: imagelist.c:88
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
Definition: muldiv.c:25
LONG lfHeight
Definition: dimm.idl:59
LONG lfWeight
Definition: dimm.idl:63
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
#define LOGPIXELSY
Definition: wingdi.h:719
#define FW_NORMAL
Definition: wingdi.h:373
HFONT WINAPI CreateFontIndirectW(_In_ const LOGFONTW *)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC WINAPI GetDC(_In_opt_ HWND)

Referenced by EventDetailsCtrl().

◆ DisplayEvent()

static VOID DisplayEvent ( _In_ HWND  hDlg,
_In_ PDETAILDATA  pDetailData 
)
static

Definition at line 53 of file evtdetctl.c.

56{
57 PEVENTLOGRECORD pevlr;
58 PEVENTLOGFILTER EventLogFilter = pDetailData->EventLogFilter;
59 INT iItem = pDetailData->iEventItem;
60 BOOL bEventData;
61
62 WCHAR szEventType[MAX_PATH];
64 WCHAR szDate[MAX_PATH];
65 WCHAR szUser[MAX_PATH];
66 WCHAR szComputer[MAX_PATH];
67 WCHAR szSource[MAX_PATH];
68 WCHAR szCategory[MAX_PATH];
69 WCHAR szEventID[MAX_PATH];
71
72 /* Retrieve and cache the pointer to the selected event item */
73 LVITEMW li;
74 li.mask = LVIF_PARAM;
75 li.iItem = iItem;
76 li.iSubItem = 0;
78 pevlr = pDetailData->pevlr = (PEVENTLOGRECORD)li.lParam;
79
80 ListView_GetItemText(hwndListView, iItem, 0, szEventType, ARRAYSIZE(szEventType));
81 ListView_GetItemText(hwndListView, iItem, 1, szDate, ARRAYSIZE(szDate));
83 ListView_GetItemText(hwndListView, iItem, 3, szSource, ARRAYSIZE(szSource));
84 ListView_GetItemText(hwndListView, iItem, 4, szCategory, ARRAYSIZE(szCategory));
85 ListView_GetItemText(hwndListView, iItem, 5, szEventID, ARRAYSIZE(szEventID));
86 ListView_GetItemText(hwndListView, iItem, 6, szUser, ARRAYSIZE(szUser));
87 ListView_GetItemText(hwndListView, iItem, 7, szComputer, ARRAYSIZE(szComputer));
88
95 SetDlgItemTextW(hDlg, IDC_EVENTIDSTATIC, szEventID);
96 SetDlgItemTextW(hDlg, IDC_EVENTTYPESTATIC, szEventType);
97
98 bEventData = (pevlr->DataLength > 0);
99 EnableDlgItem(hDlg, IDC_BYTESRADIO, bEventData);
100 EnableDlgItem(hDlg, IDC_WORDSRADIO, bEventData);
101
102 // FIXME: At the moment we support only one event log in the filter
103 GetEventMessage(EventLogFilter->EventLogs[0]->LogName, szSource, pevlr, szEventText);
104 SetDlgItemTextW(hDlg, IDC_EVENTTEXTEDIT, szEventText);
105
106 DisplayEventData(hDlg, pDetailData);
107}
BOOL GetEventMessage(IN LPCWSTR KeyName, IN LPCWSTR SourceName, IN PEVENTLOGRECORD pevlr, OUT PWCHAR EventText)
Definition: eventvwr.c:1639
static VOID DisplayEventData(_In_ HWND hDlg, _In_ PDETAILDATA pDetailData)
Definition: evtdetctl.c:190
HWND hwndListView
Definition: eventvwr.c:66
unsigned int BOOL
Definition: ntddk_ex.h:94
LARGE_INTEGER li
Definition: fxtimerapi.cpp:235
#define ListView_GetItemText(hwndLV, i, iSubItem_, pszText_, cchTextMax_)
Definition: commctrl.h:2689
#define LVIF_PARAM
Definition: commctrl.h:2316
#define ListView_GetItem(hwnd, pitem)
Definition: commctrl.h:2399
PEVENTLOG EventLogs[ANYSIZE_ARRAY]
Definition: eventvwr.h:138
PWSTR LogName
Definition: eventvwr.h:93
int32_t INT
Definition: typedefs.h:58
struct _EVENTLOGRECORD * PEVENTLOGRECORD

Referenced by EventDetailsCtrl().

◆ DisplayEventData()

static VOID DisplayEventData ( _In_ HWND  hDlg,
_In_ PDETAILDATA  pDetailData 
)
static

Definition at line 190 of file evtdetctl.c.

193{
194 PEVENTLOGRECORD pevlr = pDetailData->pevlr;
195 BOOL bDisplayWords = pDetailData->bDisplayWords;
196
198 UINT i, uOffset;
199 UINT uBufferSize, uLineLength;
200 PWCHAR pTextBuffer, pLine;
201
202 if (!pevlr)
203 return;
204
205 if (pevlr->DataLength == 0)
206 {
208 return;
209 }
210
211 if (bDisplayWords)
212 uBufferSize = ((pevlr->DataLength / 8) + 1) * 26 * sizeof(WCHAR);
213 else
214 uBufferSize = ((pevlr->DataLength / 8) + 1) * 43 * sizeof(WCHAR);
215
216 pTextBuffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, uBufferSize);
217 if (!pTextBuffer)
218 return;
219
220 pLine = pTextBuffer;
221 uOffset = 0;
222
223 for (i = 0; i < pevlr->DataLength / 8; i++)
224 {
225 pData = (LPBYTE)((LPBYTE)pevlr + pevlr->DataOffset + uOffset);
226
227 if (bDisplayWords)
228 uLineLength = PrintWordDataLine(pLine, uOffset, (PULONG)pData, 8);
229 else
230 uLineLength = PrintByteDataLine(pLine, uOffset, pData, 8);
231 pLine = pLine + uLineLength;
232
233 uOffset += 8;
234 }
235
236 if (pevlr->DataLength % 8 != 0)
237 {
238 pData = (LPBYTE)((LPBYTE)pevlr + pevlr->DataOffset + uOffset);
239
240 if (bDisplayWords)
241 PrintWordDataLine(pLine, uOffset, (PULONG)pData, pevlr->DataLength % 8);
242 else
243 PrintByteDataLine(pLine, uOffset, pData, pevlr->DataLength % 8);
244 }
245
246 SetDlgItemTextW(hDlg, IDC_EVENTDATAEDIT, pTextBuffer);
247
248 HeapFree(GetProcessHeap(), 0, pTextBuffer);
249}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
static UINT PrintByteDataLine(PWCHAR pBuffer, UINT uOffset, PBYTE pData, UINT uLength)
Definition: evtdetctl.c:111
static UINT PrintWordDataLine(PWCHAR pBuffer, UINT uOffset, PULONG pData, UINT uLength)
Definition: evtdetctl.c:154
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int UINT
Definition: ndis.h:50
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
uint32_t * PULONG
Definition: typedefs.h:59
unsigned char * LPBYTE
Definition: typedefs.h:53
uint16_t * PWCHAR
Definition: typedefs.h:56

Referenced by DisplayEvent(), and EventDetailsCtrl().

◆ EnableNavigationArrows()

static VOID EnableNavigationArrows ( _In_ HWND  hDlg,
_In_ BOOL  bEnable 
)
static

Definition at line 740 of file evtdetctl.c.

743{
744 /* Enable Previous/Next only if there is more than one item in the list */
745 if (bEnable)
749}
#define IDC_PREVIOUS
Definition: resource.h:47
#define IDC_NEXT
Definition: fontview.h:17
#define ListView_GetItemCount(hwnd)
Definition: commctrl.h:2312
_In_ BOOL bEnable
Definition: winddi.h:3426

Referenced by ClearContents(), EventDetailsCtrl(), and InitDetailsDlgCtrl().

◆ EventDetailsCtrl()

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

Definition at line 830 of file evtdetctl.c.

831{
833
835
836 switch (uMsg)
837 {
838 case WM_INITDIALOG:
839 {
840 RECT rect;
841
843 if (!pData)
844 {
845 EndDialog(hDlg, 0);
846 return (INT_PTR)TRUE;
847 }
849
850 if (lParam != 0)
851 {
853 pData->EventLogFilter = DetailInfo->EventLogFilter;
854 pData->iEventItem = DetailInfo->iEventItem;
855 }
856 else
857 {
858 pData->iEventItem = -1;
859 }
860
861 pData->bDisplayWords = FALSE;
862 pData->hMonospaceFont = CreateMonospaceFont();
863
864 GetClientRect(hDlg, &rect);
865 pData->cxOld = pData->cxMin = rect.right - rect.left;
866 pData->cyOld = pData->cyMin = rect.bottom - rect.top;
867 pData->scPos.x = pData->scPos.y = 0;
868
870 /* NOTE: Showing the event (if any) is currently delayed to later */
871 // SendMessageW(hDlg, EVT_DISPLAY, TRUE, (LPARAM)pData->iEventItem);
872
873 // OnSize(hDlg, pData, pData->cxOld, pData->cyOld);
874 return (INT_PTR)TRUE;
875 }
876
877 case WM_DESTROY:
878 if (pData)
879 {
880 if (pData->hMonospaceFont)
881 DeleteObject(pData->hMonospaceFont);
883 }
884 return (INT_PTR)TRUE;
885
886 case EVT_SETFILTER:
887 {
888 /* Disable the display first, before changing the current filter */
889 pData->pevlr = NULL;
890 pData->iEventItem = -1;
891 ClearContents(hDlg);
892 pData->EventLogFilter = (PEVENTLOGFILTER)lParam;
893 return (INT_PTR)TRUE;
894 }
895
896 case EVT_DISPLAY:
897 {
898 if (wParam)
899 {
900 INT iEventItem = (INT)lParam;
901
902 /* If no filter is set, don't change anything */
903 if (!pData->EventLogFilter)
904 return (INT_PTR)TRUE;
905
906 /* If we re-enable display from previously disabled state, re-enable the buttons */
907 if ((pData->iEventItem == -1) && (iEventItem != -1))
908 {
911 }
912 else
913 /* If we disable display from previously enabled state, clear and disable it */
914 if ((pData->iEventItem != -1) && (iEventItem == -1))
915 {
916 ClearContents(hDlg);
917 }
918
919 /* Set the new item */
920 pData->pevlr = NULL;
921 pData->iEventItem = iEventItem;
922
923 /* Display the event info, if there is one */
924 if (pData->iEventItem != -1)
925 DisplayEvent(hDlg, pData);
926 }
927 else
928 {
929 /* Enable or disable the Previous/Next buttons,
930 * but keep the existing contents, if any */
931 EnableNavigationArrows(hDlg, (lParam != -1));
932
933 // HACK: Disable the Bytes/Words mode buttons
934 // because we won't have access anymore to the
935 // event data. (This will be fixed in the future.)
936 pData->pevlr = NULL; // Invalidate also the cache.
939 }
940 return (INT_PTR)TRUE;
941 }
942
943 case WM_COMMAND:
944 switch (LOWORD(wParam))
945 {
946 case IDC_PREVIOUS:
947 case IDC_NEXT:
948 {
949 BOOL bPrev = (LOWORD(wParam) == IDC_PREVIOUS);
951 INT iItem, iSel;
952
953 if (nItems <= 0) /* No items? */
954 break;
955
956 /* Get the index of the first selected item */
958
959 /* Select the previous/next item from our current one */
961 (bPrev ? LVNI_ABOVE : LVNI_BELOW));
962 if (iItem < 0 || iItem >= nItems)
963 {
964 /* Confirm selection restart only if an item was previously
965 * selected. If not, just proceed with default selection. */
966 if (iSel != -1)
967 {
968 WCHAR szText[200];
971 szText, _countof(szText));
972 if (MessageBoxW(hDlg, szText, szTitle, MB_YESNO | MB_ICONQUESTION) != IDYES)
973 break;
974 }
975
976 /* Determine where to restart from */
977 iItem = (bPrev ? (nItems - 1) : 0);
978 }
979
980 /*
981 * Deselect the currently selected items in the list view.
982 * (They may be different from our current one, if multiple
983 * event details are being displayed concurrently!)
984 */
985 iSel = -1;
986 while ((iSel = ListView_GetNextItem(hwndListView, iSel, LVNI_SELECTED)) != -1)
987 {
990 }
991
992 /* Select the new item */
997
998 pData->pevlr = NULL;
999 pData->iEventItem = iItem;
1000
1001 /* Display the event info */
1002 if (pData->EventLogFilter)
1003 DisplayEvent(hDlg, pData);
1004 return (INT_PTR)TRUE;
1005 }
1006
1007 case IDC_COPY:
1008 if (pData->EventLogFilter)
1009 CopyEventEntry(hDlg);
1010 return (INT_PTR)TRUE;
1011
1012 case IDC_BYTESRADIO:
1013 case IDC_WORDSRADIO:
1014 pData->bDisplayWords = (LOWORD(wParam) == IDC_WORDSRADIO);
1015 if (pData->EventLogFilter)
1016 DisplayEventData(hDlg, pData);
1017 return (INT_PTR)TRUE;
1018
1019 default:
1020 break;
1021 }
1022 break;
1023
1024 case WM_NOTIFY:
1025 {
1027
1028 if (hdr->idFrom == IDC_EVENTTEXTEDIT)
1029 {
1030 switch (hdr->code)
1031 {
1032 case EN_LINK:
1033 OnLink(hDlg, (ENLINK*)lParam);
1034 break;
1035 }
1036 }
1037 break;
1038 }
1039
1040 case WM_HSCROLL:
1041 case WM_VSCROLL:
1042 {
1043 OnScroll(hDlg, pData,
1044 (uMsg == WM_HSCROLL) ? SB_HORZ : SB_VERT,
1045 LOWORD(wParam));
1047 return (INT_PTR)TRUE;
1048 }
1049
1050 case WM_SIZE:
1053 return (INT_PTR)TRUE;
1054 }
1055
1056 return (INT_PTR)FALSE;
1057}
int nItems
Definition: appswitch.c:56
#define IDS_CONTFROMBEGINNING
Definition: resource.h:108
#define IDS_CONTFROMEND
Definition: resource.h:109
WPARAM wParam
Definition: combotst.c:138
#define TRUE
Definition: types.h:120
struct _EVENTLOGFILTER * PEVENTLOGFILTER
static VOID OnScroll(HWND hDlg, PDETAILDATA pData, INT nBar, WORD sbCode)
Definition: evtdetctl.c:380
static VOID InitDetailsDlgCtrl(HWND hDlg, PDETAILDATA pData)
Definition: evtdetctl.c:780
static VOID CopyEventEntry(HWND hWnd)
Definition: evtdetctl.c:274
static HFONT CreateMonospaceFont(VOID)
Definition: evtdetctl.c:253
struct _DETAILDATA * PDETAILDATA
static VOID OnLink(HWND hDlg, ENLINK *penLink)
Definition: evtdetctl.c:342
static VOID ClearContents(_In_ HWND hDlg)
Definition: evtdetctl.c:753
static VOID DisplayEvent(_In_ HWND hDlg, _In_ PDETAILDATA pDetailData)
Definition: evtdetctl.c:53
WCHAR szTitle[]
Definition: magnifier.c:35
static VOID OnSize(HWND hDlg, PDETAILDATA pData, INT cx, INT cy)
Definition: evtdetctl.c:477
struct _EVENTDETAIL_INFO * PEVENTDETAIL_INFO
#define EVT_DISPLAY
Definition: evtdetctl.h:21
#define EVT_SETFILTER
Definition: evtdetctl.h:20
pKey DeleteObject()
char hdr[14]
Definition: iptest.cpp:33
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define LOWORD(l)
Definition: pedump.c:82
#define INT
Definition: polytest.cpp:20
#define ListView_SetItemState(hwndLV, i, data, mask)
Definition: commctrl.h:2678
#define LVNI_SELECTED
Definition: commctrl.h:2429
#define LVNI_BELOW
Definition: commctrl.h:2434
#define ListView_GetNextItem(hwnd, i, flags)
Definition: commctrl.h:2439
#define LVIS_SELECTED
Definition: commctrl.h:2324
#define LVNI_ABOVE
Definition: commctrl.h:2433
#define LVIS_FOCUSED
Definition: commctrl.h:2323
#define ListView_EnsureVisible(hwndLV, i, fPartialOK)
Definition: commctrl.h:2524
#define EN_LINK
Definition: richedit.h:202
#define WM_NOTIFY
Definition: richedit.h:61
#define _countof(array)
Definition: sndvol32.h:70
& rect
Definition: startmenu.cpp:1413
PEVENTLOGFILTER EventLogFilter
Definition: evtdetctl.h:16
int32_t INT_PTR
Definition: typedefs.h:64
#define HIWORD(l)
Definition: typedefs.h:247
#define DWLP_USER
Definition: winuser.h:883
#define GetWindowLongPtrW
Definition: winuser.h:4840
#define WM_HSCROLL
Definition: winuser.h:1754
#define WM_VSCROLL
Definition: winuser.h:1755
#define WM_SIZE
Definition: winuser.h:1622
#define SB_VERT
Definition: winuser.h:553
#define WM_COMMAND
Definition: winuser.h:1751
#define WM_INITDIALOG
Definition: winuser.h:1750
#define MB_YESNO
Definition: winuser.h:828
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
struct tagNMHDR * LPNMHDR
#define MB_ICONQUESTION
Definition: winuser.h:800
#define DWLP_MSGRESULT
Definition: winuser.h:881
#define WM_DESTROY
Definition: winuser.h:1620
#define IDYES
Definition: winuser.h:846
#define SetWindowLongPtrW
Definition: winuser.h:5366
#define SB_HORZ
Definition: winuser.h:552
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by CreateEventDetailsCtrl().

◆ GetEventMessage()

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

Definition at line 1639 of file eventvwr.c.

1643{
1644 BOOL Success = FALSE;
1645 DWORD i;
1646 size_t cch;
1647 WCHAR SourceModuleName[1024];
1648 WCHAR ParameterModuleName[1024];
1649 BOOL IsParamModNameCached = FALSE;
1650 LPWSTR lpMsgBuf = NULL;
1651 LPWSTR szStringArray, szMessage;
1652 LPWSTR *szArguments;
1653
1654 /* Get the event string array */
1655 szStringArray = (LPWSTR)((LPBYTE)pevlr + pevlr->StringOffset);
1656
1657 /* NOTE: GetEventMessageFileDLL can return a comma-separated list of DLLs */
1659 goto Quit;
1660
1661 /* Allocate space for insertion strings */
1662 szArguments = HeapAlloc(GetProcessHeap(), 0, pevlr->NumStrings * sizeof(LPVOID));
1663 if (!szArguments)
1664 goto Quit;
1665
1666 if (!IsParamModNameCached)
1667 {
1668 /* Now that the parameter file list is loaded, no need to reload it at the next run! */
1669 IsParamModNameCached = GetEventMessageFileDLL(KeyName, SourceName, EVENT_PARAMETER_MESSAGE_FILE, ParameterModuleName);
1670 // FIXME: If the string loading failed the first time, no need to retry it just after???
1671 }
1672
1673 if (IsParamModNameCached)
1674 {
1675 /* Not yet support for reading messages from parameter message DLL */
1676 }
1677
1678 szMessage = szStringArray;
1679 /*
1680 * HACK:
1681 * We do some hackish preformatting of the cached event strings...
1682 * That's because after we pass the string to FormatMessage
1683 * (via GetMessageStringFromDllList) with the FORMAT_MESSAGE_ARGUMENT_ARRAY
1684 * flag, instead of ignoring the insertion parameters and do the formatting
1685 * by ourselves. Therefore, the resulting string should have the parameter
1686 * string placeholders starting with a single '%' instead of a mix of one
1687 * and two '%'.
1688 */
1689 /* HACK part 1: Compute the full length of the string array */
1690 cch = 0;
1691 for (i = 0; i < pevlr->NumStrings; i++)
1692 {
1693 szMessage += wcslen(szMessage) + 1;
1694 }
1695 cch = szMessage - szStringArray;
1696
1697 /* HACK part 2: Now do the HACK proper! */
1698 szMessage = szStringArray;
1699 for (i = 0; i < pevlr->NumStrings; i++)
1700 {
1701 lpMsgBuf = szMessage;
1702 while ((lpMsgBuf = wcsstr(lpMsgBuf, L"%%")))
1703 {
1704 if (iswdigit(lpMsgBuf[2]))
1705 {
1706 MoveMemory(lpMsgBuf, lpMsgBuf+1, ((szStringArray + cch) - lpMsgBuf - 1) * sizeof(WCHAR));
1707 }
1708 }
1709
1710 szArguments[i] = szMessage;
1711 szMessage += wcslen(szMessage) + 1;
1712 }
1713
1714 /* Retrieve the message string without appending extra newlines */
1715 lpMsgBuf =
1716 GetMessageStringFromDllList(SourceModuleName,
1719 pevlr->EventID,
1720 0,
1721 (va_list*)szArguments);
1722 if (lpMsgBuf)
1723 {
1724 /* Trim the string */
1725 TrimNulls(lpMsgBuf);
1726
1727 szMessage = NULL;
1728 Success = (ApplyParameterStringsToMessage(ParameterModuleName,
1729 TRUE,
1730 lpMsgBuf,
1731 &szMessage) == ERROR_SUCCESS);
1732 if (Success && szMessage)
1733 {
1734 /* Free the buffer allocated by FormatMessage */
1735 LocalFree(lpMsgBuf);
1736 lpMsgBuf = szMessage;
1737 }
1738
1739 /* Copy the event text */
1740 StringCchCopyW(EventText, EVENT_MESSAGE_EVENTTEXT_BUFFER, lpMsgBuf);
1741
1742 /* Free the buffer allocated by FormatMessage */
1743 LocalFree(lpMsgBuf);
1744 }
1745
1746 HeapFree(GetProcessHeap(), 0, szArguments);
1747
1748Quit:
1749 if (!Success)
1750 {
1751 /* Get a read-only pointer to the "event-not-found" string */
1754 StringCchPrintfW(EventText, EVENT_MESSAGE_EVENTTEXT_BUFFER, lpMsgBuf, (pevlr->EventID & 0xFFFF), SourceName);
1755
1756 /* Append the strings */
1757 szMessage = szStringArray;
1758 for (i = 0; i < pevlr->NumStrings; i++)
1759 {
1760 StringCchCatW(EventText, EVENT_MESSAGE_EVENTTEXT_BUFFER, szMessage);
1762 szMessage += wcslen(szMessage) + 1;
1763 }
1764 }
1765
1766 return Success;
1767}
char * va_list
Definition: acmsvcex.h:78
WCHAR SourceName[256]
Definition: arping.c:28
#define IDS_EVENTSTRINGIDNOTFOUND
Definition: resource.h:106
#define ERROR_SUCCESS
Definition: deptool.c:10
@ Success
Definition: eventcreate.c:712
DWORD ApplyParameterStringsToMessage(IN LPCWSTR lpMessageDllList, IN BOOL bMessagePreFormatted, IN CONST LPCWSTR pMessage, OUT LPWSTR *pFinalMessage)
Definition: eventvwr.c:903
void TrimNulls(LPWSTR s)
Definition: eventvwr.c:1441
HINSTANCE hInst
Definition: eventvwr.c:48
BOOL GetEventMessageFileDLL(IN LPCWSTR lpLogName, IN LPCWSTR SourceName, IN LPCWSTR EntryName, OUT PWCHAR lpModuleName)
Definition: eventvwr.c:1528
#define EVENT_MESSAGE_EVENTTEXT_BUFFER
Definition: eventvwr.c:36
#define EVENT_PARAMETER_MESSAGE_FILE
Definition: eventvwr.c:41
LPWSTR GetMessageStringFromDllList(IN LPCWSTR lpMessageDllList, IN DWORD dwFlags, IN DWORD dwMessageId, IN DWORD nSize, IN va_list *Arguments OPTIONAL)
Definition: eventvwr.c:842
#define EVENT_MESSAGE_FILE
Definition: eventvwr.c:40
unsigned long DWORD
Definition: ntddk_ex.h:95
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
#define iswdigit(_c)
Definition: ctype.h:667
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:202
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2699
#define FORMAT_MESSAGE_MAX_WIDTH_MASK
Definition: winbase.h:451
#define MoveMemory
Definition: winbase.h:1740
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:445
#define FORMAT_MESSAGE_ARGUMENT_ARRAY
Definition: winbase.h:450
#define FORMAT_MESSAGE_FROM_HMODULE
Definition: winbase.h:448

Referenced by DisplayEvent().

◆ InitDetailsDlgCtrl()

static VOID InitDetailsDlgCtrl ( HWND  hDlg,
PDETAILDATA  pData 
)
static

Definition at line 780 of file evtdetctl.c.

781{
782 DWORD dwMask;
783
787
791
792 /* Set the default read-only RichEdit color */
794
795 /* Enable RichEdit coloured and underlined links */
798
799 /*
800 * Activate automatic URL recognition by the RichEdit control. For more information, see:
801 * https://learn.microsoft.com/en-us/archive/blogs/murrays/automatic-richedit-hyperlinks
802 * https://learn.microsoft.com/en-us/archive/blogs/murrays/richedit-friendly-name-hyperlinks
803 * https://learn.microsoft.com/en-us/windows/win32/controls/em-autourldetect
804 */
805 SendDlgItemMessageW(hDlg, IDC_EVENTTEXTEDIT, EM_AUTOURLDETECT, AURL_ENABLEURL /* | AURL_ENABLEEAURLS */, 0);
806
807 /* Note that the RichEdit control never gets themed under WinXP+; one would have to write code to simulate Edit-control theming */
808
811
812 //ClearContents(hDlg);
813 if (pData->iEventItem != -1)
814 {
817 }
818 else
819 {
822 }
825}
#define IDI_PREV
Definition: resource.h:23
#define IDI_NEXT
Definition: resource.h:22
#define IDI_COPY
Definition: resource.h:24
#define AURL_ENABLEURL
Definition: eventvwr.h:44
#define EM_GETEVENTMASK
Definition: richedit.h:92
#define EM_AUTOURLDETECT
Definition: richedit.h:125
#define ENM_LINK
Definition: richedit.h:485
#define EM_SETEVENTMASK
Definition: richedit.h:102
#define EM_SETBKGNDCOLOR
Definition: richedit.h:100
#define ENM_MOUSEEVENTS
Definition: richedit.h:476
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
DWORD WINAPI GetSysColor(_In_ int)
#define IMAGE_ICON
Definition: winuser.h:212
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE hInst, _In_ LPCWSTR name, _In_ UINT type, _In_ int cx, _In_ int cy, _In_ UINT fuLoad)
Definition: cursoricon.c:2540
#define BM_SETCHECK
Definition: winuser.h:1932
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define BM_SETIMAGE
Definition: winuser.h:1933
#define WM_SETFONT
Definition: winuser.h:1661
#define LR_DEFAULTCOLOR
Definition: winuser.h:1098
#define BST_CHECKED
Definition: winuser.h:197
#define COLOR_3DFACE
Definition: winuser.h:940

Referenced by EventDetailsCtrl().

◆ OnLink()

static VOID OnLink ( HWND  hDlg,
ENLINK penLink 
)
static

Definition at line 342 of file evtdetctl.c.

343{
344 LPWSTR pLink;
345 TEXTRANGE txtRange;
346
348
349 /* Only act on left button up events */
350 if (penLink->msg != WM_LBUTTONUP)
351 return;
352
353 /* If the range is empty, do nothing */
354 if (penLink->chrg.cpMin == penLink->chrg.cpMax)
355 return;
356
357 /* Allocate memory for the text link */
359 (max(penLink->chrg.cpMin, penLink->chrg.cpMax) -
360 min(penLink->chrg.cpMin, penLink->chrg.cpMax) + 1) * sizeof(WCHAR));
361 if (!pLink)
362 {
363 /* Not enough memory, bail out */
364 return;
365 }
366
367 txtRange.chrg = penLink->chrg;
368 txtRange.lpstrText = pLink;
370
371 /* Open the link */
372 ShellExecuteW(hDlg, L"open", pLink, NULL, NULL, SW_SHOWNOACTIVATE);
373
374 /* Free the buffer */
375 HeapFree(GetProcessHeap(), 0, pLink);
376}
#define ASSERT(a)
Definition: mode.c:44
#define min(a, b)
Definition: monoChain.cc:55
#define EM_GETTEXTRANGE
Definition: richedit.h:108
HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
Definition: shlexec.cpp:2507
LONG cpMax
Definition: richedit.h:501
LONG cpMin
Definition: richedit.h:500
UINT_PTR idFrom
Definition: winuser.h:3169
#define max(a, b)
Definition: svc.c:63
#define SW_SHOWNOACTIVATE
Definition: winuser.h:785
#define WM_LBUTTONUP
Definition: winuser.h:1788

Referenced by EventDetailsCtrl().

◆ OnScroll()

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

Definition at line 380 of file evtdetctl.c.

381{
382 RECT rect;
383
384 SCROLLINFO sInfo;
385 INT oldPos, Maximum;
386 PLONG pOriginXY;
387
388 ASSERT(nBar == SB_HORZ || nBar == SB_VERT);
389
390 GetClientRect(hDlg, &rect);
391
392 if (nBar == SB_HORZ)
393 {
394 Maximum = pData->cxMin - (rect.right-rect.left) /* pData->cxOld */;
395 pOriginXY = &pData->scPos.x;
396 }
397 else // if (nBar == SB_VERT)
398 {
399 Maximum = pData->cyMin - (rect.bottom-rect.top) /* pData->cyOld */;
400 pOriginXY = &pData->scPos.y;
401 }
402
403 /* Set scrollbar sizes */
404 sInfo.cbSize = sizeof(sInfo);
406
407 if (!GetScrollInfo(hDlg, nBar, &sInfo))
408 return;
409
410 oldPos = sInfo.nPos;
411
412 switch (sbCode)
413 {
414 case SB_LINEUP: // SB_LINELEFT:
415 sInfo.nPos--;
416 break;
417
418 case SB_LINEDOWN: // SB_LINERIGHT:
419 sInfo.nPos++;
420 break;
421
422 case SB_PAGEUP: // SB_PAGELEFT:
423 sInfo.nPos -= sInfo.nPage;
424 break;
425
426 case SB_PAGEDOWN: // SB_PAGERIGHT:
427 sInfo.nPos += sInfo.nPage;
428 break;
429
430 case SB_THUMBTRACK:
431 sInfo.nPos = sInfo.nTrackPos;
432 break;
433
434 case SB_THUMBPOSITION:
435 sInfo.nPos = sInfo.nTrackPos;
436 break;
437
438 case SB_TOP: // SB_LEFT:
439 sInfo.nPos = sInfo.nMin;
440 break;
441
442 case SB_BOTTOM: // SB_RIGHT:
443 sInfo.nPos = sInfo.nMax;
444 break;
445
446 default:
447 break;
448 }
449
450 sInfo.nPos = min(max(sInfo.nPos, 0), Maximum);
451
452 if (oldPos != sInfo.nPos)
453 {
454 POINT scOldPos = pData->scPos;
455
456 /* We now modify pData->scPos */
457 *pOriginXY = sInfo.nPos;
458
459 ScrollWindowEx(hDlg,
460 (scOldPos.x - pData->scPos.x),
461 (scOldPos.y - pData->scPos.y),
462 NULL,
463 NULL,
464 NULL,
465 NULL,
467
468 sInfo.fMask = SIF_POS;
469 SetScrollInfo(hDlg, nBar, &sInfo, TRUE);
470
471 // UpdateWindow(hDlg);
472 }
473}
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
int32_t * PLONG
Definition: typedefs.h:58
#define SB_THUMBTRACK
Definition: winuser.h:573
#define SB_LINEUP
Definition: winuser.h:564
#define SW_SCROLLCHILDREN
Definition: winuser.h:2589
#define SIF_RANGE
Definition: winuser.h:1246
#define SB_BOTTOM
Definition: winuser.h:577
#define SW_INVALIDATE
Definition: winuser.h:2590
#define SIF_PAGE
Definition: winuser.h:1244
#define SIF_TRACKPOS
Definition: winuser.h:1248
#define SB_PAGEDOWN
Definition: winuser.h:569
#define SB_LINEDOWN
Definition: winuser.h:565
#define SB_TOP
Definition: winuser.h:578
#define SIF_POS
Definition: winuser.h:1245
#define SW_ERASE
Definition: winuser.h:2591
int WINAPI SetScrollInfo(_In_ HWND, _In_ int, _In_ LPCSCROLLINFO, _In_ BOOL)
BOOL WINAPI GetScrollInfo(_In_ HWND, _In_ int, _Inout_ LPSCROLLINFO)
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_PAGEUP
Definition: winuser.h:568
#define SB_THUMBPOSITION
Definition: winuser.h:572

Referenced by EventDetailsCtrl().

◆ 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 477 of file evtdetctl.c.

478{
479 LONG_PTR dwStyle;
480 INT sbVXSize, sbHYSize;
481 SCROLLINFO sInfo;
482 POINT scOldPos;
483 HDWP hdwp;
484 HWND hItemWnd;
485 RECT rect;
486 INT y = 0;
487
488 if (!pData)
489 return;
490
491 dwStyle = GetWindowLongPtrW(hDlg, GWL_STYLE);
492 sbVXSize = GetSystemMetrics(SM_CXVSCROLL);
493 sbHYSize = GetSystemMetrics(SM_CYHSCROLL);
494
495 /* Compensate for existing scroll bars (because lParam values do not accommodate scroll bar) */
496 if (dwStyle & WS_HSCROLL) cy += sbHYSize; // Window currently has a horizontal scrollbar
497 if (dwStyle & WS_VSCROLL) cx += sbVXSize; // Window currently has a vertical scrollbar
498
499 /* Compensate for added scroll bars in window */
500 if (cx < pData->cxMin) cy -= sbHYSize; // Window will have a horizontal scroll bar
501 if (cy < pData->cyMin) cx -= sbVXSize; // Window will have a vertical scroll bar
502
503 /* Set scrollbar sizes */
504 sInfo.cbSize = sizeof(sInfo);
505
506 sInfo.fMask = SIF_POS;
507 if (GetScrollInfo(hDlg, SB_VERT, &sInfo))
508 scOldPos.y = sInfo.nPos;
509 else
510 scOldPos.y = pData->scPos.y;
511
512 sInfo.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
513 sInfo.nMin = 0;
514 if (pData->cyMin > cy)
515 {
516 sInfo.nMax = pData->cyMin - 1;
517 sInfo.nPage = cy;
518 sInfo.nPos = pData->scPos.y;
519 SetScrollInfo(hDlg, SB_VERT, &sInfo, TRUE);
520
521 /* Display the scrollbar if needed */
522 if (!(dwStyle & WS_VSCROLL))
523 ShowScrollBar(hDlg, SB_VERT, TRUE);
524 }
525 else
526 {
527 scOldPos.y = 0;
528
529 sInfo.nMax = pData->cyMin - 1;
530 sInfo.nPage = cy;
531 sInfo.nPos = pData->scPos.y;
532 sInfo.nPos = scOldPos.y;
533 SetScrollInfo(hDlg, SB_VERT, &sInfo, TRUE);
534
536
537 rect.left = cx - sbVXSize;
538 rect.right = cx;
539 rect.top = 0;
540 rect.bottom = cy;
541 InvalidateRect(hDlg, &rect, TRUE);
542 }
543
544 sInfo.fMask = SIF_POS;
545 if (GetScrollInfo(hDlg, SB_HORZ, &sInfo))
546 scOldPos.x = sInfo.nPos;
547 else
548 scOldPos.x = pData->scPos.x;
549
550 sInfo.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
551 sInfo.nMin = 0;
552 if (pData->cxMin > cx)
553 {
554 sInfo.nMax = pData->cxMin - 1;
555 sInfo.nPage = cx;
556 sInfo.nPos = pData->scPos.x;
557 SetScrollInfo(hDlg, SB_HORZ, &sInfo, TRUE);
558
559 /* Display the scrollbar if needed */
560 if (!(dwStyle & WS_HSCROLL))
561 ShowScrollBar(hDlg, SB_HORZ, TRUE);
562 }
563 else
564 {
565 scOldPos.x = 0;
566
567 sInfo.nMax = pData->cxMin - 1;
568 sInfo.nPage = cx;
569 sInfo.nPos = pData->scPos.x;
570 sInfo.nPos = scOldPos.x;
571 SetScrollInfo(hDlg, SB_HORZ, &sInfo, TRUE);
572
574
575 rect.left = 0;
576 rect.right = cx;
577 rect.top = cy - sbHYSize;
578 rect.bottom = cy;
579 InvalidateRect(hDlg, &rect, TRUE);
580 }
581
582 if ((scOldPos.x != pData->scPos.x) || (scOldPos.y != pData->scPos.y))
583 {
584 ScrollWindowEx(hDlg,
585 // (scOldPos.x - pData->scPos.x),
586 (pData->scPos.x - scOldPos.x),
587 // (scOldPos.y - pData->scPos.y),
588 (pData->scPos.y - scOldPos.y),
589 NULL,
590 NULL,
591 NULL,
592 NULL,
594
595 pData->scPos = scOldPos;
596 }
597
598 // /* Adjust the start of the visible area if we are attempting to show nonexistent areas */
599 // if ((pData->cxMin - pData->scPos.x) < cx) pData->scPos.x = pData->cxMin - cx;
600 // if ((pData->cyMin - pData->scPos.y) < cy) pData->scPos.y = pData->cyMin - cy;
601 // // InvalidateRect(GuiData->hWindow, NULL, TRUE);
602
603 /* Forbid resizing the control smaller than its minimal size */
604 if (cx < pData->cxMin) cx = pData->cxMin;
605 if (cy < pData->cyMin) cy = pData->cyMin;
606
607 if ((cx != pData->cxOld) || (cy != pData->cyOld))
608 {
609 hdwp = BeginDeferWindowPos(8);
610
611 /* Move the edit boxes */
612
613 GetWindowRect(hDlg, &rect);
614
615 hItemWnd = GetDlgItem(hDlg, IDC_EVENTTEXTEDIT);
616 GetWindowRect(hItemWnd, &rect);
617 MapWindowPoints(HWND_DESKTOP /*NULL*/, hDlg, (LPPOINT)&rect, sizeof(RECT)/sizeof(POINT));
618 // OffsetRect(&rect, 0, y);
619 // y += (cy - pData->cyOld) / 2 ; // + (cy - pData->cyOld) % 2;
621 if (cy >= pData->cyOld)
622 y += (cy - pData->cyOld) / 2 + (cy - pData->cyOld) % 2;
623 else
624 y -= (pData->cyOld - cy) / 2 + (pData->cyOld - cy) % 2;
625
626 if (hdwp)
627 hdwp = DeferWindowPos(hdwp,
628 hItemWnd,
629 0,
630 rect.left, rect.top,
631 (rect.right - rect.left) + (cx - pData->cxOld),
632 (rect.bottom - rect.top) + y, SWP_NOZORDER | SWP_NOACTIVATE);
634
635 hItemWnd = GetDlgItem(hDlg, IDC_DETAILS_STATIC);
636 GetWindowRect(hItemWnd, &rect);
637 MapWindowPoints(HWND_DESKTOP /*NULL*/, hDlg, (LPPOINT)&rect, sizeof(RECT)/sizeof(POINT));
638 // OffsetRect(&rect, 0, y);
639
640 if (hdwp)
641 hdwp = DeferWindowPos(hdwp,
642 hItemWnd,
643 0,
644 rect.left, rect.top + y,
645 0, 0,
647
648 hItemWnd = GetDlgItem(hDlg, IDC_BYTESRADIO);
649 GetWindowRect(hItemWnd, &rect);
650 MapWindowPoints(HWND_DESKTOP /*NULL*/, hDlg, (LPPOINT)&rect, sizeof(RECT)/sizeof(POINT));
651 // OffsetRect(&rect, 0, y);
652
653 if (hdwp)
654 hdwp = DeferWindowPos(hdwp,
655 hItemWnd,
656 0,
657 rect.left, rect.top + y,
658 0, 0,
660
661 hItemWnd = GetDlgItem(hDlg, IDC_WORDSRADIO);
662 GetWindowRect(hItemWnd, &rect);
663 MapWindowPoints(HWND_DESKTOP /*NULL*/, hDlg, (LPPOINT)&rect, sizeof(RECT)/sizeof(POINT));
664 // OffsetRect(&rect, 0, y);
665
666 if (hdwp)
667 hdwp = DeferWindowPos(hdwp,
668 hItemWnd,
669 0,
670 rect.left, rect.top + y,
671 0, 0,
673
674 hItemWnd = GetDlgItem(hDlg, IDC_EVENTDATAEDIT);
675 GetWindowRect(hItemWnd, &rect);
676 MapWindowPoints(HWND_DESKTOP /*NULL*/, hDlg, (LPPOINT)&rect, sizeof(RECT)/sizeof(POINT));
677 // OffsetRect(&rect, 0, y);
678 // // y -= (cy - pData->cyOld) % 2;
679
680 if (hdwp)
681 hdwp = DeferWindowPos(hdwp,
682 hItemWnd,
683 0,
684 rect.left, rect.top + y,
685 (rect.right - rect.left) + (cx - pData->cxOld),
686 (rect.bottom - rect.top) + y,
688
689 /* Move the buttons */
690
691 hItemWnd = GetDlgItem(hDlg, IDC_PREVIOUS);
692 GetWindowRect(hItemWnd, &rect);
693 MapWindowPoints(HWND_DESKTOP /*NULL*/, hDlg, (LPPOINT)&rect, sizeof(RECT)/sizeof(POINT));
694
695 if (hdwp)
696 hdwp = DeferWindowPos(hdwp,
697 hItemWnd,
698 0,
699 rect.left + (cx - pData->cxOld),
700 rect.top,
701 0, 0,
703
704 hItemWnd = GetDlgItem(hDlg, IDC_NEXT);
705 GetWindowRect(hItemWnd, &rect);
706 MapWindowPoints(HWND_DESKTOP /*NULL*/, hDlg, (LPPOINT)&rect, sizeof(RECT)/sizeof(POINT));
707
708 if (hdwp)
709 hdwp = DeferWindowPos(hdwp,
710 hItemWnd,
711 0,
712 rect.left + (cx - pData->cxOld),
713 rect.top,
714 0, 0,
716
717 hItemWnd = GetDlgItem(hDlg, IDC_COPY);
718 GetWindowRect(hItemWnd, &rect);
719 MapWindowPoints(HWND_DESKTOP /*NULL*/, hDlg, (LPPOINT)&rect, sizeof(RECT)/sizeof(POINT));
720
721 if (hdwp)
722 hdwp = DeferWindowPos(hdwp,
723 hItemWnd,
724 0,
725 rect.left + (cx - pData->cxOld),
726 rect.top,
727 0, 0,
729
730 if (hdwp)
731 EndDeferWindowPos(hdwp);
732
733 pData->cxOld = cx;
734 pData->cyOld = cy;
735 }
736}
#define IDC_DETAILS_STATIC
Definition: resource.h:51
static INT cxMin
Definition: eventvwr.c:4278
static INT cyMin
Definition: eventvwr.c:4278
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
if(dx< 0)
Definition: linetemp.h:194
#define WS_VSCROLL
Definition: pedump.c:627
#define WS_HSCROLL
Definition: pedump.c:628
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585
#define SWP_NOACTIVATE
Definition: winuser.h:1253
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define SM_CXVSCROLL
Definition: winuser.h:972
#define SWP_NOSIZE
Definition: winuser.h:1256
BOOL WINAPI EndDeferWindowPos(_In_ HDWP)
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
#define SM_CYHSCROLL
Definition: winuser.h:973
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define HWND_DESKTOP
Definition: winuser.h:1220
HDWP WINAPI DeferWindowPos(_In_ HDWP, _In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
BOOL WINAPI ShowScrollBar(_In_ HWND, _In_ int, _In_ BOOL)
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define SWP_NOZORDER
Definition: winuser.h:1258
#define GWL_STYLE
Definition: winuser.h:863
int WINAPI GetSystemMetrics(_In_ int)
HDWP WINAPI BeginDeferWindowPos(_In_ int)

Referenced by EventDetailsCtrl().

◆ PrintByteDataLine()

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

Definition at line 111 of file evtdetctl.c.

112{
113 PWCHAR p = pBuffer;
114 UINT n, i, r = 0;
115
116 if (uOffset != 0)
117 {
118 n = swprintf(p, L"\r\n");
119 p += n;
120 r += n;
121 }
122
123 n = swprintf(p, L"%04lx:", uOffset);
124 p += n;
125 r += n;
126
127 for (i = 0; i < uLength; i++)
128 {
129 n = swprintf(p, L" %02x", pData[i]);
130 p += n;
131 r += n;
132 }
133
134 for (i = 0; i < 9 - uLength; i++)
135 {
136 n = swprintf(p, L" ");
137 p += n;
138 r += n;
139 }
140
141 for (i = 0; i < uLength; i++)
142 {
143 // NOTE: Normally iswprint should return FALSE for tabs...
144 n = swprintf(p, L"%c", (iswprint(pData[i]) && (pData[i] != L'\t')) ? pData[i] : L'.');
145 p += n;
146 r += n;
147 }
148
149 return r;
150}
#define swprintf
Definition: precomp.h:40
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble n
Definition: glext.h:7729
GLfloat GLfloat p
Definition: glext.h:8902
#define iswprint(_c)
Definition: ctype.h:672
PVOID pBuffer

Referenced by DisplayEventData().

◆ PrintWordDataLine()

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

Definition at line 154 of file evtdetctl.c.

155{
156 PWCHAR p = pBuffer;
157 UINT n, i, r = 0;
158
159 if (uOffset != 0)
160 {
161 n = swprintf(p, L"\r\n");
162 p += n;
163 r += n;
164 }
165
166 n = swprintf(p, L"%04lx:", uOffset);
167 p += n;
168 r += n;
169
170 for (i = 0; i < uLength / sizeof(ULONG); i++)
171 {
172 n = swprintf(p, L" %08lx", pData[i]);
173 p += n;
174 r += n;
175 }
176
177 /* Display the remaining bytes if uLength was not a multiple of sizeof(ULONG) */
178 for (i = (uLength / sizeof(ULONG)) * sizeof(ULONG); i < uLength; i++)
179 {
180 n = swprintf(p, L" %02x", ((PBYTE)pData)[i]);
181 p += n;
182 r += n;
183 }
184
185 return r;
186}
BYTE * PBYTE
Definition: pedump.c:66

Referenced by DisplayEventData().

Variable Documentation

◆ hwndListView

◆ szTitle

WCHAR szTitle[]
extern

Definition at line 35 of file magnifier.c.

Referenced by EventDetailsCtrl().