⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ie.asm

📁 windows汇编语言程序设计 吴中平著 一书所附所有源代码。 该书重点讲解了Windows环境下汇编语言程序设计的基本原理及其实现过程
💻 ASM
📖 第 1 页 / 共 2 页
字号:
      mov TxtRange.chrg.cpMin,eax         
      invoke SendMessage,hWnd,EM_CHARFROMPOS,0,addr rect.right
      mov LastChar,eax
      mov TxtRange.chrg.cpMax,eax  
      invoke GetDC,hWnd
      mov hdc,eax    
      invoke SetBkMode,hdc,TRANSPARENT    
      invoke CreateRectRgn,rect.left,rect.top,rect.right,rect.bottom
      mov hRegion,eax
      invoke SelectObject,hdc,hRegion
      mov hOldRegion,eax
      lea eax,buffer
      mov TxtRange.lpstrText,eax
      invoke SendMessage,hWnd,EM_GETTEXTRANGE,0,addr TxtRange
      mov nSize,eax
      .if  SelectMenuMark==1
         invoke SendMessage,hWnd,EM_SETBKGNDCOLOR,0,0efffffh
         lea edi,strbuffer
         lea esi,buffer
         mov pTempStore,esi
         mov EffectLen,0
         cld
         inc nSize
         .while nSize
            .if  (byte ptr[esi]==20H || byte ptr[esi]==9H ||byte ptr[esi]==0 ||byte ptr[esi]=='='||byte ptr[esi]=='<' ||byte ptr[esi]=='>' || byte ptr[esi]==13 || byte ptr[esi]==10)&&EffectLen
               push esi
               mov esi,pTempStore
               .while byte ptr[esi]==20H || byte ptr[esi]==9H || byte ptr[esi]=='='||byte ptr[esi]=='<' ||byte ptr[esi]=='>'|| byte ptr[esi]==13 || byte ptr[esi]==10
                  inc esi
               .endw
               push esi
               mov ecx,EffectLen
               rep movsb
               mov byte ptr[edi],0
               pop esi
               lea eax,buffer
               sub esi,eax                
               add esi,FirstChar
               invoke HighLightSyntax, addr strbuffer,esi,hWnd,hdc
               lea edi,strbuffer
               pop esi
               mov pTempStore,esi
               mov EffectLen,0 
            .endif
            .if  ( byte ptr[esi]!=20H && byte ptr[esi]!='=' && byte ptr[esi]!='<' && byte ptr[esi]!='>' && byte ptr[esi]!=13 && byte ptr[esi]!=10 && byte ptr[esi]!=9H)
               inc EffectLen
            .endif
            inc esi
            dec nSize
         .endw
      .elseif SelectMenuMark==2
         mov SelectMenuMark,0
      .endif
      invoke SelectObject,hdc,hOldRegion
      invoke ReleaseDC,hWnd,hdc
      invoke ShowCaret,hWnd
      ret
   .elseif  uMsg==WM_CLOSE
     invoke SetWindowLong,hWnd,GWL_WNDPROC,OldWndProc
   .else
      invoke CallWindowProc,OldWndProc,hWnd,uMsg,wParam,lParam
      ret
   .endif
SubClassRichEditProc  endp


HighLightSyntax proc uses esi edi pChar:DWORD,pos:DWORD,hWnd:DWORD,hdc:dword
   local pt:POINT
   lea edi,SynArray
   mov esi,pChar 
   .if byte ptr [esi]=='/'
      inc esi
   .endif 
   mov al,[esi]
   .if al>="A" && al<="Z"
      sub al,"A"
      add al,"a"
   .endif
   movzx eax,al
   shl eax,2
   add eax,edi
   .if  dword ptr[eax]!=0
      mov edi,dword ptr [eax]
      assume edi:ptr WORDINFO
      .while edi
         invoke lstrlen,esi
         .if  eax==[edi].WordLen
            invoke lstrcmpi,[edi].pszWord,esi
            .if  !eax
               .if RichEditVersion==3
                  invoke SendMessage,hWnd,EM_POSFROMCHAR,addr pt,pos
               .else
                  invoke SendMessage,hWnd,EM_POSFROMCHAR,pos,0
                  mov ecx,eax
                  and ecx,0FFFFh
                  mov pt.x,ecx
                  shr eax,16
                  mov pt.y,eax 
               .endif
               mov edx,[edi].pColor
               invoke SetTextColor,hdc,dword ptr [edx]								
               invoke lstrlen,pChar
               invoke TextOut,hdc,pt.x,pt.y,pChar,eax
               .break
            .endif
         .endif         
         push [edi].NextLink
         pop edi
      .endw
   .endif
   assume edi:nothing
   ret
HighLightSyntax endp

LinkTable proc uses esi edi ArrayOffset:DWORD,pBuffer:DWORD
   invoke HeapAlloc,hHeap,HEAP_ZERO_MEMORY,sizeof WORDINFO
   mov esi,eax
   assume esi:ptr WORDINFO
   invoke lstrlen,pBuffer
   push eax
   pop [esi].WordLen
   push ArrayOffset
   pop [esi].pColor
   inc eax
   invoke HeapAlloc,hHeap,HEAP_ZERO_MEMORY,eax
   mov [esi].pszWord,eax
   mov edx,eax
   invoke lstrcpy,edx,pBuffer
   lea eax,SynArray
   mov edi,pBuffer
   movzx edx,byte ptr [edi]   
   shl edx,2
   add eax,edx
   .if dword ptr [eax]==0
      mov dword ptr [eax],esi
   .else
      push dword ptr [eax]
      pop [esi].NextLink
      mov dword ptr [eax],esi
   .endif
   assume esi:nothing
   ret
LinkTable endp 

RetrieveSyntax proc uses esi edi pBuffer:DWORD, nSize:DWORD, ArrayOffset:DWORD
   local buffer[64]:byte
   local EffectLen:dword
   local pTempStore:dword
   lea edi,buffer
   mov esi,pBuffer
   mov pTempStore,esi
   mov EffectLen,0
   invoke CharLower,esi
   cld
   inc nSize
   .while nSize
      .if  (byte ptr[esi]==20H || byte ptr[esi]==9H ||byte ptr[esi]==0)&&EffectLen
         push esi
         mov esi,pTempStore
         .while byte ptr[esi]==20H || byte ptr[esi]==9H 
            inc esi
         .endw
         mov ecx,EffectLen
         rep movsb
         mov byte ptr[edi],0
         invoke LinkTable,ArrayOffset,addr buffer
         pop esi
         mov pTempStore,esi
         lea edi,buffer
         mov EffectLen,0   
      .endif

      .if  (byte ptr[esi]!=20H &&byte ptr[esi]!=9H)
         inc EffectLen
      .endif
      inc esi
      dec nSize
   .endw
   ret
RetrieveSyntax endp

CreateIndex proc uses edi
   local pHighlightWord:LPSTR
   local nSize:dword
   invoke GetFileAttributes,addr SyntaxFileName
   .if eax==INVALID_HANDLE_VALUE
      invoke MessageBox,NULL,addr SynwordFileNoExist,addr TitleName,MB_OK
      mov eax,-1
      ret
   .else
      mov nSize,4096
      invoke HeapAlloc,hHeap,HEAP_ZERO_MEMORY,nSize
      mov pHighlightWord,eax        
      invoke GetPrivateProfileString,addr SynSection,addr KeyName1,addr ZeroString,pHighlightWord,nSize,addr SyntaxFileName
      .if eax!=0
         mov edx,offset SynColorArray
         invoke RetrieveSyntax,pHighlightWord,eax,edx
      .endif
      invoke GetPrivateProfileString,addr SynSection,addr KeyName2,addr ZeroString,pHighlightWord,nSize,addr SyntaxFileName
      .if eax!=0
         mov edx,offset SynColorArray
         add edx,4
         invoke RetrieveSyntax,pHighlightWord,eax,edx
      .endif
      invoke GetPrivateProfileString,addr SynSection,addr KeyName3,addr ZeroString,pHighlightWord,nSize,addr SyntaxFileName
      .if eax!=0
         mov edx,offset SynColorArray
         add edx,8
         invoke RetrieveSyntax,pHighlightWord,eax,edx
      .endif
      invoke GetPrivateProfileString,addr SynSection,addr KeyName4,addr ZeroString,pHighlightWord,nSize,addr SyntaxFileName
      .if eax!=0
         mov edx,offset SynColorArray
         add edx,12
         invoke RetrieveSyntax,pHighlightWord,eax,edx
      .endif
      invoke GetPrivateProfileString,addr SynSection,addr KeyName5,addr ZeroString,pHighlightWord,nSize,addr SyntaxFileName
      .if eax!=0
         mov edx,offset SynColorArray
         add edx,16
         invoke RetrieveSyntax,pHighlightWord,eax,edx
      .endif
      invoke GetPrivateProfileString,addr SynSection,addr KeyName6,addr ZeroString,pHighlightWord,nSize,addr SyntaxFileName
      .if eax!=0
         mov edx,offset SynColorArray
         add edx,20
         invoke RetrieveSyntax,pHighlightWord,eax,edx
      .endif
      invoke GetPrivateProfileString,addr SynSection,addr KeyName7,addr ZeroString,pHighlightWord,nSize,addr SyntaxFileName
      .if eax!=0
         mov edx,offset SynColorArray
         add edx,24
         invoke RetrieveSyntax,pHighlightWord,eax,edx
      .endif
      invoke GetPrivateProfileString,addr SynSection,addr KeyName8,addr ZeroString,pHighlightWord,nSize,addr SyntaxFileName
      .if eax!=0
         mov edx,offset SynColorArray
         add edx,28
         invoke RetrieveSyntax,pHighlightWord,eax,edx
      .endif
      invoke GetPrivateProfileString,addr SynSection,addr KeyName9,addr ZeroString,pHighlightWord,nSize,addr SyntaxFileName
      .if eax!=0
         mov edx,offset SynColorArray
         add edx,32
         invoke RetrieveSyntax,pHighlightWord,eax,edx
      .endif
      invoke GetPrivateProfileString,addr SynSection,addr KeyName10,addr ZeroString,pHighlightWord,nSize,addr SyntaxFileName
      .if eax!=0
         mov edx,offset SynColorArray
         add edx,36
         invoke RetrieveSyntax,pHighlightWord,eax,edx
      .endif
      invoke GetPrivateProfileString,addr SynSection,addr KeyName11,addr ZeroString,pHighlightWord,nSize,addr SyntaxFileName
      .if eax!=0
         mov edx,offset SynColorArray
         add edx,40
         invoke RetrieveSyntax,pHighlightWord,eax,edx
      .endif
      invoke GetPrivateProfileString,addr SynSection,addr KeyName12,addr ZeroString,pHighlightWord,nSize,addr SyntaxFileName
      .if eax!=0
         mov edx,offset SynColorArray
         add edx,44
         invoke RetrieveSyntax,pHighlightWord,eax,edx
      .endif
      invoke GetPrivateProfileString,addr SynSection,addr KeyName13,addr ZeroString,pHighlightWord,nSize,addr SyntaxFileName
      .if eax!=0
         mov edx,offset SynColorArray
         add edx,48
         invoke RetrieveSyntax,pHighlightWord,eax,edx
      .endif
      invoke HeapFree,hHeap,HEAP_ZERO_MEMORY,pHighlightWord
   .endif
   ret
CreateIndex endp

make_skt proc uses  esi edi hwnd:dword
   local sin:sockaddr_in
   invoke socket ,AF_INET,SOCK_STREAM,0
   .if  eax==INVALID_SOCKET
      invoke MessageBox,hwnd,addr SocketError,addr TitleName,MB_OK
      invoke SendMessage,hwnd,WM_CLOSE,0,0   
   .endif
   mov hsocket,eax
   invoke WSAAsyncSelect,hsocket,hwnd,UM_SOCK,FD_CONNECT or FD_WRITE or FD_READ or FD_CLOSE
   .if  eax==SOCKET_ERROR
      invoke WSAGetLastError
      .if  eax!=WSAEWOULDBLOCK
         invoke closesocket,hsocket
         invoke MessageBox,hwnd,addr SelectError,addr TitleName,MB_OK
         invoke SendMessage,hwnd,WM_CLOSE,0,0   
      .endif
   .endif
   invoke htons, DEFAULT_PORT
   mov sin.sin_port,ax
   mov sin.sin_family,AF_INET
   lea edi,HostBuffer
   assume edi:ptr hostent
   mov esi,[edi].h_list
   mov eax,[esi]
   mov esi,[eax]
   assume edi:nothing
   mov sin.sin_addr,esi
   invoke connect,hsocket,addr sin,sizeof sin
   ret
make_skt endp

receive_pkt proc uses esi edi hs:dword,hwnd:HANDLE
   invoke RtlZeroMemory,addr RecvBuffer,1024
   invoke recv ,hs,addr RecvBuffer,1024,0
   invoke SendMessage,hwndRichEdit,EM_SETSEL,-1,-1
   invoke SendMessage,hwndRichEdit,EM_REPLACESEL,0,addr RecvBuffer     
   ret
receive_pkt endp

end start

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -