Originally Posted by
Apoc
I assume self-commenting code is just not a possibility eh?
Ask Cypher how most of my code looks, very very rarely do I ever comment anything. The code does it for me. And if you can't read code, then you couldn't understand what the hell was happening anyway, with or without comments.
Cypher's code is usually fairly clean (for the exception of that DBC dumper he posted earlier), though he's retarded enough to write that code in the first place.
P.S; EW!!!!! VB!!!! EWW!!!!
That was more of a PoC/"oh it works".
Clean version (and I must say I'm quite proud of how clean and terse I managed to get such a low level function)
:
Code:
const unsigned int PointerDist = 0xB, IndexDist = 0x1, LoopDist = 0x14, OpcodeRet = 0xC3, RegCallDist = 0x10, GetCallDist = 0x10, NamePtrDist = 0x1;
for(unsigned int Start = gpRedPillMgr->GetFindPattern()->GetAddress("CDBClient__RegisterBase"); ResolveLea<BYTE>(Start) != OpcodeRet; Start += LoopDist)
{
CDBClient* pDBClient = ResolveLea<CDBClient*>(Start + PointerDist);
unsigned int Index = ResolveLea<unsigned int>(Start + IndexDist);
unsigned int RegFunc = ResolveRel(Start + RegCallDist);
unsigned int GetFunc = ResolveRel(RegFunc + GetCallDist);
std::string Name = FormatString(ResolveLea<const char*>(GetFunc + NamePtrDist));
gpRedPillMgr->GetLog()->Add(str(boost::format("0x%p -> DBClient(Name: %s Index: %i)") %pDBClient %Name.c_str() %Index));
m_Databases[Index] = pDBClient;
m_DatabaseNames[Index] = Name;
m_DatabaseIndexes[Name] = Index;
}
And yes. Self explanatory (ie clean, well written) code is always better than disgusting but heavily commented code.