Log in

View Full Version : NASM - GUI related question


OHPen
January 29th, 2008, 13:46
Hey everyone,

actually i contiune my work on GPE (Generic Plugin Engine) and i have some probs with a log window:

this is the code to colorize in WM_CTLCOLOREDIT of my log field :

Code:

push 0x00000001
push dword[wparam]
call [SetBkMode]

push 0x0000FFFF
push dword[wparam]
call [SetTextColor]

push 0x00000000
call [CreateSolidBrush]


everything works fine the field is black and the color yellow. but a problem occurs when i delete characters. only if i delete a whole line the chars are delete but if i only delete a few chars there are not deleted

Any idea ??

Thx

Kayaker
January 29th, 2008, 16:27
Hey. Not sure why you get that problem specifically, but usually with those WM_CTLCOLOR* messages you're supposed to return a handle to a brush, so you could finish with something like

invoke GetStockObject, DC_BRUSH
ret ; return handle to the brush

OHPen
January 30th, 2008, 04:23
hi kayaker,

thx for answering. i know that have to return a brush. and thats exactly what i do by calling the CreateSolidBrush api. it returns a brush.
i haven't had time yet to try it but i will in my break.

i will post the problem when it is solved, my someone is interested in the solution.

cheers,

OHPen

dELTA
January 30th, 2008, 09:09
What is this "GPE (Generic Plugin Engine)"?

OHPen
January 30th, 2008, 10:31
@delta: generic plugin engine can be considered as a reverse engineering platform which will be base on a simple plugin architecture i developed. the platform will provide basic functionality like scripting, logging and a transformation mechanism which will be based on XSLT to convert between different data sources.

i plan to release a disassembler and a debugger plugin with the first release. the disassembler is already finished and works for x86(32 and 64 bit - AMD/INTEL). once released everyone can use it to develop its own plugins. if you start developing a new plugin you can use the functionality of already existing plugings by registering the needed functionality via the interface. if the plugin is not present the functionality is just disabled.

i see eclipse as the prototype for my idea because i developed a lot of java applications in the past and imho eclipse is the best ide which is availible atm (concerning refactoring, code templates, autocompletition, and so on and yeah only for java i know, but with the first good cdt release this will change )

I have no idea whether someone will use it but due to my work i have to code nasm and its a way to build the needed practice.

Polaris
January 30th, 2008, 10:52
Actually, it sounds really interesting... I am really looking forward to its release. Is there any limitation in terms of the language used to code the plugins?

OHPen
January 30th, 2008, 12:19
@polaris: i will provide a plugin sdk with a couple of languages, so no restriction in that direction.

@kayaker: i try your suggestion and i have the same result. i called GetStockObject with BLACK_BRUSH constant and i got the same result. it seems that there is another problem.

Maybe i described my problem not that appropriate so here a better one:

Lets assume i type following text inside my log box:

abcdefg
123
XYZANDSOON

You see my textbox contains 3 lines. the cursor is actually placed at the end of the third line. now i press the delete button one time. the cursor moves one char left. i can do that 8 times again and nothing happens expect that the cursor is now placed right from "X". Still the whole line is completly intact. If i know press the delete button one more time the third line disappears and the cursor is now placed right from the "3". so the mechnism of updating the background only work when the cariage return of a previous line was deleted.
i have no idea why this behaves in this strange way. i used log windows in c and c++ formerly without having such problems but in this case i code everything in nasm. i also compared the diassembly of a working c example with the code i generate and i can not see big differences, so its really strange.

nevertheless, just a matter of time and thats why i hate such silly problems

Kayaker
January 30th, 2008, 13:13
EDIT: I wrote this before your last edit OHPen, sorry.

I know that seemed like a redundant statement OHPen, since you're already returning a brush. But, you're getting a glitch one way or another and I was just trying to find a possible reason for it.

WM_CTLCOLOREDIT - for the returned brush, "The system uses the brush to paint the background of the edit control."

I thought perhaps the brush you are returning was causing a background effect and that was giving you the visual problems.

From some of the stuff I've read, I alway use that GetStockObject statement with any DC stuff.

http://blogs.msdn.com/oldnewthing/archive/2005/04/20/410031.aspx

Might not be the source of your problem but it was the only thing I could think of from the initial description

dELTA
January 30th, 2008, 16:30
Sounds like a very nice tool OHPen, make sure to let us know as soon as it is released (and we/you can then also add it to the CRCETL).

OHPen
January 31st, 2008, 04:47
@delta: i will be a pleasure for me to hear other peoples comment about the gpe, especially for future enhancements. when i release the first version i will upload it the collaborative tools.

@kayaker: i used sice to debug the message and there is definitivly no difference between using GetStockObject and CreateSolidBrush. So my search continues...

OHPen
January 31st, 2008, 08:11
Hoi,

finally i found a solution for my problem. It's still kind of irritating for me why i have to do it that way, because in every high level language it works with the "default" way. Anyway this solved the problem in my case:

Code:


;set flag that background color should be drawn before new text is drawn
push OPAQUE
push dword[wparam]
call [SetBkMode]

;set background color
push RGB_COLOR_BLACK
push dword[wparam]
call [SetBkColor]

;set text color
push RGB_COLOR_YELLOW
push dword[wparam]
call [SetTextColor]

;create solid brush with black color to return
push RGB_COLOR_BLACK
call [CreateSolidBrush]



Regards,

OHPen aka PAPiLLiON