Hey it's me again
Please excuse me, I been on a roll putting stuff together the right way for the very first time and have to call you so that i don't spend another 2 years doing nothing but playing with boxes.

Anyway, i am one mile deep in a procudure but I need to jump back up to WM_COMMAND positions. I can't seem to jump out of the procedure i'm in, jmp want let me. could some one tell me how to manually move around in an apps.
Thank again
Posted on 2001-11-28 17:31:50 by cmax
Don't. That's the easy answer. The long answer involves the stack
and lots of description. Sorry, you'll have to do ret, possible combined
with error checking aaaaaaaaaaaall the way down. If this is the case,
you might want to re-think your program design (:. The sloppy method
is using something equivalent to a "jump buffer". At a known safe
point, you store all registers (including esp!) in a structure. If something
messes up, you can restore all registers from this structure, and
jmp to the safe spot. But there are usually much better ways around this.
Posted on 2001-11-28 20:01:53 by f0dder
Hey f0dder, I sorry i did not explain it. I just got a button in a procedure like Icz LISTBOX tute. I just turned it into Static (BitMap) Buttons so if i click it goes right to ..........
jump _BackTo
I have to do it this way because i got a piece of code up there that cause me to loss other stuff in code if i activate the button for it..... So I just put it in a dead button. I firgure I should be able to use another button from another procedure strictly for a jump to get back to that twisted piece of code. . . But for right now a jump will do. Do this make it easier, or is it still hard to do. I don't need speed, i just want to get up there. I was on a row. It's alway something, but I still prefer to deal with it. How would that Safe Buffer thing work. By the way i am a CreateFile fool now . . .Ya taught me WeLL . . .

Thanks f0dder
Posted on 2001-11-28 22:57:23 by cmax
Hmmm, I'm too tired to make sense of your post right now. Will
look at it again after a good 6 to 8 hours of sleep, unless somebody
else fixes your problem first :). If you can demonstrate what you
want to do with a small piece of source, post it.
Posted on 2001-11-28 23:00:29 by f0dder
;I don't know how to send zip over the web...What i am trying to do is jump out of a proc back up to
;WM_COMMAND ... if it work the app would close........I get ERROR:::: undefined symbol _GoTo

.386
.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
; ##########################
szText MACRO Name, Text:VARARG
LOCAL lbl
jmp lbl
Name db Text,0
lbl:
ENDM
return MACRO arg
mov eax, arg
ret
ENDM
;=================
; Local prototypes
;=================
WinMain PROTO :DWORD,:DWORD,:DWORD,:DWORD
WndProc PROTO :DWORD,:DWORD,:DWORD,:DWORD

ListBox PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
ListBoxProc PROTO :DWORD,:DWORD,:DWORD,:DWORD

.data
szDisplayName db "List Box Demo",0
CommandLine dd 0
hWnd dd 0
hInstance dd 0

hList1 dd 0
lpLstBox1 dd 0

.code

start:
invoke GetModuleHandle, NULL
mov hInstance, eax

invoke GetCommandLine
mov CommandLine, eax

invoke WinMain,hInstance,NULL,CommandLine,SW_SHOWDEFAULT
invoke ExitProcess,eax

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

WinMain proc hInst :DWORD,
hPrevInst :DWORD,
CmdLine :DWORD,
CmdShow :DWORD

;====================
; Put LOCALs on stack
;====================

LOCAL wc :WNDCLASSEX
LOCAL msg :MSG

LOCAL Wwd :DWORD
LOCAL Wht :DWORD
LOCAL Wtx :DWORD
LOCAL Wty :DWORD

;==================================================
; Fill WNDCLASSEX structure with required variables
;==================================================

mov wc.cbSize, sizeof WNDCLASSEX
mov wc.style, CS_HREDRAW or CS_VREDRAW \
or CS_BYTEALIGNWINDOW
mov wc.lpfnWndProc, offset WndProc
mov wc.cbClsExtra, NULL
mov wc.cbWndExtra, NULL
push hInst
pop wc.hInstance

mov wc.hbrBackground, COLOR_WINDOW+1
mov wc.lpszMenuName, NULL
mov wc.lpszClassName, offset szClassName
invoke LoadIcon,hInst,500 ; icon ID
mov wc.hIcon, eax
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor, eax
mov wc.hIconSm, 0

invoke RegisterClassEx, ADDR wc

;================================
; Centre window at following size
;================================


szText szClassName,"Template_Class"


INVOKE CreateWindowEx,WS_EX_WINDOWEDGE,ADDR szClassName,ADDR szDisplayName,\
WS_OVERLAPPEDWINDOW ,607,\
0,675,375,NULL,NULL,hInst,NULL



mov hWnd,eax

invoke LoadMenu,hInst,600 ; menu ID
invoke SetMenu,hWnd,eax

invoke ShowWindow,hWnd,SW_SHOWNORMAL
invoke UpdateWindow,hWnd


;===================================
; Loop until PostQuitMessage is sent
;===================================

StartLoop:
invoke GetMessage,ADDR msg,NULL,0,0
cmp eax, 0
je ExitLoop
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
jmp StartLoop
ExitLoop:

return msg.wParam

WinMain endp

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

WndProc proc hWin :DWORD,
uMsg :DWORD,
wParam :DWORD,
lParam :DWORD

.if uMsg == WM_COMMAND


_GoTo: invoke PostQuitMessage,NULL ;;;; NEED TO JUMP TO THIS POSITION



.if wParam == 1000
invoke SendMessage,hWin,WM_SYSCOMMAND,SC_CLOSE,NULL
.endif


.elseif uMsg == WM_CREATE


;;* * * * * * * * * * * * * * * * * * * * * * * * * * *
invoke ListBox,21,50,44,25,hWin,501
mov hList1, eax
invoke SetWindowLong,hList1,GWL_WNDPROC,ListBoxProc
mov lpLstBox1, eax
;;* * * * * * * * * * * * * * * * * * * * * * * * * * *
.elseif uMsg == WM_CLOSE
.if eax == IDNO
return 0
.endif
.elseif uMsg == WM_DESTROY
invoke PostQuitMessage,NULL
return 0
.endif
invoke DefWindowProc,hWin,uMsg,wParam,lParam
ret
WndProc endp
; ########################################################################

ListBox proc a:DWORD,b:DWORD,wd:DWORD,ht:DWORD,hParent:DWORD,ID:DWORD

szText lstBox,"LISTBOX"

invoke CreateWindowEx,WS_EX_WINDOWEDGE,ADDR lstBox,0,
WS_CHILD or WS_VISIBLE or \
WS_BORDER or \
LBS_HASSTRINGS,
a,b,wd,ht,hParent,ID,hInstance,NULL

ret

ListBox endp

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

ListBoxProc proc hCtl :DWORD,
uMsg :DWORD,
wParam :DWORD,
lParam :DWORD
.if uMsg == WM_LBUTTONDOWN
mov eax, hList1
.if hCtl == eax

jmp _GoTo ;;; TRYING TO JUMP FROM THIS PROC



.endif
.endif
invoke CallWindowProc,lpLstBox1,hCtl,uMsg,wParam,lParam
ret
ListBoxProc endp
; #########################################################################

end start

; from Icz LISTBOX.ASM
Posted on 2001-11-29 00:23:55 by cmax
You could figure out how to make the jmp, but that is very bad programming. Each PROC has it's own stack frame (EBP and ESP are adjusted in a specific way). You could post the message from ListBoxProc, or set a flag to post the message later within the other PROC. I don't know the proper way, but unless you really know what's going on in the stack, the jmp is a very bad idea. Beyond that both these PROCs are executed by windows at different times for different reasons. It's like jumping trains going in opposite directions and expecting to get to the same destination - ain't going to happen. :)
Posted on 2001-11-29 01:25:49 by bitRAKE
Why don't you do a SendMessage(hWnd, WM_CREATE, ...), or a WM_NOTIFY? By using SendMessage, it will not return until the message is processed, which is the same effect you would get from a JMP.
Posted on 2001-11-29 05:21:54 by sluggy
Sound like Mission Imposible. I don't wan't to take that ride. I think i'm going to try to do sluggy idea. If that don't work I just jist have to move the code to an new proc. I guest you can't have your steak and eat it toooooo!!!
Thanks Guys
Posted on 2001-11-29 13:12:54 by cmax
cmax,

That is probably the best approach to take, the overhead is only a CALL/RET and it saves you many problems. If you bother to decompile the code and have a look at what it assembles to, you will see that if you don't use any locals or parameters, you don't get any stack overhead at all by making a procedure.

Regards,

hutch@movsd.com
Posted on 2001-11-29 15:23:32 by hutch--
Thanks Hutch...
f0dder, when you find the time could you please post some ideas or code sample about using "jump buffer". ... i love to know how the "jump buffer" work. just testing it would be very interesting to me. And thanks agan everybody. I learned a lot more than what i was after, Believe Me.
Posted on 2001-11-29 20:42:56 by cmax
Well, here's a little quick and dirty example I just threw together.
It should work :].
Posted on 2001-11-29 21:42:12 by f0dder