ReactOS 0.4.16-dev-340-g0540c21
hexedit.c
Go to the documentation of this file.
1/*
2 * Hex editor control
3 *
4 * Copyright (C) 2004 Thomas Weidenmueller <w3seek@reactos.com>
5 * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
6 */
7
8#include "regedit.h"
9
10typedef struct
11{
26
30
35
39
40static const WCHAR ClipboardFormatName[] = L"RegEdit_HexData";
42
43/* hit test codes */
44#define HEHT_LEFTMARGIN (0x1)
45#define HEHT_ADDRESS (0x2)
46#define HEHT_ADDRESSSPACING (0x3)
47#define HEHT_HEXDUMP (0x4)
48#define HEHT_HEXDUMPSPACING (0x5)
49#define HEHT_ASCIIDUMP (0x6)
50#define HEHT_RIGHTMARGIN (0x7)
51
53
54ATOM
57{
59
61
63 WndClass.cbSize = sizeof(WNDCLASSEXW);
64 WndClass.style = CS_DBLCLKS;
65 WndClass.lpfnWndProc = HexEditWndProc;
66 WndClass.cbWndExtra = sizeof(PHEXEDIT_DATA);
67 WndClass.hInstance = hInstance;
69 WndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
70 WndClass.lpszClassName = HEX_EDIT_CLASS_NAME;
71
73}
74
75BOOL
78{
80}
81
82/*** Helper functions *********************************************************/
83
84static VOID
86{
87 SCROLLINFO si;
88
89 si.cbSize = sizeof(SCROLLINFO);
90 si.fMask = SIF_POS;
91 GetScrollInfo(hed->hWndSelf, SB_VERT, &si);
92
93 if(Scroll)
94 {
95 if(si.nPos > hed->CaretLine)
96 {
97 si.nPos = hed->CaretLine;
99 GetScrollInfo(hed->hWndSelf, SB_VERT, &si);
101 }
102 else if(hed->CaretLine >= (hed->nVisibleLinesComplete + si.nPos))
103 {
104 si.nPos = hed->CaretLine - hed->nVisibleLinesComplete + 1;
105 SetScrollInfo(hed->hWndSelf, SB_VERT, &si, TRUE);
106 GetScrollInfo(hed->hWndSelf, SB_VERT, &si);
108 }
109 }
110
111 if(hed->EditingField)
112 SetCaretPos(hed->LeftMargin + ((4 + hed->AddressSpacing + (3 * hed->CaretCol) + hed->InMid * 2) * hed->CharWidth) - 1, (hed->CaretLine - si.nPos) * hed->LineHeight);
113 else
114 SetCaretPos(hed->LeftMargin + ((4 + hed->AddressSpacing + hed->SplitSpacing + (3 * hed->ColumnsPerLine) + hed->CaretCol) * hed->CharWidth) - 2, (hed->CaretLine - si.nPos) * hed->LineHeight);
115}
116
117static VOID
119{
120 SCROLLINFO si;
121 RECT rcClient;
122 BOOL SbVisible;
123 INT bufsize, cvislines;
124
125 GetClientRect(hed->hWndSelf, &rcClient);
127
128 bufsize = (hed->hBuffer ? (INT) LocalSize(hed->hBuffer) : 0);
129 hed->nLines = max(bufsize / hed->ColumnsPerLine, 1);
130 if(bufsize > hed->ColumnsPerLine && (bufsize % hed->ColumnsPerLine) > 0)
131 {
132 hed->nLines++;
133 }
134
135 if(hed->LineHeight > 0)
136 {
137 hed->nVisibleLinesComplete = cvislines = rcClient.bottom / hed->LineHeight;
139 if(rcClient.bottom % hed->LineHeight)
140 {
141 hed->nVisibleLines++;
142 }
143 }
144 else
145 {
146 hed->nVisibleLines = cvislines = 0;
147 }
148
149 SbVisible = bufsize > 0 && cvislines < hed->nLines;
150 ShowScrollBar(hed->hWndSelf, SB_VERT, SbVisible);
151
152 /* update scrollbar */
153 si.cbSize = sizeof(SCROLLINFO);
154 si.fMask = SIF_RANGE | SIF_PAGE;
155 si.nMin = 0;
156 si.nMax = ((bufsize > 0) ? hed->nLines - 1 : 0);
157 si.nPage = ((hed->LineHeight > 0) ? rcClient.bottom / hed->LineHeight : 0);
158 SetScrollInfo(hed->hWndSelf, SB_VERT, &si, TRUE);
159
160 if(IsWindowVisible(hed->hWndSelf) && SbVisible != hed->SbVisible)
161 {
163 }
164
165 hed->SbVisible = SbVisible;
166}
167
168static HFONT
170{
171 LOGFONT lf;
173 return CreateFontIndirect(&lf);
174}
175
176static VOID
178{
179 DWORD dx, dy, linestart;
180 INT i, isave, i0, i1, x;
182 size_t bufsize;
183 WCHAR hex[3], addr[17];
184 RECT rct, rct2;
185
186 FillRect(hDC, rc, (HBRUSH)(COLOR_WINDOW + 1));
188
189 if (hed->SelStart < hed->SelEnd)
190 {
191 i0 = hed->SelStart;
192 i1 = hed->SelEnd;
193 }
194 else
195 {
196 i0 = hed->SelEnd;
197 i1 = hed->SelStart;
198 }
199
200 if(hed->hBuffer)
201 {
202 bufsize = LocalSize(hed->hBuffer);
203 buf = LocalLock(hed->hBuffer);
204 }
205 else
206 {
207 buf = NULL;
208 bufsize = 0;
209
210 if(ScrollPos + First == 0)
211 {
212 /* draw address */
213 wsprintf(addr, L"%04X", 0);
214 TextOutW(hDC, hed->LeftMargin, First * hed->LineHeight, addr, 4);
215 }
216 }
217
218 if(buf)
219 {
220 end = buf + bufsize;
221 dy = First * hed->LineHeight;
222 linestart = (ScrollPos + First) * hed->ColumnsPerLine;
223 i = linestart;
224 current = buf + linestart;
225 Last = min(hed->nLines - ScrollPos, Last);
226
228 while(First <= Last && current < end)
229 {
230 DWORD dh;
231
232 dx = hed->LeftMargin;
233
234 /* draw address */
235 wsprintf(addr, L"%04lX", linestart);
236 TextOutW(hDC, dx, dy, addr, 4);
237
238 dx += ((4 + hed->AddressSpacing) * hed->CharWidth);
239 dh = (3 * hed->CharWidth);
240
241 rct.left = dx;
242 rct.top = dy;
243 rct.right = rct.left + dh;
244 rct.bottom = dy + hed->LineHeight;
245
246 /* draw hex map */
247 dx += (hed->CharWidth / 2);
248 line = current;
249 isave = i;
250 for(x = 0; x < hed->ColumnsPerLine && current < end; x++)
251 {
252 rct.left += dh;
253 rct.right += dh;
254
255 wsprintf(hex, L"%02X", *(current++));
256 if (i0 <= i && i < i1)
257 {
258 rct2.left = dx;
259 rct2.top = dy;
260 rct2.right = dx + hed->CharWidth * 2 + 1;
261 rct2.bottom = dy + hed->LineHeight;
262 InflateRect(&rct2, hed->CharWidth / 2, 0);
263 FillRect(hDC, &rct2, (HBRUSH)(COLOR_HIGHLIGHT + 1));
265 ExtTextOutW(hDC, dx, dy, 0, &rct, hex, 2, NULL);
267 }
268 else
269 ExtTextOutW(hDC, dx, dy, ETO_OPAQUE, &rct, hex, 2, NULL);
270 dx += dh;
271 i++;
272 }
273
274 /* draw ascii map */
275 dx = ((4 + hed->AddressSpacing + hed->SplitSpacing + (hed->ColumnsPerLine * 3)) * hed->CharWidth);
276 current = line;
277 i = isave;
278 for(x = 0; x < hed->ColumnsPerLine && current < end; x++)
279 {
280 wsprintf(hex, L"%C", *(current++));
281 hex[0] = ((hex[0] & L'\x007f') >= L' ' ? hex[0] : L'.');
282 if (i0 <= i && i < i1)
283 {
284 rct2.left = dx;
285 rct2.top = dy;
286 rct2.right = dx + hed->CharWidth;
287 rct2.bottom = dy + hed->LineHeight;
288 FillRect(hDC, &rct2, (HBRUSH)(COLOR_HIGHLIGHT + 1));
290 TextOutW(hDC, dx, dy, hex, 1);
292 }
293 else
294 TextOutW(hDC, dx, dy, hex, 1);
295 dx += hed->CharWidth;
296 i++;
297 }
298
299 dy += hed->LineHeight;
300 linestart += hed->ColumnsPerLine;
301 First++;
302 }
303 }
304
305 LocalUnlock(hed->hBuffer);
306}
307
308static DWORD
310{
311 int d;
312
313 if(pt.x <= hed->LeftMargin)
314 {
315 return HEHT_LEFTMARGIN;
316 }
317
318 pt.x -= hed->LeftMargin;
319 d = (4 * hed->CharWidth);
320 if(pt.x <= d)
321 {
322 return HEHT_ADDRESS;
323 }
324
325 pt.x -= d;
326 d = (hed->AddressSpacing * hed->CharWidth);
327 if(pt.x <= d)
328 {
329 return HEHT_ADDRESSSPACING;
330 }
331
332 pt.x -= d;
333 d = ((3 * hed->ColumnsPerLine + 1) * hed->CharWidth);
334 if(pt.x <= d)
335 {
336 return HEHT_HEXDUMP;
337 }
338
339 pt.x -= d;
340 d = ((hed->SplitSpacing - 1) * hed->CharWidth);
341 if(pt.x <= d)
342 {
343 return HEHT_HEXDUMPSPACING;
344 }
345
346 pt.x -= d;
347 d = (hed->ColumnsPerLine * hed->CharWidth);
348 if(pt.x <= d)
349 {
350 return HEHT_ASCIIDUMP;
351 }
352
353 return HEHT_RIGHTMARGIN;
354}
355
356static DWORD
358{
359 SCROLLINFO si;
361
362 si.cbSize = sizeof(SCROLLINFO);
363 si.fMask = SIF_POS;
364 GetScrollInfo(hed->hWndSelf, SB_VERT, &si);
365
366 EditPos->x = 0;
367
368 if(hed->LineHeight > 0)
369 {
370 EditPos->y = min(si.nPos + (pt.y / hed->LineHeight), hed->nLines - 1);
371 }
372 else
373 {
374 EditPos->y = si.nPos;
375 }
376
377 switch(Hit)
378 {
379 case HEHT_LEFTMARGIN:
380 case HEHT_ADDRESS:
382 case HEHT_HEXDUMP:
383 pt.x -= (SHORT) hed->LeftMargin + ((4 + hed->AddressSpacing) * hed->CharWidth);
384 *EditField = TRUE;
385 break;
386
387 default:
388 pt.x -= hed->LeftMargin + ((4 + hed->AddressSpacing + hed->SplitSpacing + (3 * hed->ColumnsPerLine)) * hed->CharWidth);
389 *EditField = FALSE;
390 break;
391 }
392
393 if(pt.x > 0)
394 {
395 INT BlockWidth = (*EditField ? hed->CharWidth * 3 : hed->CharWidth);
396 EditPos->x = min(hed->ColumnsPerLine, (pt.x + BlockWidth / 2) / BlockWidth);
397 }
398
399 bufsize = (hed->hBuffer ? (DWORD) LocalSize(hed->hBuffer) : 0);
400 Index = (EditPos->y * hed->ColumnsPerLine) + EditPos->x;
401 if(Index > bufsize)
402 {
403 INT tmp = bufsize % hed->ColumnsPerLine;
404 Index = bufsize;
405 EditPos->x = (tmp == 0 ? hed->ColumnsPerLine : tmp);
406 }
407 return Index;
408}
409
410static VOID
412{
413 PBYTE pb, buf;
414 UINT cb;
415 INT i0, i1;
416 HGLOBAL hGlobal;
417
418 if (hed->SelStart < hed->SelEnd)
419 {
420 i0 = hed->SelStart;
421 i1 = hed->SelEnd;
422 }
423 else
424 {
425 i0 = hed->SelEnd;
426 i1 = hed->SelStart;
427 }
428
429 cb = i1 - i0;
430 if (cb == 0)
431 return;
432
433 hGlobal = GlobalAlloc(GHND | GMEM_SHARE, cb + sizeof(DWORD));
434 if (hGlobal == NULL)
435 return;
436
437 pb = GlobalLock(hGlobal);
438 if (pb)
439 {
440 *(PDWORD)pb = cb;
441 pb += sizeof(DWORD);
442 buf = (PBYTE) LocalLock(hed->hBuffer);
443 if (buf)
444 {
445 CopyMemory(pb, buf + i0, cb);
446 LocalUnlock(hed->hBuffer);
447 }
448 GlobalUnlock(hGlobal);
449
450 if (OpenClipboard(hed->hWndSelf))
451 {
455 }
456 }
457 else
458 GlobalFree(hGlobal);
459}
460
461static VOID
463{
464 PBYTE buf;
465 INT i0, i1;
467
468 if (hed->SelStart < hed->SelEnd)
469 {
470 i0 = hed->SelStart;
471 i1 = hed->SelEnd;
472 }
473 else
474 {
475 i0 = hed->SelEnd;
476 i1 = hed->SelStart;
477 }
478
479 if (i0 != i1)
480 {
481 bufsize = (hed->hBuffer ? LocalSize(hed->hBuffer) : 0);
482 buf = (PBYTE) LocalLock(hed->hBuffer);
483 if (buf)
484 {
485 MoveMemory(buf + i0, buf + i1, bufsize - i1);
486 LocalUnlock(hed->hBuffer);
487 }
488 HexEdit_SetMaxBufferSize(hed->hWndSelf, bufsize - (i1 - i0));
489 hed->InMid = FALSE;
490 hed->Index = hed->SelStart = hed->SelEnd = i0;
491 hed->CaretCol = hed->Index % hed->ColumnsPerLine;
492 hed->CaretLine = hed->Index / hed->ColumnsPerLine;
495 }
496}
497
498static VOID
500{
501 HGLOBAL hGlobal;
503 PBYTE pb, buf;
504 DWORD cb;
505
506 HEXEDIT_Delete(hed);
507 bufsize = (hed->hBuffer ? LocalSize(hed->hBuffer) : 0);
508
509 if (OpenClipboard(hed->hWndSelf))
510 {
512 if (hGlobal != NULL)
513 {
514 pb = (PBYTE) GlobalLock(hGlobal);
515 cb = *(PDWORD) pb;
516 pb += sizeof(DWORD);
518 buf = (PBYTE) LocalLock(hed->hBuffer);
519 if (buf)
520 {
521 MoveMemory(buf + hed->Index + cb, buf + hed->Index,
522 bufsize - hed->Index);
523 CopyMemory(buf + hed->Index, pb, cb);
524 LocalUnlock(hed->hBuffer);
525 }
526 GlobalUnlock(hGlobal);
527 }
529 }
532}
533
534static VOID
536{
537 HEXEDIT_Copy(hed);
538 HEXEDIT_Delete(hed);
539}
540
541static VOID
543{
544 INT bufsize;
545
546 bufsize = (hed->hBuffer ? (INT) LocalSize(hed->hBuffer) : 0);
547 hed->Index = hed->SelStart = 0;
548 hed->SelEnd = bufsize;
551}
552
553/*** Control specific messages ************************************************/
554
555static LRESULT
557{
558 if(Buffer != NULL && Size > 0)
559 {
560 LPVOID buf;
561
562 if(hed->MaxBuffer > 0 && Size > hed->MaxBuffer)
563 {
564 Size = hed->MaxBuffer;
565 }
566
567 if(hed->hBuffer)
568 {
569 if(Size > 0)
570 {
571 if(LocalSize(hed->hBuffer) != Size)
572 {
574 }
575 }
576 else
577 {
578 hed->hBuffer = LocalFree(hed->hBuffer);
579 hed->Index = 0;
580 HEXEDIT_Update(hed);
581
582 return 0;
583 }
584 }
585 else if(Size > 0)
586 {
587 hed->hBuffer = LocalAlloc(LHND, Size);
588 }
589
590 if(Size > 0)
591 {
592 buf = LocalLock(hed->hBuffer);
593 if(buf)
594 {
596 }
597 else
598 Size = 0;
599 LocalUnlock(hed->hBuffer);
600 }
601
602 hed->Index = 0;
603 HEXEDIT_Update(hed);
604 return Size;
605 }
606 else if(hed->hBuffer)
607 {
608 hed->Index = 0;
609 hed->hBuffer = LocalFree(hed->hBuffer);
610 HEXEDIT_Update(hed);
611 }
612
613 return 0;
614}
615
616static LRESULT
618{
619 size_t nCpy;
620
621 if(!hed->hBuffer)
622 {
623 return 0;
624 }
625
626 if(Buffer != NULL && Size > 0)
627 {
628 nCpy = min(Size, LocalSize(hed->hBuffer));
629 if(nCpy > 0)
630 {
631 PVOID buf;
632
633 buf = LocalLock(hed->hBuffer);
634 if(buf)
635 {
636 memcpy(Buffer, buf, nCpy);
637 }
638 else
639 nCpy = 0;
640 LocalUnlock(hed->hBuffer);
641 }
642 return nCpy;
643 }
644
645 return (LRESULT)LocalSize(hed->hBuffer);
646}
647
648static LRESULT
650{
651 hed->MaxBuffer = nMaxSize;
652 if (hed->MaxBuffer == 0)
653 {
654 hed->hBuffer = LocalFree(hed->hBuffer);
655 return 0;
656 }
657 if (hed->hBuffer)
659 else
661 HEXEDIT_Update(hed);
662 return 0;
663}
664
665/*** Message Proc *************************************************************/
666
667static LRESULT
669{
670 PHEXEDIT_DATA hed;
671
672 if(!(hed = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(HEXEDIT_DATA))))
673 {
674 return FALSE;
675 }
676
677 hed->hWndSelf = hWnd;
678 hed->hWndParent = cs->hwndParent;
679 hed->style = cs->style;
680
681 hed->ColumnsPerLine = 8;
682 hed->LeftMargin = 2;
683 hed->AddressSpacing = 2;
684 hed->SplitSpacing = 2;
685 hed->EditingField = TRUE; /* in hexdump field */
686
688 HEXEDIT_Update(hed);
689
690 return TRUE;
691}
692
693static LRESULT
695{
696 if(hed->hBuffer)
697 {
698 //while(LocalUnlock(hed->hBuffer));
699 LocalFree(hed->hBuffer);
700 }
701
702 if(hed->hFont)
703 {
704 DeleteObject(hed->hFont);
705 }
706
708 HeapFree(GetProcessHeap(), 0, hed);
709
710 return 0;
711}
712
713static LRESULT
715{
717 return 1;
718}
719
720static LRESULT
722{
723 CreateCaret(hed->hWndSelf, 0, 1, hed->LineHeight);
725 ShowCaret(hed->hWndSelf);
726 return 0;
727}
728
729static LRESULT
731{
733 DestroyCaret();
734 return 0;
735}
736
737static LRESULT
738HEXEDIT_WM_VSCROLL(PHEXEDIT_DATA hed, WORD ThumbPosition, WORD SbCmd)
739{
740 int ScrollY;
741 SCROLLINFO si;
742
743 UNREFERENCED_PARAMETER(ThumbPosition);
744
745 ZeroMemory(&si, sizeof(SCROLLINFO));
746 si.cbSize = sizeof(SCROLLINFO);
747 si.fMask = SIF_ALL;
748 GetScrollInfo(hed->hWndSelf, SB_VERT, &si);
749
750 ScrollY = si.nPos;
751 switch(SbCmd)
752 {
753 case SB_TOP:
754 si.nPos = si.nMin;
755 break;
756
757 case SB_BOTTOM:
758 si.nPos = si.nMax;
759 break;
760
761 case SB_LINEUP:
762 si.nPos--;
763 break;
764
765 case SB_LINEDOWN:
766 si.nPos++;
767 break;
768
769 case SB_PAGEUP:
770 si.nPos -= si.nPage;
771 break;
772
773 case SB_PAGEDOWN:
774 si.nPos += si.nPage;
775 break;
776
777 case SB_THUMBTRACK:
778 si.nPos = si.nTrackPos;
779 break;
780 }
781
782 si.fMask = SIF_POS;
783 SetScrollInfo(hed->hWndSelf, SB_VERT, &si, TRUE);
784 GetScrollInfo(hed->hWndSelf, SB_VERT, &si);
785
786 if(si.nPos != ScrollY)
787 {
788 ScrollWindow(hed->hWndSelf, 0, (ScrollY - si.nPos) * hed->LineHeight, NULL, NULL);
790 }
791
792 return 0;
793}
794
795static LRESULT
797{
798 HDC hDC;
800 HFONT hOldFont = 0;
801
802 if(hFont == 0)
803 {
805 }
806
807 hed->hFont = hFont;
808 hDC = GetDC(hed->hWndSelf);
809 if(hFont)
810 {
811 hOldFont = SelectObject(hDC, hFont);
812 }
814 hed->LineHeight = tm.tmHeight;
815 hed->CharWidth = tm.tmAveCharWidth;
816 if(hOldFont)
817 {
818 SelectObject(hDC, hOldFont);
819 }
820 ReleaseDC(hed->hWndSelf, hDC);
821
822 if(bRedraw)
823 {
825 }
826
827 return 0;
828}
829
830static LRESULT
832{
833 return (LRESULT)hed->hFont;
834}
835
836static LRESULT
838{
839 PAINTSTRUCT ps;
840 SCROLLINFO si;
841 RECT rc;
842 HBITMAP hbmp, hbmpold;
843 INT nLines, nFirst;
844 HFONT hOldFont;
845 HDC hTempDC;
847
848 if(GetUpdateRect(hed->hWndSelf, &rc, FALSE) && (hed->LineHeight > 0))
849 {
850 ZeroMemory(&si, sizeof(SCROLLINFO));
851 si.cbSize = sizeof(SCROLLINFO);
852 si.fMask = SIF_POS;
853 GetScrollInfo(hed->hWndSelf, SB_VERT, &si);
854
855 height = (rc.bottom - rc.top);
856 nLines = height / hed->LineHeight;
857 if((height % hed->LineHeight) > 0)
858 {
859 nLines++;
860 }
861 if(nLines > hed->nLines - si.nPos)
862 {
863 nLines = hed->nLines - si.nPos;
864 }
865 nFirst = rc.top / hed->LineHeight;
866
867 BeginPaint(hed->hWndSelf, &ps);
868 if(!(hTempDC = CreateCompatibleDC(ps.hdc)))
869 {
870 FillRect(ps.hdc, &rc, (HBRUSH)(COLOR_WINDOW + 1));
871 goto epaint;
872 }
874 {
875 FillRect(ps.hdc, &rc, (HBRUSH)(COLOR_WINDOW + 1));
876 DeleteDC(hTempDC);
877 goto epaint;
878 }
879 hbmpold = SelectObject(hTempDC, hbmp);
880 hOldFont = SelectObject(hTempDC, hed->hFont);
881 HEXEDIT_PaintLines(hed, hTempDC, si.nPos, nFirst, nFirst + nLines, &ps.rcPaint);
882 BitBlt(ps.hdc, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, hTempDC, rc.left, rc.top, SRCCOPY);
883 SelectObject(hTempDC, hOldFont);
884 SelectObject(hTempDC, hbmpold);
885
887 DeleteDC(hTempDC);
888
889epaint:
890 EndPaint(hed->hWndSelf, &ps);
891 }
892
893 return 0;
894}
895
896static LRESULT
897HEXEDIT_WM_MOUSEWHEEL(PHEXEDIT_DATA hed, int cyMoveLines, WORD ButtonsDown, LPPOINTS MousePos)
898{
899 SCROLLINFO si;
900 int ScrollY;
901
902 UNREFERENCED_PARAMETER(ButtonsDown);
903 UNREFERENCED_PARAMETER(MousePos);
904
905 SetFocus(hed->hWndSelf);
906
907 si.cbSize = sizeof(SCROLLINFO);
908 si.fMask = SIF_ALL;
909 GetScrollInfo(hed->hWndSelf, SB_VERT, &si);
910
911 ScrollY = si.nPos;
912
913 si.fMask = SIF_POS;
914 si.nPos += cyMoveLines;
915 SetScrollInfo(hed->hWndSelf, SB_VERT, &si, TRUE);
916
917 GetScrollInfo(hed->hWndSelf, SB_VERT, &si);
918 if(si.nPos != ScrollY)
919 {
920 ScrollWindow(hed->hWndSelf, 0, (ScrollY - si.nPos) * hed->LineHeight, NULL, NULL);
922 }
923
924 return 0;
925}
926
927static LRESULT
929{
932}
933
934static LRESULT
936{
937 BOOL NewField;
938 POINT EditPos;
939 DWORD Hit;
940
942 SetFocus(hed->hWndSelf);
943
944 if (GetAsyncKeyState(VK_SHIFT) < 0)
945 {
946 if (hed->EditingField)
947 hed->Index = HEXEDIT_IndexFromPoint(hed, Pt, HEHT_HEXDUMP, &EditPos, &NewField);
948 else
949 hed->Index = HEXEDIT_IndexFromPoint(hed, Pt, HEHT_ASCIIDUMP, &EditPos, &NewField);
950 hed->SelEnd = hed->Index;
951 }
952 else
953 {
954 Hit = HEXEDIT_HitRegionTest(hed, Pt);
955 hed->Index = HEXEDIT_IndexFromPoint(hed, Pt, Hit, &EditPos, &NewField);
956 hed->SelStart = hed->SelEnd = hed->Index;
957 hed->EditingField = NewField;
958 SetCapture(hed->hWndSelf);
959 }
960 hed->CaretCol = EditPos.x;
961 hed->CaretLine = EditPos.y;
962 hed->InMid = FALSE;
965
966 return 0;
967}
968
969static LRESULT
971{
972 BOOL NewField;
973 POINT EditPos;
974 if (GetCapture() == hed->hWndSelf)
975 {
976 if (hed->EditingField)
977 hed->Index = HEXEDIT_IndexFromPoint(hed, Pt, HEHT_HEXDUMP, &EditPos, &NewField);
978 else
979 hed->Index = HEXEDIT_IndexFromPoint(hed, Pt, HEHT_ASCIIDUMP, &EditPos, &NewField);
980 hed->CaretCol = EditPos.x;
981 hed->CaretLine = EditPos.y;
982 hed->SelEnd = hed->Index;
986 }
987 return 0;
988}
989
990static LRESULT
992{
993 BOOL NewField;
994 POINT EditPos;
995 if (GetCapture() == hed->hWndSelf)
996 {
997 if (hed->EditingField)
998 hed->Index = HEXEDIT_IndexFromPoint(hed, Pt, HEHT_HEXDUMP, &EditPos, &NewField);
999 else
1000 hed->Index = HEXEDIT_IndexFromPoint(hed, Pt, HEHT_ASCIIDUMP, &EditPos, &NewField);
1001 hed->CaretCol = EditPos.x;
1002 hed->CaretLine = EditPos.y;
1003 hed->SelEnd = hed->Index;
1005 HEXEDIT_MoveCaret(hed, TRUE);
1006 }
1007 return 0;
1008}
1009
1010static BOOL
1012{
1013 size_t bufsize;
1014 PBYTE buf;
1015 INT i0, i1;
1016
1017 if(GetKeyState(VK_MENU) & 0x8000)
1018 {
1019 return FALSE;
1020 }
1021
1022 bufsize = (hed->hBuffer ? LocalSize(hed->hBuffer) : 0);
1023
1024 if (hed->SelStart < hed->SelEnd)
1025 {
1026 i0 = hed->SelStart;
1027 i1 = hed->SelEnd;
1028 }
1029 else
1030 {
1031 i0 = hed->SelEnd;
1032 i1 = hed->SelStart;
1033 }
1034
1035 switch(VkCode)
1036 {
1037 case 'X':
1038 if (GetAsyncKeyState(VK_SHIFT) >= 0 &&
1039 GetAsyncKeyState(VK_CONTROL) < 0 && hed->SelStart != hed->SelEnd)
1040 HEXEDIT_Cut(hed);
1041 else
1042 return TRUE;
1043 break;
1044
1045 case 'C':
1046 if (GetAsyncKeyState(VK_SHIFT) >= 0 &&
1047 GetAsyncKeyState(VK_CONTROL) < 0 && hed->SelStart != hed->SelEnd)
1048 HEXEDIT_Copy(hed);
1049 else
1050 return TRUE;
1051 break;
1052
1053 case 'V':
1055 HEXEDIT_Paste(hed);
1056 else
1057 return TRUE;
1058 break;
1059
1060 case 'A':
1062 HEXEDIT_SelectAll(hed);
1063 else
1064 return TRUE;
1065 break;
1066
1067 case VK_INSERT:
1068 if (hed->SelStart != hed->SelEnd)
1069 {
1071 HEXEDIT_Copy(hed);
1072 }
1074 HEXEDIT_Paste(hed);
1075 break;
1076
1077 case VK_DELETE:
1079 hed->SelStart != hed->SelEnd)
1080 HEXEDIT_Copy(hed);
1081 if (i0 != i1)
1082 {
1083 buf = (PBYTE) LocalLock(hed->hBuffer);
1084 if (buf)
1085 {
1086 MoveMemory(buf + i0, buf + i1, bufsize - i1);
1087 LocalUnlock(hed->hBuffer);
1088 }
1089 HexEdit_SetMaxBufferSize(hed->hWndSelf, bufsize - (i1 - i0));
1090 hed->InMid = FALSE;
1091 hed->Index = hed->SelStart = hed->SelEnd = i0;
1092 hed->CaretCol = hed->Index % hed->ColumnsPerLine;
1093 hed->CaretLine = hed->Index / hed->ColumnsPerLine;
1094 }
1095 else
1096 {
1097 if (hed->InMid && hed->EditingField)
1098 {
1099 buf = (PBYTE) LocalLock(hed->hBuffer);
1100 if (buf)
1101 {
1102 MoveMemory(buf + hed->Index, buf + hed->Index + 1,
1103 bufsize - hed->Index - 1);
1104 LocalUnlock(hed->hBuffer);
1105 }
1107 hed->InMid = FALSE;
1108 }
1109 else if (hed->Index < bufsize)
1110 {
1111 buf = (PBYTE) LocalLock(hed->hBuffer);
1112 if (buf)
1113 {
1114 MoveMemory(buf + hed->Index, buf + hed->Index + 1,
1115 bufsize - hed->Index - 1);
1116 LocalUnlock(hed->hBuffer);
1117 }
1119 }
1120 }
1122 HEXEDIT_MoveCaret(hed, TRUE);
1123 break;
1124
1125 case VK_BACK:
1126 if (i0 != i1)
1127 {
1128 buf = (PBYTE) LocalLock(hed->hBuffer);
1129 if (buf)
1130 {
1131 MoveMemory(buf + i0, buf + i1, bufsize - i1);
1132 LocalUnlock(hed->hBuffer);
1133 }
1134 HexEdit_SetMaxBufferSize(hed->hWndSelf, bufsize - (i1 - i0));
1135 hed->InMid = FALSE;
1136 hed->Index = hed->SelStart = hed->SelEnd = i0;
1137 hed->CaretCol = hed->Index % hed->ColumnsPerLine;
1138 hed->CaretLine = hed->Index / hed->ColumnsPerLine;
1139 }
1140 else
1141 {
1142 if (hed->InMid && hed->EditingField)
1143 {
1144 buf = (PBYTE) LocalLock(hed->hBuffer);
1145 if (buf)
1146 {
1147 MoveMemory(buf + hed->Index, buf + hed->Index + 1,
1148 bufsize - hed->Index - 1);
1149 LocalUnlock(hed->hBuffer);
1150 }
1151 }
1152 else if (hed->Index > 0)
1153 {
1154 buf = (PBYTE) LocalLock(hed->hBuffer);
1155 if (buf)
1156 {
1157 MoveMemory(buf + hed->Index - 1, buf + hed->Index,
1158 bufsize - hed->Index);
1159 LocalUnlock(hed->hBuffer);
1160 }
1161 hed->Index--;
1162 hed->SelStart = hed->SelEnd = hed->Index;
1163 hed->CaretCol = hed->Index % hed->ColumnsPerLine;
1164 hed->CaretLine = hed->Index / hed->ColumnsPerLine;
1165 }
1166 else
1167 return TRUE;
1169 hed->InMid = FALSE;
1170 }
1172 HEXEDIT_MoveCaret(hed, TRUE);
1173 break;
1174
1175 case VK_LEFT:
1176 if (hed->Index > 0)
1177 {
1178 hed->Index--;
1179 if (GetAsyncKeyState(VK_SHIFT) < 0)
1180 hed->SelEnd = hed->Index;
1181 else
1182 hed->SelStart = hed->SelEnd = hed->Index;
1183 hed->CaretCol = hed->Index % hed->ColumnsPerLine;
1184 hed->CaretLine = hed->Index / hed->ColumnsPerLine;
1185 hed->InMid = FALSE;
1187 HEXEDIT_MoveCaret(hed, TRUE);
1188 }
1189 break;
1190
1191 case VK_RIGHT:
1192 if (hed->Index < (INT)bufsize)
1193 {
1194 hed->Index++;
1195 if (GetAsyncKeyState(VK_SHIFT) < 0)
1196 hed->SelEnd = hed->Index;
1197 else
1198 hed->SelStart = hed->SelEnd = hed->Index;
1199 hed->CaretCol = hed->Index % hed->ColumnsPerLine;
1200 hed->CaretLine = hed->Index / hed->ColumnsPerLine;
1201 hed->InMid = FALSE;
1203 HEXEDIT_MoveCaret(hed, TRUE);
1204 }
1205 break;
1206
1207 case VK_UP:
1208 if (hed->Index >= hed->ColumnsPerLine)
1209 {
1210 hed->Index -= hed->ColumnsPerLine;
1211 if (GetAsyncKeyState(VK_SHIFT) < 0)
1212 hed->SelEnd = hed->Index;
1213 else
1214 hed->SelStart = hed->SelEnd = hed->Index;
1215 hed->CaretCol = hed->Index % hed->ColumnsPerLine;
1216 hed->CaretLine = hed->Index / hed->ColumnsPerLine;
1217 hed->InMid = FALSE;
1219 HEXEDIT_MoveCaret(hed, TRUE);
1220 }
1221 break;
1222
1223 case VK_DOWN:
1224 if (hed->Index + hed->ColumnsPerLine <= (INT) bufsize)
1225 hed->Index += hed->ColumnsPerLine;
1226 else
1227 hed->Index = bufsize;
1228 hed->CaretCol = hed->Index % hed->ColumnsPerLine;
1229 hed->CaretLine = hed->Index / hed->ColumnsPerLine;
1230 if (GetAsyncKeyState(VK_SHIFT) < 0)
1231 hed->SelEnd = hed->Index;
1232 else
1233 hed->SelStart = hed->SelEnd = hed->Index;
1234 hed->InMid = FALSE;
1236 HEXEDIT_MoveCaret(hed, TRUE);
1237 break;
1238
1239 default:
1240 return TRUE;
1241 }
1242
1243 return FALSE;
1244}
1245
1246static BOOL
1248{
1249 size_t bufsize;
1250 CHAR ch = (CHAR)wch; // keep the lowest octet.
1251 PBYTE buf;
1252 INT i0, i1;
1253
1254 bufsize = (hed->hBuffer ? LocalSize(hed->hBuffer) : 0);
1255 if (hed->SelStart < hed->SelEnd)
1256 {
1257 i0 = hed->SelStart;
1258 i1 = hed->SelEnd;
1259 }
1260 else
1261 {
1262 i0 = hed->SelEnd;
1263 i1 = hed->SelStart;
1264 }
1265 if (!hed->EditingField)
1266 {
1267 if (0x20 <= ch && ch <= 0xFF)
1268 {
1269 if (hed->SelStart != hed->SelEnd)
1270 {
1271 buf = (PBYTE) LocalLock(hed->hBuffer);
1272 if (buf)
1273 {
1274 MoveMemory(buf + i0, buf + i1, bufsize - i1);
1275 LocalUnlock(hed->hBuffer);
1276 }
1277 HexEdit_SetMaxBufferSize(hed->hWndSelf, bufsize - (i1 - i0));
1278 hed->InMid = FALSE;
1279 bufsize = (hed->hBuffer ? LocalSize(hed->hBuffer) : 0);
1280 hed->Index = hed->SelStart = hed->SelEnd = i0;
1281 }
1283 buf = (PBYTE) LocalLock(hed->hBuffer);
1284 if (buf)
1285 {
1286 MoveMemory(buf + hed->Index + 1, buf + hed->Index,
1287 bufsize - hed->Index);
1288 buf[hed->Index] = ch;
1289 LocalUnlock(hed->hBuffer);
1290 }
1291 hed->Index++;
1292 hed->CaretCol = hed->Index % hed->ColumnsPerLine;
1293 hed->CaretLine = hed->Index / hed->ColumnsPerLine;
1295 HEXEDIT_MoveCaret(hed, TRUE);
1296 return FALSE;
1297 }
1298 }
1299 else
1300 {
1301 if (('0' <= ch && ch <= '9') || ('A' <= ch && ch <= 'F') ||
1302 ('a' <= ch && ch <= 'f'))
1303 {
1304 if (hed->SelStart != hed->SelEnd)
1305 {
1306 buf = (PBYTE) LocalLock(hed->hBuffer);
1307 if (buf)
1308 {
1309 MoveMemory(buf + i0, buf + i1, bufsize - i1);
1310 LocalUnlock(hed->hBuffer);
1311 }
1312 HexEdit_SetMaxBufferSize(hed->hWndSelf, bufsize - (i1 - i0));
1313 hed->InMid = FALSE;
1314 bufsize = (hed->hBuffer ? LocalSize(hed->hBuffer) : 0);
1315 hed->Index = hed->SelStart = hed->SelEnd = i0;
1316 }
1317 if (hed->InMid)
1318 {
1319 buf = (PBYTE) LocalLock(hed->hBuffer);
1320 if (buf)
1321 {
1322 if ('0' <= ch && ch <= '9')
1323 buf[hed->Index] |= ch - '0';
1324 else if ('A' <= ch && ch <= 'F')
1325 buf[hed->Index] |= ch + 10 - 'A';
1326 else if ('a' <= ch && ch <= 'f')
1327 buf[hed->Index] |= ch + 10 - 'a';
1328 LocalUnlock(hed->hBuffer);
1329 }
1330 hed->InMid = FALSE;
1331 hed->Index++;
1332 }
1333 else
1334 {
1336 buf = (PBYTE) LocalLock(hed->hBuffer);
1337 if (buf)
1338 {
1339 MoveMemory(buf + hed->Index + 1, buf + hed->Index,
1340 bufsize - hed->Index);
1341 if ('0' <= ch && ch <= '9')
1342 buf[hed->Index] = (ch - '0') << 4;
1343 else if ('A' <= ch && ch <= 'F')
1344 buf[hed->Index] = (ch + 10 - 'A') << 4;
1345 else if ('a' <= ch && ch <= 'f')
1346 buf[hed->Index] = (ch + 10 - 'a') << 4;
1347 LocalUnlock(hed->hBuffer);
1348 }
1349 hed->InMid = TRUE;
1350 }
1351 hed->CaretCol = hed->Index % hed->ColumnsPerLine;
1352 hed->CaretLine = hed->Index / hed->ColumnsPerLine;
1354 HEXEDIT_MoveCaret(hed, TRUE);
1355 return FALSE;
1356 }
1357 }
1358 return TRUE;
1359}
1360
1361static LRESULT
1362HEXEDIT_WM_SIZE(PHEXEDIT_DATA hed, DWORD sType, WORD NewWidth, WORD NewHeight)
1363{
1365 UNREFERENCED_PARAMETER(NewHeight);
1366 UNREFERENCED_PARAMETER(NewWidth);
1367 HEXEDIT_Update(hed);
1368 return 0;
1369}
1370
1371static VOID
1373{
1374 HMENU hMenu;
1375 RECT rc;
1376
1377 if (x == -1 && y == -1)
1378 {
1379 GetWindowRect(hed->hWndSelf, &rc);
1380 x = rc.left;
1381 y = rc.top;
1382 }
1383
1385 if (hed->SelStart == hed->SelEnd)
1386 {
1391 }
1392 else
1393 {
1398 }
1399
1401 TrackPopupMenu(hMenu, TPM_RIGHTBUTTON, x, y, 0, hed->hWndSelf, NULL);
1402 PostMessageW(hed->hWndSelf, WM_NULL, 0, 0);
1403}
1404
1407{
1408 PHEXEDIT_DATA hed;
1409 POINTS p;
1410
1412 switch(uMsg)
1413 {
1414 case WM_ERASEBKGND:
1415 return TRUE;
1416
1417 case WM_PAINT:
1418 return HEXEDIT_WM_PAINT(hed);
1419
1420 case WM_KEYDOWN:
1421 return HEXEDIT_WM_KEYDOWN(hed, (INT)wParam);
1422
1423 case WM_CHAR:
1424 return HEXEDIT_WM_CHAR(hed, (WCHAR)wParam);
1425
1426 case WM_VSCROLL:
1428
1429 case WM_SIZE:
1431
1432 case WM_LBUTTONDOWN:
1433 {
1434 p.x = LOWORD(lParam);
1435 p.y = HIWORD(lParam);
1436 return HEXEDIT_WM_LBUTTONDOWN(hed, (INT)wParam, p);
1437 }
1438
1439 case WM_LBUTTONUP:
1440 {
1441 p.x = LOWORD(lParam);
1442 p.y = HIWORD(lParam);
1443 return HEXEDIT_WM_LBUTTONUP(hed, (INT)wParam, p);
1444 }
1445
1446 case WM_MOUSEMOVE:
1447 {
1448 p.x = LOWORD(lParam);
1449 p.y = HIWORD(lParam);
1450 return HEXEDIT_WM_MOUSEMOVE(hed, (INT)wParam, p);
1451 }
1452
1453 case WM_MOUSEWHEEL:
1454 {
1455 UINT nScrollLines = 3;
1456 int delta = 0;
1457
1458 SystemParametersInfoW(SPI_GETWHEELSCROLLLINES, 0, &nScrollLines, 0);
1459 delta -= (SHORT)HIWORD(wParam);
1460 if(abs(delta) >= WHEEL_DELTA && nScrollLines != 0)
1461 {
1462 p.x = LOWORD(lParam);
1463 p.y = HIWORD(lParam);
1464 return HEXEDIT_WM_MOUSEWHEEL(hed, nScrollLines * (delta / WHEEL_DELTA), LOWORD(wParam), &p);
1465 }
1466 break;
1467 }
1468
1469 case HEM_LOADBUFFER:
1471
1472 case HEM_COPYBUFFER:
1474
1477
1478 case WM_SETFOCUS:
1479 return HEXEDIT_WM_SETFOCUS(hed);
1480
1481 case WM_KILLFOCUS:
1482 return HEXEDIT_WM_KILLFOCUS(hed);
1483
1484 case WM_GETDLGCODE:
1486
1487 case WM_SETFONT:
1489
1490 case WM_GETFONT:
1491 return HEXEDIT_WM_GETFONT(hed);
1492
1493 case WM_CREATE:
1494 return HEXEDIT_WM_CREATE(hed);
1495
1496 case WM_NCCREATE:
1497 if(!hed)
1498 {
1500 }
1501 break;
1502
1503 case WM_NCDESTROY:
1504 if(hed)
1505 {
1506 return HEXEDIT_WM_NCDESTROY(hed);
1507 }
1508 break;
1509
1510 case WM_CONTEXTMENU:
1511 HEXEDIT_WM_CONTEXTMENU(hed, (short)LOWORD(lParam), (short)HIWORD(lParam));
1512 break;
1513
1514 case WM_COMMAND:
1515 switch(LOWORD(wParam))
1516 {
1517 case ID_HEXEDIT_CUT:
1518 HEXEDIT_Cut(hed);
1519 break;
1520
1521 case ID_HEXEDIT_COPY:
1522 HEXEDIT_Copy(hed);
1523 break;
1524
1525 case ID_HEXEDIT_PASTE:
1526 HEXEDIT_Paste(hed);
1527 break;
1528
1529 case ID_HEXEDIT_DELETE:
1530 HEXEDIT_Delete(hed);
1531 break;
1532
1534 HEXEDIT_SelectAll(hed);
1535 break;
1536 }
1537 break;
1538 }
1539
1540 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
1541}
static HDC hDC
Definition: 3dtext.c:33
WCHAR First[]
Definition: FormatMessage.c:11
HWND hWnd
Definition: settings.c:17
HMENU hPopupMenus
Definition: main.c:25
HFONT hFont
Definition: main.c:53
#define PM_HEXEDIT
Definition: main.h:26
#define ID_HEXEDIT_PASTE
Definition: resource.h:68
#define ID_HEXEDIT_COPY
Definition: resource.h:67
#define ID_HEXEDIT_DELETE
Definition: resource.h:69
#define ID_HEXEDIT_SELECT_ALL
Definition: resource.h:70
#define ID_HEXEDIT_CUT
Definition: resource.h:66
#define CHAR(Char)
HBITMAP hbmp
WCHAR WndClass[]
Definition: capicon.c:23
HINSTANCE hInstance
Definition: charmap.c:19
Definition: bufpool.h:45
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
struct @1642 Msg[]
WORD ATOM
Definition: dimm.idl:113
#define rct2
Definition: dlgs.h:148
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define CALLBACK
Definition: compat.h:35
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define pt(x, y)
Definition: drawing.c:79
static VOID BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Delta)
Definition: common.c:57
#define abs(i)
Definition: fconv.c:206
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
pKey DeleteObject()
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLuint GLuint end
Definition: gl.h:1545
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum const GLvoid * addr
Definition: glext.h:9621
GLfloat GLfloat p
Definition: glext.h:8902
GLenum GLuint GLsizei bufsize
Definition: glext.h:7473
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
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
HLOCAL NTAPI LocalReAlloc(HLOCAL hMem, SIZE_T dwBytes, UINT uFlags)
Definition: heapmem.c:1625
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
LPVOID NTAPI LocalLock(HLOCAL hMem)
Definition: heapmem.c:1616
BOOL NTAPI LocalUnlock(HLOCAL hMem)
Definition: heapmem.c:1805
SIZE_T NTAPI LocalSize(HLOCAL hMem)
Definition: heapmem.c:1794
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
static VOID HEXEDIT_Delete(PHEXEDIT_DATA hed)
Definition: hexedit.c:462
ATOM WINAPI RegisterHexEditorClass(HINSTANCE hInstance)
Definition: hexedit.c:56
#define HEHT_RIGHTMARGIN
Definition: hexedit.c:50
static LRESULT HEXEDIT_HEM_COPYBUFFER(PHEXEDIT_DATA hed, PVOID Buffer, DWORD Size)
Definition: hexedit.c:617
static VOID HEXEDIT_SelectAll(PHEXEDIT_DATA hed)
Definition: hexedit.c:542
static LRESULT HEXEDIT_WM_KILLFOCUS(PHEXEDIT_DATA hed)
Definition: hexedit.c:730
#define HEHT_HEXDUMP
Definition: hexedit.c:47
BOOL WINAPI UnregisterHexEditorClass(HINSTANCE hInstance)
Definition: hexedit.c:77
static VOID HEXEDIT_Copy(PHEXEDIT_DATA hed)
Definition: hexedit.c:411
static LRESULT HEXEDIT_WM_GETDLGCODE(LPMSG Msg)
Definition: hexedit.c:928
struct HEXEDIT_DATA * PHEXEDIT_DATA
static LRESULT HEXEDIT_WM_PAINT(PHEXEDIT_DATA hed)
Definition: hexedit.c:837
static VOID HEXEDIT_MoveCaret(PHEXEDIT_DATA hed, BOOL Scroll)
Definition: hexedit.c:85
static VOID HEXEDIT_PaintLines(PHEXEDIT_DATA hed, HDC hDC, DWORD ScrollPos, DWORD First, DWORD Last, RECT *rc)
Definition: hexedit.c:177
static LRESULT HEXEDIT_WM_MOUSEWHEEL(PHEXEDIT_DATA hed, int cyMoveLines, WORD ButtonsDown, LPPOINTS MousePos)
Definition: hexedit.c:897
static LRESULT HEXEDIT_WM_NCDESTROY(PHEXEDIT_DATA hed)
Definition: hexedit.c:694
static DWORD HEXEDIT_HitRegionTest(PHEXEDIT_DATA hed, POINTS pt)
Definition: hexedit.c:309
static BOOL HEXEDIT_WM_CHAR(PHEXEDIT_DATA hed, WCHAR wch)
Definition: hexedit.c:1247
#define HEHT_ASCIIDUMP
Definition: hexedit.c:49
static LRESULT HEXEDIT_WM_VSCROLL(PHEXEDIT_DATA hed, WORD ThumbPosition, WORD SbCmd)
Definition: hexedit.c:738
LRESULT CALLBACK HexEditWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: hexedit.c:1406
static VOID HEXEDIT_Update(PHEXEDIT_DATA hed)
Definition: hexedit.c:118
#define HEHT_HEXDUMPSPACING
Definition: hexedit.c:48
static UINT ClipboardFormatID
Definition: hexedit.c:41
static BOOL HEXEDIT_WM_KEYDOWN(PHEXEDIT_DATA hed, INT VkCode)
Definition: hexedit.c:1011
static LRESULT HEXEDIT_WM_MOUSEMOVE(PHEXEDIT_DATA hed, INT Buttons, POINTS Pt)
Definition: hexedit.c:991
static LRESULT HEXEDIT_WM_GETFONT(PHEXEDIT_DATA hed)
Definition: hexedit.c:831
#define HEHT_ADDRESSSPACING
Definition: hexedit.c:46
static VOID HEXEDIT_WM_CONTEXTMENU(PHEXEDIT_DATA hed, INT x, INT y)
Definition: hexedit.c:1372
static LRESULT HEXEDIT_WM_SETFOCUS(PHEXEDIT_DATA hed)
Definition: hexedit.c:721
static LRESULT HEXEDIT_HEM_SETMAXBUFFERSIZE(PHEXEDIT_DATA hed, DWORD nMaxSize)
Definition: hexedit.c:649
static const WCHAR ClipboardFormatName[]
Definition: hexedit.c:40
static DWORD HEXEDIT_IndexFromPoint(PHEXEDIT_DATA hed, POINTS pt, DWORD Hit, POINT *EditPos, BOOL *EditField)
Definition: hexedit.c:357
#define HEHT_LEFTMARGIN
Definition: hexedit.c:44
static LRESULT HEXEDIT_WM_SIZE(PHEXEDIT_DATA hed, DWORD sType, WORD NewWidth, WORD NewHeight)
Definition: hexedit.c:1362
static VOID HEXEDIT_Paste(PHEXEDIT_DATA hed)
Definition: hexedit.c:499
static LRESULT HEXEDIT_WM_LBUTTONUP(PHEXEDIT_DATA hed, INT Buttons, POINTS Pt)
Definition: hexedit.c:970
static LRESULT HEXEDIT_WM_NCCREATE(HWND hWnd, CREATESTRUCT *cs)
Definition: hexedit.c:668
#define HEHT_ADDRESS
Definition: hexedit.c:45
static LRESULT HEXEDIT_WM_LBUTTONDOWN(PHEXEDIT_DATA hed, INT Buttons, POINTS Pt)
Definition: hexedit.c:935
static LRESULT HEXEDIT_WM_CREATE(PHEXEDIT_DATA hed)
Definition: hexedit.c:714
static LRESULT HEXEDIT_WM_SETFONT(PHEXEDIT_DATA hed, HFONT hFont, BOOL bRedraw)
Definition: hexedit.c:796
static LRESULT HEXEDIT_HEM_LOADBUFFER(PHEXEDIT_DATA hed, PVOID Buffer, DWORD Size)
Definition: hexedit.c:556
static VOID HEXEDIT_Cut(PHEXEDIT_DATA hed)
Definition: hexedit.c:535
static HFONT HEXEDIT_GetFixedFont(VOID)
Definition: hexedit.c:169
#define HEM_COPYBUFFER
Definition: hexedit.h:20
#define HEM_SETMAXBUFFERSIZE
Definition: hexedit.h:21
#define HEM_LOADBUFFER
Definition: hexedit.h:19
#define HEX_EDIT_CLASS_NAME
Definition: hexedit.h:3
#define HexEdit_SetMaxBufferSize(hWnd, Size)
Definition: hexedit.h:36
#define cs
Definition: i386-dis.c:442
int hex(char ch)
#define d
Definition: ke_i.h:81
GLint dy
Definition: linetemp.h:97
GLint dx
Definition: linetemp.h:97
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
struct task_struct * current
Definition: linux.c:32
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:88
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
static HMODULE MODULEINFO DWORD cb
Definition: module.c:33
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:63
#define min(a, b)
Definition: monoChain.cc:55
static const TBBUTTON Buttons[]
Definition: mplay32.c:41
unsigned int UINT
Definition: ndis.h:50
#define DWORD
Definition: nt_native.h:44
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:325
#define L(x)
Definition: ntvdm.h:50
#define LOWORD(l)
Definition: pedump.c:82
BYTE * PBYTE
Definition: pedump.c:66
DWORD * PDWORD
Definition: pedump.c:68
short SHORT
Definition: pedump.c:59
#define INT
Definition: polytest.cpp:20
#define WM_CONTEXTMENU
Definition: richedit.h:64
INT nVisibleLines
Definition: hexedit.c:20
DWORD MaxBuffer
Definition: hexedit.c:16
INT nLines
Definition: hexedit.c:18
INT CaretCol
Definition: hexedit.c:32
INT ColumnsPerLine
Definition: hexedit.c:17
BOOL EditingField
Definition: hexedit.c:31
BOOL InMid
Definition: hexedit.c:34
INT Index
Definition: hexedit.c:21
INT SelStart
Definition: hexedit.c:36
HFONT hFont
Definition: hexedit.c:24
DWORD style
Definition: hexedit.c:15
INT nVisibleLinesComplete
Definition: hexedit.c:19
INT LeftMargin
Definition: hexedit.c:27
INT SelEnd
Definition: hexedit.c:37
INT LineHeight
Definition: hexedit.c:22
INT CaretLine
Definition: hexedit.c:33
HWND hWndSelf
Definition: hexedit.c:12
HWND hWndParent
Definition: hexedit.c:13
HLOCAL hBuffer
Definition: hexedit.c:14
INT CharWidth
Definition: hexedit.c:23
INT AddressSpacing
Definition: hexedit.c:28
INT SplitSpacing
Definition: hexedit.c:29
BOOL SbVisible
Definition: hexedit.c:25
Definition: parser.c:49
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
Definition: time.h:68
#define max(a, b)
Definition: svc.c:63
#define WHEEL_DELTA
Definition: treelist.c:99
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
#define WM_MOUSEWHEEL
Definition: treelist.c:96
uint32_t DWORD_PTR
Definition: typedefs.h:65
int32_t INT
Definition: typedefs.h:58
#define HIWORD(l)
Definition: typedefs.h:247
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
#define LMEM_MOVEABLE
Definition: winbase.h:395
#define ZeroMemory
Definition: winbase.h:1737
#define LMEM_ZEROINIT
Definition: winbase.h:401
#define CopyMemory
Definition: winbase.h:1735
#define MoveMemory
Definition: winbase.h:1734
#define GHND
Definition: winbase.h:323
#define GMEM_SHARE
Definition: winbase.h:331
#define LHND
Definition: winbase.h:408
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
#define WINAPI
Definition: msvc.h:6
#define ANSI_FIXED_FONT
Definition: wingdi.h:906
HGDIOBJ WINAPI GetStockObject(_In_ int)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define TRANSPARENT
Definition: wingdi.h:950
#define SRCCOPY
Definition: wingdi.h:333
BOOL WINAPI ExtTextOutW(_In_ HDC hdc, _In_ int x, _In_ int y, _In_ UINT options, _In_opt_ const RECT *lprect, _In_reads_opt_(c) LPCWSTR lpString, _In_ UINT c, _In_reads_opt_(c) const INT *lpDx)
#define ETO_OPAQUE
Definition: wingdi.h:647
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
BOOL WINAPI TextOutW(_In_ HDC hdc, _In_ int x, _In_ int y, _In_reads_(c) LPCWSTR lpString, _In_ int c)
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:918
#define GetObject
Definition: wingdi.h:4468
BOOL WINAPI DeleteDC(_In_ HDC)
#define GetTextMetrics
Definition: wingdi.h:4474
#define CreateFontIndirect
Definition: wingdi.h:4444
#define WM_PAINT
Definition: winuser.h:1623
HWND WINAPI SetCapture(_In_ HWND hWnd)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define WM_ERASEBKGND
Definition: winuser.h:1628
DWORD WINAPI GetSysColor(_In_ int)
#define SB_THUMBTRACK
Definition: winuser.h:573
BOOL WINAPI ShowCaret(_In_opt_ HWND)
#define SB_LINEUP
Definition: winuser.h:564
#define COLOR_WINDOW
Definition: winuser.h:921
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2890
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define COLOR_WINDOWTEXT
Definition: winuser.h:924
struct tagSCROLLINFO SCROLLINFO
#define WM_VSCROLL
Definition: winuser.h:1747
#define TPM_RIGHTBUTTON
Definition: winuser.h:2383
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define SIF_RANGE
Definition: winuser.h:1238
#define WM_CREATE
Definition: winuser.h:1611
#define DLGC_WANTCHARS
Definition: winuser.h:2621
#define WM_SIZE
Definition: winuser.h:1614
#define COLOR_HIGHLIGHT
Definition: winuser.h:929
HANDLE WINAPI SetClipboardData(_In_ UINT, _In_opt_ HANDLE)
#define SB_VERT
Definition: winuser.h:553
#define SB_BOTTOM
Definition: winuser.h:577
#define WM_COMMAND
Definition: winuser.h:1743
BOOL WINAPI SetForegroundWindow(_In_ HWND)
BOOL WINAPI CloseClipboard(void)
Definition: ntwrapper.h:178
#define VK_CONTROL
Definition: winuser.h:2206
UINT WINAPI RegisterClipboardFormatW(_In_ LPCWSTR)
#define VK_UP
Definition: winuser.h:2228
#define WM_SETFOCUS
Definition: winuser.h:1616
#define SIF_PAGE
Definition: winuser.h:1236
#define WM_MOUSEMOVE
Definition: winuser.h:1778
HWND WINAPI GetCapture(void)
Definition: message.c:2881
BOOL WINAPI OpenClipboard(_In_opt_ HWND)
#define CS_DBLCLKS
Definition: winuser.h:651
#define WM_LBUTTONDOWN
Definition: winuser.h:1779
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2157
HANDLE WINAPI GetClipboardData(_In_ UINT)
#define WM_GETFONT
Definition: winuser.h:1654
#define WM_NCCREATE
Definition: winuser.h:1686
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define RegisterClassEx
Definition: winuser.h:5849
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
HWND WINAPI SetFocus(_In_opt_ HWND)
#define MF_ENABLED
Definition: winuser.h:128
#define WM_SETFONT
Definition: winuser.h:1653
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
#define DLGC_WANTARROWS
Definition: winuser.h:2613
BOOL WINAPI EmptyClipboard(void)
Definition: ntwrapper.h:190
BOOL WINAPI UpdateWindow(_In_ HWND)
#define SB_PAGEDOWN
Definition: winuser.h:569
#define SIF_ALL
Definition: winuser.h:1235
#define WM_NULL
Definition: winuser.h:1610
#define IDC_IBEAM
Definition: winuser.h:688
#define VK_BACK
Definition: winuser.h:2201
#define COLOR_HIGHLIGHTTEXT
Definition: winuser.h:930
HDC WINAPI GetDC(_In_opt_ HWND)
#define SB_LINEDOWN
Definition: winuser.h:565
#define wsprintf
Definition: winuser.h:5877
#define WM_LBUTTONUP
Definition: winuser.h:1780
BOOL WINAPI SystemParametersInfoW(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)
#define WM_CHAR
Definition: winuser.h:1720
#define VK_LEFT
Definition: winuser.h:2227
#define WM_NCDESTROY
Definition: winuser.h:1687
#define VK_RIGHT
Definition: winuser.h:2229
#define SB_TOP
Definition: winuser.h:578
#define SIF_POS
Definition: winuser.h:1237
#define VK_DOWN
Definition: winuser.h:2230
struct _WNDCLASSEXW WNDCLASSEXW
#define VK_SHIFT
Definition: winuser.h:2205
BOOL WINAPI TrackPopupMenu(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _Reserved_ int, _In_ HWND, _Reserved_ LPCRECT)
int WINAPI SetScrollInfo(_In_ HWND, _In_ int, _In_ LPCSCROLLINFO, _In_ BOOL)
#define VK_DELETE
Definition: winuser.h:2236
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)
SHORT WINAPI GetAsyncKeyState(_In_ int)
BOOL WINAPI ShowScrollBar(_In_ HWND, _In_ int, _In_ BOOL)
#define WM_KEYDOWN
Definition: winuser.h:1718
BOOL WINAPI SetCaretPos(_In_ int, _In_ int)
BOOL WINAPI CreateCaret(_In_ HWND, _In_opt_ HBITMAP, _In_ int, _In_ int)
BOOL WINAPI DestroyCaret(void)
Definition: caret.c:35
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define GWL_STYLE
Definition: winuser.h:855
BOOL WINAPI GetScrollInfo(_In_ HWND, _In_ int, _Inout_ LPSCROLLINFO)
BOOL WINAPI GetUpdateRect(_In_ HWND, _Out_opt_ LPRECT, _In_ BOOL)
BOOL WINAPI IsWindowVisible(_In_ HWND)
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
BOOL WINAPI ScrollWindow(_In_ HWND, _In_ int, _In_ int, _In_opt_ LPCRECT, _In_opt_ LPCRECT)
#define WM_KILLFOCUS
Definition: winuser.h:1617
#define SB_PAGEUP
Definition: winuser.h:568
#define VK_INSERT
Definition: winuser.h:2235
#define WM_GETDLGCODE
Definition: winuser.h:1692
SHORT WINAPI GetKeyState(_In_ int)
#define VK_MENU
Definition: winuser.h:2207
#define MF_GRAYED
Definition: winuser.h:129
__wchar_t WCHAR
Definition: xmlstorage.h:180
char CHAR
Definition: xmlstorage.h:175