Zoomin is a magnifying glass for the Windows screen. Quite cute. The 32-bit MASM source is in this zip:
http://www3.telus.net/ldh/asm/zoomin.zip
and this is the exe, less than 6K:
http://www3.telus.net/ldh/asm/zoomin.exe
The idea comes from a source sample in an early version of Microsoft Visual C.
Posted on 2004-10-17 06:22:20 by LarryH
Doesn't work on Win2k, SP4. Probably forgotten to preserve esi/edi ?

Yup, saw your code - you dirty ESI in the beginning, and actually never have its must-have value in the app runtime.
Posted on 2004-10-17 06:40:45 by Ultrano
One of your problem is here:


1.
call CreateWindowEx
or eax,eax ;this is hWnd but we don't save it
jz Done ;with eax=0
...
2.
Done: leave
ret 10h

Until the point 1. there is nothing in ebp your app placed into (so it's kinda unkown value) and the same about valid return.
So trace in your mind what happen in point 2. if CreateWindowEx fails then
that "unpredicted" ebp (by leave) loaded into esp and after that in addition 10h is added to it. What would be "return address" then? - God knows.
In my system (WinNT 4.0 WS) after your CreateWindowEx fails
"leave" movs 0012FFE4 77F1B9EA RETURN to KERNEL32.77F1B9EA
to esp (and 0 from stack to ebp)
then ret 10 adds 10 so it now 0012FFF4 wich in it's turn points to 0 :)

You can easily imagine what the system do with your app after that ;)
Posted on 2004-10-17 11:00:40 by The Svin
Quite right, Ultrano and Svin. That "leave" error was especially bad :oops: . I've done some repairs and replaced the two files
http://www3.telus.net/ldh/asm/zoomin.zip
http://www3.telus.net/ldh/asm/zoomin.exe
and here is the asm alone:
http://www3.telus.net/ldh/asm/zoomin.asm .
Posted on 2004-10-17 19:27:53 by LarryH
Still crashes on XP SP2, at 0x4012F9
Posted on 2004-10-18 02:24:19 by f0dder
Gosh, I must learn to be more careful. Okay, those links now get you "Version 3", which I'm pretty sure will be okay.
The crash site was a "leave" instruction and I had blown esi.
I've made the asm file a little more orthodox, at the cost of a few bytes.
Posted on 2004-10-18 07:02:04 by LarryH
Here is one in just 4k.

KetilO
Posted on 2004-10-18 08:07:54 by KetilO
It's 4K, but it uses a dll of 2.5K, and the performance :o it never releases the mouse, the magnification is not adjustible, and there is no help text.

Can someone confirm that my Version 3 is working on the newer Windows? I wonder what other software will start crashing after I "upgrade" beyond Windows 98 :-D
Posted on 2004-10-18 18:18:13 by LarryH
Can someone confirm that my Version 3 is working on the newer Windows?

Unfortunatly, no.
It's not matter of "newer Windows" it's the matter of "NT kernel Windows" like NT 4, 5 (2000) and XP.
Posted on 2004-10-18 18:43:11 by The Svin
:( but thanks Svin. Here's "Version 4":
http://www3.telus.net/ldh/asm/zoomin.zip
http://www3.telus.net/ldh/asm/zoomin.exe
http://www3.telus.net/ldh/asm/zoomin.asm
(the zip contains the other two). Now there is no mention at all of esi or edi. If it doesn't work, I'll leave it to others to adapt the code for NT.
Posted on 2004-10-18 20:05:15 by LarryH
CreateWindowEx returns 0 and I can not see any changes about "leave" issue, it still jumps if eax==0 after CreateWindowEx to that leave and then returns to "nowhere"
Posted on 2004-10-18 23:23:54 by The Svin


call CreateWindowEx
or eax,eax
jz Done
;should be:
call CreateWindowEx
or eax,eax
jz Quit_with_EAX

Sorry about that. But I don't know why CreateWindowEx doesn't work on NT. Here's the data that goes to it:


MainWindow label dword ;in reverse order,
;gets pushed for CreateWindowEx
dd 0 ;window creation data (only for MDI)
ProgInstance2 dd ?
dd 0 ;hMenu -- no class menu
dd 0 ;no parent or owner window
dd 180 ;height
dd 180 ;width
dd 40 ;Y
dd 40 ;X
dd WS_SYSMENU
dd offset DisplayName$ ; db "ZoomIn",0
dd offset ClassName$ ; db "ZI",0
dd WS_THICKFRAME or WS_CAPTION \
or WS_MINIMIZEBOX or WS_VISIBLE

We could just rewrite this bit to use "invoke", I suppose, but I don't know why it fails in NT just the way it is. Is the class name valid? I'm guessing.
Posted on 2004-10-19 00:27:39 by LarryH
The style parameter is wrong.



MainWindow label dword ;in reverse order,
;gets pushed for CreateWindowEx
dd 0 ;window creation data (only for MDI)
ProgInstance2 dd ?
dd 0 ;hMenu -- no class menu
dd 0 ;no parent or owner window
dd 180 ;height
dd 180 ;width
dd 40 ;Y
dd 40 ;X
dd WS_SYSMENU or WS_THICKFRAME or WS_CAPTION \
or WS_MINIMIZEBOX or WS_VISIBLE
dd offset DisplayName$ ; db "ZoomIn",0
dd offset ClassName$ ; db "ZI",0
dd 0



KetilO
Posted on 2004-10-19 02:29:04 by KetilO
Got rid of dll, added menu and about box.
The exe is still only 4k
The moral must be that it is possible to size optimize a few bytes here and there until your code becomes unreadable and the optimalizations that matters get lost.

KetilO
Posted on 2004-10-19 06:01:58 by KetilO
Thanks very much KetilO. I think you may have a point, simply because my own understanding of those style flags is very sketchy :lol: Here is Version 5:
http://www3.telus.net/ldh/asm/zoomin.zip
http://www3.telus.net/ldh/asm/zoomin.exe
http://www3.telus.net/ldh/asm/zoomin.asm
The only changes from Version 4 are that my error about jz Done0 is corrected and the style fields are changed as you suggested. All the versions run fine on Win98. Can somebody test the exe on NT? Thx.
Posted on 2004-10-19 08:23:41 by LarryH
Still does not work. The program exited by itself
Posted on 2004-10-19 08:26:43 by roticv
is it just me the one who cant download this :
http://www3.telus.net/ldh/asm/zoomin.zip
??
Posted on 2004-10-22 05:33:59 by IceCold
Hi Ice, I just tried it, and it downloaded with no problem. I can send a copy by email if you like. I am at larryhammick@telus.net.
Posted on 2004-10-23 22:07:27 by LarryH
Hi, LarryH,
I tried your app on Windows XP... no good...

This is the reason: you are using for first argument of CreateWindowsEx (dwExStyle) some invalid bits. In that argument only values WS_EX_... are allowed.
Try to replace that argument with 0, and unify all bits into argument 'dwStyle'. In other words, instead of WS_SYSMENU alone, put
WS_SYSMENU or WS_THICKFRAME or WS_CAPTION or WS_MINIMIZEBOX or WS_VISIBLE
: now everything will work (rather) well.
One bug is left: if you drag the window rectangle on the left or above the little ZoomIn window, the rectangle will be lost!

Regards, bilbo
Posted on 2004-10-26 07:49:24 by bilbo
Thanks bilbo, I will try your suggestions and then test the program at an internet cafe that has XP machines.
About the rectangle, I wrote the code such that if the viewing space overlaps the original ZoomIn window, the margin is visible outside but not inside the window. If we don't take that precaution, an unwanted loop starts happening -- the program reads bits from the window, writes them, reads them again, and so on.
I guess the source could be adjusted to prevent "mouse droppings" when the viewing rectangle extends outside the screen. An alternative: don't allow the mouse pointer to get too close to the edge of the screen.
Back in a day or two...
Posted on 2004-10-29 00:36:57 by LarryH