Page 1 of 1

Impressive 'hacks'

Posted: Sun Apr 26, 2009 9:39 pm
by earlz
Hi, I was stumbling across some of my code and saw a thing I had never seen done before, yet standard compliant. (and took at least 6 hours to figure out by trial and error)

Code: Select all

typedef void (x86Lib::x86CPU::*opcode)();
//x86Lib is a namespace. x86CPU is a class. opcode is a function pointer type
//x86CPU::Opcodes is an array of the opcode type.
void x86CPU::Cycle(){
....
		*(uint32_t*)&op_cache=ReadDword(cCS,eip);
		(this->*Opcodes[op_cache[0]])();
		//operate on the this class with the opcode functions in this class
		eip=(uint16_t)eip+1;
...

}

//you had to use a full function declaration...
InstallOp(0xF4,&x86CPU::op16_hlt);
This hack took a very long time, yet is one of the most useful I've yet to find. This made it so I could have multiple x86CPU classes and each of them have different opcodes loaded(and therefore I could have one CPU in realmode and the other in pmode or whatever)

Anyone else discovered hacks like these that somehow are just amazing and work?

Re: Impressive 'hacks'

Posted: Mon Apr 27, 2009 5:13 am
by JamesM
Hmm, in a few hours I'm going to attempt to hack into my router, install telnet and bnc and have an irc bouncer on it, although I don't think that's quite what you were suggesting!

Re: Impressive 'hacks'

Posted: Mon Apr 27, 2009 6:51 am
by earlz
JamesM wrote:Hmm, in a few hours I'm going to attempt to hack into my router, install telnet and bnc and have an irc bouncer on it, although I don't think that's quite what you were suggesting!
It could be... depends on if you find a clever way to do that in say one step lol

Re: Impressive 'hacks'

Posted: Mon Apr 27, 2009 8:55 am
by Firestryke31
There's my Firebird hack for the 5G/5.5G iPod, which was the very first hack based on the v1.3 firmware (so I had to do everything from scratch, including resizing images). It was Firebird that made me write my popular utility iPNG to convert PNG files to the iPod's internal format, as well as another utility to resize images and move them around to minimize wasted space.

Though I don't think either of those were what you meant either.

Re: Impressive 'hacks'

Posted: Mon Apr 27, 2009 6:06 pm
by Love4Boobies
I sometimes enjoy make-up sex. But I don't think that's what you meant either.

Re: Impressive 'hacks'

Posted: Mon Apr 27, 2009 6:37 pm
by Troy Martin
Booblover: Well it is a 'hack' in a sense...

Re: Impressive 'hacks'

Posted: Mon Apr 27, 2009 9:09 pm
by earlz
Love4Boobies wrote:I sometimes enjoy make-up sex. But I don't think that's what you meant either.
rofl.. I suppose it's a hack... I've never really been able to do that too well though.. but I think too much...

Re: Impressive 'hacks'

Posted: Thu Apr 30, 2009 1:24 pm
by Owen
The cast through op_cache there looks like it may violate strict aliasing requirements, which are a part of the C and C++ standards