- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
您好,我试图挂起一个远程线程,但在途中我偶然发现 DuplicateHandle 失败并出现错误 6,ERROR_INVALID_HANDLE。
下面的方法适用于当前进程,但如果给出了像“calc”(在同一主机中)这样的远程进程,则 DuplicateHandle 会失败。
进程以 Admin priv 运行,SeDebugPriv 和 SeSecurityPriv 被授予(Process Explorer 确认),但没有用。任何的想法?`
bool DbgHelpWrapper::GetThreadStartAddress( IntPtr processHandle, DWORD processId, DWORD threadID, DWORD *dwStartAddress )
{
// Get ntdll entry points.
HMODULE ntDLLHandle = LoadLibrary(L"ntdll.dll");
tNtQueryInformationThread NtQueryInformationThread = (tNtQueryInformationThread)GetProcAddress(ntDLLHandle, "NtQueryInformationThread");
// Open thread with wrong access rights.
HANDLE hRemoteProcess = OpenProcess( PROCESS_ALL_ACCESS, FALSE, processId );
HANDLE hRemoteThread = OpenThread(THREAD_SUSPEND_RESUME, FALSE, threadID);
if (hRemoteThread != 0 && hRemoteProcess != 0 )
{
try
{
// Duplicate handle to get correct access rights.
HANDLE temporaryHandle = 0;
DWORD duplicateHandleResult = DuplicateHandle(hRemoteProcess, hRemoteThread, GetCurrentProcess(),
&temporaryHandle, THREAD_QUERY_INFORMATION, FALSE, 0 );
System::Console::WriteLine( String::Format("DuplicateHandle returned {0}", duplicateHandleResult ));
System::Console::WriteLine( String::Format("DuplicateHandle error {0}", Marshal::GetLastWin32Error()));
if (duplicateHandleResult != 0 )
{
try
{
NTSTATUS ntStatus = NtQueryInformationThread(temporaryHandle, ThreadQuerySetWin32StartAddress, dwStartAddress, sizeof(DWORD), NULL);
System::Console::WriteLine( String::Format("NtQueryInformationThread returned {0}", ntStatus ));
if (ntStatus == 0)
{
System::Console::WriteLine( String::Format("StartAddress: {0:X16}", *dwStartAddress ));
return true;
}
else
{
System::Console::WriteLine( String::Format("NtQueryInformationThread error {0}", Marshal::GetLastWin32Error()));
return false;
}
}
finally
{
CloseHandle(temporaryHandle);
}
}
else
{
System::Console::WriteLine( String::Format("Cannot duplicate the thread handle to THREAD_QUERY_INFORMATION rights"));
return false;
}
}
finally
{
// Cleanup
CloseHandle(hRemoteThread);
}
}
else
{
System::Console::WriteLine( String::Format("Cannot open the thread with THREAD_SUSPEND_RESUME rights"));
return FALSE;
}
}
`
最佳答案
您告诉 DuplicateHandle
hRemoteThread
是 hRemoteProcess
中的句柄,但它不是。它是您当前流程中的句柄 - 您之前几行打开了它。 (线程是远程进程的一部分,但它的句柄不是。)
关于c++ - 远程线程的 DuplicateHandle 失败,错误为 ERROR_INVALID_HANDLE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12234159/
为什么每次执行下面的代码时,SetThreadDesktop()失败并显示以下消息: ERROR_INVALID_HANDLE 新桌面创建成功,表示句柄打开了。 发生了什么事? program Pro
我正在尝试使用 DuplicateHandle 函数将句柄从 process1 传递到 process2。我使用 CreateFile 函数获取句柄: HANDLE COMportHandle; CO
我试图通过调用 WaitForSingleObject() 来确定一个进程是否仍然存在(在我检查的那一刻,我知道它可以在我检查后立即关闭)带句柄从Process.MainWindowHandle得到这
我是第一次尝试使用 CreateFileMapping,当我使用 GetLastError() 时出现此错误: ERROR_INVALID_HANDLE: The handle is invalid.
我正在ctypes中使用winsock2套接字,我可以很好地执行closesocket(),但是调用CloseHandle,总是会导致ERROR_INVALID_HANDLE (6)。我该如何正确关闭
我正在尝试实现一个系统,其中任意数量的进程将通过命名管道相互通信。 Windows 中的实现是在 C++ 中。但是,我被卡住了,因为进程似乎无法接收消息。我找不到类似的问题,如果已经有人问过,我深表歉
免责声明:这是程序要求的一部分,因此没有任何不良意义。如果您发现任何误用,请随时指出。我是 C++ 的初学者。 基本上,我正在尝试使用 C++ 在 Windows 上重新启动 Outlook.exe。
您好,我试图挂起一个远程线程,但在途中我偶然发现 DuplicateHandle 失败并出现错误 6,ERROR_INVALID_HANDLE。 下面的方法适用于当前进程,但如果给出了像“calc”(
我尝试在两个类之间共享一个 HPBUFFERARB:TGLForm 和 TGLForm2。(我试过 FBO,但我有一个旧的 Borland Builder 6 版本,我无法使用 FBO 进行管理) 我
我正在尝试获取引用特定 USB 设备的 Windows::Devices::Usb::UsbDevice 对象,以便将其传递给第 3 方插件。由于项目限制,我无法使用 C++/CX 扩展。 在查看了无
成功调用 CreateProcess 后,我尝试使用 GetModuleFileNameEx 获取创建的进程的路径(lpApplicationName 和 lpCommandLine 参数可以变化或为
我正在尝试 VirtualDisk API,到目前为止,我可以打开 VHDX 文件,并使用 GetVirtualDiskInformation 获取一些属性。但我无法获取 RCT 信息和 Change
我正在将二进制组件转换为 js-ctypes,而 StartPagePrinter 给了我 ERROR_INVALID_HANDLE。我正在使用标准 Windows 技术进行打印。 (搜索“MSDN
我正在创建一个 .NET Windows 服务来与智能卡读卡器通信。主要组件是一个名为 winscard.dll 的 Windows DLL,我在 .NET 代码中将其与 DLLImport 属性一起
我是一名优秀的程序员,十分优秀!