-
-
[原创]windows消息发送过程例子
-
发表于: 2007-6-11 15:01 4931
-
用于分析窗口接收到的消息。大概流程如下,还没有用.lib方式,完整的见附件!
生成的result.dat为分析结果文件。
在WinMain进程中要处理的2处
;在WinMain中初始化
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
invoke GlobalAlloc,GMEM_ZEROINIT or GMEM_FIXED,1024*513 ;0.51Mbyte
.if eax
mov hGlobalAlloc,eax
.else
invoke MessageBox,NULL,CTEXT('内存分配失败'),CTEXT('faily:'),MB_OK
invoke ExitProcess,1
.endif ;//
invoke CreateFile,CTEXT("result.dat"),GENERIC_WRITE,FILE_SHARE_WRITE or FILE_SHARE_READ,0,CREATE_ALWAYS,FILE_FLAG_BACKUP_SEMANTICS,0
.if eax != -1
mov hFile,eax
.else
invoke GlobalFree,hGlobalAlloc
invoke MessageBox,NULL,CTEXT('创建文件失败'),CTEXT('faily:'),MB_OK
invoke ExitProcess,1
.endif ;//
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;退出程序时保存最后一次没有保存的内容
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
invoke lstrcat,hGlobalAlloc,CTEXT(13,10,"====< End >====",13,10)
add Debug_i,19
invoke WriteFile,hFile,hGlobalAlloc,Debug_i,addr dwDebug_Write,0
invoke CloseHandle,hFile
invoke GlobalFree,hGlobalAlloc
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;在主处理进程中的主要处理如下:
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
mov eax,uMsg
.if eax == 8000h
lea eax,WM_@_8000
.else
mov eax,WM_Table[eax*4]
lea ebx,WM_@_UNKNOW
.if eax == ebx
invoke wsprintf,ADDR lpDebugBuffer,CTEXT("●%s: %08x%s<lParam:%08x wParam:%08x>%s"),eax,uMsg,addr CR_LF,lParam,wParam,addr CR_LF
.else
invoke wsprintf,ADDR lpDebugBuffer,CTEXT("%s%s<lParam:%08x wParam:%08x>%s"),eax,addr CR_LF,lParam,wParam,addr CR_LF
.endif
.endif ;//
invoke lstrlen,ADDR lpDebugBuffer
add Debug_i,eax
invoke lstrcat,hGlobalAlloc,ADDR lpDebugBuffer
;---------------------------------------------------------------------------
;写文件
;---------------------------------------------------------------------------
.if Debug_i > 1024*512 ;512Kbyte时写入文件
invoke WriteFile,hFile,hGlobalAlloc,Debug_i,addr dwDebug_Write,0
;---------------------------------------------------------------------------
;清hGlobalAlloc、Debug_i
;---------------------------------------------------------------------------
mov eax,hGlobalAlloc ;invoke RtlZeroMemory,hGlobalAlloc,4 ;等同
xor ebx,ebx
mov [eax],ebx
push 0
pop Debug_i
.endif ;//
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
附件b55K9s2c8@1M7q4)9K6b7g2)9J5c8W2)9J5c8X3u0J5K9h3g2X3j5$3q4K6k6g2)9J5k6i4c8G2L8g2)9J5k6h3y4G2L8g2)9J5c8X3c8G2N6$3&6D9L8$3q4V1i4K6u0W2M7r3S2H3i4K6y4r3k6X3W2D9k6f1W2p5i4K6y4p5y4o6b7#2y4U0t1J5x3b7`.`.
生成的result.dat为分析结果文件。
在WinMain进程中要处理的2处
;在WinMain中初始化
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
invoke GlobalAlloc,GMEM_ZEROINIT or GMEM_FIXED,1024*513 ;0.51Mbyte
.if eax
mov hGlobalAlloc,eax
.else
invoke MessageBox,NULL,CTEXT('内存分配失败'),CTEXT('faily:'),MB_OK
invoke ExitProcess,1
.endif ;//
invoke CreateFile,CTEXT("result.dat"),GENERIC_WRITE,FILE_SHARE_WRITE or FILE_SHARE_READ,0,CREATE_ALWAYS,FILE_FLAG_BACKUP_SEMANTICS,0
.if eax != -1
mov hFile,eax
.else
invoke GlobalFree,hGlobalAlloc
invoke MessageBox,NULL,CTEXT('创建文件失败'),CTEXT('faily:'),MB_OK
invoke ExitProcess,1
.endif ;//
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;退出程序时保存最后一次没有保存的内容
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
invoke lstrcat,hGlobalAlloc,CTEXT(13,10,"====< End >====",13,10)
add Debug_i,19
invoke WriteFile,hFile,hGlobalAlloc,Debug_i,addr dwDebug_Write,0
invoke CloseHandle,hFile
invoke GlobalFree,hGlobalAlloc
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;在主处理进程中的主要处理如下:
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
mov eax,uMsg
.if eax == 8000h
lea eax,WM_@_8000
.else
mov eax,WM_Table[eax*4]
lea ebx,WM_@_UNKNOW
.if eax == ebx
invoke wsprintf,ADDR lpDebugBuffer,CTEXT("●%s: %08x%s<lParam:%08x wParam:%08x>%s"),eax,uMsg,addr CR_LF,lParam,wParam,addr CR_LF
.else
invoke wsprintf,ADDR lpDebugBuffer,CTEXT("%s%s<lParam:%08x wParam:%08x>%s"),eax,addr CR_LF,lParam,wParam,addr CR_LF
.endif
.endif ;//
invoke lstrlen,ADDR lpDebugBuffer
add Debug_i,eax
invoke lstrcat,hGlobalAlloc,ADDR lpDebugBuffer
;---------------------------------------------------------------------------
;写文件
;---------------------------------------------------------------------------
.if Debug_i > 1024*512 ;512Kbyte时写入文件
invoke WriteFile,hFile,hGlobalAlloc,Debug_i,addr dwDebug_Write,0
;---------------------------------------------------------------------------
;清hGlobalAlloc、Debug_i
;---------------------------------------------------------------------------
mov eax,hGlobalAlloc ;invoke RtlZeroMemory,hGlobalAlloc,4 ;等同
xor ebx,ebx
mov [eax],ebx
push 0
pop Debug_i
.endif ;//
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
附件b55K9s2c8@1M7q4)9K6b7g2)9J5c8W2)9J5c8X3u0J5K9h3g2X3j5$3q4K6k6g2)9J5k6i4c8G2L8g2)9J5k6h3y4G2L8g2)9J5c8X3c8G2N6$3&6D9L8$3q4V1i4K6u0W2M7r3S2H3i4K6y4r3k6X3W2D9k6f1W2p5i4K6y4p5y4o6b7#2y4U0t1J5x3b7`.`.
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课
赞赏
他的文章
- [求助]C语言中没有Currency类型? 4683
- [求助]远程注入失败。 3353
- [原创]在MASM中调用标准C函数 7602
- [下载]Radasm2.2.1.3下载 9614
- [求助]SHA512求助 3533
赞赏
雪币:
留言: