The MASM Forum

General => The Workshop => Topic started by: clamicun on January 28, 2017, 02:38:02 AM

Title: mysleep proc
Post by: clamicun on January 28, 2017, 02:38:02 AM
mysleep proc
Is this an ideia ?

;mysqlinit:
;INVOKE mysql_init,NULL
;mov db_connect,eax
;INVOKE   mysql_real_connect,db_connect,offset hostname,offset u_root,offset pw_buffer,0,0,0,0
;INVOKE mysql_errno,db_connect

;.if eax == 2003    ;errno mysql 'Server does not run'
;INVOKE MessageBox,NULL,offset Error_connect,offset AppName,MB_ICONERROR  ;Msg 'Server does not run'
;INVOKE ShellExecute,main_hwnd,offset fOpen,offset mysql_startfile,NULL,NULL,SW_HIDE
;mysql_startfile   db "mysql_start.exe",0

;Here I need 3 seconds before trying again - the server needs it

;call mysleep
;jmp mysqlinit
;==========

mysleep proc

;two_ints db "%u%u",0
;goodforall dd ?
;buffer_tmp 10 up(?),0

;====Aktuelle Sekunde Millisekunde
INVOKE GetLocalTime,offset systemTime
movsx eax,systemTime.wSecond
movsx ecx,systemTime.wMilliseconds

add eax,3
INVOKE wsprintf,offset buffer_tmp,offset two_ints,eax,ecx
INVOKE crt_atoi,offset buffer_tmp
mov goodforall,eax          ;Endvalue to check

chkthesec:

INVOKE GetLocalTime,offset systemTime
movsx eax,systemTime.wSecond
movsx ecx,systemTime.wMilliseconds

INVOKE wsprintf,offset buffer_tmp,offset two_ints,eax,ecx
INVOKE crt_atoi,offset buffer_tmp

.if eax >= goodforall      ;Cmp ends
jmp outchk
.else
jmp chkthesec
.endif

outchk:

ret
mysleep endp
Title: Re: mysleep proc
Post by: jj2007 on January 28, 2017, 03:16:08 AM
What's wrong with invoke Sleep, 3000??
Title: Re: mysleep proc
Post by: clamicun on January 28, 2017, 04:52:52 AM
Obviously the sleep function stops the whole program for a defined time.
I only want some seconds between  start_mysql (takes 2,3 seconds) and trying to check the password again
Title: Re: mysleep proc
Post by: hutch-- on January 28, 2017, 09:17:45 AM
Use a timer.
Title: Re: mysleep proc
Post by: clamicun on January 29, 2017, 02:52:08 AM
Yes hutch,
I do that.
But this will not change much.
Perhaps it is more "standard".
Thanks
Title: Re: mysleep proc
Post by: fearless on January 29, 2017, 05:38:07 AM
Sounds like you should be looking at threads and signalling back to the main program thread when the connection status has changed and to what status (disconnected, no internet, connected, incorrect login details etc etc)
Title: Re: mysleep proc
Post by: coder on January 29, 2017, 12:04:34 PM
Excuse my noobish question, but this statement puzzles me;

.if eax == 2003
INVOKE something


but where's the .else and / or the .endif part? I see some serious logical flaw here that leads to infinite loop... but maybe I am wrong. I know nothing about mysql.
Title: Re: mysleep proc
Post by: jj2007 on January 29, 2017, 08:04:05 PM
Quote from: coder on January 29, 2017, 12:04:34 PMbut where's the .else and / or the .endif part?

The .if is commented out. If it wasn't, the assembler would confirm your doubts with a fat error message 8)
Title: Re: mysleep proc
Post by: coder on January 29, 2017, 11:43:25 PM
jj2007

ok then. I hope it's just a pseudo. But even if it is, it still scares me to see multiple instances of the database are loaded in an infinite loop (if it is even possible at all with mysql).
Title: Re: mysleep proc
Post by: clamicun on February 01, 2017, 10:23:38 AM
To all you guys,
I resolved it . Everything runs perfectly...
Title: Re: mysleep proc
Post by: clamicun on February 01, 2017, 10:26:01 AM
The only problem I am still having ...

Does someone know how to translate this goasm syntax

;Start the button IDs at one so we don't use 0 (we'll have to dec in order to get the right menu)
TbBtns TBBUTTON <0,1,TBSTATE_ENABLED,TBSTYLE_AUTOSIZE | TBSTYLE_DROPDOWN,0,0,0>
      TBBUTTON <1,2,TBSTATE_ENABLED,TBSTYLE_AUTOSIZE | BSTYLE_DROPDOWN,0,0,1>
      TBBUTTON <3,3,TBSTATE_ENABLED,TBSTYLE_AUTOSIZE | BSTYLE_DROPDOWN,0,0,2>
       TBBUTTON <4,4,TBSTATE_ENABLED,TBSTYLE_AUTOSIZE | BSTYLE_DROPDOWN,0,0,3>

into something which might work ?
Title: Re: mysleep proc
Post by: HSE on February 01, 2017, 02:08:36 PM
It's an array of structures, almost the same in all languajes.
Title: Re: mysleep proc
Post by: jj2007 on February 01, 2017, 07:14:32 PM
BSTYLE_DROPDOWN is undefined 8)
Title: Re: mysleep proc
Post by: TWell on February 01, 2017, 08:40:39 PM
TbBtns TBBUTTON <0,1,TBSTATE_ENABLED,TBSTYLE_AUTOSIZE OR TBSTYLE_DROPDOWN,0,0,0>
       TBBUTTON <1,2,TBSTATE_ENABLED,TBSTYLE_AUTOSIZE OR TBSTYLE_DROPDOWN,0,0,1>
       TBBUTTON <3,3,TBSTATE_ENABLED,TBSTYLE_AUTOSIZE OR TBSTYLE_DROPDOWN,0,0,2>
       TBBUTTON <4,4,TBSTATE_ENABLED,TBSTYLE_AUTOSIZE OR TBSTYLE_DROPDOWN,0,0,3>
Title: Re: mysleep proc
Post by: clamicun on February 02, 2017, 05:06:57 AM
Twell ???
Exactely what I wrote.
Does not compile
Title: Re: mysleep proc
Post by: jj2007 on February 02, 2017, 05:22:14 AM
Writing "does not compile" is a no-no. Every compiler spits out error messages, and it would be extremely helpful to show them here. Btw did you use BSTYLE_DROPDOWN as posted above, or TBSTYLE_DROPDOWN?
Title: Re: mysleep proc
Post by: TWell on February 02, 2017, 05:26:18 AM
My test:.model flat

TBBUTTON STRUCT
iBitmap DWORD ?
idCommand DWORD ?
fsState BYTE ?
fsStyle BYTE ?
; bReserved BYTE 6 DUP (?) ; x64
; bReserved BYTE 2 DUP (?) ; x86
bReserved DWORD ?
dwData DWORD PTR ?
iString DWORD PTR ?
TBBUTTON ENDS

TBSTATE_ENABLED = 4h
TBSTYLE_DROPDOWN = 8h
TBSTYLE_AUTOSIZE = 10h
BTNS_DROPDOWN = TBSTYLE_DROPDOWN

LPSTR typedef PTR BYTE

.data
;Start the button IDs at one so we don't use 0 (we'll have to dec in order to get the right menu)
TbBtns TBBUTTON <0,1,TBSTATE_ENABLED,TBSTYLE_AUTOSIZE OR TBSTYLE_DROPDOWN,0,0,0>
       TBBUTTON <1,2,TBSTATE_ENABLED,TBSTYLE_AUTOSIZE OR TBSTYLE_DROPDOWN,0,0,1>
       TBBUTTON <3,3,TBSTATE_ENABLED,TBSTYLE_AUTOSIZE OR TBSTYLE_DROPDOWN,0,0,2>
       TBBUTTON <4,4,TBSTATE_ENABLED,TBSTYLE_AUTOSIZE OR TBSTYLE_DROPDOWN,0,0,3>

END
so check your header or at least tell us what header file you use and what compiler?