Guest User

Untitled

a guest
Jul 20th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. HANDLE h = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
  2. if (h != INVALID_HANDLE_VALUE)
  3. {
  4. THREADENTRY32 te;
  5. te.dwSize = sizeof(te);
  6. if (Thread32First(h, &te)) {
  7. do
  8. {
  9. if (te.dwSize >= FIELD_OFFSET(THREADENTRY32, th32OwnerProcessID) + sizeof(te.th32OwnerProcessID))
  10. {
  11. if( GetProcessId( GetCurrentProcess() ) == te.th32OwnerProcessID )
  12. SetThreadContext( OpenThread(THREAD_ALL_ACCESS, 0, te.th32ThreadID), &ctx);
  13. }
  14. te.dwSize = sizeof(te);
  15. }
  16. while (Thread32Next(h, &te));
  17. }
  18. CloseHandle(h);
  19. }
Add Comment
Please, Sign In to add comment