如何挂起另外一个进程或进程下一个线程呢?
SuspendThread过期了,如何挂起另外一个进程或进程下一个线程呢?
VB.NET 2010.
[解决办法]
求版主或达人指教~~
[解决办法]
求版主或达人指教~~
[解决办法]
[解决办法]
过期就是在VB.NET 2010里不能继续使用。我看MSDN里这么写的。
[解决办法]
我的理解是在.net中进程过期后系统会自动关闭并收回内存空间
[解决办法]
是挂起其他进程或线程,非自己的。
[解决办法]
如果你怕麻烦,过期的也可以用。
个人觉得要操作线程,都是用标识比较好,只是会麻烦些,视情况而定。
如
dim t as new thread(addressof a)
t.start
dim btag
sub t()
while true
...
while btag
thread.sleep(1)
end while
...
end while
end sub
sub b()
btag=true
end wub
sub c()
btag=false
end sub
最好写临界点
这机器上没装VS
[解决办法]
不好意思,没看清。
以为是自己的线程
[解决办法]
没看清,以为是自己的线程。
[解决办法]
注入到目标进程
然后获取线程句柄
然后TerminateThread()
[解决办法]
一定要注入吗?
[解决办法]
不用注入。下面是MSDN的例子
BOOL ListProcessThreads( DWORD dwOwnerPID )
{
HANDLE hThreadSnap = INVALID_HANDLE_VALUE;
THREADENTRY32 te32;
// Take a snapshot of all running threads
hThreadSnap = CreateToolhelp32Snapshot( TH32CS_SNAPTHREAD, 0 );
if( hThreadSnap == INVALID_HANDLE_VALUE )
return( FALSE );
// Fill in the size of the structure before using it.
te32.dwSize = sizeof(THREADENTRY32 );
// Retrieve information about the first thread,
// and exit if unsuccessful
if( !Thread32First( hThreadSnap, &te32 ) )
{
printError( "Thread32First" ); // Show cause of failure
CloseHandle( hThreadSnap ); // Must clean up the
// snapshot object!
return( FALSE );
}
// Now walk the thread list of the system,
// and display information about each thread
// associated with the specified process
do
{
if( te32.th32OwnerProcessID == dwOwnerPID )
{
//暂停线程
}
} while( Thread32Next(hThreadSnap, &te32 ) );
// Don't forget to clean up the snapshot object.
CloseHandle( hThreadSnap );
return( TRUE );
}
[解决办法]
最终用了ntsuspendprocess()函数一步搞定。