Pelles C forum

Assembly language => Assembly discussions => Topic started by: Vortex on October 28, 2025, 08:25:32 PM

Title: Masking passwords
Post by: Vortex on October 28, 2025, 08:25:32 PM
Here is a dialog box example with an edit control hiding the text in the client area. Exiting the application, a message box displays the text entered to the edit control.

include     HiddenPasswd.inc

IDC_EDIT    equ 4001
PWD_CHAR    equ 43 ; ASCII(*)=42
BUFF_SIZE   equ 64

.data

DlgBox db 'DLGBOX',0
capt   db 'Hidden text',0

.data?

hEdit  dd ?
buffer db BUFF_SIZE dup(?)

.code

start:

    invoke  GetModuleHandle,0
    xor     ecx,ecx
    invoke  DialogBoxParam,eax,\
            ADDR DlgBox,ecx,ADDR DlgProc,ecx
    invoke  ExitProcess,eax

DlgProc PROC hWnd:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD

    .IF uMsg==WM_INITDIALOG

        invoke  GetDlgItem,hWnd,IDC_EDIT
        mov     hEdit,eax
        invoke  SendMessage,eax,EM_SETPASSWORDCHAR,PWD_CHAR,0

    .ELSEIF uMsg==WM_CLOSE

        invoke  GetWindowText,hEdit,ADDR buffer,BUFF_SIZE
        xor     ecx,ecx
        invoke  MessageBox,ecx,ADDR buffer,ADDR capt,ecx
        invoke  EndDialog,hWnd,0

    .ELSE

        xor     eax,eax
        ret

    .ENDIF

    mov     eax,TRUE
    ret

DlgProc ENDP

END start