工作一直没有着落,手上的事情却都搁置不顾。心态每况愈下,无一丝慰籍。
无聊之余,想到以后写程序时或许会用到些代码。现在想出一点,打发时间。
用 YONSM 的 DEBUGTRACE 时 甚感舒服,可惜ABOUT上只有C的调用代码,于是写段 WIN32ASM 的代码,以后改进。
code:
01 .386
02 .model flat, stdcall
03 option casemap :none
04 ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
05 ; Include 文件定义
06 ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
07 include \masm32\include\windows.inc
08 include \masm32\include\kernel32.inc
09 include \masm32\include\user32.inc
10 include \masm32\include\masm32.inc
11
12 includelib \masm32\lib\kernel32.lib
13 includelib \masm32\lib\user32.lib
14 includelib \masm32\lib\masm32.lib
15 include \masm32\macros\macros.asm
16 include \masm32\macros\strings.mac
17 ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
18 ; Equ 等值定义
19 ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
20 EbNetBuffer_s struct
21
22 next dd ?
23 char dd ?
24 buffer dd ?
25 alength dd ?
26
27 EbNetBuffer_s ends
28
29 .data?
30 EbNetBuffer EbNetBuffer_s <?>
31 hInstance dd ?
32 szbuffer db 1024 dup (?)
33
34 .code
35 DbgPrint proc uses ebx edi esi debugcommon:dword,debugvalue:dword
36 local @buffer[256]:BYTE
37 local @addr[64]:BYTE
38
39 mov eax, ebp
40 add eax, 4h
41 mov eax, [eax]
42 sub eax, 5h
43 invoke wsprintf, addr @addr, $CTA0("addr:00%lXh || "), eax
44 invoke wsprintf, addr @buffer, debugcommon, debugvalue
45 invoke lstrcat, addr @addr, addr @buffer
46 invoke OutputDebugString, addr @addr
47 ret
48 DbgPrint endp
49
50 start:
51 invoke GetModuleHandle,NULL
52 mov hInstance,eax
53 invoke RtlZeroMemory, addr EbNetBuffer, sizeof EbNetBuffer
54 mov [EbNetBuffer.next],31323334h
55 mov [EbNetBuffer.char], 'abcd'
56 invoke DbgPrint, $CTA0("values is :%s"), addr EbNetBuffer
57 invoke ExitProcess,NULL
58 ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
59 end start
60
DbgPrint ,为了和 DebugPrint 有所区分,起了这个名字。相信以后会有用的,呵呵……
本文地址:http://com.8s8s.com/it/it22561.htm