C++ casting error

Started by
18 comments, last by Sik_the_hedgehog 15 years ago
Quote:Original post by Rich76
No, he did not write it. For your information, the senior programmer now works for Yahoo!, lol. I don't think the decompilation gives him justice, though.


Appearances of "lol" in phrases that are not jokes or otherwise funny somehow make me nervous. But it might just be me.
Advertisement
Quote:Original post by phresnel
Quote:Original post by Rich76
No, he did not write it. For your information, the senior programmer now works for Yahoo!, lol. I don't think the decompilation gives him justice, though.


Appearances of "lol" in phrases that are not jokes or otherwise funny somehow make me nervous. But it might just be me.



Hmm, maybe you understood it differently. It's like hearing news Barney Fife became head of the FBI. But in any case, I'm sorry I made you feel nervous. :(
Quote:Original post by Rich76
Quote:Original post by phresnel
Quote:Original post by Rich76
No, he did not write it. For your information, the senior programmer now works for Yahoo!, lol. I don't think the decompilation gives him justice, though.


Appearances of "lol" in phrases that are not jokes or otherwise funny somehow make me nervous. But it might just be me.



Hmm, maybe you understood it differently. It's like hearing news Barney Fife became head of the FBI. But in any case, I'm sorry I made you feel nervous. :(


Oh, I think it was my fault. Looks like I missed some of your other posts. Never post on gamedev when undercaffeinated, lol.

Seriously, often people post "lol's" and kiddiespeak all over the place, where it is really overdosed or unfitting, which in turn looks childish, but I am wrong here, I think :S

*facepalming, rating up*
Absolutely. I agree with you. I have been known to abuse the LOL and have said to myself, "that wasn't really funny". :)
Quote:Original post by Rich76
Absolutely. I agree with you. I have been known to abuse the LOL and have said to myself, "that wasn't really funny". :)


Heh :D
Quote:Original post by Chrono1081
Quote:Original post by Rich76
I'm a C# programmer, however, I need to figure out how to fix a C++ conditional statement for a friend. C++ conditional statements look a bit confusing to me.

Can you cast the following variable as an int in a conditional statement:

CWinThread* pThread = AfxGetThread();


int v8;

if ( (*(int (**)(int))(*(DWORD *)pThread + 80))(pThread) )
{
v8 = (*(int (**)(int))(*(DWORD *)pThread + 84))(pThread);
}


Best...code...evar...:P

Man I can't decifer that. The (**) confuses me but I'm also kind of a beginner.

You don't need to be a beginner to get confused by that x_X (EDIT: I mean the whole casting in general, if you mean the (**), that's a cast to a pointer to a pointer... still no idea what is being done there though o_O)

Also how come the source code is gone? o_O That, and the only thing I can say is good luck, decompiling the game isn't exactly going to be an easy task. I know perfectly what I mean, I've done similar things already ._.'
Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.
Quote:Original post by Rich76
if ( (*(int (**)(int))(*(DWORD *)pThread + 80))(pThread) )
{
v8 = (*(int (**)(int))(*(DWORD *)pThread + 84))(pThread);
}

You are three weeks late for April Fool's Day.
Quote:
Quote:
Quote:
if ( (*(int (**)(int))(*(DWORD *)pThread + 80))(pThread) )
{
v8 = (*(int (**)(int))(*(DWORD *)pThread + 84))(pThread);
}



Man I can't decifer that. The (**) confuses me but I'm also kind of a beginner.

EDIT: I mean the whole casting in general, if you mean the (**), that's a cast to a pointer to a pointer... still no idea what is being done there though o_O


Its not a cast to a pointer to a pointer. Look at the parentheses. It is part of the type. "int (**)(int)" is a pointer-to a pointer to a function that takes and returns an integer (or integer sized argument on this architecture).
int foo(int x){}// Typedefs make function pointers, and C++ in general, more manageable.typedef int (*FunctionPtr) (int);typedef FunctionPtr *FunctionPtrPtr;int main(){    // hard way    int (*ptr)(int) = foo;    // easy way    FunctionPtr ptr = foo;    // very hard way    int (**ptr_to_ptr)(int) = &ptr;    // easier    FunctionPtrPtr ptr_to_ptr = &ptr;}

I've used integers here, but given the argument passed to the function it is more likely the parameter is a pointer type. I imagine that including pointer parameters in the above would not have helped its already dubious clarity. [smile]
Quote:Original post by DevFred
Quote:Original post by Rich76
if ( (*(int (**)(int))(*(DWORD *)pThread + 80))(pThread) )
{
v8 = (*(int (**)(int))(*(DWORD *)pThread + 84))(pThread);
}

You are three weeks late for April Fool's Day.


You are 794 minutes and 31 seconds late for blaming.

Quote:Original post by Rich76 -- Posted - 4/21/2009 9:43:02 PM
LOL, sorry guys.

It's not his fault. He's not a programmer. This is decompiled source code. pThread is the only name change of the decompilation.

Our original source code is gone.
Quote:Original post by rip-off
Quote:
Quote:
Quote:
if ( (*(int (**)(int))(*(DWORD *)pThread + 80))(pThread) )
{
v8 = (*(int (**)(int))(*(DWORD *)pThread + 84))(pThread);
}



Man I can't decifer that. The (**) confuses me but I'm also kind of a beginner.

EDIT: I mean the whole casting in general, if you mean the (**), that's a cast to a pointer to a pointer... still no idea what is being done there though o_O


Its not a cast to a pointer to a pointer. Look at the parentheses. It is part of the type. "int (**)(int)" is a pointer-to a pointer to a function that takes and returns an integer (or integer sized argument on this architecture).
*** Source Snippet Removed ***
I've used integers here, but given the argument passed to the function it is more likely the parameter is a pointer type. I imagine that including pointer parameters in the above would not have helped its already dubious clarity. [smile]

Oops, I've only taken into account the (**) which is what he mentioned and not the whole thing... Like I said, that thing is so ridicuously complex that I didn't even bother to try to understand it x_X
Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.

This topic is closed to new replies.

Advertisement