Results 1 to 1 of 1
  1. #1
    jaxBR
    jaxBR is offline
    New member jaxBR's Avatar
    Join Date
    2012 Jan
    Posts
    37
    Thanks
    33
    Thanked 35 Times in 15 Posts
    Rep Power
    0

    listing threads of a process

    Code:
    var
     hThreadSnap: THandle;
     te32: tagTHREADENTRY32;
    begin
     PID:=GetPID(MaskEdit1.Text);
    // Take a snapshot of all running threads
     hThreadSnap := CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
    if (hThreadSnap = INVALID_HANDLE_VALUE) then Exit;
    // Fill in the size of the structure before using it.
     te32.dwSize := SizeOf(THREADENTRY32);
    try
     if not Thread32First(hThreadSnap, te32) then Exit;
     if GetLastError = ERROR_NO_MORE_FILES then Exit;
    repeat
     if te32.th32OwnerProcessID = PID then // <<< Always 4
    begin
    ListBox.Items.Add(IntToHex(te32.th32ThreadID, 8));    //'Thread ID: 0x' +
    ListBox.Items.Add('base priority: ' + IntToStr(te32.tpBasePri));
    ListBox.Items.Add('delta priority: ' + IntToStr(te32.tpDeltaPri));
    ListBox.Items.Add(' ');
       end;
      until not Thread32Next(hThreadSnap, te32);
     finally
    CloseHandle(hThreadSnap);
    end;
    end;

    or

    Code:
    var
      hSnapshot     : THandle;
      NextThread    : Boolean;
      TThreadEntry  : TThreadEntry32;
      Result : Boolean;
    begin
      PID:=GetPID(MaskEdit1.Text);
       if PID<>0 then
      hSnapshot := CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0); //Takes a snapshot of the all threads
      Result := (hSnapshot <> INVALID_HANDLE_VALUE);
      if Result then
        try
          TThreadEntry.dwSize := SizeOf(TThreadEntry);
          NextThread := Thread32First(hSnapshot, TThreadEntry);//get the first Thread
          while NextThread do
          begin
            if TThreadEntry.th32OwnerProcessID = PID then //Check the owner Pid against the PID requested
             ListBox3.Items.Add(Format('Thread Id %.8x Start Address %p',[TThreadEntry.th32ThreadID, GetThreadStartAddress(TThreadEntry.th32ThreadID)]));
            NextThread := Thread32Next(hSnapshot, TThreadEntry);//get the Next Thread
          end;
        finally
          CloseHandle(hSnapshot);
        end;
    end;

Similar Threads

  1. Replies: 2
    Last Post: 2018-04-02, 04:48 PM
  2. [Info] Dragon Nest Useful Threads Index
    By Grooguz in forum Dragon Nest
    Replies: 1
    Last Post: 2016-02-04, 11:18 AM
  3. listing all processes
    By jaxBR in forum Delphi
    Replies: 2
    Last Post: 2013-12-26, 06:48 PM
  4. [Info] Warning on reactivating old threads
    By Summon in forum Aika Guides, Tutorials
    Replies: 3
    Last Post: 2012-09-16, 03:07 AM
  5. [Process, Services & Network] Process Hacker
    By wildspirit in forum Files & Tools
    Replies: 0
    Last Post: 2011-11-09, 05:00 AM
Visitors found this page by searching for:
Nobody landed on this page from a search engine, yet!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •