首页
社区
课程
招聘
[旧帖] [求助]罗云彬的汇编书里的GDI例子在Win7失效 0.00雪花
发表于: 2012-7-28 18:31 2130

[旧帖] [求助]罗云彬的汇编书里的GDI例子在Win7失效 0.00雪花

2012-7-28 18:31
2130
第7.1.2章节展示了一个叫DcCopy的程序,程序运行时有两个窗口,设置了定时器,每100ms就把一个窗口的图像拷贝到另一个窗口。下图为程序在Windows 7和Windows XP下的运行情况。

 
在Windows 7下失效了,原因不明。
附上源码给大牛研究。
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; Sample code for < Win32ASM Programming 2nd Edition>
; by 蹕堁梃, http://asm.yeah.net
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; DcCopy.asm
; 聆彸扢掘遠噫腔測鎢ㄛ蔚珨跺敦諳 DC 勤茼腔砓匼蕭探善鍚珨跺敦諳笢
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 妏蚚 nmake 麼狟蹈韜鍔輛俴晤祒睿蟈諉:
; ml /c /coff DcCopy.asm
; Link /subsystem:windows DcCopy.obj
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    .386
    .model flat,stdcall
    option casemap:none
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; Include 恅璃隅砱
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include    windows.inc
include    gdi32.inc
includelib  gdi32.lib
include    user32.inc
includelib  user32.lib
include    kernel32.inc
includelib  kernel32.lib
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
ID_TIMER  equ  1
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 杅擂僇
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    .data?
hInstance  dd    ?
hWin1    dd    ?
hWin2    dd    ?
dwCounter  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
    inc    dwCounter
    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

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

收藏
免费 0
支持
分享
最新回复 (7)
雪    币: 39
活跃值: (51)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
不懂  但是帮你顶起  呵呵
2012-7-28 20:56
0
雪    币: 285
活跃值: (16)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
3
哪出的问题也不说原因
2012-7-28 21:40
0
雪    币: 42
活跃值: (25)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
4
这个是不是问题的问题是你只要把window的主题换成window经典模式就可以了
2013-10-27 01:56
0
雪    币: 279
活跃值: (113)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
5
可能windows7的gdi有改动
2014-7-29 16:47
0
雪    币: 6
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
6
不能用透明主题     换成经典
2014-7-31 12:04
0
雪    币: 1727
活跃值: (925)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
7
是不是管理员权限的问题
2014-7-31 13:28
0
雪    币: 209
活跃值: (14)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
8
主题的原因~~~
2014-8-3 17:37
0
游客
登录 | 注册 方可回帖
返回
//