小编Kar*_*son的帖子

来自Win32 app的x64图像上的OpenProcess

这很奇怪.早些时候,运行Windows 7 x64,我无法针对64位进程调用Win32 OpenProcess.谷歌搜索了一下,并得出了沉没的结论,这不会发生.

然后发生了一件有趣的事.我尝试使用explorer.exe和神圣鲤鱼的进程ID ,它有效!开始向它抛出其他进程ID,这只是一个愚蠢的废话.

事实证明,我可以针对大量的x64进程调用OpenProcess - explorer,itype,ipoint,taskhost,cmd,mstsc,...等.

其他人弹出5(访问被拒绝) - winlogon,csrss,services,svchost,mdm,...

我正在使用Process Explorer确认"bitness"和进程ID.另外,在64位进程上调用GetModuleFileNameEx总是失败,因此可以对32/64进行双重检查.

这是代码:

' Get a handle to the process.
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION Or PROCESS_VM_READ, 0, ProcessID)
If hProcess Then
   ' Grab the filename for base module.
   nChars = GetModuleFileNameEx(hProcess, 0, Buffer, Len(Buffer))
   ' If running in x64, http://winprogger.com/?p=26
   If Err.LastDllError = ERROR_PARTIAL_COPY Then
      nChars = GetProcessImageFileName(hProcess, Buffer, Len(Buffer))
   End If
   ' Truncate and return buffer.
   If nChars Then
      GetProcessFileName = Left$(Buffer, nChars)
   End If
   Call …
Run Code Online (Sandbox Code Playgroud)

winapi access-denied 32bit-64bit

5
推荐指数
1
解决办法
5915
查看次数

标签 统计

32bit-64bit ×1

access-denied ×1

winapi ×1