首页
社区
课程
招聘
[讨论]给汇编高手的一道题:关于oop与底层的
发表于: 2011-3-3 08:57 4646

[讨论]给汇编高手的一道题:关于oop与底层的

2011-3-3 08:57
4646
首先推荐一本书:WINDOWS汇编语言及系统程序设计 张豫夫  曹建文  译
      英文名:WINDOWS ASSEMBLY LANGUAGE & SYSTEMS PROGRAMMING
                  16- and 32-bit  low-level programming  for the PC and Windows
                                                                by Barry Kauler
这本书比罗云彬那本强,罗云彬那本满篇的高级语法,这本书没有,更高级的是它还有面向对象的编程,用C++等高级的面向对象的语言,若不会asm的oop,我怎吗说这些人呢?

这些书在网上都有,特别是英文版的,书中的代码我用谷歌在俄国的一所大学里面搜索到了,可以是里面的数据损坏了。

这本书满篇精华,

暂这选一例:
      这个程序最令人激动之处在于它仅仅使用最普通的 BIOS 和 DOS 视频服务生成了这个
窗口,且丝毫也没有与 Windows产生冲突。这个窗口完全是我们的私有财产,以至 Windows
根本不会意识到它的存在。

它的代码如下:
;DPMI.ASM
;This demo program is written in TASM v3.0.
;It uses the WINASMOO.INC OO-file developed in Chapter 7.
;This program makes use of DPMI & low-level Windows functions.
;This program relates to discussion in Chapter 9.
;remember that Windows funcs only preserve SI,DI,BP & DS.

INCLUDE        WINDOWS.INC
INCLUDE        WINASMOO.INC
IDM_QUIT         EQU        100
IDM_ABOUT        EQU        101

.DATA
window1        WINDOW { szclassname="DPMI",sztitlename="DPMI DEMO",\
                 paint=w1paint,create=w1create,command=w1command, \
                 createstylehi=WS_OVERLAPPEDWINDOW+WS_CLIPCHILDREN, \
                 char=w1char, sziconname="icon_1",y_coord=10,timer=w1timer,\
                 destroy=w1destroy }
control1 CONTROL { szclassname="BUTTON",sztitlename="OK",\
                 x_coord=20,y_coord=40,wwidth=30,wheight=20, \
                 hmenu=IDOK,createstylehi=WS_CHILD+WS_VISIBLE,\
                 createstylelo=BS_PUSHBUTTON }
.CODE
kickstart:
        lea        si,window1                        ;addr of window object.
        call        [si].make PASCAL,si                ;make the window.
        lea        si,control1
        call        [si].make PASCAL,si                ;make child window
        ret
;............................
w1paint        PROC PASCAL
        LOCAL        hdc:WORD
        LOCAL        paintstructa:PAINTSTRUCT
        lea        di,paintstructa
        call         BEGINPAINT PASCAL,[si].hwnd, ss,di
        mov        hdc,ax
        call         SELECTOBJECT PASCAL,ax, [si].hfont
        call         TEXTOUT PASCAL,hdc,10,20, cs,OFFSET outstring,33
        call         ENDPAINT PASCAL,[si].hwnd, ss,di
        ret
outstring        DB "Click button for direct video o/p "
w1paint        ENDP
;.............................................
w1create:
        call        GETSTOCKOBJECT PASCAL,OEM_FIXED_FONT        ;Windows func.
        mov        [si].hfont,ax
        ret
;.............................................
w1command:
        cmp        WORD PTR [si].lparam,0        ;lo half=0 if a menu selection.
        jne        notmenu
        ret
notmenu:
        cmp        [si].wparam,IDOK        ;button child window selected?
                ;note that lo-word of lparam has handle of control window,
                ;hi-word of lparam has notification code.
        jne        notbutton
        lea        si,control1        ;since si points to window1.
        call        DESTROYWINDOW PASCAL,[si].hwnd        ;kill the button
        mov        [si].hwnd,0        ;must clear hwnd, if want to make() later.

;what we will do now is make the new window always stay visible....
        lea        si,window1
        call        SETTIMER PASCAL,[si].hwnd,1,200, 0,0        ;200mSec timeout.
                ;post WM_TIMER to window every 200mS. 1=timer id.

notbutton:
        ret
szmsg        DB        "Created by Barry Kauler, 1992",0
szhdg        DB        "Message Box",0
;...................................................
w1char:
;let's bring back the button if any key pressed...
        lea        si,control1                ;since si points to window1.
        call        [si].make PASCAL,si
        ret
;......................
w1destroy:
        call        KILLTIMER PASCAL,[si].hwnd,1        ;created by SETTIMER().
        call         POSTQUITMESSAGE PASCAL,0
        ret
;........................
w1timer:
;comes this way if a WM_TIMER message....
;this WinApp keeps on posting a WM_TIMER message to itself, thus this
;section is in a continuous loop...
        call         dpmidemo
        ret
;............................................................
dpmidemo:
;comes here if button selected.  now we will do some direct video...
        mov        ah,0Fh           ;get current video state
        int        10h                ;--> al=mode,ah=width,bh=page
        mov        mode,al                ;save
        mov        columns,ah        ;        /
        mov        vpage,bh                ;        /
        mov        ah,3           ;get current cursor position
        mov        bh,vpage                ;video page
        int        10h                ;-->dh=row,dl=col,cx=cur.size
        mov        curpos,dx        ;save.
;all of this below, writes the pseudo text mode window onto the scrn...
        mov        ah,2           ;set cursor position
        mov        dh,5                ;row=5
        mov        dl,columns
        shr        dl,1                ;centre cursor on screen
        mov        bh,vpage                ;video page
        push        dx                ;save
        int        10h
        mov        dx,OFFSET szdirect
        mov        ah,9           ;write a string to scrn
        int        21h
        pop        dx                ;restore
        inc        dh                ;next row
        mov        bh,vpage
        mov        ah,2
        push        dx                ;save
        int        10h                ;set cursor
        mov        ah,9               ;write string
        mov        dx,OFFSET szdir2
        int        21h
        pop        dx                ;restore
        inc        dh                ;next row on scrn
        mov        bh,vpage
        mov        ah,2
        int        10h                ;set cursor
        mov        ah,9                ;write string
        mov        dx,OFFSET szdir3
        int        21h

        mov        ah,2                  ;restore cursor pos.
        mov        dx,curpos
        mov        bh,vpage
        int        10h
        ret
.DATA
mode        DB        0
columns        DB        0
vpage        DB        0
curpos        DW        0
szdirect DB "谀哪哪哪哪哪目$"
szdir2         DB "矪IOS/DOS O/P?"
szdir3         DB "滥哪哪哪哪哪馁$"
;...........................................................
END

请看官完善补充:WINASMOO.INC
请问:这是不是只能在windows 95 或者 98 下运行,能在nt及以后的操作系统运行吗?

附上本书的中文版及不完整的代码。

[培训]《安卓高级研修班(网课)》月薪三万计划,掌握调试、分析还原ollvm、vmp的方法,定制art虚拟机自动化脱壳的方法

上传的附件:
收藏
免费 0
支持
分享
最新回复 (3)
雪    币: 1140
活跃值: (3041)
能力值: ( LV12,RANK:385 )
在线值:
发帖
回帖
粉丝
2
有关DPMI & low-level Windows functions的资料,请到我的百度空间的首页里面的资料库里面搜索。
my baidu space:http://hi.baidu.com/correy.
2011-3-3 09:03
0
雪    币: 544
活跃值: (264)
能力值: ( LV12,RANK:210 )
在线值:
发帖
回帖
粉丝
3
这书也太老了。

推荐《Intel汇编语言程序设计》
2011-3-3 11:45
0
雪    币: 777
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
4
额。。。老没关系啊。 只要有用
2011-3-3 12:01
0
游客
登录 | 注册 方可回帖
返回
//