首页
社区
课程
招聘
[旧帖] [分享]第二个Windows程序 0.00雪花
发表于: 2010-8-19 09:06 2046

[旧帖] [分享]第二个Windows程序 0.00雪花

2010-8-19 09:06
2046
;根据http://sunscf.blog.163.com/blog/static/1338896152009113105545886/改编
;本程序在BTASM4.1程序下通过
;2010 8 19

include windows.inc
.data ;数据段
szCaption db '抬头串',0
szText db 'Hello!',0
.code ;代码段
start:
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK ;按钮

;invoke MessageBox, ;显示信息框
;NULL, ;父窗口句柄
;offset szText, ;正文串的地址
;offset szCaption, ;抬头串的地址
;MB_OK ;按钮

invoke ExitProcess,NULL

;invoke ExitProcess, ;终止一个进程
;NULL ;退出代码

[课程]Linux pwn 探索篇!

收藏
免费 0
支持
分享
最新回复 (5)
雪    币: 30
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
;根据http://sunscf.blog.163.com/blog/static/1338896152009113105546437/?latestBlog改编
;if-elseif-endif的使用
;BTASM4.1编译通过 2010 8 19

include windows.inc

.data

CapMsg db '输出',0

szFmt    db 'number是正数:%d',0

szFmt2   db 'number是负数:%d',0
;10
number dd -1
;number dd -9

buffer   db   80 dup(0)

.code

start:

mov eax,number
;20
invoke   wsprintf,addr buffer,addr szFmt,eax

mov eax,number

.if eax == -1
;.if eax == -9

     invoke   wsprintf,addr buffer,addr szFmt2,eax ;二进制数

.endif;30

invoke   MessageBox,NULL,offset buffer,offset CapMsg,MB_OK ;按钮"确定"

INVOKE ExitProcess,0 ; 结束进程

end start
2010-8-19 09:30
0
雪    币: 30
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
;根据http://sunscf.blog.163.com/blog/static/1338896152009113105546245/改编
;在btasm4.1下通过 2010 8 19

;repeat-until的格式为:

;.repeat

;   偱环体(条件不满足时执行)

;.until(条件)

;程序功能:用repeat偱环给双字数组赋值并计算。

include windows.inc

.data

a dd 10 dup(0) ;定义双字数组

buffer db   10 dup(0)

CapMsg db '输出',0

szFmt   db '结果是:%d',0  

i dd 0

sum dd 0

.code

start:

mov edi,0

.repeat

   mov eax,i

   mov a[edi],eax

   inc i

   add edi,4

.until (i>=10)

mov i,0

mov edi,0

.repeat

   mov eax,a[edi]

   add sum,eax

   inc i

   add edi,4

.until (i>=10)

mov eax,sum

invoke   wsprintf,addr buffer,addr szFmt,eax ;二进制数

invoke   MessageBox,NULL,offset buffer,offset CapMsg,MB_OK ;按钮"确定"

INVOKE ExitProcess,0 ;结束进程

end start
2010-8-19 09:54
0
雪    币: 30
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
4
;Windows汇编窗口程序
;根据http://sunscf.blog.163.com/blog/static/1338896152009113105545650/?latestBlog改编
;本程序用btasm 4.1编译通过 2010 8 19
include        windows.inc
.data?
hInstance    dd        ?
hWinMain     dd        ?

        .const

szClassName    db    'MyClass',0
szCaptionMain    db    'My first Window !',0  ;10
szText        db    'Win32 Assembly, Simple and powerful !',0

        .code
; 窗口过程
_ProcWinMain    proc    uses ebx edi esi,hWnd,uMsg,wParam,lParam
        local    @stPs:PAINTSTRUCT     ;设备描述表结构   
        local    @stRect:RECT        ;矩形结构
        local    @hDc            ;设备描述表句柄

        mov    eax,uMsg  ;20
;********************************************************************
        .if    eax ==    WM_PAINT
            invoke    BeginPaint,hWnd,addr @stPs
            mov    @hDc,eax

invoke    GetClientRect,hWnd,addr @stRect ;获取窗口客户区大小
invoke    DrawText,@hDc,addr szText,-1,addr @stRect,DT_SINGLELINE or DT_CENTER or DT_VCENTER   ;输出方式
;invoke    DrawText, ;写窗口中的文本   
;@hDc,    ;设备描述表句柄
;addr szText, ;文本串
;-1,    ;文本串以0结尾
;addr @stRect, ;矩形结构的地址
;DT_SINGLELINE or DT_CENTER or DT_VCENTER   ;输出方式
            invoke    EndPaint,hWnd,addr @stPs ;释放设备描述表句柄
;********************************************************************
        .elseif    eax ==    WM_CLOSE ;关闭窗口
            invoke    DestroyWindow,hWinMain ;擦除窗口
            invoke    PostQuitMessage,NULL    ;在消息队列插入一个WM_QUIT消息
;********************************************************************
        .else
            ;窗口过程中不予处理的消息,传给此涵数.该涵数依次调用BeginPaint和EndPaint
            invoke    DefWindowProc,hWnd,uMsg,wParam,lParam
            ret
        .endif
;********************************************************************
        xor    eax,eax
        ret

_ProcWinMain    endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_WinMain    proc
        local    @stWndClass:WNDCLASSEX
        local    @stMsg:MSG

        invoke    GetModuleHandle,NULL ;获取本模块
        mov    hInstance,eax ;获取本窗口实例的句柄
        invoke    RtlZeroMemory,addr @stWndClass,sizeof @stWndClass
;********************************************************************
; 注册窗口类
;********************************************************************
        invoke    LoadCursor,0,IDC_ARROW
        mov    @stWndClass.hCursor,eax
        push    hInstance
        pop    @stWndClass.hInstance
        mov    @stWndClass.cbSize,sizeof WNDCLASSEX
        mov    @stWndClass.style,CS_HREDRAW or CS_VREDRAW
        mov    @stWndClass.lpfnWndProc,offset _ProcWinMain
        mov    @stWndClass.hbrBackground,COLOR_WINDOW + 1
        mov    @stWndClass.lpszClassName,offset szClassName
        invoke    RegisterClassEx,addr @stWndClass
;********************************************************************
; 建立并显示窗口
;********************************************************************
        invoke    CreateWindowEx,WS_EX_CLIENTEDGE,offset szClassName,offset szCaptionMain,\
            WS_OVERLAPPEDWINDOW,\
            100,100,600,400,\
            NULL,NULL,hInstance,NULL
        mov    hWinMain,eax
        invoke    ShowWindow,hWinMain,SW_SHOWNORMAL
        invoke    UpdateWindow,hWinMain
;********************************************************************
; 消息循环
;********************************************************************
        .while    TRUE
            invoke    GetMessage,addr @stMsg,NULL,0,0
            .break    .if eax    == 0
            invoke    TranslateMessage,addr @stMsg
            invoke    DispatchMessage,addr @stMsg
        .endw
        ret

_WinMain    endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
start:
        call    _WinMain
        invoke    ExitProcess,NULL
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        end    start
2010-8-19 10:17
0
雪    币: 16
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
5
看不懂 什么DD?
2010-8-19 10:17
0
雪    币: 30
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
6
; DcCopy.asm
; 测试设备环境的代码,将一个窗口 DC 对应的象素拷贝到另一个窗口中
;根据http://topic.csdn.net/u/20091004/08/c651152d-e4d3-47fa-bb95-bcc0a652f5e0.html?seed=761550205&r=67797127#r_67797127改编

include        windows.inc
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
ID_TIMER    equ    1
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 数据段
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        .data?
hInstance    dd        ?
hWin1        dd        ?
hWin2        dd        ?

        .const
szClass1    db    'SourceWindow',0
szClass2    db    'DestWindow',0
szCaption1    db    '请尝试用别的窗口覆盖本窗口!',0
szCaption2    db    '本窗口图像拷贝自另一窗口',0
szText        db    'Win32 Assembly, Simple and powerful !',0
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        .code
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 定时器过程
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_ProcTimer    proc    _hWnd,uMsg,_idEvent,_dwTime
        local    @hDc1,@hDc2
        local    @stRect:RECT

        invoke    GetDC,hWin1
        mov    @hDc1,eax
        invoke    GetDC,hWin2
        mov    @hDc2,eax
        invoke    GetClientRect,hWin1,addr @stRect
        invoke    BitBlt,@hDc2,0,0,@stRect.right,@stRect.bottom,\
            @hDc1,0,0,SRCCOPY
        invoke    ReleaseDC,hWin1,@hDc1
        invoke    ReleaseDC,hWin2,@hDc2
        ret

_ProcTimer    endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 窗口过程
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_ProcWinMain    proc    uses ebx edi esi,hWnd,uMsg,wParam,lParam
        local    @stPs:PAINTSTRUCT
        local    @stRect:RECT
        local    @hDc

        mov    eax,uMsg
        mov    ecx,hWnd
;********************************************************************
        .if    eax ==    WM_PAINT && ecx == hWin1
            invoke    BeginPaint,hWnd,addr @stPs
            mov    @hDc,eax
            invoke    GetClientRect,hWnd,addr @stRect
            invoke    DrawText,@hDc,addr szText,-1,\
                addr @stRect,\
                DT_SINGLELINE or DT_CENTER or DT_VCENTER
            invoke    EndPaint,hWnd,addr @stPs
;********************************************************************
        .elseif    eax ==    WM_CLOSE
            invoke    PostQuitMessage,NULL
            invoke    DestroyWindow,hWin1
            invoke    DestroyWindow,hWin2
;********************************************************************
        .else
            invoke    DefWindowProc,hWnd,uMsg,wParam,lParam
            ret
        .endif
;********************************************************************
        xor    eax,eax
        ret

_ProcWinMain    endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_WinMain    proc
        local    @stWndClass:WNDCLASSEX
        local    @stMsg:MSG
        local    @hTimer

        invoke    GetModuleHandle,NULL
        mov    hInstance,eax
        invoke    RtlZeroMemory,addr @stWndClass,sizeof @stWndClass
;********************************************************************
        invoke    LoadCursor,0,IDC_ARROW
        mov    @stWndClass.hCursor,eax
        push    hInstance
        pop    @stWndClass.hInstance
        mov    @stWndClass.cbSize,sizeof WNDCLASSEX
        mov    @stWndClass.style,CS_HREDRAW or CS_VREDRAW
        mov    @stWndClass.lpfnWndProc,offset _ProcWinMain
        mov    @stWndClass.hbrBackground,COLOR_WINDOW + 1
        mov    @stWndClass.lpszClassName,offset szClass1
        invoke    RegisterClassEx,addr @stWndClass
        invoke    CreateWindowEx,WS_EX_CLIENTEDGE,offset szClass1,offset szCaption1,\
            WS_OVERLAPPEDWINDOW,\
            450,100,300,300,\
            NULL,NULL,hInstance,NULL
        mov    hWin1,eax
        invoke    ShowWindow,hWin1,SW_SHOWNORMAL
        invoke    UpdateWindow,hWin1
;********************************************************************
        mov    @stWndClass.lpszClassName,offset szClass2
        invoke    RegisterClassEx,addr @stWndClass
        invoke    CreateWindowEx,WS_EX_CLIENTEDGE,offset szClass2,offset szCaption2,\
            WS_OVERLAPPEDWINDOW,\
            100,100,300,300,\
            NULL,NULL,hInstance,NULL
        mov    hWin2,eax
        invoke    ShowWindow,hWin2,SW_SHOWNORMAL
        invoke    UpdateWindow,hWin2
;********************************************************************
; 设置定时器
;********************************************************************
        invoke    SetTimer,NULL,NULL,100,addr _ProcTimer
        mov    @hTimer,eax
;********************************************************************
; 消息循环
;********************************************************************
        .while    TRUE
            invoke    GetMessage,addr @stMsg,NULL,0,0
            .break    .if eax    == 0
            invoke    TranslateMessage,addr @stMsg
            invoke    DispatchMessage,addr @stMsg
        .endw
;********************************************************************
; 清除定时器
;********************************************************************
        invoke    KillTimer,NULL,@hTimer
        ret

_WinMain    endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
start:
        call    _WinMain
        invoke    ExitProcess,NULL
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        end    start
2010-8-19 11:32
0
游客
登录 | 注册 方可回帖
返回
//