iczelion tut35[14]

[入库:2005年8月19日] [更新:2007年3月24日]

本文简介:选择自 jimgreen 的 blog

				shl eax,2
				add eax,edi		; edi contains the pointer to the wordinfo pointer array
				.if dword ptr [eax]!=0

after that, we skip to the corresponding dword in asmsyntaxarray and check whether the value in that dword is 0. if it is, we can skip to the next word.

					mov eax,dword ptr [eax]
					assume eax:ptr wordinfo
					.while eax!=0
						.if edx==[eax].wordlen

if the value in the dword is non-zero, it points to the linked list of wordinfo structures. we process to walk the linked list, comparing the length of the word in our local buffer with the length of the word in the wordinfo structure. this is a quick test before we compare the words. should save some clock cycles.

							pushad
							invoke lstrcmpi,[eax].pszword,esi
							.if eax==0

if the lengths of both words are equal, we proceed to compare them with lstrcmpi.

								popad
								mov ecx,esi
								lea edx,buffer
								sub ecx,edx
								add ecx,firstchar

we construct the character index from the address of the first character of the matching word in the buffer. we first obtain its relative offset from the starting address of the buffer then add the character index of the first visible character to it.

								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

once we know the character index of the first character of the word to be hilighted, we proceed to obtain the coordinate of it by sending em_posfromchar message. however, this message is interpreted differently by richedit 2.0 and 3.0. for richedit 2.0, wparam contains the character index and lparam is not used. it returns the coordinate in eax. for richedit 3.0, wparam is the pointer to a point structure that will be filled with the coordinate and lparam contains the character index.

as you can see, passing the wrong arguments to em_posfromchar can wreak havoc to your system. that's why i have to differentiate between richedit control versions.

								mov edx,[eax].pcolor
								invoke settextcolor,hdc,dword ptr [edx]								
								invoke drawtext,hdc,esi,-1,addr rect,0

once we got the coordinate to start, we set the text color with the one specified in the wordinfo structure. and then proceed to overwrite the word with the new color.

本文关键:iczelion asm
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top