ok, i had some problems with this function, it would only process one handle even if i returned the TRUE value, i noticed on the board that other people had/have the same problem, but couldnt find a solution anywhere, so i started doing some research with my debugger...

i've discovered that EnumWindows uses ebx to rember at which window it is, so if you use EBX in your callback function you need to restore it to its value at the beginning of the callback function.

Thought i'd let you people know :)
Posted on 2004-12-23 14:33:09 by Scorpie
I thoguht as a safe rule, if it is a calback function you should preserver edi, esi and ebx. Best to follow that rule.
Posted on 2004-12-23 18:29:35 by roticv
You can also rely on these registers being preserved by all windows functions.
Posted on 2004-12-23 20:57:44 by QuantumMatrix1024
You can also rely on these registers being preserved by all windows functions.

Shouldn't it be
You can also rely on these registers being overwritten/used by all windows functions.
? :)
Scorpie, thanks about the note :wink:
Posted on 2004-12-24 01:18:36 by Ultrano
Nope, it shouldn't. Not the ones you're supposed to use, anyway.
Posted on 2004-12-24 10:53:43 by Sephiroth3
The rule is that you must preserve ESI, EDI and EBX if you use them as they are used by Windows for callbacks (enums and dialog procs etc...). You can freely use EAX, EDX and ECX as no Windows function expects them to be preserved, at least no one has found one yet AFAIK. If you are using a stack frame you should also pay attention to EBP and ESP as they are used to maintain stack pointers.

Windows will always preserve the ESP, EBP, ESI, EBX and EDI registers and may or may not modify the others. In some cases a particular version of Windows may not require a register to be preserved or may not modify others but other versions will so you are best to always follow the guidelines or you will eventually get nasty GPFs.
Posted on 2004-12-24 11:08:40 by donkey
offcourse, how could i have been so blind :oops:

i knew you had to preserve EBX, ESI and EDI in a dll but it just didnt cross my mind this would also go for callback functions....

still happy i figured it out myself :)
Posted on 2004-12-27 11:46:35 by Scorpie