flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Tommy
that's because you're not using local labels inside the proc... you're using wdmINITDIALOG.test1... it's defined as dialog_procedureA.test1
|
|||
![]() |
|
vbVeryBeginner
thanks tommy,
i didn't realize that once we use a : we are in another scope! Code: wdmINITDIALOG: jmp there .test1 dd ? there: lea eax,[wdmINITDIALOG.test1] lea eax,[dialog_procedureA.test1] stdcall testing,2,4,6,8 return this clear my confuse ![]() |
|||
![]() |
|
revolution
It's not the : that makes a new scope, it is a label that does nos begin with a . that makes a new scope.
Try this with the four extra .'s instead. Code: proc dialog_procedureA,hDlg,uMsg,wParam,lParam .test1 dd ? ;define the symbol enter cmp [uMsg],WM_CLOSE je .wdmCLOSE cmp [uMsg],WM_INITDIALOG je .wdmINITDIALOG return .wdmCLOSE: invoke EndDialog,[hDlg],0 return .wdmINITDIALOG: lea eax,[.test1] ; Now it works. stdcall testing,2,4,6,8 return endp |
|||
![]() |
|
vbVeryBeginner
thanks revolution but ...
Code: format PE GUI 4.0 entry start include '%fasminc%\win32a.inc' section '.data' data readable writeable insH dd ? wndTitle db 'On Test',0 buf1 rb 0x30 buf2 rb 0x30 f1 db '.wdmINITDIALOG -> %lu',0 f2 db '.wdmCTLCOLORSTATIC -> %lu',0 section '.code' code readable executable start: invoke GetModuleHandle,0 mov [insH],eax invoke DialogBoxParam,eax,30,NULL,dialog_procedureA,NULL proc dialog_procedureA,hDlg,uMsg,wParam,lParam .t2 dd ? enter cmp [uMsg],WM_CLOSE je .wdmCLOSE cmp [uMsg],WM_INITDIALOG je .wdmINITDIALOG cmp [uMsg],WM_CTLCOLORSTATIC je .wdmCTLCOLORSTATIC return .wdmCLOSE: invoke EndDialog,[hDlg],0 return .wdmINITDIALOG: mov [.t2],30 ;<- so, we move 30 into it mov eax,[.t2] invoke wsprintf,buf1,f1,eax invoke MessageBox,NULL,buf1,wndTitle,MB_OK return .wdmCTLCOLORSTATIC: mov eax,[.t2] ;<- now, do you have any idea invoke wsprintf,buf2,f2,eax ; why it shouldn't be 30? invoke MessageBox,NULL,buf2,wndTitle,MB_OK mov eax,FALSE return endp section '.idata' import data readable library kernel32, 'KERNEL32.DLL',\ user32, 'USER32.DLL' include '%fasminc%\apia\Kernel32.inc' include '%fasminc%\apia\User32.inc' section '.rsrc' resource data readable directory RT_DIALOG,appDialog resource appDialog,\ 30,LANG_NEUTRAL,dlgTest dialog dlgTest,'Test',0,0,170,50,\ DS_MODALFRAME + WS_VISIBLE + WS_CAPTION + WS_POPUP + WS_SYSMENU dialogitem 'STATIC','',0,5,5,100,40,SS_LEFT + WS_VISIBLE enddialog |
|||
![]() |
|
revolution
The variable ".t2" is not a static variable. It is on the stack. Each time dialog_procedureA is called a new space is allocated within the stack. More than likely the value will be changed by many other things happening on the stack between calls the dialog_procedureA
You need to put ".t2" in the same place as buf1 and the others for it to keep values between calls. Try viewing the actual code generated in a debugger. It may help you to understand how the stack is used by the "proc" macro. |
|||
![]() |
|
Matrix
Code: stackerproc: .t1 ; this is interpreted as stackerproc.t1 jmp .t2 ; now you see what is the case? cxz: .t2 ; this is interpreted as cxz.t2 .t4 ; this is interpreted as cxz..t4 .t3 ; this is interpreted as cxz.t3 ret local labels are referenced to the nearest global label/procedure upwards. |
|||
![]() |
|
vbVeryBeginner
arent the stack supposely cannot be modifed?
|
|||
![]() |
|
revolution
Stacks are always being modified. It is one of the most volitile places to store data. Once the routine returns (RET) it releases the stack for use by other code.
|
|||
![]() |
|
vbVeryBeginner
thanks you revolution, you RET clears my confuse
![]() ps: i am acutally quite new to assembly language, play with NASM before for a very short time, (no application produced!), any later on, i found FASM (which makes me stick until now) about 4 months already ![]() |
|||
![]() |
|
revolution
Kembali.
PS: Selamat Hari Raya. Anda balik kampung untuk minggu depan? |
|||
![]() |
|
vbVeryBeginner
thank you revolution
![]() are you from malaysia? anyway, i am chinese :p 希望您开斋节快乐! i don't have kampung to balik lah :p |
|||
![]() |
|
revolution
Saya tak cakap bahasa cina.
Saya cakap sedikit sahaja bahasa Melayu. Saya kerja dalam Malaysia sebelum ini. Suka berlatih bila-bila saya dapat peluang. |
|||
![]() |
|
vbVeryBeginner
bagus lah, sedikit pun jadilah :p
chinese language is fun, if you got time, you could learn it ![]() |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.