Click here to Skip to main content
15,900,511 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: MFC Thread queue size Pin
Stephen Hewitt14-Apr-10 1:18
Stephen Hewitt14-Apr-10 1:18 
GeneralRe: MFC Thread queue size Pin
ajmalsiddiqi14-Apr-10 2:10
ajmalsiddiqi14-Apr-10 2:10 
GeneralRe: MFC Thread queue size Pin
Stephen Hewitt14-Apr-10 2:48
Stephen Hewitt14-Apr-10 2:48 
GeneralRe: MFC Thread queue size Pin
ajmalsiddiqi14-Apr-10 3:35
ajmalsiddiqi14-Apr-10 3:35 
QuestionCustom dropdown for CComboBox [modified] Pin
SpaceMonkey197012-Apr-10 21:25
SpaceMonkey197012-Apr-10 21:25 
AnswerRe: Custom dropdown for CComboBox Pin
Iain Clarke, Warrior Programmer12-Apr-10 22:57
Iain Clarke, Warrior Programmer12-Apr-10 22:57 
GeneralRe: Custom dropdown for CComboBox Pin
SpaceMonkey197013-Apr-10 0:47
SpaceMonkey197013-Apr-10 0:47 
GeneralRe: Custom dropdown for CComboBox Pin
Iain Clarke, Warrior Programmer13-Apr-10 0:56
Iain Clarke, Warrior Programmer13-Apr-10 0:56 
AnswerRe: Custom dropdown for CComboBox Pin
Code-o-mat13-Apr-10 6:18
Code-o-mat13-Apr-10 6:18 
GeneralRe: Custom dropdown for CComboBox Pin
SpaceMonkey197013-Apr-10 8:49
SpaceMonkey197013-Apr-10 8:49 
GeneralRe: Custom dropdown for CComboBox Pin
Code-o-mat13-Apr-10 9:15
Code-o-mat13-Apr-10 9:15 
QuestionConverting an image into jpeg format Pin
Srivathsa_12-Apr-10 20:57
Srivathsa_12-Apr-10 20:57 
AnswerRe: Converting an image into jpeg format Pin
Vijjuuu.12-Apr-10 21:06
Vijjuuu.12-Apr-10 21:06 
GeneralRe: Converting an image into jpeg format Pin
Iain Clarke, Warrior Programmer12-Apr-10 23:20
Iain Clarke, Warrior Programmer12-Apr-10 23:20 
GeneralRe: Converting an image into jpeg format Pin
CPallini12-Apr-10 23:35
mveCPallini12-Apr-10 23:35 
GeneralRe: Converting an image into jpeg format Pin
Vijjuuu.12-Apr-10 23:40
Vijjuuu.12-Apr-10 23:40 
GeneralRe: Converting an image into jpeg format Pin
CPallini12-Apr-10 23:47
mveCPallini12-Apr-10 23:47 
AnswerRe: Converting an image into jpeg format Pin
Cedric Moonen12-Apr-10 21:12
Cedric Moonen12-Apr-10 21:12 
AnswerRe: Converting an image into jpeg format Pin
CPallini12-Apr-10 21:21
mveCPallini12-Apr-10 21:21 
QuestionWindows date change event Pin
Vijjuuu.12-Apr-10 20:40
Vijjuuu.12-Apr-10 20:40 
AnswerRe: Windows date change event Pin
David Crow13-Apr-10 2:56
David Crow13-Apr-10 2:56 
AnswerRe: Windows date change event Pin
KarstenK13-Apr-10 4:34
mveKarstenK13-Apr-10 4:34 
QuestionC - Application reusing memory locations that have been altered Pin
Member 259847812-Apr-10 13:35
Member 259847812-Apr-10 13:35 
AnswerRe: C - Application reusing memory locations that have been altered Pin
Garth J Lancaster12-Apr-10 15:09
professionalGarth J Lancaster12-Apr-10 15:09 
GeneralRe: C - Application reusing memory locations that have been altered Pin
Member 259847812-Apr-10 17:06
Member 259847812-Apr-10 17:06 
So i have two functions

void Send(Char* Input, UINT32 DisplayType)
UINT8 SwapBits(UINT8 b)


I then call

Send("Hello", 0);


Which gets the length of Input and then
for(int i=0;i < len;i++)
{
     Input[i] = SwapBits(Input[i]);
}


While doing this i have WinDbg open and look at the pointer location for Input, lets say its x00500, you can see all 5 characters in Hello and their hex codes in Byte view.

Swapbits reverses the hi 4 bits for the low 4 bits in each UINT8 byte put in. It does this through a lot of bit manipulation, i dont have the code available now but it doesnt matter its not pertinent really. So instead of having a Hex of 0x25 fed in, it outputs 0x52. Sort of a ghetto encryption method.

All good so far.
Now call this again...
Send("Hello", 0);


if you look at the pointer it uses it does NOT create a new char* pointer. Instead it points to the one it made the first time at 0x500(still encrypted). Obviously passing in the bit swapped value just bit swaps it back. So swapbits outputs 0x25, from the previous example.

Every time you call Send("Hello", 0) it will point to 0x500 not knowing its been manipulated. It has to be some compiler thing trying to optimize these strings used multiple times only delcaring them in memory once, but its breaking everything.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.