pfree,hmainheap,0,ptemp .endif ret fillhiliteinfo endp newricheditproc proc hwnd:dword, umsg:dword, wparam:dword, lparam:dword local hdc:dword local holdfont:dword local firstchar:dword local rect:rect local txtrange:textrange local buffer[1024*10]:byte local hrgn:dword local holdrgn:dword local realrect:rect local pstring:dword local buffersize:dword local pt:point .if umsg==wm_paint push edi push esi invoke hidecaret,hwnd invoke callwindowproc,oldwndproc,hwnd,umsg,wparam,lparam push eax mov edi,offset asmsyntaxarray invoke getdc,hwnd mov hdc,eax invoke setbkmode,hdc,transparent invoke sendmessage,hwnd,em_getrect,0,addr rect invoke sendmessage,hwnd,em_charfrompos,0,addr rect invoke sendmessage,hwnd,em_linefromchar,eax,0 invoke sendmessage,hwnd,em_lineindex,eax,0 mov txtrange.chrg.cpmin,eax mov firstchar,eax invoke sendmessage,hwnd,em_charfrompos,0,addr rect.right mov txtrange.chrg.cpmax,eax push rect.left pop realrect.left push rect.top pop realrect.top push rect.right pop realrect.right push rect.bottom pop realrect.bottom invoke createrectrgn,realrect.left,realrect.top,realrect.right,realrect.bottom mov hrgn,eax invoke selectobject,hdc,hrgn mov holdrgn,eax invoke settextcolor,hdc,commentcolor lea eax,buffer mov txtrange.lpstrtext,eax invoke sendmessage,hwnd,em_gettextrange,0,addr txtrange .if eax>0 mov esi,eax ; esi == size of the text mov buffersize,eax push edi push ebx lea edi,buffer mov edx,edi ; used as the reference point mov ecx,esi mov al,";" scanmore: repne scasb je nextskip jmp nomorehit nextskip: dec edi inc ecx mov pstring,edi mov ebx,edi sub ebx,edx add ebx,firstchar mov txtrange.chrg.cpmin,ebx push eax mov al,0dh repne scasb pop eax hilitethecomment: .if ecx>0 mov byte ptr [edi-1],0 .endif mov ebx,edi sub ebx,edx add ebx,firstchar mov txtrange.chrg.cpmax,ebx pushad mov edi,pstring mov esi,txtrange.chrg.cpmax sub esi,txtrange.chrg.cpmin ; esi contains the length of the buffer mov eax,esi push edi .while eax>0 .if byte ptr [edi]==9 mov byte ptr [edi],0 .endif inc edi dec eax .endw pop edi .while esi>0 .if byte ptr [edi]!=0 invoke lstrlen,edi push eax mov ecx,edi lea edx,buffer sub ecx,edx add ecx,firstchar .if richeditversion==3 invoke sendmessage,hwnd,em_posfromchar,addr rect,ecx .else invoke sendmessage,hwnd,em_posfromchar,ecx,0 mov ecx,eax and ecx,0ffffh mov rect.left,ecx shr eax,16 mov rect.top,eax .endif invoke drawtext,hdc,edi,-1,addr rect,0 pop eax add edi,eax sub esi,eax .else inc edi dec esi .endif .endw mov ecx,txtrange.chrg.cpmax sub ecx,txtrange.chrg.cpmin invoke rtlzeromemory,pstring,ecx popad .if ecx>0 jmp scanmore .endif nomorehit: pop ebx pop edi mov ecx,buffersize lea esi,buffer .while ecx>0 mov al,byte ptr [esi] .if al==" " || al==0dh || al=="/" || al=="," || al=="|" || al=="+" || al=="-" || al=="*" || al=="&" || al=="<" || al==">" || al=="=" || al=="(" || al==")" || al=="{" || al=="}" || al=="[" || al=="]" || al=="^" || al==":" || al==9 mov byte ptr [esi],0 .endif dec ecx inc esi .endw lea esi,buffer mov ecx,buffersize .while ecx>0 mov al,byte ptr [esi] .if al!=0 push ecx invoke lstrlen,esi push eax mov edx,eax ; edx contains the length of the string movzx eax,byte ptr [esi] .if al>="a" && al<="z" sub al,"a" add al,"a" .endif shl eax,2 add eax,edi ; edi contains the pointer to the wordinfo pointer array .if dword ptr [eax]!=0 mov eax,dword ptr [eax] assume eax:ptr wordinfo .while eax!=0 .if edx==[eax].wordlen pushad invoke lstrcmpi,[eax].pszword,esi .if eax==0 popad mov ecx,esi lea edx,buffer sub ecx,edx add ecx,firstchar pushad .if richeditversion==3 invoke sendmessage,hwnd,em_posfromchar,addr rect,ecx .else invoke sendmessage,hwnd,em_posfromchar,ecx,0 mov ecx,eax and ecx,0ffffh mov rect.left,ecx shr eax,16 mov rect.top,eax .endif popad mov edx,[eax].pcolor invoke settextcolor,hdc,dword ptr [edx] invoke drawtext,hdc,esi,-1,addr rect,0 .break .endif popad .endif push [eax].nextlink pop eax .endw .endif pop eax pop ecx