IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

x86 32-bits / 64-bits Assembleur Discussion :

Questions sur ListeView (Icon & colors)


Sujet :

x86 32-bits / 64-bits Assembleur

  1. #1
    Candidat au Club
    Inscrit en
    Novembre 2009
    Messages
    11
    Détails du profil
    Informations forums :
    Inscription : Novembre 2009
    Messages : 11
    Points : 4
    Points
    4
    Par défaut Questions sur ListeView (Icon & colors)
    Salut tout le monde

    je débute en ASM et je viens d'écrire ce petit programme

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    .386
    .model flat,stdcall
    option casemap:none
     
    include windows.inc
    include kernel32.inc
    include user32.inc
    include comctl32.inc
     
     
     
    includelib kernel32.lib
    includelib user32.lib
    includelib comctl32.lib
     
     
     
     
     
     
    DlgProc proto :DWORD,:DWORD,:DWORD,:DWORD
    InsertColumn proto
    scan proto
     
     
    .data
     
    Colm db "Process Name",0
     
    .data?
    hSnapshot dd ?
    hInstance HINSTANCE ?
    TProcess  PROCESSENTRY32 <>
    hList   dd ?
     
    .const 
     
    ListView equ 1011
     
    .code
    start:
    invoke GetModuleHandle,NULL
    mov hInstance,eax
    invoke DialogBoxParam,hInstance,1001,NULL,addr DlgProc,NULL
    invoke InitCommonControls
    invoke ExitProcess,eax
     
     
    DlgProc proc hWnd:HWND,uMsg:UINT,wParam:WPARAM, lParam:LPARAM
     
     
     
      .if  uMsg== WM_INITDIALOG
       invoke GetDlgItem,hWnd,1011
       mov hList,eax
     
        invoke InsertColumn
        invoke scan
     
     
        .elseif uMsg == WM_CLOSE
             invoke EndDialog,hWnd,0
             .endif
               xor eax,eax
                 ret
     
    DlgProc endp
     
    InsertColumn proc
     LOCAL lvc:LV_COLUMN
     
     
     
        invoke SendMessage,hList,LVM_DELETEALLITEMS,NULL,NULL
    	invoke SendMessage,hList,LVM_GETEXTENDEDLISTVIEWSTYLE,NULL,NULL
    	or eax,LVS_EX_FULLROWSELECT or LVS_EX_GRIDLINES or LVS_EX_FLATSB
    	invoke SendMessage,hList,LVM_SETEXTENDEDLISTVIEWSTYLE,NULL,eax
    mov lvc.imask,LVCF_TEXT+LVCF_WIDTH
      mov lvc.pszText,offset Colm
      mov lvc.lx,150
      invoke SendMessage,hList,LVM_INSERTCOLUMN,0, addr lvc
     
     
    	Ret
    InsertColumn endp
     
    scan proc
     
    LOCAL LVI:LV_ITEM
     
     
     
    invoke SendMessage,hList,LVM_DELETEALLITEMS,0,0
    mov LVI.iItem,0
    mov LVI.imask,LVIF_TEXT
    invoke CreateToolhelp32Snapshot,TH32CS_SNAPPROCESS,0
    mov hSnapshot,eax
    mov TProcess.dwSize,SIZEOF TProcess
    invoke Process32First,hSnapshot,addr TProcess
     
    nextprocess:
     
    mov LVI.iSubItem,0
    invoke Process32Next,hSnapshot,addr TProcess
     
    cmp eax,0
    jz exit
     
     
    mov LVI.pszText,offset TProcess.szExeFile
    invoke SendMessage,hList,LVM_INSERTITEM,NULL,addr LVI
    inc LVI.iItem
     
    jmp nextprocess
    exit:
    	Ret
    scan endp
     
    end start
    c'est juste un programme qui obtient les processus , j'aimerai savoir la methode pour obtenir l'icone de chaque processus et la metre dans la liste view a coté du nom du processus

    autre question : comment je peux coloriser les lignes sur une liste view
    par exemple ( ligne blanche , ligne bleu , blanche bleu blanche bleu .... )

    Merci d'avance

  2. #2
    Noteworthy
    Invité(e)
    Par défaut
    Salut Pr2009,

    Pour obtenir l'icône de chaque processus et le mettre dans la ListView, tu peux peux utiliser la fonction ImageList_Create () comme suit:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    	invoke	ImageList_Create, 16, 16, ILC_COLOR16 or ILC_MASK, 19,0
    	mov	hImageList, eax
    	invoke	LoadBitmap, hInstance, IDB_BITMAP1
    	push	eax
    	invoke	ImageList_AddMasked, hImageList, eax, iBmpMaskColor
    	call	DeleteObject
    Sinon, check cette source, tu trouvera sûrement ton besoin, après, tu extrapoles la partie qui t'interesse le plus puis tu développes

    Noteworthy.
    Fichiers attachés Fichiers attachés

  3. #3
    Candidat au Club
    Inscrit en
    Novembre 2009
    Messages
    11
    Détails du profil
    Informations forums :
    Inscription : Novembre 2009
    Messages : 11
    Points : 4
    Points
    4
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    invoke	ImageList_Create, 16, 16, ILC_COLOR16 or ILC_MASK, 19,0
    	mov	hImageList, eax
    	invoke	LoadBitmap, hInstance, IDB_BITMAP1
    	push	eax
    	invoke	ImageList_AddMasked, hImageList, eax, iBmpMaskColor
    Jusqu'à la c'est compris
    mais quelle est la relation entre ce code et la listeview ?
    comment je peux obtenir l image d'un procesus et la envoyer au listeview
    c'est cela que je cherche

    j'ai deja le source de EzProcess mais j'ai pas encore compris la methode

  4. #4
    Rédacteur
    Avatar de Neitsa
    Homme Profil pro
    Chercheur sécurité informatique
    Inscrit en
    Octobre 2003
    Messages
    1 041
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Chercheur sécurité informatique

    Informations forums :
    Inscription : Octobre 2003
    Messages : 1 041
    Points : 1 956
    Points
    1 956
    Par défaut
    Bonjour,

    Citation Envoyé par Pr2009 Voir le message
    comment je peux obtenir l image d'un procesus et la envoyer au listeview
    c'est cela que je cherche

    j'ai deja le source de EzProcess mais j'ai pas encore compris la methode
    Pour l'extraction d'icône d'un exécutable ou d'une DLL, tout tourne autour de la fonction ExtractIcon(Ex):

    http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx

  5. #5
    Candidat au Club
    Inscrit en
    Novembre 2009
    Messages
    11
    Détails du profil
    Informations forums :
    Inscription : Novembre 2009
    Messages : 11
    Points : 4
    Points
    4
    Par défaut
    voila mon code :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    .386
    .model flat,stdcall
    option casemap:none
     
    include windows.inc
    include kernel32.inc
    include user32.inc
    include shell32.inc
     
     
    includelib shell32.lib
    includelib kernel32.lib
    includelib user32.lib
     
     
     
     
     
     
    DlgProc proto :DWORD,:DWORD,:DWORD,:DWORD
    InsertColumn proto
    scan proto
    GetProcessFileName	Proto	dProcessID:DWORD
     
     
    .data
     
    Colm db "Process Name",0
     
    .data?
    hSnapshot dd ?
    hInstance HINSTANCE ?
    TProcess  PROCESSENTRY32 <>
    hList   dd ?
    himage  dd ?
     
    .const 
    IDC_STATUSBAR1012 equ 1012
    ListView equ 1011
    IDC_TOOLBAR1014 equ 1014
    .code
    start:
    invoke GetModuleHandle,NULL
    mov hInstance,eax
    invoke DialogBoxParam,hInstance,1001,NULL,addr DlgProc,NULL
    invoke InitCommonControls
    invoke ExitProcess,eax
     
     
    DlgProc proc hWnd:HWND,uMsg:UINT,wParam:WPARAM, lParam:LPARAM
     
     
     
      .if  uMsg== WM_INITDIALOG
       invoke GetDlgItem,hWnd,1011
       mov hList,eax
     
        invoke InsertColumn
        invoke scan
     
     
        .elseif uMsg == WM_CLOSE
             invoke EndDialog,hWnd,0
             .endif
               xor eax,eax
                 ret
     
    DlgProc endp
     
    InsertColumn proc
     LOCAL lvc:LV_COLUMN
     
     
     
        invoke SendMessage,hList,LVM_DELETEALLITEMS,NULL,NULL
    	invoke SendMessage,hList,LVM_GETEXTENDEDLISTVIEWSTYLE,NULL,NULL
    	or eax,LVS_EX_FULLROWSELECT or LVS_EX_GRIDLINES or LVS_EX_FLATSB
    	invoke SendMessage,hList,LVM_SETEXTENDEDLISTVIEWSTYLE,NULL,eax
    mov lvc.imask,LVCF_TEXT+LVCF_WIDTH
      mov lvc.pszText,offset Colm
      mov lvc.lx,150
      invoke SendMessage,hList,LVM_INSERTCOLUMN,0, addr lvc
     
     
    	Ret
    InsertColumn endp
     
    scan proc
     
    LOCAL LVI:LV_ITEM
     
     
     
    invoke SendMessage,hList,LVM_DELETEALLITEMS,0,0
    mov LVI.iItem,0
    mov LVI.imask,LVIF_TEXT
    invoke CreateToolhelp32Snapshot,TH32CS_SNAPPROCESS,0
    mov hSnapshot,eax
    mov TProcess.dwSize,SIZEOF TProcess
    invoke Process32First,hSnapshot,addr TProcess
     
    nextprocess:
     
    mov LVI.iSubItem,0
    invoke Process32Next,hSnapshot,addr TProcess
     
     
    cmp eax,0
    jz exit
     
     
    invoke ExtractIcon,hInstance,offset TProcess.szExeFile,0
    mov himage,eax
     
    mov LVI.pszText,offset TProcess.szExeFile
    invoke SendMessage,hList,LVM_INSERTITEM,NULL,addr LVI
    inc LVI.iItem
     
     
     
    jmp nextprocess
    exit:
    	Ret
    scan endp
     
     
     
    end start

    c'est juste comme ça ?

    je fais quoi maintenant pour envoyer cette image au listeview ?

    -----------

    juste une remarque après un déboguage du programme

    par fois le retour du fonction ExtractIcon et un handle mais la plupart du fois et 0




  6. #6
    Rédacteur
    Avatar de Neitsa
    Homme Profil pro
    Chercheur sécurité informatique
    Inscrit en
    Octobre 2003
    Messages
    1 041
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Chercheur sécurité informatique

    Informations forums :
    Inscription : Octobre 2003
    Messages : 1 041
    Points : 1 956
    Points
    1 956
    Par défaut
    Bonjour,

    par fois le retour du fonction ExtractIcon et un handle mais la plupart du fois et 0
    La documentation est claire sur ce point (cf. "Return Value"):

    Return Value

    The return value is a handle to an icon. If the file specified was not an executable file, DLL, or icon file, the return is 1. If no icons were found in the file, the return value is NULL.
    La valeur de retour est 0 si le programme ne contient aucune icône. Il faut gérer ce cas dans ton programme.

    D'ailleurs tu devrais tester tous les retours de fonctions, si jamais une fonction ne fonctionne pas, c'est le programme entier qui va tomber...

    Pour passer les icônes à ta listview c'est un peu plus compliqué:

    - 1) Créer une ImageList via ImageList_Create

    N.B: Tu peux aussi en créer deux, une pour les icônes de grandes tailles et une autre pour les petites icônes par exemple.

    - 2) ExtractIcon

    - 3) Ajout de l'icône retournée en 2) via ImageList_ReplaceIcon

    - 4) Relâche le handle via DestroyIcon

    - 5) Attache l'ImageList à la listview via LVM_SETIMAGELIST

    - 6) Associe l'image via lvi.iImage (membre de la listview)

    Pas testé mais ça devrait être qque chose comme ça.

  7. #7
    Candidat au Club
    Inscrit en
    Novembre 2009
    Messages
    11
    Détails du profil
    Informations forums :
    Inscription : Novembre 2009
    Messages : 11
    Points : 4
    Points
    4
    Par défaut
    Merci "Neitsa" pour l'explication des étapes , je vais essayé

  8. #8
    Candidat au Club
    Inscrit en
    Novembre 2009
    Messages
    11
    Détails du profil
    Informations forums :
    Inscription : Novembre 2009
    Messages : 11
    Points : 4
    Points
    4
    Par défaut
    bon voila j'ai essayé d'écrire un code correcte

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    .386
    .model flat,stdcall
    option casemap:none
     
    include windows.inc
    include kernel32.inc
    include user32.inc
     
    include shell32.inc
     
    includelib shell32.lib
    includelib kernel32.lib
    includelib user32.lib
     
     
     
     
     
     
    DlgProc proto :DWORD,:DWORD,:DWORD,:DWORD
    InsertColumn proto
    scan proto
    GetProcessFileName	Proto	dProcessID:DWORD
     
     
    .data
     
    Colm db "Process Name",0
     
    .data?
    hSnapshot dd ?
    hInstance HINSTANCE ?
    TProcess  PROCESSENTRY32 <>
    hList   dd ?
    hImageList  dd ?
    himage   dd ?
     
    .const 
    IDC_STATUSBAR1012 equ 1012
    ListView equ 1011
    IDC_TOOLBAR1014 equ 1014
    .code
    start:
    invoke GetModuleHandle,NULL
    mov hInstance,eax
    invoke DialogBoxParam,hInstance,1001,NULL,addr DlgProc,NULL
    invoke InitCommonControls
    invoke ExitProcess,eax
     
     
    DlgProc proc hWnd:HWND,uMsg:UINT,wParam:WPARAM, lParam:LPARAM
     
     
     
      .if  uMsg== WM_INITDIALOG
       invoke GetDlgItem,hWnd,1011
       mov hList,eax
     
        invoke InsertColumn
        invoke scan
     
     
     
     
     
     
        .elseif uMsg == WM_CLOSE
             invoke EndDialog,hWnd,0
             .endif
               xor eax,eax
                 ret
     
    DlgProc endp
     
    InsertColumn proc
     LOCAL lvc:LV_COLUMN
     
     
     
        invoke SendMessage,hList,LVM_DELETEALLITEMS,NULL,NULL
    	invoke SendMessage,hList,LVM_GETEXTENDEDLISTVIEWSTYLE,NULL,NULL
    	or eax,LVS_EX_FULLROWSELECT or LVS_EX_GRIDLINES or LVS_EX_FLATSB
    	invoke SendMessage,hList,LVM_SETEXTENDEDLISTVIEWSTYLE,NULL,eax
    mov lvc.imask,LVCF_TEXT+LVCF_WIDTH
      mov lvc.pszText,offset Colm
      mov lvc.lx,150
      invoke SendMessage,hList,LVM_INSERTCOLUMN,0, addr lvc
     
     
    	Ret
    InsertColumn endp
     
    scan proc
     
    LOCAL LVI:LV_ITEM
     
     
     
    invoke SendMessage,hList,LVM_DELETEALLITEMS,0,0
    mov LVI.iItem,0
    mov LVI.imask,LVIF_TEXT
    invoke CreateToolhelp32Snapshot,TH32CS_SNAPPROCESS,0
    mov hSnapshot,eax
    mov TProcess.dwSize,SIZEOF TProcess
    invoke Process32First,hSnapshot,addr TProcess
     
    nextprocess:
     
    mov LVI.iSubItem,0
    invoke Process32Next,hSnapshot,addr TProcess
     
     
    cmp eax,0
    jz exit
     
    ;------------------------------------------------------------------
     
    invoke ImageList_Create,16,16,ILC_COLOR16,1,0
        mov hImageList, eax
     
    invoke ExtractIcon,hInstance,offset TProcess.szExeFile,0
    mov himage,eax
     
    invoke ImageList_Replace,hImageList,0,himage,NULL
     
    invoke DestroyIcon,himage
     
    mov LVI.iImage,0
     
    invoke SendMessage,hList,LVM_SETIMAGELIST,NULL,addr LVI
     
    ;------------------------------------------------------------------
     
    mov LVI.pszText,offset TProcess.szExeFile
    invoke SendMessage,hList,LVM_INSERTITEM,NULL,addr LVI
    inc LVI.iItem
     
     
     
    jmp nextprocess
    exit:
    	Ret
    scan endp
     
     
     
    end start

    pas de fautes en compilation mais il marche pas

  9. #9
    Futur Membre du Club
    Profil pro
    Inscrit en
    Mars 2009
    Messages
    10
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2009
    Messages : 10
    Points : 8
    Points
    8
    Par défaut
    Salut,

    Il y a aussi cette methode:

    1 : CreateToolhelp32Snapshot
    2 : Module32First
    3 : ExtractAssociatedIcon

    (Seul soucis, affiche le premier Icon du prog trouvé... Pas forcement celui de la fenetre principal du process)

    Exemple ici :
    http://nooptax.free.fr/ProcessKiller_v1.exe

    NoopTax

  10. #10
    Candidat au Club
    Inscrit en
    Novembre 2009
    Messages
    11
    Détails du profil
    Informations forums :
    Inscription : Novembre 2009
    Messages : 11
    Points : 4
    Points
    4
    Par défaut
    le lien ne marche pas
    peux tu me donner le code source s'il vous plaît

  11. #11
    Candidat au Club
    Inscrit en
    Novembre 2009
    Messages
    11
    Détails du profil
    Informations forums :
    Inscription : Novembre 2009
    Messages : 11
    Points : 4
    Points
    4
    Par défaut
    J'ai reussi a créer une image liste dans la listeview



    mais comment faire pour extraire les icônes ?

  12. #12
    Futur Membre du Club
    Profil pro
    Inscrit en
    Mars 2009
    Messages
    10
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2009
    Messages : 10
    Points : 8
    Points
    8
    Par défaut
    Citation Envoyé par Pr2009 Voir le message
    Y a pas de réponse ????????
    Salut,

    Je viens de tester le lien que je t'ai donné, il marche !

    Sinon, ton code est bon, tu a juste à ajouter ca pour afficher les icons

    push OFFSET IconIndex ---> En general tu laisse sur 0 (offset 0)
    push OFFSET moduleszExePath ---> Adresse du Path+nom de l'exe
    push hInstance ---> Hinstance du prog
    call ExtractAssociatedIconA ---> Api Windows pour recuperer l'Icon d'un Exe

  13. #13
    Candidat au Club
    Inscrit en
    Novembre 2009
    Messages
    11
    Détails du profil
    Informations forums :
    Inscription : Novembre 2009
    Messages : 11
    Points : 4
    Points
    4
    Par défaut
    peux tu me donner le code source ????

    s'il vous plaît

  14. #14
    Candidat au Club
    Inscrit en
    Novembre 2009
    Messages
    11
    Détails du profil
    Informations forums :
    Inscription : Novembre 2009
    Messages : 11
    Points : 4
    Points
    4
    Par défaut
    17 jours est passé , et j'ai pas encore trouvé la bonne réponse

Discussions similaires

  1. Question sur algorithme et icone exe
    Par kqesar dans le forum Qt
    Réponses: 4
    Dernier message: 17/06/2010, 13h08
  2. [Delphi 7] Question sur déplacement fichier sur icone..
    Par shell13010 dans le forum Langage
    Réponses: 5
    Dernier message: 14/07/2009, 17h52
  3. [C#] Question sur icones
    Par nesquik dans le forum Windows Forms
    Réponses: 1
    Dernier message: 12/06/2006, 11h55
  4. Quelqu'un a-t-il une Epson Stylus Color 880? (Question sur l'encre)
    Par annedeblois dans le forum Périphériques
    Réponses: 6
    Dernier message: 03/05/2006, 13h53
  5. Question sur les ICONES
    Par nicordi dans le forum Autres Logiciels
    Réponses: 17
    Dernier message: 19/10/2005, 11h11

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo