Page 1 sur 1

Gestionnaire des taches

Publié : lun. 22/nov./2010 17:46
par Parole De JOJO
est il possible de recreer le gestionnaire des taches de windows?
de connaitre la liste des exe qui tournent, leur temps processeur, leur cpu et l'adresse de l'exe?
et de le fermer directement?
en fait je me dis qu'avec les api windows on doit pouvoir tout faire alors si qquelqun sait quel api fait ca ca m'aiderais bcp

merci

Re: Gestionnaire des taches

Publié : lun. 22/nov./2010 20:45
par Backup
ya une Api genial sur le Forum , c'est le bouton "Rechercher" !!

si on lui fourni les parametres "process" , ou "taches" , ou "processus"

ça te retourne des liens vers le Graal !! ;)

si si !!

Re: Gestionnaire des taches

Publié : lun. 22/nov./2010 23:12
par Warkering
J'aime bien ton humour, Dobro! :lol:

Re: Gestionnaire des taches

Publié : mar. 23/nov./2010 17:06
par Parole De JOJO
moi aussi
lol

Re: Gestionnaire des taches

Publié : mar. 23/nov./2010 17:45
par Backup
...................

Re: Gestionnaire des taches

Publié : mar. 23/nov./2010 17:52
par Parole De JOJO
merci bcp dobro t'est un master

Re: Gestionnaire des taches

Publié : mar. 23/nov./2010 17:53
par Backup
non pas vraiment , ce code est de Fred

je suis surtout un collectionneur de codes
comme ça lorsque j'en ai besoin, je code en utilisant les morceaux de codes
glané ça et là :)

du codage en kit en sommes :)

je vais changer de pseudo , je vais prendre IKEA :)

Re: Gestionnaire des taches

Publié : mar. 23/nov./2010 17:57
par Parole De JOJO
moi aussi je fais ca
je kif ton humour...
tu m'as pas dit ce que tu pensais sur mon prog d'esspionnage

Re: Gestionnaire des taches

Publié : mar. 23/nov./2010 17:59
par Backup
désolé, j'ai pas eu le temps de tester :?

faudra que je prenne le temps
car là vois tu , je passe la serpillere chez moi !!
ici il neige , et on salis vite :)

Re: Gestionnaire des taches

Publié : mer. 24/nov./2010 17:11
par Parole De JOJO
le code est vraiment genial mais il ne me donne pas la location de l'exe

Re: Gestionnaire des taches

Publié : mer. 24/nov./2010 17:55
par Patrick88

Code : Tout sélectionner

; read the text contents of all (known) window classes (debug tool)
; ----------------------------------------------------
; known classes:
; --------------
; v syslistview32
; v systreeview32
; v static
; v button
; v combobox
; v listbox
; * ToolbarWindow32
; -

; structures
Structure window
   window.l
   title.s
   class.s
   parent.l
EndStructure

; globals
Global NewList win.window()
Global NewList win1.window()
Global parent.l

; read treeview
Procedure readsystreeview32(hTreeView)
    Define TVItem.TV_ITEM
    Buffer = AllocateMemory(100)
    GetWindowThreadProcessId_(hTreeView, @ProcID)   
    hProc = OpenProcess_(#PROCESS_VM_OPERATION | #PROCESS_VM_READ | #PROCESS_VM_WRITE, 0, ProcID)
    Result = VirtualAllocEx_(hProc, 0, SizeOf(TV_ITEM), #MEM_RESERVE | #MEM_COMMIT, #PAGE_READWRITE)
    TVItem\mask = #TVIF_TEXT | #TVIF_HANDLE
    TVItem\pszText = Result +400
    TVItem\cchTextMax = 100
    If hTreeView
      For i = 0 To SendMessage_(hTreeView, #TVM_GETCOUNT, 0, 0)-1
        hItem = SendMessage_(hTreeView, #TVM_GETNEXTITEM, #TVGN_ROOT, 0)
        For ii.l = 0 To i-1
          hItem2 = SendMessage_(hTreeView, #TVM_GETNEXTITEM, #TVGN_CHILD, hItem)
          Repeat
            If hItem2 = #Null : hItem2 = SendMessage_(hTreeView, #TVM_GETNEXTITEM, #TVGN_NEXT, hItem) : EndIf
            If hItem2 = #Null : hItem = SendMessage_(hTreeView, #TVM_GETNEXTITEM, #TVGN_PARENT, hItem) : EndIf
          Until hItem2 <> #Null
          hItem = hItem2
        Next ii
        TVItem\hItem = hItem
        WriteProcessMemory_(hProc, Result, @TVItem, SizeOf(TV_ITEM), 0)
        SendMessage_(hTreeView, #TVM_GETITEM, 0, Result)
        ReadProcessMemory_(hProc, Result +400, Buffer, MemorySize(Buffer), 0)
        Debug "("+Str(i)+")"+PeekS(Buffer)
      Next i
    EndIf
    VirtualFreeEx_(hProc, Result, 0, #MEM_RELEASE)
CloseHandle_(hProc)
EndProcedure

; read listview
Procedure readsyslistview32(listview)
    count=SendMessage_(listview, #LVM_GETITEMCOUNT, 0, 0);
    Debug("listview: " + Str(listview))
    Debug("Row count: " + Str(count))
    lvi.LVITEM
    *_lvi.LVITEM
    item.s=Space(512)
    subitem.s=Space(512)
    GetWindowThreadProcessId_(listview, @pid)
    process=OpenProcess_(#PROCESS_VM_OPERATION|#PROCESS_VM_READ|#PROCESS_VM_WRITE|#PROCESS_QUERY_INFORMATION, #False, pid)
    *_lvi=VirtualAllocEx_(process, #Null, SizeOf(LVITEM), #MEM_COMMIT, #PAGE_READWRITE)
    *_item=VirtualAllocEx_(process, #Null, 512, #MEM_COMMIT, #PAGE_READWRITE)
    *_subitem=VirtualAllocEx_(process, #Null, 512, #MEM_COMMIT, #PAGE_READWRITE)
    lvi\cchTextMax=512
    For i=0 To count-1
        lvi\iSubItem=0
        lvi\pszText=*_item
        WriteProcessMemory_(process, *_lvi, @lvi, SizeOf(LVITEM), #Null)
        SendMessage_(listview, #LVM_GETITEMTEXT, i, *_lvi)
        lvi\iSubItem=1
        lvi\pszText=*_subitem
        WriteProcessMemory_(process, *_lvi, @lvi, SizeOf(LVITEM), #Null)
        SendMessage_(listview, #LVM_GETITEMTEXT, i, *_lvi)
        ReadProcessMemory_(process, *_item, item, 512, #Null)
        ReadProcessMemory_(process, *_subitem, subitem, 512, #Null)
        Debug("Row: " + Str(i))
        Debug("Item: " + item)
        Debug("Subitem: " + subitem)
    Next
    VirtualFreeEx_(process, *_lvi, 0, #MEM_RELEASE)
    VirtualFreeEx_(process, *_item, 0, #MEM_RELEASE)
    VirtualFreeEx_(process, *_subitem, 0, #MEM_RELEASE)
    CloseHandle_(process)
EndProcedure

;List top-level windows' children (called by ListWindows)...
Procedure ListChildWindows (window, parameter)
    mem = AllocateMemory (255)
    GetClassName_ (window, mem, 255)
    class$ = PeekS (mem)
    mem = ReAllocateMemory (mem, 255)
    GetWindowText_ (window, mem, 255)
    title$ = PeekS (mem)
    FreeMemory (mem)

    Debug Str(window)+" / "+title$+" / "+class$ +" / "+ Str(parent)
    
    AddElement(win())
    win()\window = window
    win()\title  = title$
    win()\class  = class$
    win()\parent = parent

    EnumChildWindows_ (window, @ListChildWindows (), parameter + 1)
    ProcedureReturn #True
EndProcedure

; List top-level windows...
Procedure ListWindows (window, parameter)
    mem = AllocateMemory (255)
    GetClassName_ (window, mem, 255)
    class$ = PeekS (mem)
    mem = ReAllocateMemory (mem, 255)
    GetWindowText_ (window, mem, 255)
    title$ = PeekS (mem)
    FreeMemory (mem)
    
    AddElement(win())
    win()\window = window
    win()\title  = title$
    win()\class  = class$
    win()\parent = 0
   
    parent=window
   
    EnumChildWindows_ (window, @ListChildWindows (), 1)
    ProcedureReturn #True
EndProcedure

; list all windows in listicongadget
Procedure listallwindows()
      EnumWindows_ (@ListWindows (), 0)
      ResetList(win())
      While NextElement(win())
         If Listsize(win1())=0
            AddElement(win1())
            win1()\title = win()\title
            win1()\class = win()\class
            win1()\window= win()\window
            win1()\parent= win()\parent
         Else
            dubbel=0
            ResetList(win1())
            While NextElement(win1())
               If win1()\window = win()\window
                  dubbel=1
                  DeleteElement(win())
                  LastElement(win1())
               EndIf
            Wend
            If dubbel=0
               AddElement(win1())
               win1()\title = win()\title
               win1()\class = win()\class
               win1()\window= win()\window
               win1()\parent= win()\parent     
            EndIf
         EndIf
      Wend
      ClearList(win1())
      
      ClearGadgetItems(0)
      ;ClearGadgetItemList(0)
      ResetList(win())
      While NextElement(win())       
         AddGadgetItem(0, -1, Chr(34)+win()\title+Chr(34)+Chr(10)+Chr(34)+win()\class+Chr(34)+Chr(10)+Str(win()\window)+Chr(10)+Str(win()\parent))
         ;If IsWindowVisible_(win()\window)
            If win()\parent=0
               SetGadgetItemColor(0, ListIndex(win()), #PB_Gadget_FrontColor, RGB(0,0,255))                   
            Else
               Select win()\class
                  Case "SysListView32", "SysTreeView32", "Static", "Button", "ComboBox", "ListBox", "ToolbarWindow32"
                     SetGadgetItemColor(0, ListIndex(win()), #PB_Gadget_FrontColor, RGB(0,255,0))         
                  Default
                     SetGadgetItemColor(0, ListIndex(win()), #PB_Gadget_FrontColor, RGB(255,0,0))         
               EndSelect
            EndIf
         ;Else     
         ;   SetGadgetItemColor(0, ListIndex(win()), #PB_Gadget_FrontColor, RGB(0,0,0)) ;Color [, Column])
         ;EndIf
      Wend
EndProcedure

Enumeration 0 
#g_list
#g_Refresh
#g_Draw
#g_Items
EndEnumeration

;{ main loop
If OpenWindow(0, 10, 10, 660, 560, "Windows", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
   ;If CreateGadgetList(WindowID(0))
      ListIconGadget(#g_list, 10, 10, 640, 500, "Title", 200, #PB_ListIcon_FullRowSelect)
      AddGadgetColumn(#g_list, 2, "Class", 200)
      AddGadgetColumn(#g_list, 3, "WindowID", 100)
      AddGadgetColumn(#g_list, 4, "ParentID", 100)
      ButtonGadget(#g_Refresh, 10, 510, 60, 20, "Refresh")
      ButtonGadget(#g_Draw, 70, 510, 60, 20, "Draw")
      ButtonGadget(#g_Items, 130,510, 60, 20, "Items")
      DisableGadget(#g_Draw, #True)
      DisableGadget(#g_Items, #True)
      listallwindows()
      Repeat
         wevent=WaitWindowEvent()
         If wevent=#PB_Event_Gadget
            Select EventGadget()
               Case #g_list
                  gad = GetGadgetState(0)
                  SelectElement(win(), gad)
                  If win()\parent=0
                      DisableGadget(2, #False)
                  Else
                      DisableGadget(2, #True)
                  EndIf
                  Select win()\class
                     Case "SysListView32", "Static", "Button", "ComboBox", "ListBox", "ToolbarWindow32"
                        DisableGadget(3, #False)
                     Case "SysTreeView32"
                        DisableGadget(3, #False)
                     Default
                        DisableGadget(3, #True) 
                  EndSelect                       
               Case #g_Refresh
                  listallwindows()
                  
               Case #g_Draw
                  gad = GetGadgetState(0)
                  SelectElement(win(), gad)
                  window = win()\window
                  title.s = win()\title
                  class.s = win()\class
                  GetWindowRect_(window, @r.Rect)
                  sx = r\left
                  sy = r\top
                  width = r\right-r\left
                  height= r\bottom-r\top                 
                  dc = GetWindowDC_(win()\window)
                  If CreateImage(0, width, height, 32)
                     StartDrawing(ImageOutput(0))
                        col1 = GetBkColor_(dc)
                        Box(0, 0, width, height, col1)
                        While NextElement(win())
                           If win()\parent = window
                              GetWindowRect_(win()\window, @r.Rect)
                              dc = GetWindowDC_(win()\window)
                              col = GetBkColor_(dc)
                              Box(r\left-sx, r\top-sy, r\right-r\left, r\bottom-r\top, RGB(0,0,0))
                              Box(r\left-sx+1, r\top-sy+1, r\right-r\left-2, r\bottom-r\top-2, col)
                              If Len(win()\class)
                                 DrawText((r\left-sx)+((r\right-r\left)/2)-(TextWidth(win()\class)/2), (r\top-sy)+((r\bottom-r\top)/2)-(TextHeight(win()\class)/2), win()\class)
                              EndIf
                           Else
                              LastElement(win())
                           EndIf
                        Wend
                     StopDrawing()
                     wi.Windowinfo
                     GetWindowInfo_(window, @wi)
                     If OpenWindow(1, sy, sx, width, height, "", #PB_Window_BorderLess|#PB_Window_ScreenCentered)                       
                        ;SetWindowLong_(WindowID(1), #GWL_STYLE, wi\dwstyle)
                        ;SetWindowPos_(WindowID(1), #HWND_TOPMOST, sx, sy, WindowWidth(1), WindowHeight(1), #SWP_FRAMECHANGED) ;                       
                        StartDrawing(WindowOutput(1))
                           DrawImage(ImageID(0), 0, 0)
                        StopDrawing()
                        Repeat                       
                           wevent=WaitWindowEvent()
                        Until wevent=#PB_Event_CloseWindow
                        wevent=0
                        CloseWindow(1)
                     EndIf
                  EndIf
               Case #g_Items
                  gad = GetGadgetState(0)
                  SelectElement(win(), gad)
                  Select win()\class
                     
                     Case "SysListView32"
                        readsyslistview32(win()\window)                       
                     
                     Case "SysTreeView32"
                        readsystreeview32(win()\window)
                     
                     Case "Button", "Static"
                        mem = AllocateMemory (255)
                        GetClassName_ (win()\window, mem, 255)
                        Debug PeekS(mem)
                        mem = ReAllocateMemory (mem, 255)
                        GetWindowText_ (win()\window, mem, 255)
                        Debug PeekS(mem)
                        FreeMemory (mem)
                       
                     Case "ComboBox"
                        items = SendMessage_(win()\window, #CB_GETCOUNT, 0, 0)
                        If items
                           For a = 0 To items-1
                              len = SendMessage_(win()\window, #CB_GETLBTEXTLEN, a, 0)
                              str$ = Space(len+1)
                              SendMessage_(win()\window, #CB_GETLBTEXT, a, @str$)
                              Debug str$
                           Next
                        EndIf
                       
                     Case "ListBox"
                        items = SendMessage_(win()\window, #LB_GETCOUNT, 0, 0)
                        If items
                           For a = 0 To items-1
                              len = SendMessage_(win()\window, #LB_GETTEXTLEN, a, 0)
                              str$ = Space(len+1)
                              SendMessage_(win()\window, #LB_GETTEXT, a, @str$)
                              Debug str$
                           Next
                        EndIf 
                                           
                     Case "ToolbarWindow32"
                        items = SendMessage_(win()\window, #TB_BUTTONCOUNT, 0, 0)
                        If items

                        EndIf
                                             
                     Default
                  EndSelect               
            EndSelect
         EndIf
      Until wevent=#PB_Event_CloseWindow
   ;EndIf
EndIf
;}

;{ The end
End
;} 

Re: Gestionnaire des taches

Publié : mer. 24/nov./2010 17:57
par Patrick88
Récupère chemin+nom d'exécutable à partir du handle

à mixer avec le code de Dobro

Code : Tout sélectionner

;; auteur : dlolo
;; purebasic forum french : http://www.purebasic.fr/french/viewtopic.php?t=3622&start=0&postdays=0&postorder=asc&highlight=list+process

#PROCESS_ALL_ACCESS=$01F0FFF
#MAX_PATH=$0104

Procedure.s GetExePath(hWnd.l)
  pid.l=0
  GetWindowThreadProcessId_( hWnd, @pid )
  hProcess.l = OpenProcess_( #PROCESS_ALL_ACCESS, 0, pid );
  Name.s=Space(256)
 
  If OpenLibrary(0,"PSAPI.DLL")
    *F=GetFunction(0,"GetModuleFileNameExA")
    If *F
      CallFunctionFast(*F,hProcess,0,@Name,#MAX_PATH )
    Else
      Debug "Fonction non trouvé"
      CloseLibrary(0)
      End
    EndIf
  Else
    Debug "Library non ouverte"
    End
  EndIf
  ProcedureReturn Name
EndProcedure

Procedure FindWindowExeName()
 
  hWnd.l = FindWindow_( 0, 0 )
 
  While hWnd <> 0
    If GetWindowLong_(hWnd, #GWL_STYLE) & #WS_VISIBLE = #WS_VISIBLE
      If GetWindowLong_(hWnd, #GWL_EXSTYLE) & #WS_EX_TOOLWINDOW <> #WS_EX_TOOLWINDOW
        txt.s = Space(256)
        GetWindowText_(hWnd,@txt,256)
       
        If txt <> ""
         
          Debug txt +" - " + GetExePath(hWnd)
         
        EndIf
      EndIf
    EndIf
    hWnd = GetWindow_(hWnd, #GW_HWNDNEXT)
  Wend
EndProcedure

FindWindowExeName() 

Re: Gestionnaire des taches

Publié : dim. 28/nov./2010 17:07
par Parole De JOJO
merci beaucoup