1. The binary representation of 2 is 10 and of 6 is 110. As the length of "10" is smaller, so add a '0' to it making it "100', to make the length of binary representations equal. XOR of 100 and 110 gives 010 which is 2.
You can get the length of each value (remember to save the originals) by repeatedly shifting one bit right until it is zero. You then shift the smaller value left by the difference between their lengths. That will give you two integers of the same length. All you need then is to create the XOR of the two and print it out.
unsignedint myxor(unsignedint a, unsignedint b)
if ( a < b) swap(a,b);
// now a >= b
int lab = 0; // difference of a and b binary length
int ca = a;
int cb = b;
while ( ca )
if ( cb == 0 )
ca >>= 1;
cb >>= 1;
return ( a ^ (b << lab));
In the C/C++ code below debugptr comes up as null however when I go into Disassembly the value return in register rax from __imp_Cwnd::FromHandle is correct as I place an eyecatcher "Debug" in CprogDebug and when I go to look at that memory address I can see that literal in the memory
more so when I got to rsi + 118h the value of the rax register is there
When I do a quickwatch in VS on Debugptr its NULL
BTW I do a get an exception utilizing debugptr as a pointer
Wow you are good I’ll do it again but I was still at a breakpoint when I copied the text while was tracing and verifying the output I’m in bed as it’s 2:37 in the morning so I’ll do it again tommorow or in the morning
I re-built its the the code at 5:52 est I just tested it did a disassembly it the same disassembly I posted it strange because the value returned from Cwnd::FromHandle has a valid return in rax I check rsi + 118 h and that value has the rax register also nore rsi + 118h = FA2C48D158 however I do quick watch on &debugptr and that value is null the value of &debugptr is 7FFd34e61810 which is strange shouldn't rsi + 118h == &debugptr ???
First let just say what I am trying to accomplish I have CProgDebug object of Cwnd type I am trying to save all the info in that Object I have two modal dialogboxes which gather info that I need so when I create these two Modal Dialog Boxes one after the other I create them with pParent being = to the Created Dialog the documentation says in that Case if pParent is not equal to NULL the pParent Cwnd will be the Parent or Owner maybe I should try debugptr = temptr->GetParent(); and see what Happens I think your logic is right though
Richard as you noted the assembly didn't match the source It lead me to insert #pragma optimize("",off) and #pragma optimize ('',on) around the function the call to __imp CWnd::FromHandle disappeard and debugptr had the right value