begin process at 2008 09 06 19:00:42
1 237 892 membres
276 nouveaux aujourd'hui
14 314 membres club

Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum.
Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !

TYPE DE LECTEUR EN ASM INLINE VC++


Information sur la source

Catégorie :API Niveau : Expert Date de création : 24/01/2003 Date de mise à jour : 24/01/2003 19:56:51 Vu / téléchargé: 1 751 / 124

Note :
10 / 10 - par 1 personne
10,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10

Commentaire sur cette source (0)
Ajouter un commentaire et/ou une note


Description

Des radioButtons remplissent une Combo avec liste des lecteurs correspondants. Le prog est en C qui appelle le remplissage en asm.
LectLogic.cpp dans le zip contient la version remplissage en C mais invalidée.
Tous les fichiers pour recompiler sont dans le zip.

Source

  • LectLogic.cpp
  • #include <windows.h>
  • #include "resource.h"
  • #include "CmbDrvs.h"
  • BOOL CALLBACK AppDlgProc(HWND hdlg, UINT mssg, WPARAM wParam, LPARAM lParam)
  • {
  • switch(mssg) {
  • case WM_INITDIALOG:
  • SetClassLong(hdlg, GCL_HICON, (long)LoadIcon(0, IDI_APPLICATION));
  • SendDlgItemMessage(hdlg, IDRAD_FLOP, BM_SETCHECK, 1, 0);
  • PostMessage(hdlg, WM_COMMAND, IDRAD_FLOP, 0);
  • return 1;
  • case WM_COMMAND:
  • switch(wParam) {
  • TYPEDRV tpdrv;
  • case IDRAD_FLOP:
  • tpdrv = LECT_DSKT; goto drvchng;
  • case IDRAD_FIX:
  • tpdrv = LECT_DDUR; goto drvchng;
  • case IDRAD_CD:
  • tpdrv = LECT_CD; goto drvchng;
  • case IDRAD_FLOP_CD:
  • tpdrv = LECT_DSKT_CD; goto drvchng;
  • case IDRAD_FLOP_FIX:
  • tpdrv = LECT_DSKT_DDUR; goto drvchng;
  • case IDRAD_FIX_CD:
  • tpdrv = LECT_DDUR_CD; goto drvchng;
  • case IDRAD_TOUS:
  • tpdrv = LECT_TOUS;
  • drvchng:
  • FillCmbDrives(GetDlgItem(hdlg, IDCMB_DRV), tpdrv);
  • return 0;
  • case IDCANCEL: EndDialog(hdlg, 0);
  • }
  • }
  • return 0;
  • }
  • int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, PSTR, int)
  • {
  • DialogBox(hInstance, MAKEINTRESOURCE(IDD_APP), NULL, AppDlgProc);
  • return 0;
  • }
  • -----------------------------------------------------
  • CmbDrvs.cpp
  • #include "CmbDrvs.h"
  • __declspec(naked) void __stdcall FillCmbDrives(HWND hcmb, TYPEDRV typLect)
  • {
  • __asm {
  • lea eax, [esp-36] ; [esp-20]
  • mov [esp-12], esi
  • mov [esp-4], ebp
  • mov [esp-16], edi
  • mov [eax+28], ebx
  • xor ecx, ecx
  • mov dword ptr[eax+16], 5C3A00h ; "\0:\\0"
  • mov esi, [eax+44] ; ESI = typLect
  • mov ebp, [eax+40] ; EBP = hcmb
  • mov esp, eax ; + 4 params de SendMessage
  • mov [eax+12], ecx
  • mov [eax+8], ecx
  • mov dword ptr[eax+4], 14Bh ; CB_RESETCONTENT
  • mov [eax], ebp
  • call dword ptr GetLogicalDrives
  • mov edi, eax ; EDI = dwdrvs
  • call dword ptr SendMessage ; ESP += 16
  • mov ebx, 65
  • goDrvs:
  • shr edi, 1
  • jc short insDrv
  • jz short drvsEnd
  • jmp short nextDrv
  • insDrv:
  • mov byte ptr[esp], bl
  • or esi, esi
  • jz short drvOK
  • push esp
  • call dword ptr GetDriveType
  • test esi, 0F00h
  • jz short typUnic
  • mov ecx, esi
  • mov edx, esi
  • cmp ch, al
  • je short drvOK
  • cmp dl, al
  • je short drvOK
  • jmp short nextDrv
  • typUnic:
  • cmp eax, esi
  • jne short nextDrv
  • drvOK:
  • push esp
  • push 0
  • push 143h ; CB_ADDSTRING
  • push ebp
  • call dword ptr SendMessage
  • nextDrv:
  • inc ebx
  • jmp short goDrvs
  • drvsEnd:
  • lea eax, [esp+4]
  • mov [esp], ebp
  • mov edi, [eax]
  • mov esi, [eax+4]
  • mov ebx, [eax+8]
  • mov dword ptr[eax+8], 0
  • mov dword ptr[eax+4], 0
  • mov dword ptr[eax], 14Eh ; CB_SETCURSEL
  • call dword ptr SendMessage ; ESP += 16
  • pop ebp
  • ret 8
  • }
  • }
               LectLogic.cpp
#include <windows.h>
#include "resource.h"
#include "CmbDrvs.h"

BOOL CALLBACK AppDlgProc(HWND hdlg, UINT mssg, WPARAM wParam, LPARAM lParam)
{
  switch(mssg) {
    case WM_INITDIALOG:
      SetClassLong(hdlg, GCL_HICON, (long)LoadIcon(0, IDI_APPLICATION));
      SendDlgItemMessage(hdlg, IDRAD_FLOP, BM_SETCHECK, 1, 0);
      PostMessage(hdlg, WM_COMMAND, IDRAD_FLOP, 0);
      return 1;
    case WM_COMMAND:
      switch(wParam) {
        TYPEDRV tpdrv;
        case IDRAD_FLOP:
          tpdrv = LECT_DSKT; goto drvchng;
        case IDRAD_FIX:
          tpdrv = LECT_DDUR; goto drvchng;
        case IDRAD_CD:
          tpdrv = LECT_CD; goto drvchng;
        case IDRAD_FLOP_CD:
          tpdrv = LECT_DSKT_CD; goto drvchng;
        case IDRAD_FLOP_FIX:
          tpdrv = LECT_DSKT_DDUR; goto drvchng;
        case IDRAD_FIX_CD:
          tpdrv = LECT_DDUR_CD; goto drvchng;
        case IDRAD_TOUS:
          tpdrv = LECT_TOUS;
drvchng:
          FillCmbDrives(GetDlgItem(hdlg, IDCMB_DRV), tpdrv);
          return 0;
        case IDCANCEL: EndDialog(hdlg, 0);
      }
  }
  return 0;
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, PSTR, int)
{
  DialogBox(hInstance, MAKEINTRESOURCE(IDD_APP), NULL, AppDlgProc);
  return 0;
}
   -----------------------------------------------------
           CmbDrvs.cpp
#include "CmbDrvs.h"

__declspec(naked) void __stdcall FillCmbDrives(HWND hcmb, TYPEDRV typLect)
{
  __asm {
    lea     eax, [esp-36] ; [esp-20]
    mov     [esp-12], esi
    mov     [esp-4], ebp
    mov     [esp-16], edi
    mov     [eax+28], ebx
    xor     ecx, ecx
    mov     dword ptr[eax+16], 5C3A00h    ; "\0:\\0"
    mov     esi, [eax+44]              ; ESI = typLect
    mov     ebp, [eax+40]              ; EBP = hcmb
    mov     esp, eax                   ; + 4 params de SendMessage
    mov     [eax+12], ecx
    mov     [eax+8], ecx
    mov     dword ptr[eax+4], 14Bh      ; CB_RESETCONTENT
    mov     [eax], ebp
    call    dword ptr GetLogicalDrives
    mov     edi, eax                    ; EDI = dwdrvs
    call    dword ptr SendMessage ; ESP += 16
    mov     ebx, 65
goDrvs:
    shr     edi, 1
    jc      short insDrv
    jz      short drvsEnd
    jmp     short nextDrv
insDrv:
    mov     byte ptr[esp], bl
    or      esi, esi
    jz      short drvOK
    push    esp
    call    dword ptr GetDriveType
    test    esi, 0F00h
    jz      short typUnic
    mov     ecx, esi
    mov     edx, esi
    cmp     ch, al
    je      short drvOK
    cmp     dl, al
    je      short drvOK
    jmp     short nextDrv
typUnic:
    cmp     eax, esi
    jne     short nextDrv
drvOK:
    push    esp
    push    0
    push    143h                  ; CB_ADDSTRING
    push    ebp
    call    dword ptr SendMessage
nextDrv:
    inc     ebx
    jmp     short goDrvs
drvsEnd:
    lea     eax, [esp+4]
    mov     [esp], ebp
    mov     edi, [eax]
    mov     esi, [eax+4]
    mov     ebx, [eax+8]
    mov     dword ptr[eax+8], 0
    mov     dword ptr[eax+4], 0
    mov     dword ptr[eax], 14Eh        ; CB_SETCURSEL
    call    dword ptr SendMessage ; ESP += 16
    pop     ebp
    ret     8
  }
}

Conclusion

__declspec(naked) est mis devant la fonction asm pour dire au compilo qu'il n'y mette pas ses pattes. Ceci permet toute liberté sur manipulation des registres.
Pour les "Membres Club", vous pouvez télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !

Télécharger le zip

    Aucun commentaire pour le moment.

Ajouter un commentaire

Pub



Appels d'offres

CalendriCode

Septembre 2008
LMMJVSD
1234567
891011121314
15161718192021
22232425262728
2930     

Boutique

Boutique de goodies CodeS-SourceS