鱼C论坛

 找回密码
 立即注册
查看: 1996|回复: 3

x

[复制链接]
发表于 2012-6-15 12:43:43 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本帖最后由 Mr.Wǎng 于 2012-6-15 16:43 编辑

初学Win32汇编,调用api写了一个小东西,关键代码如下:
  1. _EnableDebugPriv proc uses ebx
  2.     LOCAL   @hToken
  3.     LOCAL   @tkp:TOKEN_PRIVILEGES
  4.     szText  szPrivilegeName, 'SeDebugPrivilege'
  5.    
  6.     LEA ebx, @hToken
  7.     invoke GetCurrentProcess
  8.     invoke OpenProcessToken, eax, TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, ebx
  9.     invoke LookupPrivilegeValue, NULL, addr szPrivilegeName, addr @tkp.Privileges[0].Luid
  10.    
  11.     mov @tkp.PrivilegeCount, 1
  12.     mov @tkp.Privileges[0].Attributes, SE_PRIVILEGE_ENABLED

  13.     invoke AdjustTokenPrivileges, @hToken, FALSE, addr @tkp, sizeof TOKEN_PRIVILEGES, NULL, NULL
  14.     invoke CloseHandle, @hToken
  15.    
  16.     ret
  17. _EnableDebugPriv endp

  18. _UpdateMemory proc
  19.    
  20.     invoke _EnableDebugPriv
  21.    
  22.     invoke FindWindow, offset szTargetClassName, offset szTargetWindowTitle
  23.     .if eax == NULL    ;没有找到
  24.         invoke MessageBox, 0, offset szNotFound, offset szCaption, MB_OK or MB_ICONWARNING
  25.         invoke ExitProcess, 0
  26.     .endif
  27.     mov hWinTarget, eax
  28.    
  29.     invoke GetWindowThreadProcessId, hWinTarget, offset hProcessId
  30.    
  31. ;    szText szFormatProcessId, 'the Tartget Process ID is : %d '
  32. ;    invoke wsprintf, offset cBuf, addr szFormatProcessId, hProcessId
  33. ;    invoke MessageBox, 0, offset cBuf, offset szCaption, MB_OK or MB_ICONWARNING
  34.    
  35.     invoke OpenProcess, PROCESS_ALL_ACCESS, FALSE, hProcessId

  36.     .if !eax
  37.         invoke GetLastError
  38.         szText szFormatOpenProcess, 'Error of OpenProcess is : %d'
  39.         invoke wsprintf, offset cBuf, addr szFormatOpenProcess, eax
  40.         invoke MessageBox, 0, offset cBuf, offset szCaption, MB_OK or MB_ICONWARNING
  41.         invoke ExitProcess, 0
  42.     .endif
  43.     mov hTargetProc, eax

  44.     invoke WriteProcessMemory, hTargetProc, baseAddr, offset dwTime, sizeof dwTime, offset dwBytes
  45.    
  46.     .if !eax
  47.         invoke GetLastError
  48.         szText szWriteMemory, 'Error of WriteProcessMemory is %d :'
  49.         invoke wsprintf, offset cBuf, addr szWriteMemory, eax
  50.         invoke MessageBox, 0, offset cBuf, offset szCaption, MB_OK or MB_ICONWARNING
  51.         invoke ExitProcess, 0
  52.     .endif
  53.    
  54.     ret
  55. _UpdateMemory endp
复制代码
其中33、34、35三行让我很费解
注释掉,OpenProcess失败,错误码998
取消注释,OpenProcess就成功了
百度、Google一大圈子,没有答案,郁闷死了

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
 楼主| 发表于 2012-6-15 12:46:51 | 显示全部楼层
顶起来,求大虾们帮解决,求鱼哥关注
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
 楼主| 发表于 2012-6-15 12:53:49 | 显示全部楼层
我擦,要沉了
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
 楼主| 发表于 2012-6-15 15:36:27 | 显示全部楼层
果然沉了!
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-5-3 10:43

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表