当前位置: 代码迷 >> 汇编语言 >> 小妹有有关问题,关于Svchost进程与桌面交互的代码
  详细解决方案

小妹有有关问题,关于Svchost进程与桌面交互的代码

热度:7451   发布时间:2013-02-26 00:00:00.0
小妹有问题,关于Svchost进程与桌面交互的代码
在Svchost进程中插入了一个DLL,该DLL是无法使用FindWindow函数找到桌面上某窗口的句柄的。
下面这个代码是我自己写的,希望能开启与桌面的交互,从而使FindWindow能查找到桌面中某窗口的句柄,从而进行SendMessage。但是以下代码执行无效,希望哪位高手能帮忙修改并测试一下下。小妹感激不尽 ^-^


  invoke GetProcessWindowStation
  .if eax == NULL
  ret
  .endif
  mov hwinstaCurrent,eax
  invoke GetCurrentThreadId
  invoke GetThreadDesktop,eax
  .if eax == NULL
  ret
  .endif
  mov hdeskCurrent,eax
  invoke OpenWindowStation,addr szwinsta0,FALSE, WINSTA_ACCESSCLIPBOARD or \  
  WINSTA_ACCESSGLOBALATOMS or \  
  WINSTA_CREATEDESKTOP or \  
  WINSTA_ENUMDESKTOPS or \  
  WINSTA_ENUMERATE or \  
  WINSTA_EXITWINDOWS or \  
  WINSTA_READATTRIBUTES or \  
  WINSTA_READSCREEN or \  
  WINSTA_WRITEATTRIBUTES
  .if eax == NULL
  ret
  .endif
  mov hwinsta,eax
  invoke SetProcessWindowStation,hwinsta
  .if eax == NULL
  ret
  .endif
  invoke OpenDesktop,addr szdefault,0,FALSE,DESKTOP_CREATEMENU or DESKTOP_CREATEWINDOW or DESKTOP_ENUMERATE or DESKTOP_HOOKCONTROL or DESKTOP_JOURNALPLAYBACK or\  
  DESKTOP_JOURNALRECORD or \ 
  DESKTOP_READOBJECTS or \
  DESKTOP_SWITCHDESKTOP or \  
  DESKTOP_WRITEOBJECTS
  .if eax == NULL
  ret
  .endif
  mov hdesk,eax
  invoke SetThreadDesktop,hdesk
  invoke FindWindow,addr szWndClass,addr szWndWindow
  .if eax == NULL
  ret
  .endif
  mov hDestWnd,eax
  invoke SetProcessWindowStation,hwinstaCurrent
  invoke SetThreadDesktop,hdeskCurrent
  invoke SendMessage,hDestWnd,WM_WNDH,NULL,NULL
  invoke FindWindow,addr szWndClass,addr szWndWindow
  .if eax == NULL
  ret
  .endif
  mov hDestWnd,eax
  invoke SendMessage,hDestWnd,WM_WNDH,NULL,NULL
  invoke CloseWindowStation,hwinsta
  invoke CloseDesktop,hdesk
  invoke SendMessage,hDestWnd,WM_WNDH,NULL,NULL

------解决方案--------------------------------------------------------
关注,帮顶!看楼下强人