I'm not sure why win 2k wont run my programs but every time i make something in assembly it being very simple programs right now like a run dialog with a drag drop interface and such. Well the program crashes on win 2k, why wont it run any ideas like compatibility issues between win 9x and win 2k programs.
Posted on 2001-10-23 09:38:24 by Crackpipe2k
Hi Crackpipe2k

Win2k is very picky about register preservation. Always remember to save ebx, esi and edi in DlgProc or WndProg or other callbacks.

KetilO
Posted on 2001-10-23 09:45:37 by KetilO
so before i call the main dialog i should save ebx, esi and edi. How would i save them ? push them to the stack ? move them some where else ?
I am still a newbie so any exmaple of how it should be performed that would help me under stand would be appreciated. Thanks though now you have given me some where to look into why my prog doesn't work. I remember that i saw Mov eax,eax in some of the eamples with the masm package something about being needed to run in NT. Is that kinda what i have to do ?
Posted on 2001-10-23 09:56:43 by Crackpipe2k
Hi Crackpipe2k


If you use masm then:

WndProc uses ebx esi edi,hWnd:HWND ......

will do. You don't need to push/pop, masm will do it for you.

KetilO
Posted on 2001-10-23 10:52:23 by KetilO
Hi,
you can save all register via pushad.
You can restore all register via popad.

For me it is a good solution to use vars
instead of register between API call's.

Yes KetilO, win2k is restricted, for example I encounter a situation where I must init a buffer
on API "GetOpenFileName" to zero.

But this are easy errors, because most programs
don't crash.


TD
Posted on 2001-10-23 11:02:33 by Test Department
thanks for the answers now my prog runs on win2k I've never seen such a helpful place.
Posted on 2001-10-24 07:35:55 by Crackpipe2k
TestDepartment:
pushad/popad = lazy, unless you really use all reigsters. If not, you
might as well go code in C and let the compiler handle preservation for you ;).

CrackPipe, the stack is definitely the place to store preserved registers.
Sure, storing them in scratch dwords in your data section will work,
but your code+data will be a little bigger, and you will be unable to
use the code with multithreading. Adding the "uses ebx, esi, edi"
saves on stack. Only add the registers you destroy. You can destroy
eax,ebx,ecx as you see fit, without preserving them.
Posted on 2001-10-24 08:10:07 by f0dder
Thank you, i used the "uses" method pointed out by KetilO it just seemed the best way at the time. Now i see why, and i have better understanding of what win 2k wont like me doing but i can see that there will probally be more probs with my programs and win 2k in the future. Mainly because i don't know everything it doesn't allow.
Posted on 2001-10-24 08:14:46 by Crackpipe2k
win2k compatibility is just about playing by the rules :). No direct
port access, be careful if writing to to other processes' memory.
Set "structure.size" members on API calls that expect this (most APIs
that take structures as arguments). Always fill in all required fields
(or see GetOpenFileName and friends b0rk)... it's not all that hard, really :).
Posted on 2001-10-24 08:21:44 by f0dder