invoke getfileattributes,addr buffer .if eax!=-1
i use this method as a quick way of checking whether a file exists.
mov blocksize,1024*10 invoke heapalloc,hmainheap,0,blocksize mov ptemp,eax
allocate the memory block to store the words. default to 10k. the memory is allocated from the default heap.
@@: invoke getprivateprofilestring,addr asmsection,addr c1key,addr zerostring,ptemp,blocksize,addr buffer .if eax!=0
i use getprivateprofilestring to retrieve the content of each key in wordfile.txt. the key starts from c1 to c10.
inc eax .if eax==blocksize ; the buffer is too small add blocksize,1024*10 invoke heaprealloc,hmainheap,0,ptemp,blocksize mov ptemp,eax jmp @b .endif
checking whether the memory block is large enough. if it is not, we increment the size by 10k until the block is large enough.
mov edx,offset asmcolorarray invoke parsebuffer,hmainheap,ptemp,eax,edx,addr asmsyntaxarray
pass the words, the memory block handle, the size of the data read from wordfile.txt, the address of the color dword that will be used to hilight the words and the address of asmsyntaxarray.
now, let's examine what parsebuffer does. in essence, this function accepts the buffer containing the words to be hilighted ,parses them to individual words and stores each of them in a wordinfo structure array that can be accessed quickly from asmsyntaxarray.
parsebuffer proc uses edi esi hheap:dword,pbuffer:dword, nsize:dword, arrayoffset:dword,parray:dword local buffer[128]:byte local inprogress:dword mov inprogress,false
inprogress is the flag i use to indicate whether the scanning process has begun. if the value is false, we haven't encountered a non-white space character yet.
lea esi,buffer mov edi,pbuffer invoke charlower,edi
esi points to our local buffer that will contain the word we have parsed from the word list. edi points to the word list string. to simplify the search later, we convert all characters to lowercase.