Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HANDLE h = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
- if (h != INVALID_HANDLE_VALUE)
- {
- THREADENTRY32 te;
- te.dwSize = sizeof(te);
- if (Thread32First(h, &te)) {
- do
- {
- if (te.dwSize >= FIELD_OFFSET(THREADENTRY32, th32OwnerProcessID) + sizeof(te.th32OwnerProcessID))
- {
- if( GetProcessId( GetCurrentProcess() ) == te.th32OwnerProcessID )
- SetThreadContext( OpenThread(THREAD_ALL_ACCESS, 0, te.th32ThreadID), &ctx);
- }
- te.dwSize = sizeof(te);
- }
- while (Thread32Next(h, &te));
- }
- CloseHandle(h);
- }
Add Comment
Please, Sign In to add comment