Hard Light Productions Forums

Off-Topic Discussion => Programming => Topic started by: blackhole on May 08, 2009, 08:45:57 pm

Title: Ah, winAPI
Post by: blackhole on May 08, 2009, 08:45:57 pm
Finishing an update for my document encryptor app, I discovered that the default behavior of the rich edit textbox control (copy selected text to clipboard) had an interesting effect of locking up any application that that text was pasted into. So I had to override that functionality and put the text into the clipboard myself to prevent my program from becoming a weapon of mass lockup.

Only winAPI locks itself up.

EDIT: I retract that statement. Even after replacing the copy code with my own, the bug pops up erractically in completely random circumstaces. First it only happens on the start menu, then it only happens OFF the start menu. Then it doesn't happen at all. Then it DOES. it's completely ****ing random.

Oh, and when I paste the copy-text-of-doom to anyone on MSN, it crashes both my client and theirs.

I can crash people's MSN by pasting text into my window.

Wow.
Title: Re: Ah, winAPI
Post by: karajorma on May 09, 2009, 04:53:48 am
With great power comes great responsibility. :p
Title: Re: Ah, winAPI
Post by: captain-custard on May 09, 2009, 04:56:18 am
is this availible for download ; it sounds like a useful  chat weapon
Title: Re: Ah, winAPI
Post by: blackhole on May 09, 2009, 11:21:27 am
Sadly the MSN thing only happened about 4 times and then the effect mysteriously vanished. Either way I finally nailed the bug for good after preventing the textbox from processing the copy request. I'm fairly sure it was copying the text to the clipboard without a null terminator because when I accidentally copied the text to the clipboard without a null terminator I achieved the same effect.

This, of course, begs the question, WHY is the default behavoir of the rich edit control to copy text to the clipboard without a null terminator? and for that matter, why does not having a null terminator on the text create a paste-of-doom with the power to crash any application except notepad? For that matter the only explanation for the MSN crash thing is that I managed to create a buffer overrun by pasting text.
Title: Re: Ah, winAPI
Post by: Bobboau on May 10, 2009, 12:45:37 am
microsoft windows.


asside from that are you useing any threads in this thing?
Title: Re: Ah, winAPI
Post by: blackhole on May 10, 2009, 01:54:59 am
microsoft windows.


asside from that are you useing any threads in this thing?

Nope. It's just a text editor. One window with a big fat huge rich textbox control.
Title: Re: Ah, winAPI
Post by: portej05 on May 10, 2009, 04:50:12 am
I can answer the 'paste of doom' part for you. NULL termination is part of the spec. If you don't follow the spec, the results are undefined.
As for why there isn't NULL termination, you'll have to show us how you're getting data out of the textbox.
Title: Re: Ah, winAPI
Post by: blackhole on May 10, 2009, 10:56:08 am
I can answer the 'paste of doom' part for you. NULL termination is part of the spec. If you don't follow the spec, the results are undefined.
As for why there isn't NULL termination, you'll have to show us how you're getting data out of the textbox.

Well that's the thing - I have no control over it. It was the default built-in behavior of the textbox itself. Without any intervention with me, hitting ctrl-C created a paste-of-doom.
Title: Re: Ah, winAPI
Post by: Bobboau on May 16, 2009, 12:51:20 am
I'm thinking you are some how overwriting the null terminator. somehow...
Title: Re: Ah, winAPI
Post by: blackhole on May 16, 2009, 03:30:17 am
I'm thinking you are some how overwriting the null terminator. somehow...

But HOW?! I don't modify or touch the textbox internals in any way whatsoever!