I am creating a login program that will input a username and password. my question is for example the valid username is user and password is pass. iF the user input a wrong username and password 3x the program will exit.Please correct me if my code is not right.

I am new to assembly programming please help me. Thanks in advance.
Sorry for my bad english.

Mhike


here is my code:

dialog.asm


; #########################################################################

.486
.model flat, stdcall
option casemap :none ; case sensitive

; #########################################################################

include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc

includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib

; #########################################################################

;=============
; Local macros
;=============

szText MACRO Name, Text:VARARG
LOCAL lbl
jmp lbl
Name db Text,0
lbl:
ENDM

szDlgName MACRO Name, Text:VARARG
LOCAL lbl
jmp lbl
Name db Text,0
lbl:
ENDM

FUNC MACRO parameters:VARARG
invoke parameters
EXITM <eax>
ENDM

; ---------------------
; literal string MACRO
; ---------------------
literal MACRO quoted_text:VARARG
LOCAL local_text
.data
local_text db quoted_text,0
.code
EXITM <local_text>
ENDM
; --------------------------------
; string address in INVOKE format
; --------------------------------
SADD MACRO quoted_text:VARARG
EXITM <ADDR literal(quoted_text)>
ENDM

;=================
; Local prototypes
;=================

DlgProc proto :DWORD,:DWORD,:DWORD,:DWORD


.data?
hInstance HINSTANCE ?
CommandLine LPSTR ?
buffer db 512 dup (?)

.code

start:

; #########################################################################

invoke GetModuleHandle, NULL
mov hInstance, eax

; -------------------------------------------
; Call the dialog box stored in resource file
; -------------------------------------------
szDlgName DlgName,"MYDIALOG"
invoke DialogBoxParam,hInstance,ADDR DlgName,0,ADDR DlgProc,0

invoke ExitProcess,eax

; #########################################################################

DlgProc proc hWnd :HWND,
uMsg :UINT,
wParam :WPARAM,
lParam :LPARAM

.if uMsg == WM_INITDIALOG
;szText dlgTitle,"Login Program"
;invoke SendMessage,hWin,WM_SETTEXT,0,ADDR dlgTitle
invoke GetDlgItem,hWnd,100
invoke SetFocus,eax

.elseif uMsg == WM_CLOSE
quit_dialog:
invoke EndDialog,hWnd,0


.elseif uMsg == WM_COMMAND
mov eax,wParam
.if lParam == 0
jmp quit_dialog
.else
mov edx,wParam
shr edx,16
.if dx == BN_CLICKED
.if ax == 103
invoke MessageBox,NULL,ADDR buffer,SADD ("AppName"),MB_OK
.elseif ax == 104
jmp quit_dialog
.endif

.endif
.endif
.endif

xor eax, eax
ret

DlgProc endp

; ########################################################################


end start


; ########################################################################





This is the .RC file



; ########################################################################

#include "resource.h"



MYDIALOG DIALOGEX 10, 10, 196, 98
STYLE DS_MODALFRAME | DS_CENTER | DS_CONTEXTHELP | WS_VISIBLE | WS_CAPTION |
WS_SYSMENU
EXSTYLE WS_EX_CONTEXTHELP
CAPTION "Login Account"
FONT 8, "Tahoma"
BEGIN
EDITTEXT 100,54,24,127,13,NOT WS_BORDER,WS_EX_STATICEDGE
EDITTEXT 101,54,40,127,13,ES_PASSWORD | NOT WS_BORDER,WS_EX_STATICEDGE
CONTROL "Change Password",102,"Button",BS_AUTOCHECKBOX | BS_FLAT |
WS_TABSTOP,54,56,72,13
DEFPUSHBUTTON "&OK",103,71,77,52,15,BS_FLAT
PUSHBUTTON "&Cancel",104,129,77,52,15,BS_FLAT
CONTROL "User Name:",105,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,
12,27,38,8
LTEXT "Password:",106,12,42,37,8
GROUPBOX "Enter Username and Password",107,6,8,183,65,BS_FLAT
END

; ########################################################################
Posted on 2003-07-23 00:42:06 by coredump
Hello, coredump

Some problems were with your macros.
And here's an working example.
It uses plain passwords in files (name of the file = username w/o extension)
And do not count wrong attempts, I hope i'll get the idea how to do it.

I suppose you've already downloaded RadASM :alright:


P.S.
this is my 1st dialog app, so bugs are possible ;)
p.p.s
Sorry for my bad english, too :grin:

S.T.A.S.
Posted on 2003-08-06 11:19:50 by S.T.A.S.
Interesting code I must say, though you have forgottten to preserve ebx (might result in crashes on some OS).
Posted on 2003-08-06 11:24:49 by roticv

you have forgottten to preserve ebx


i thinked its saved by win32
Posted on 2003-08-06 11:39:03 by S.T.A.S.
Nope, for callback functions, if you use edi, esi and ebx, do remmeber to preserve. If not, there might be nasty crashes.
Posted on 2003-08-06 11:40:54 by roticv
roticv,
thanks for an advice, I've never experiensed this problem on WinXP & 98 :stupid:
(but some push/pop will help, i hope)


S.T.A.S.

Posted on 2003-08-06 11:53:49 by S.T.A.S.
might result in crashes on some OS

yea, on win2k :mad:
Interesting code I must say

pop eax
invoke CloseHandle, EAX

hmm, i was really slippy this night
shure to use simple "call CloseHandle" instead of it :stupid:

new version is uploaded :cool:

S.T.A.S.
Posted on 2003-08-06 19:10:20 by S.T.A.S.
thank you!!! now i understand ASM. more power people!!!
i'm reading some tutorials and documentations regarding ASM.

Thank you & God Bless!

coredump
Posted on 2003-08-17 03:32:15 by coredump
Thank you, too!
I found out some important things, with userlogin prog :cool:

1.
for callback functions, if you use edi, esi and ebx, do remmeber to preserve

2. This board, probably, is the best plase to learn assembly!
Posted on 2003-08-18 01:00:36 by S.T.A.S.