; allocate a block of memory from the heap for the strings
mov BlockSize,1024*10
mov r8,BlockSize
xor edx,edx
mov rcx,hMainHeap
call HeapAlloc
mov pTemp,rax
mov eax,offset C1Key
mov CKeyIndex,rax
mov eax,offset ASMColorArray
mov ASMColorArrayIndex,rax
@@: mov [rsp+28h],rdi;rax
mov rax,BlockSize
mov [rsp+20h],rax
mov r9,pTemp
mov r8d,offset ZeroString
mov rdx,CKeyIndex
mov ecx,offset ASMSection
call GetPrivateProfileString
or eax,eax;.if eax!=0
jz @f
inc eax
cmp rax,BlockSize ; the buffer is too small
jnz a2
add BlockSize,1024*10
mov r9,BlockSize
mov r8,pTemp
xor edx,edx
mov rcx,hMainHeap
call HeapReAlloc
mov pTemp,rax
jmp @B
a2: mov ecx,10;offset ASMSyntaxArray
a4: mov temp1,rcx
db 48h;mov ecx,offset ASMSyntaxArray
dd 202444C7h,ASMSyntaxArray;mov [rsp+20h],rcx
mov r9,ASMColorArrayIndex
mov r8d,eax
mov rdx,pTemp
mov rcx,hMainHeap
call ParseBuffer
add CKeyIndex,3
add ASMColorArrayIndex,4
@@: mov [rsp+28],rdi
mov rax,BlockSize
mov [rsp+20h],rax
mov r9,pTemp
mov r8d,offset ZeroString
mov rdx,CKeyIndex
mov ecx,offset ASMSection
call GetPrivateProfileString
or eax,eax;.if eax!=0
jz a3
inc eax
cmp rax,BlockSize ; the buffer is too small
jnz a3
add BlockSize,1024*10
mov r9,BlockSize
mov r8,pTemp
xor edx,edx
mov rcx,hMainHeap
call HeapReAlloc
mov pTemp,rax
jmp @B
a3: mov rcx,temp1
dec ecx;loop a4
jnz a4
mov r8,pTemp
xor edx,edx
mov rcx,hMainHeap
call HeapFree
a0: mov rdi,old_rdi
leave
ret
FillHiliteInfo endp
NewRichEditProc proc hWnd:QWORD, uMsg:QWORD, wParam:QWORD, lParam:QWORD
LOCAL hdc:QWORD
LOCAL hOldFont:QWORD
LOCAL FirstChar:QWORD
LOCAL rect:RECT
LOCAL txtrange:TEXTRANGE
LOCAL buffer[1024*10]:BYTE
LOCAL hRgn:QWORD
LOCAL hOldRgn:QWORD
LOCAL RealRect:RECT
LOCAL pString:QWORD
LOCAL BufferSize:QWORD
LOCAL pt:POINT
push rbp
mov ebp,esp
sub esp,(30h+8*7+2*(sizeof RECT)+sizeof TEXTRANGE+\
sizeof POINT+1024*10+15)and(-16)
mov hWnd,rcx
mov uMsg,rdx
mov wParam,r8
mov lParam,r9
cmp edx,WM_PAINT
je wmPAINT
cmp edx,WM_CLOSE
je wmCLOSE
wmDEFAULT:mov [rsp+20h],r9
mov r9,r8
mov r8d,edx
mov edx,ecx
mov rcx,OldWndProc
call CallWindowProc
leave
retn
wmPAINT:push rdi
push rsi
sub esp,30h
mov rcx,hWnd
call HideCaret
mov rax,lParam
mov [rsp+20h],rax
mov r9,wParam
mov r8,uMsg
mov rdx,hWnd
mov rcx,OldWndProc
call CallWindowProc
add esp,10h
mov edx,eax
mov rcx,hWnd
call GetDC
mov hdc,rax
mov edx,TRANSPARENT
mov ecx,eax
call SetBkMode
; Do syntax hiliting here!
lea edi,rect
mov r9d,edi;lea r9d,rect
xor r8d,r8d
mov edx,EM_GETRECT
mov rcx,hWnd
call SendMessage
mov r9d,edi;lea r9d,rect
xor r8d,r8d
mov edx,EM_CHARFROMPOS
mov rcx,hWnd
call SendMessage
; obtain the line number
xor r9d,r9d
mov r8d,eax
mov edx,EM_LINEFROMCHAR
mov rcx,hWnd
call SendMessage
xor r9d,r9d
mov r8d,eax
mov edx,EM_LINEINDEX
mov rcx,hWnd
call SendMessage
mov txtrange.chrg.cpMin,eax
mov FirstChar,rax
lea r9d,rect.right
xor r8d,r8d
mov edx,EM_CHARFROMPOS
mov rcx,hWnd
call SendMessage
mov txtrange.chrg.cpMax,eax
mov esi,edi
lea edi,RealRect
movsq;
;mov eax,rect.left
;mov RealRect.left,eax
;mov eax, rect.top
;mov RealRect.top,eax
movsq;
;mov eax, rect.right
;mov RealRect.right,eax
;mov eax,rect.bottom
;mov RealRect.bottom,eax
mov r9d,RealRect.bottom
mov r8d,RealRect.right
mov edx,RealRect.top
mov ecx,RealRect.left
call CreateRectRgn
mov hRgn,rax
mov edx,eax;hRgn
mov rcx,hdc
call SelectObject
mov hOldRgn,rax
mov edx,CommentColor
mov rcx,hdc
call SetTextColor
; Get the visible text into buffer
lea eax,buffer
mov txtrange.lpstrText,rax
lea r9d,txtrange
xor r8d,r8d
mov edx,EM_GETTEXTRANGE
mov rcx,hWnd
call SendMessage
add esp,20h
mov esi,eax ; esi == size of the text
cmp esi,0
jbe @0
mov BufferSize,rax
; Search for comments first
mov edi,offset ASMSyntaxArray
push rdi
push rbx
lea edi,buffer
mov edx,edi ; used as the reference point
mov ecx,esi
mov al,";"
ScanMore:
repne scasb
jne NoMoreHit
NextSkip: dec edi
inc ecx
mov pString,rdi
mov ebx,edi
sub ebx,edx
add rbx,FirstChar
mov txtrange.chrg.cpMin,ebx
; search the end of line or the end of buffer
push rax
mov al,0Dh
repne scasb
pop rax
HiliteTheComment: cmp ecx,0
jbe @1
mov byte ptr [rdi-1],0
@1: mov ebx,edi
sub ebx,edx
add rbx,FirstChar
mov txtrange.chrg.cpMax,ebx
push rax
push rbx
push rcx
push rdx
push rsi
push rdi
; Now we must search the range for the tabs
mov rdi,pString
mov esi,txtrange.chrg.cpMax
sub esi,txtrange.chrg.cpMin; esi contains the length of the buffer
mov eax,esi
push rdi
push rdi
@3: cmp byte ptr [rdi],9
jnz @4
mov byte ptr [rdi],0
@4: inc edi
dec eax
jnz @3
pop rdi
pop rdi
jmp @5; .while esi>0
@6: cmp byte ptr [rdi],0
jz @7
sub esp,20h
mov ecx,edi
call lstrlen
add esp,20h
push rax
push rax
mov ecx,edi
lea edx,buffer
sub ecx,edx
add rcx,FirstChar
cmp RichEditVersion,3
jnz @8
sub esp,20h
mov r9d,ecx
lea r8d,rect
mov edx,EM_POSFROMCHAR
mov rcx,hWnd
call SendMessage
add esp,20h
jmp @9; .else
@8: sub esp,20h
xor r9d,r9d
mov r8d,ecx
mov edx,EM_POSFROMCHAR
mov rcx,hWnd
call SendMessage
add esp,20h
movzx ecx,ax
mov rect.left,ecx
shr eax,16
mov rect.top,eax
@9: sub esp,30h
mov qword ptr [rsp+20h],0
lea r9d,rect
or r8,-1
mov edx,edi
mov rcx,hdc
call DrawText
add esp,30h
pop rax
pop rax
add edi,eax
sub esi,eax
jmp @5; .else
@7: inc edi
dec esi
@5: cmp esi,0
ja @6
mov edx,txtrange.chrg.cpMax
sub edx,txtrange.chrg.cpMin
sub esp,20h
mov rcx,pString
call RtlZeroMemory
add esp,20h
pop rdi
pop rsi
pop rdx
pop rcx
pop rbx
pop rax
cmp ecx,0
jnbe ScanMore
NoMoreHit: pop rbx
pop rdi
; Now that the comments are out of our way, Get rid of the separators
mov rcx,BufferSize
lea esi,buffer
jrcxz @10; .while ecx>0
@11: lodsb;mov al,byte ptr [esi]
cmp al,'.'
je @14
cmp al,"%"
je @14
cmp al,'0'
jb @12
cmp al,'9'
jbe @14
cmp al,"?";3Fh
jb @12
cmp al,"[";5B
jb @14
cmp al,"\";60h
jbe @12
cmp al,"{";7B
jb @14
cmp al,"~";7F
ja @14
@12: mov byte ptr [rsi-1],0
@14: loop @11
; Begin the search
lea esi,buffer
@10: mov rcx,BufferSize
test ecx,ecx
jz @0; .while ecx>0
@16: cmp byte ptr [rsi],0
jz @17
push rcx
sub esp,20h
mov ecx,esi
call lstrlen
add esp,20h
push rax
mov edx,eax ; edx contains the length of the string
movzx eax,byte ptr [esi]
cmp al,"A";.if al>="A" && al<="Z"
jb @f
cmp al,"Z"
ja @f
add al,20h;"a"
@@: lea eax,[rdi+rax*4]; edi contains the pointer to the WORDINFO pointer array
cmp dword ptr [rax],0
jz @19
mov eax,[rax]
jmp @20
@21: cmp edx,[eax+WORDINFO.WordLen]
jnz @22
push rax
push rbx
push rcx
push rdx
push rsi
push rdi
sub esp,20h
mov edx,esi
mov ecx,[rax+WORDINFO.pszWord]
call lstrcmpi
add esp,20h
or eax,eax;.if eax==0
jnz @23
pop rdi
pop rsi
pop rdx
pop rcx
pop rbx
pop rax
; hilite the word
mov ecx,esi
lea edx,buffer
sub ecx,edx
add rcx,FirstChar
push rax
push rbx
push rcx
push rdx
push rsi
push rdi
cmp [RichEditVersion],3
jnz @24
sub esp,20h
mov r9d,ecx
lea r8d,rect
mov edx,EM_POSFROMCHAR
mov rcx,hWnd
call SendMessage
add esp,20h
jmp @25;.else
@24: sub esp,20h
xor r9d,r9d
mov r8d,ecx
mov edx,EM_POSFROMCHAR
mov rcx,hWnd
call SendMessage
add esp,20h
movzx ecx,ax
mov rect.left,ecx
shr eax,16
mov rect.top,eax
@25: pop rdi
pop rsi
pop rdx
pop rcx
pop rbx
pop rax
mov edx,[eax+WORDINFO.pColor]
sub esp,20h
mov edx,dword ptr [edx]
mov rcx,hdc
call SetTextColor
sub esp,10h
mov qword ptr [rsp+20h],0
lea r9d,rect
or r8d,-1
mov edx,esi
mov rcx,hdc
call DrawText
add esp,30h
jmp @19;.endif
@23: pop rdi
pop rsi
pop rdx
pop rcx
pop rbx
pop rax
@22: mov eax,[eax+WORDINFO.NextLink]
@20: or eax,eax;.endw
jnz @21;.endif
@19: pop rax
pop rcx
add esi,eax
sub ecx,eax
jmp @15;.else
@17: inc esi
dec ecx
@15: jnz @16
@0: sub esp,20h
mov rdx,hOldRgn
mov rcx,hdc
call SelectObject
mov rcx,hRgn
call DeleteObject
mov rdx,hOldFont
mov rcx,hdc
call SelectObject
mov rdx,hdc
mov rcx,hWnd
call ReleaseDC
mov rcx,hWnd
call ShowCaret
add esp,20h
pop rax
pop rsi
pop rdi
leave
retn
wmCLOSE:mov r8,OldWndProc
mov edx,GWL_WNDPROC
call SetWindowLongPtr;hWnd
NewRichEditProc endp
WndProc proc hWnd:QWORD, uMsg:QWORD, wParam:QWORD, lParam:QWORD
LOCAL ofn:OPENFILENAME
LOCAL buffer[256]:BYTE
LOCAL editstream:EDITSTREAM
LOCAL hFile:QWORD
LOCAL hPopup:QWORD
LOCAL old_rsi:QWORD
LOCAL pt:POINT
LOCAL chrg:CHARRANGE
push rbp
mov ebp,esp
sub esp,(40h+sizeof OPENFILENAME+256+sizeof EDITSTREAM+\
3*8+sizeof POINT+sizeof CHARRANGE+15)and(-16)
mov hWnd,rcx
mov uMsg,rdx
mov wParam,r8
mov lParam,r9
cmp edx,WM_NOTIFY
je wmNOTIFY
cmp edx,WM_INITMENUPOPUP
je wmINITMENUPOPUP
cmp edx,WM_COMMAND
je wmCOMMAND
cmp edx,WM_CLOSE
je wmCLOSE
cmp edx,WM_SIZE
je wmSIZE
cmp edx,WM_DESTROY
je wmDESTROY
wmDEFAULT:leave
jmp DefWindowProc
wmDESTROY:mov rcx,hRichEdit
call FreeLibrary
xor ecx,ecx
call ExitProcess
wmNOTIFY:mov old_rsi,rsi
mov rsi,r9;lParam
cmp [rsi+NMHDR._code],EN_MSGFILTER;.if [esi]._code==EN_MSGFILTER
jnz @f;assume esi:ptr MSGFILTER
cmp [rsi+MSGFILTER.msg],WM_RBUTTONDOWN;.if [esi].msg==WM_RBUTTONDOWN
jnz @f
mov rcx,hWnd
call GetMenu
mov edx,1
mov ecx,eax
call GetSubMenu
mov hPopup,rax
mov ecx,eax;hPopup
call PrepareEditMenu
mov rdx,[rsi+MSGFILTER.lParam]
mov ecx,edx
and edx,0FFFFh
shr ecx,16
mov pt.x,edx
mov pt.y,ecx
lea edx,pt
mov rcx,hWnd
call ClientToScreen
mov qword ptr [rsp+30h],NULL
mov rax,hWnd
mov [rsp+28h],rax
mov qword ptr [rsp+20h],NULL
mov r9d,pt.y
mov r8d,pt.x
mov edx,TPM_LEFTALIGN or TPM_BOTTOMALIGN
mov rcx,hPopup
call TrackPopupMenu
@@: mov rsi,old_rsi
jmp wmBYE
wmINITMENUPOPUP:
mov eax,r9d;lParam
or ax,ax;.if ax==0; file menu
jnz @0
cmp FileOpened,TRUE; a file is already opened
setne bl;в ebx MF_ENABLED=0 или MF_GRAYED=1
mov r8d,ebx;MF_ENABLED
mov edx,IDM_CLOSE
mov rcx,wParam
call EnableMenuItem
mov r8d,ebx;MF_ENABLED
mov edx,IDM_SAVE
mov rcx,wParam
call EnableMenuItem
mov r8d,ebx;MF_ENABLED
mov edx,IDM_SAVEAS
mov rcx,wParam
call EnableMenuItem
xor ebx,1
mov r8d,ebx;MF_GRAYED
mov edx,IDM_OPEN
mov rcx,wParam
call EnableMenuItem
xor ebx,ebx
jmp wmBYE
@0: cmp ax,1;.elseif ax==1 ; edit menu
jnz @f
mov rcx,wParam
call PrepareEditMenu
jmp wmBYE
@@: cmp ax,2;.elseif ax==2 ; search menu bar
jnz wmBYE
cmp FileOpened,TRUE;.if FileOpened==TRUE
setne bl;в ebx MF_ENABLED=0 или MF_GRAYED=1
mov r8d,ebx;MF_ENABLED
mov edx,IDM_FIND
mov rcx,wParam
call EnableMenuItem
mov r8d,ebx;MF_ENABLED
mov edx,IDM_FINDNEXT
mov rcx,wParam
call EnableMenuItem
mov r8d,ebx;MF_ENABLED
mov edx,IDM_FINDPREV
mov rcx,wParam
call EnableMenuItem
mov r8d,ebx;MF_ENABLED
mov edx,IDM_REPLACE
mov rcx,wParam
call EnableMenuItem
mov r8d,ebx;MF_ENABLED
mov edx,IDM_GOTOLINE
mov rcx,wParam
call EnableMenuItem
xor ebx,ebx
jmp wmBYE
wmCOMMAND:
or r9,r9;.if lParam==0 ; menu commands
jnz wmBYE
mov eax,r8d;mov eax,wParam
sub eax,IDM_OPEN;.if ax==IDM_OPEN
cmp eax,IDM_FINDPREV-IDM_OPEN
ja wmBYE
jmp handle1[rax*8]
OPEN: mov edx,sizeof OPENFILENAME
lea ecx,ofn
call RtlZeroMemory
lea ecx,ofn
mov [rcx+OPENFILENAME.lStructSize],sizeof ofn
mov rax,hWnd
mov [rcx+OPENFILENAME.hwndOwner],rax
mov [rcx+OPENFILENAME.hInstance],IMAGE_BASE
mov eax,offset ASMFilterString
mov [rcx+OPENFILENAME.lpstrFilter],rax
mov eax,offset FileName
mov [rcx+OPENFILENAME.lpstrFile],rax
mov byte ptr [FileName],0
mov [rcx+OPENFILENAME.nMaxFile],sizeof FileName
mov [rcx+OPENFILENAME.Flags],OFN_FILEMUSTEXIST or OFN_HIDEREADONLY or OFN_PATHMUSTEXIST
call GetOpenFileName
or eax,eax; .if eax!=0
jz wmBYE
mov qword ptr [rsp+30h],0
mov qword ptr [rsp+28h],FILE_ATTRIBUTE_NORMAL
mov qword ptr [rsp+20h],OPEN_EXISTING
xor r9d,r9d
mov r8d,FILE_SHARE_READ
mov edx,GENERIC_READ
mov ecx,offset FileName
call CreateFile
inc eax;.if eax!=INVALID_HANDLE_VALUE
jz @f
dec eax
mov hFile,rax
; stream the text into the richedit control
lea r9,editstream
mov [r9+EDITSTREAM.dwCookie],rax
mov eax,offset StreamInProc
mov [r9+EDITSTREAM.pfnCallback],rax
mov r8d,SF_TEXT
mov edx,EM_STREAMIN
mov rcx,hwndRichEdit
call SendMessage
; Initialize the modify state to false
xor r9d,r9d
xor r8d,r8d
mov edx,EM_SETMODIFY
mov rcx,hwndRichEdit
call SendMessage
mov rcx,hFile
call CloseHandle
mov FileOpened,TRUE
jmp wmBYE
@@: mov r9d,MB_OK or MB_ICONERROR
mov r8d,offset ClassName
mov edx,offset OpenFileFail
mov rcx,hWnd
call MessageBox
jmp wmBYE
CLOSE1: mov rcx,hWnd
call CheckModifyState
or eax,eax;.if eax==TRUE
jz wmBYE
xor edx,edx
mov rcx,hwndRichEdit
call SetWindowText
mov FileOpened,FALSE
jmp wmBYE
SAVE: mov ecx,offset FileName
jmp @f
SAVEAS: mov edx,sizeof ofn
lea ecx,ofn
call RtlZeroMemory
lea ecx,ofn
mov [rcx+OPENFILENAME.lStructSize],sizeof ofn
mov rax,hWnd
mov [rcx+OPENFILENAME.hwndOwner],rax
mov [rcx+OPENFILENAME.hInstance],IMAGE_BASE
mov eax,offset ASMFilterString
mov [rcx+OPENFILENAME.lpstrFilter],rax
mov eax,offset AlternateFileName
mov [rcx+OPENFILENAME.lpstrFile],rax
mov byte ptr [AlternateFileName],0
mov [rcx+OPENFILENAME.nMaxFile],sizeof AlternateFileName
mov [rcx+OPENFILENAME.Flags],OFN_FILEMUSTEXIST or OFN_HIDEREADONLY or OFN_PATHMUSTEXIST
call GetSaveFileName
or eax,eax;.if eax!=0
jz wmBYE
mov ecx,offset AlternateFileName
@@: mov qword ptr [rsp+30h],0
mov qword ptr [rsp+28h],FILE_ATTRIBUTE_NORMAL
mov qword ptr [rsp+20h],CREATE_ALWAYS
mov r9d,NULL
mov r8d,FILE_SHARE_READ
mov edx,GENERIC_WRITE
call CreateFile
inc eax;.if eax!=INVALID_HANDLE_VALUE
jz wmBYE
dec eax
mov hFile,rax
; stream the text to the file
lea r9,editstream
mov [r9+EDITSTREAM.dwCookie],rax
mov eax,offset StreamOutProc
mov [r9+EDITSTREAM.pfnCallback],rax
mov r8d,SF_TEXT
mov edx,EM_STREAMOUT
mov rcx,hwndRichEdit
call SendMessage
; Initialize the modify state to false
xor r9d,r9d
mov r8d,FALSE
mov edx,EM_SETMODIFY
mov rcx,hwndRichEdit
call SendMessage
mov rcx,hFile
call CloseHandle
jmp wmBYE
COPY:
mov ecx,WM_COPY;invoke SendMessage,hwndRichEdit,WM_COPY,0,0
jmp @19
CUT:
mov ecx,WM_CUT;invoke SendMessage,hwndRichEdit,WM_CUT,0,0
jmp @19
PASTE:
mov ecx,WM_PASTE;invoke SendMessage,hwndRichEdit,WM_PASTE,0,0
jmp @19
DELETE1:
xor r9d,r9d
mov r8d,TRUE
mov edx,EM_REPLACESEL
jmp @21;invoke SendMessage,hwndRichEdit,EM_REPLACESEL,TRUE,0
SELECTALL:
mov chrg.cpMin,0
mov chrg.cpMax,-1
lea r9,chrg
mov edx,EM_EXSETSEL
jmp @20;invoke SendMessage,hwndRichEdit,EM_EXSETSEL,0,addr chrg
UNDO:
mov ecx,EM_UNDO;invoke SendMessage,hwndRichEdit,EM_UNDO,0,0
jmp @19
REDO:
mov edx,EM_REDO
@19: xor r9d,r9d
@20: xor r8d,r8d
@21: mov rcx,hwndRichEdit
call SendMessage;invoke SendMessage,hwndRichEdit,0,0
jmp wmBYE
OPTIONS:mov qword ptr [rsp+20h],0
mov r9d,offset OptionProc
mov r8,hWnd
mov edx,IDD_OPTIONDLG
mov ecx,IMAGE_BASE
call DialogBoxParam;invoke DialogBoxParam,hInstance,IDD_OPTIONDLG,hWnd,addr OptionProc,0
jmp wmBYE
FIND: cmp hSearch,0;.if hSearch==0
jnz wmBYE
mov r9d,offset SearchProc
mov edx,IDD_FINDDLG
jmp @f
REPLACE:cmp hSearch,0;.if hSearch==0
jnz wmBYE
mov r9d,offset ReplaceProc
mov edx,IDD_REPLACEDLG
jmp @f
GOTOLINE:cmp hSearch,0;.if hSearch==0
jnz wmBYE
mov r9d,offset GoToProc
mov edx,IDD_GOTODLG
@@: mov ecx,IMAGE_BASE
mov r8,hWnd
mov qword ptr [rsp+20h],0
call CreateDialogParam
jmp wmBYE
FINDNEXT:mov ecx,offset FindBuffer
call lstrlen
or eax,eax;.if eax!=0
jz wmBYE
mov r9d,offset findtext.chrg
xor r8d,r8d
mov edx,EM_EXGETSEL
mov rcx,hwndRichEdit
call SendMessage
mov eax,findtext.chrg.cpMin
cmp eax,findtext.chrg.cpMax
jz @f
mov eax,findtext.chrg.cpMax
mov findtext.chrg.cpMin,eax
@@: mov findtext.chrg.cpMax,-1
mov r8d,FR_DOWN
jmp @f
FINDPREV:
mov ecx,offset FindBuffer
call lstrlen
or eax,eax;.if eax!=0
jz wmBYE
mov r9d,offset findtext.chrg
xor r8d,r8d
mov edx,EM_EXGETSEL
mov rcx,hwndRichEdit
call SendMessage
mov findtext.chrg.cpMax,0
xor r8d,r8d
@@: mov eax,offset FindBuffer
mov findtext.lpstrText,rax
mov r9d,offset findtext
mov edx,EM_FINDTEXTEX
mov rcx,hwndRichEdit
call SendMessage;invoke SendMessage,hwndRichEdit,EM_FINDTEXTEX,0,addr findtext
inc eax;.if eax!=-1
jz wmBYE
mov r9d,offset findtext.chrgText
xor r8d,r8d
mov edx,EM_EXSETSEL
mov rcx,hwndRichEdit
call SendMessage;invoke SendMessage,hwndRichEdit,EM_EXSETSEL,0,addr findtext.chrgText
jmp wmBYE
EXIT: xor r9d,r9d
xor r8d,r8d
mov edx,WM_CLOSE
mov rcx,hWnd
call SendMessage
jmp wmBYE
wmCLOSE:call CheckModifyState;,hWnd
or eax,eax;.if eax==TRUE
jz wmBYE
mov rcx,hWnd
call DestroyWindow
jmp wmBYE
wmSIZE: mov eax,r9d;lParam
and r9,0FFFFh
shr eax,16
mov qword ptr [rsp+28h],TRUE
mov [rsp+20h],rax
xor edx,edx
mov r8,rdx
mov rcx,hwndRichEdit
call MoveWindow
wmBYE: leave
ret
handle1 dq OPEN,SAVE,CLOSE1,SAVEAS,EXIT,COPY,CUT,PASTE,DELETE1,SELECTALL
dq OPTIONS,UNDO,REDO,FIND,FINDNEXT,REPLACE,GOTOLINE,FINDPREV
WndProc endp
ClassName db 'Win64 Iczelion''s lesson #35: IczEdit version 3.0',0
RichEditDLL db "riched20.dll",0
RichEditClass db "RichEdit20A",0
NoRichEdit db "Cannot find riched20.dll",0
ASMFilterString db "ASM Source code (*.asm)",0,"*.asm",0
db "All Files (*.*)",0,"*.*",0,0
OpenFileFail db "Cannot open the file",0
WannaSave db "The data in the control is modified. Want to save it?",0
FileOpened dq FALSE
BackgroundColor dd 0FFFFFFh ; default to white
TextColor dd 0 ; default to black
WordFileName db "\wordfile.txt",0
ASMSection db "ASSEMBLY",0
C1Key db "C1",0
C2Key db "C2",0
C3Key db "C3",0
C4Key db "C4",0
C5Key db "C5",0
C6Key db "C6",0
C7Key db "C7",0
C8Key db "C8",0
C9Key db "C9",0
C10Key db "C10",0
ZeroString db 0
ASMColorArray dd 0FF0000h,0805F50h,0FFh,666F00h,44F0h,5F8754h,4 dup(0FF0000h)
CommentColor dd 808000h
hInstance dq IMAGE_BASE
hRichEdit dq ?
hwndRichEdit dq ?
FileName db 256 dup(?)
AlternateFileName db 256 dup(?)
CustomColors dd 16 dup(?)
FindBuffer db 256 dup(?)
ReplaceBuffer db 256 dup(?)
uFlags dd ?
findtext FINDTEXTEX <>
ASMSyntaxArray dd 256 dup(?)
hSearch dq ? ; handle to the search/replace dialog box
hAccel dq ?
hMainHeap dq ? ; heap handle
OldWndProc dq ?
RichEditVersion dq ?
Rect RECT <?>
end