invoke    GetWindowText,hEdit2,addr password,sizeof password
invoke    lstrlen,addr password
.if    eax
invoke    lstrcmp,addr password,addr password1;compare your inputs with passwd1
.if    eax != 0
invoke    MessageBox,hDlg,CTXT("your inut is wrong"),CTXT("please reinput"),MB_ICONINFORMATION or MB_OK
invoke    SetFocus,hEdit1;this is a edit control 's handle
inc        LandingNum    ;use as count    LandingNum???0
mov        eax,LandingNum
.if        eax <=3
mov        flag,0
invoke    SetWindowText,hEdit2,NULL
ret
.else
mov        flag,0
invoke    MessageBox,hDlg,CTXT("you have landed wrong of  three times!"),CTXT("thank for your landing!"),MB_OK or MB_ICONINFORMATION
invoke    _FreeRes,hDlg,hdback1,hbitback,hdc1,hbrBrush1
ret
.endif
Posted on 2007-04-13 20:50:10 by hero liu
My question are:
1,I can land two times in a wrong password ,But when i use the wrong password for the third landing ,the programe made a anomaly.
windows info:041f1a48h can't be writted,why?
Posted on 2007-04-13 20:54:54 by hero liu

My question are:
1,I can land two times in a wrong password ,But when i use the wrong password for the third landing ,the programe made a anomaly.
windows info:041f1a48h can't be writted,why?


Start inserting breakpoints (such as RET) at various points in your code. Start by where the code *should* work, and move up or down from there. This is about the easiest form of troubleshooting/debugging that you can do.
Posted on 2007-04-13 21:48:56 by SpooK
Can you attach your program?
Posted on 2007-04-14 00:51:21 by roticv

invoke    SetWindowText,hEdit2,NULL


BOOL SetWindowText(

    HWND hWnd, // handle of window or control
    LPCTSTR lpString // address of string
  );

Parameters

hWnd
Identifies the window or control whose text is to be changed.

lpString
Points to a null-terminated string to be used as the new title or control text.

----------------

dont think 'NULL' is allowed / accepted by send message


just a guess, without seeing the whole source its a bit tricky to find the problem
Posted on 2007-04-14 13:26:43 by evlncrn8
setwindowtext (hwnd,lpsz)
it is  current to set lpsz with "null"

Posted on 2007-04-16 12:09:34 by hero liu
The whole source :
.data
ClassName db "login",0
WindowName db "????",0
query db "select password from login where name = ?",0
SQLAppStmt db "insert into login (name,password) values (?,?)",0
strconnect db "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=",0
dbname db "text.mdb",0
zlc db "?????????",0
connfail db "Connection attempt failed",0
appname db "ODBC Test",0
allocconnfail db "Connection handle allocation failed",0
setattrfail db "Cannot set desired ODBC version",0
allocenvfail db "Environment handle allocation failed",0
ToolTipsClassName db  "Tooltips_class32",0
szPath db MAX_PATH dup(?)
szPath1 db MAX_PATH dup(?)
.data?
hInstance dd ?
hWinMain dd ?
hwndTool dd ?
hconn dd ?
hsmt dd ?
hEdit1 dd ?
hEdit2 dd ?
henv dd ?
strlen dd ?
LandingNum dd ?
connectstring db 1024 dup(?)
progpath db 256 dup(?)
conn db 256 dup(?)
name1 db 6 dup(?)
password1 db 6 dup(?)
hcmain dd ?
hcmov dd ?
buffer2lh dd ?
namel dd ?
passwordl dd ?
flag dd ?
hDlg1 dd ?
hdc1 dd ?
hdback1 dd ?
hbrBrush1 dd ?
hbrBrush2 dd ?
hbrBrush3 dd ?
hDlg2 dd ?
hdc2 dd ?
hdback2 dd ?
hWinToolbar dd ?

MOVmw    MACRO Var1, Var2
              lea     esi, Var2
              lea     edx, Var1
           REPEAT     2
                 mov     al,
                 mov     , al
                 inc     esi
                 inc     edx
           ENDM
        ENDM
RGB MACRO Blue,Green,Red
xor eax,eax
mov al,Blue
shl eax,8
mov al,Green
shl eax,8
mov al,Red
ENDM
;**********************************************************************
;???????
.code
WinMain proc
local @stwc:WNDCLASSEX
local @stmsg:MSG
local @stRect:RECT
local Wtx:DWORD
local Wty:DWORD


invoke RtlZeroMemory,addr @stwc,sizeof @stwc
mov   @stwc.cbSize,SIZEOF WNDCLASSEX
mov   @stwc.style, CS_HREDRAW or CS_VREDRAW or CS_BYTEALIGNWINDOW
mov   @stwc.lpfnWndProc, OFFSET _WndProc
; mov  @stwc.hbrBackground,COLOR_BTNFACE+1
push   hInstance
pop   @stwc.hInstance
invoke LoadIcon,hInstance,IDI_APPLICATION
mov   @stwc.hIcon,eax
mov   @stwc.hIconSm,eax
mov   @stwc.lpszClassName,offset ClassName

invoke RegisterClassEx, addr @stwc
mov Wwd,700
mov Wht,700
invoke GetSystemMetrics,SM_CXSCREEN
shr Wwd,1
shr eax,1
sub eax,Wwd
mov Wtx,eax
invoke GetSystemMetrics,SM_CYSCREEN
shr Wht,1
shr eax,1
sub eax,Wht
mov Wty,eax
invoke CreateWindowEx,NULL,addr ClassName,addr WindowName,WS_CAPTION or WS_SYSMENU or WS_BORDER or WS_MINIMIZEBOX ,
          Wtx,Wty,570,590,NULL,NULL,hInstance,NULL
mov   hWinMain,eax

invoke AnimateWindow,hWinMain,1000,AW_BLEND
invoke SetForegroundWindow,hWinMain
invoke LoadMenu,hInstance,101
mov hmenu,eax
invoke SetMenu,hWinMain,eax
invoke LoadAccelerators,hInstance,101
mov haccel,eax

invoke GetSubMenu,hmenu,1
mov hsubmenu,eax
invoke ShowWindow,hWinMain ,SW_SHOWNORMAL
invoke UpdateWindow,hWinMain

.while TRUE
invoke GetMessage,addr @stmsg,NULL,NULL,NULL
.break .if(!eax)
invoke TranslateAccelerator,hWinMain,haccel,addr @stmsg
.if eax==0
invoke TranslateMessage,addr @stmsg
invoke DispatchMessage,addr @stmsg
.endif
.endw
mov eax,@stmsg.wParam
ret
WinMain endp

;**********************************************************************
;get the main process path name
_GetProgramPath proc
invoke GetModuleFileName,NULL,addr progpath,sizeof progpath
std
mov edi,offset progpath
add edi,sizeof progpath-1
mov al,"\"
mov ecx,sizeof progpath
repne scasb
cld
mov BYTE  ptr ,0
ret
_GetProgramPath endp

;***********************************************************************
;?????
_odbcconnect proc  hWnd:DWORD
invoke SQLAllocHandle,SQL_HANDLE_ENV,SQL_NULL_HANDLE,addr henv
.if ax==SQL_SUCCESS || ax==SQL_SUCCESS_WITH_INFO
invoke SQLSetEnvAttr,henv,SQL_ATTR_ODBC_VERSION,SQL_OV_ODBC3,0
.if ax==SQL_SUCCESS || ax==SQL_SUCCESS_WITH_INFO
invoke SQLAllocHandle,SQL_HANDLE_DBC,henv,addr hconn
.if ax==SQL_SUCCESS || ax==SQL_SUCCESS_WITH_INFO
invoke  SQLSetConnectAttr,hconn,SQL_ATTR_ODBC_CURSORS,SQL_CUR_USE_ODBC,0
invoke lstrcpy,addr connectstring,addr strconnect
invoke lstrcat,addr connectstring,addr progpath
invoke lstrcat,addr connectstring,addr dbname
invoke SQLDriverConnect,hconn,hWnd,addr connectstring,sizeof connectstring,\
addr conn,sizeof conn,addr strlen,SQL_DRIVER_COMPLETE
.if ax==SQL_SUCCESS || ax==SQL_SUCCESS_WITH_INFO
invoke SQLAllocHandle,SQL_HANDLE_STMT,hconn,addr hsmt
.if !(ax==SQL_SUCCESS || ax==SQL_SUCCESS_WITH_INFO)
invoke MessageBox,hWnd,addr zlc,addr zlc,MB_OK OR MB_ICONERROR
.endif
.else
invoke SQLFreeHandle,SQL_HANDLE_DBC,hconn
invoke SQLFreeHandle,SQL_HANDLE_ENV,henv
invoke MessageBox,hWnd,addr connfail,addr appname,MB_OK OR MB_ICONERROR
.endif
.else
           
invoke SQLFreeHandle,SQL_HANDLE_ENV,henv
invoke MessageBox,hWnd,addr allocconnfail,addr appname,MB_OK OR MB_ICONERROR
.endif
.else
invoke SQLFreeHandle,SQL_HANDLE_ENV,henv
invoke MessageBox,hWnd,addr setattrfail,addr appname,MB_OK OR MB_ICONERROR
.endif
.else
invoke MessageBox,hWnd,addr allocenvfail,addr appname,MB_OK OR MB_ICONERROR
.endif
ret
_odbcconnect endp
;*****************************************************************
;disconnect the odbc
_OdbcDisconnect proc hDlg
invoke SQLDisconnect,hconn
invoke SQLFreeHandle,SQL_HANDLE_DBC,hconn
invoke SQLFreeHandle,SQL_HANDLE_ENV,henv
ret
_OdbcDisconnect endp

;*************************************************************************
;********************************************************************
;the button classlong callback function of Dialog1
_BtnProc1 proc hCtl,uMsg,wParam,lParam
local ID

invoke GetDlgCtrlID,hCtl
mov ID,eax
.if uMsg==WM_LBUTTONDOWN
invoke SetCapture,hCtl
.if ID==1
invoke SendMessage,hCtl,STM_SETIMAGE,IMAGE_BITMAP,hsure2
.elseif ID==2
invoke SendMessage,hCtl,STM_SETIMAGE,IMAGE_BITMAP,happly2
.elseif ID==3
invoke SendMessage,hCtl,STM_SETIMAGE,IMAGE_BITMAP,hexit2
.endif
.elseif uMsg==WM_LBUTTONUP
.if ID==1
invoke SendMessage,hCtl,STM_SETIMAGE,IMAGE_BITMAP,hsure1
invoke SendMessage,hDlg1,WM_COMMAND,10,hCtl
.elseif ID==2
invoke SendMessage,hCtl,STM_SETIMAGE,IMAGE_BITMAP,happly1
invoke SendMessage,hDlg1,WM_COMMAND,11,hCtl
.elseif ID==3
invoke SendMessage,hCtl,STM_SETIMAGE,IMAGE_BITMAP,hexit1
invoke SendMessage,hDlg1,WM_COMMAND,12,hCtl
.endif
invoke ReleaseCapture
.endif
invoke GetWindowLong,hCtl,GWL_USERDATA
invoke CallWindowProc,eax,hCtl,uMsg,wParam,lParam
ret
_BtnProc1 endp

;*********************************************************
;release the resource
_FreeRes proc _hDlg,_hdback,_hbitback,_hdc,_hbrBrush
invoke _OdbcDisconnect,_hDlg
invoke DeleteDC,_hdback
invoke DeleteObject,_hbitback
invoke DeleteObject,_hbrBrush
invoke ReleaseDC,_hDlg,_hdc
invoke EndDialog,_hDlg,NULL
ret
_FreeRes endp

;********************************************************************
;The landing dialog  why can't give user three chances to landing
_DlgProc1 proc hDlg:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
local @stPaint:PAINTSTRUCT
local password[9]:BYTE
local ti:TOOLINFO
local dwTemp:DWORD
local hDlgbitmap:DWORD
local hbitback,TempNum


mov eax,uMsg
.if eax == WM_COMMAND
mov eax,wParam
shr eax,16
.if ax == 0
mov eax,wParam
and eax,0FFFFh
.if(eax == 10)
invoke SQLBindParameter,hsmt,1,SQL_PARAM_INPUT,SQL_C_CHAR,\
                       SQL_CHAR,10,0,addr name1,sizeof name1,addr dwTemp
mov LandingNum,1
invoke GetWindowText,hEdit1,addr name1,sizeof name1
invoke lstrlen,addr name1
mov dwTemp,eax
.if !dwTemp
invoke MessageBox,hDlg,CTXT("??????"),CTXT("??"),MB_OK or MB_ICONINFORMATION
invoke SetFocus,hEdit1
ret
.endif

invoke SQLExecute,hsmt

invoke SQLBindCol,hsmt,1,SQL_C_CHAR,addr password1,10,addr dwTemp
invoke SQLFetch,hsmt

invoke SQLCloseCursor,hsmt
invoke SQLFreeHandle, SQL_HANDLE_STMT, hsmt

invoke GetWindowText,hEdit2,addr password,sizeof password
invoke lstrlen,addr password
.if eax
invoke lstrcmp,addr password,addr password1  ;compare the input password with the right password .if eax != 0
invoke MessageBox,hDlg,CTXT("you input a wrong password"),CTXT("please reinput"),MB_ICONINFORMATION or MB_OK
invoke SetFocus,hEdit1

mov eax,LandingNum
.if eax ==4
mov flag,0
invoke MessageBox,hDlg,CTXT("you have landing three times ,thank you!"),CTXT("thank Landing!"),MB_OK or MB_ICONINFORMATION
invoke _FreeRes,hDlg,hdback1,hbitback,hdc1,hbrBrush1
ret

.else
mov flag,0
inc LandingNum ;use as a count
invoke SetWindowText,hEdit2,NULL
ret
.endif
.else
mov flag,1
invoke _FreeRes,hDlg,hdback1,hbitback,hdc1,hbrBrush1
ret
.endif
.else
mov eax,TRUE
ret
.endif

.elseif(eax == 11) ; invoke ShowWindow,hDlg1,SW_HIDE
invoke DialogBoxParam,hInstance,100,hDlg,offset _DialogProc2,NULL
.elseif(eax == 12)
invoke _FreeRes,hDlg,hdback1,hbitback,hdc1,hbrBrush1
.endif
.endif
.elseif eax == WM_PAINT
invoke BeginPaint,hDlg,addr @stPaint
mov hdc1,eax
invoke BitBlt,hdc1,0,0,600,400,hdback1,0,0,SRCCOPY
invoke EndPaint,hDlg,addr @stPaint
.elseif eax == WM_INITDIALOG
invoke CreateRoundRectRgn,30,10,420,250,80,80
push eax
invoke SetWindowRgn,hDlg,eax,TRUE
pop eax
invoke DeleteObject,eax
invoke SetWindowPos,hDlg,HWND_TOPMOST,250,250,0,0,SWP_NOSIZE
push hDlg
pop hDlg1
invoke CreateWindowEx,WS_EX_TOPMOST,ADDR ToolTipsClassName,NULL,\
           TTS_NOPREFIX or TTS_ALWAYSTIP or TTS_BALLOON,\
   CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,\
   NULL,NULL, hInstance,NULL
  mov hwndTool,eax
  mov ti.cbSize,sizeof TOOLINFO
  mov ti.uFlags,TTF_SUBCLASS
  push hDlg
  pop ti.hWnd
  invoke EnumChildWindows,hDlg,addr EnumChild,addr ti
mov TempNum,1
@@:
invoke GetDlgItem,hDlg,TempNum
push eax
invoke SetWindowLong,eax,GWL_WNDPROC,offset _BtnProc1
pop ecx
invoke SetWindowLong,ecx,GWL_USERDATA,eax
inc TempNum
cmp TempNum,3
jbe @B
invoke LoadCursor,hInstance,102
mov hcmov,eax
invoke LoadBitmap,hInstance,107
mov hDlgbitmap,eax
invoke GetDC,hDlg
mov hdc1,eax
invoke CreateCompatibleDC,hdc1
mov hdback1,eax
invoke CreateCompatibleBitmap,hdc1,600,400
mov hbitback,eax
invoke SelectObject,hdback1,hbitback

invoke CreatePatternBrush,hDlgbitmap
mov hbrBrush1,eax
invoke SelectObject,hdback1,eax
invoke DeleteObject,eax
invoke PatBlt,hdback1,0,0,600,400,PATCOPY ;paint the Landing face
; invoke BitBlt,hdc1,0,0,600,400,hdback1,0,0,SRCCOPY

invoke GetDlgItem,hDlg,6
mov hEdit1,eax
invoke SendMessage,hEdit1,EM_LIMITTEXT,6,0
invoke GetDlgItem,hDlg,7
mov hEdit2,eax
invoke SendMessage,hEdit2,EM_LIMITTEXT,6,0
invoke _odbcconnect,hDlg
invoke SetFocus,hEdit1
invoke SQLAllocHandle,SQL_HANDLE_STMT,hconn,addr hsmt
.if ax == SQL_SUCCESS || ax == SQL_SUCCESS_WITH_INFO
invoke SQLPrepare,hsmt,addr query,sizeof query
ret
.else
invoke MessageBox,hDlg,CTXT("????????"),("??"),MB_OK
ret
.endif
.elseif eax == WM_CLOSE
@@:
mov num,101
invoke DeleteObject,addr num
inc num
cmp num,112
jbe @B  
invoke _FreeRes,hDlg,hdback1,hbitback,hdc1,hbrBrush1
.elseif eax == WM_LBUTTONDOWN ;??????????????
invoke SetCursor,hcmov
invoke UpdateWindow,hDlg
invoke ReleaseCapture
invoke SendMessage,hDlg,WM_NCLBUTTONDOWN,HTCAPTION,0
invoke SetCursor,hcmain
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
xor eax,eax
ret
_DlgProc1 endp


;*; found the file that user want  but when i found the file ,the found process can't run out ******************************************************************
;_FindFile proc uses edi ebx _lpszPath
local @stFindFile:WIN32_FIND_DATA
local @hFindFile
local @szPath:BYTE ;used as loadint "the path\"
local @szSearch:BYTE ;used as loading?the path\*.*?
local @szFindFile:BYTE ;used as loading?the path\the file?
local @szbuffer:BYTE

invoke GetDlgItemText,hDlg4,1000,addr @szbuffer,sizeof @szbuffer
invoke lstrcpy,addr @szPath,_lpszPath
;********************************************************************
;add this \*.* behind the path
;********************************************************************
@@:
invoke lstrlen,addr @szPath
lea esi,@szPath
add esi,eax
xor eax,eax
mov al,'\'
.if BYTE  ptr != al
mov WORD  ptr ,ax
.endif
invoke lstrcpy,addr @szSearch,addr @szPath
invoke lstrcat,addr @szSearch,addr szAll   ;szAll defined as '\*.*"
;********************************************************************; found the file that user want  but when i found the file ,the found process can't run out
;********************************************************************
invoke FindFirstFile,addr @szSearch,addr @stFindFile
.if eax != INVALID_HANDLE_VALUE
mov @hFindFile,eax
.while eax !=0
invoke lstrcpy,addr @szFindFile,addr @szPath
invoke lstrcat,addr @szFindFile,addr @stFindFile.cFileName
.if @stFindFile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY
.if @stFindFile.cFileName != '.'
invoke _FindFile,addr @szFindFile
.endif
.else
invoke SetDlgItemText,hDlg4,110,addr @szFindFile
invoke lstrcmp,addr @szbuffer,addr @stFindFile.cFileName ;@szbuffer  is the file name that user want to found .if eax == 0
invoke FindClose,@hFindFile
ret
.endif
.endif
invoke FindNextFile,@hFindFile,addr @stFindFile
.endw
.if @hFindFile
invoke FindClose,@hFindFile
ret
.endif
.endif
ret
_FindFile endp

;**************************************************************************
;Get the full path file name _GetFileName proc
local lvi:LV_ITEM
local @szbuffer:BYTE

invoke lstrcpy,addr szPath1,addr szPath
invoke SendMessage,hList,LVM_GETNEXTITEM,-1,LVNI_FOCUSED
mov lvi.iItem,eax
mov lvi.iSubItem,0
mov lvi.imask,LVIF_TEXT
lea eax,@szbuffer
mov lvi.pszText,eax
mov lvi.cchTextMax,256
invoke SendMessage,hList,LVM_GETITEM,0,addr lvi
push lvi.iItem
pop iItem
invoke lstrlen,addr szPath1
sub eax,1
.if BYTE ptr szPath !='\'
invoke lstrcat,addr szPath1,CTXT("\")
invoke lstrcat,addr szPath1,addr @szbuffer
.else
invoke lstrcat,addr szPath1,addr @szbuffer
.endif
ret
_GetFileName endp

;The Main process entry
start:
invoke GetModuleHandle,NULL
mov hInstance,eax
call _GetProgramPath
invoke LoadBitmap,hInstance,110
mov hsure2,eax
invoke LoadBitmap,hInstance,104
mov hsure1,eax
invoke LoadBitmap,hInstance,105
mov happly1,eax
invoke LoadBitmap,hInstance,112
mov happly2,eax
invoke LoadBitmap,hInstance,106
mov hexit1,eax
invoke LoadBitmap,hInstance,117
mov hexit2,eax
invoke DialogBoxParam,hInstance,65h,NULL,offset _DlgProc1,NULL
mov hDlg1,eax
.if flag
invoke WinMain
invoke ExitProcess,NULL
.else
invoke ExitProcess,NULL
.endif

end start
Posted on 2007-04-16 13:06:51 by hero liu
I know why the program can't run in the third time of wrong password landing
Because the sql_handle_stmt 's handle was release in the first time landing,but did't create in the second time ,of course in the third time ..
Posted on 2007-04-18 05:13:40 by hero liu