Skip to content

Commit

Permalink
make addr finder for pszWpnEntTranslationList
Browse files Browse the repository at this point in the history
  • Loading branch information
sigsegv-mvm committed Jan 18, 2016
1 parent 48062e0 commit 1695aa5
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
45 changes: 45 additions & 0 deletions addr/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,54 @@ class CAddr_pszWpnEntTranslationList : public IAddr_Sym

virtual bool FindAddrWin(uintptr_t& addr) const override
{
// +0x00 ptr: "tf_weapon_shotgun"
// +0x04 ptr: ""
// +0x08 ptr: ""
// +0x0c ptr: ""
// +0x10 ptr: "tf_weapon_shotgun_soldier"
// +0x14 ptr: ""
// +0x18 ptr: ""
// +0x1c ptr: "tf_weapon_shotgun_hwg"
// +0x20 ptr: "tf_weapon_shotgun_pyro"
// +0x24 ptr: ""
// +0x28 ptr: "tf_weapon_shotgun_primary"

auto strscan1 = new CStringScanner(ScanResults::ALL, "tf_weapon_shotgun");
auto strscan2 = new CStringScanner(ScanResults::ALL, "tf_weapon_shotgun_soldier");
auto strscan3 = new CStringScanner(ScanResults::ALL, "tf_weapon_shotgun_hwg");
auto strscan4 = new CStringScanner(ScanResults::ALL, "tf_weapon_shotgun_pyro");
auto strscan5 = new CStringScanner(ScanResults::ALL, "tf_weapon_shotgun_primary");
CMultiScan scan1(ScanDir::FORWARD, CLibSegBounds(Library::SERVER, ".rdata"), 1,
{ strscan1, strscan2, strscan3, strscan4, strscan5 });
if (strscan1->Matches().size() != 1) { DevMsg("Fail strscan1\n"); return false; }
if (strscan2->Matches().size() != 1) { DevMsg("Fail strscan2\n"); return false; }
if (strscan3->Matches().size() != 1) { DevMsg("Fail strscan3\n"); return false; }
if (strscan4->Matches().size() != 1) { DevMsg("Fail strscan4\n"); return false; }
if (strscan5->Matches().size() != 1) { DevMsg("Fail strscan5\n"); return false; }

ByteBuf seek(0x32);
ByteBuf mask(0x32);
mask.SetDword(0x00, 0xffffffff); seek.SetDword(0x00, (uint32_t)strscan1->Matches()[0]);
mask.SetDword(0x10, 0xffffffff); seek.SetDword(0x10, (uint32_t)strscan2->Matches()[0]);
mask.SetDword(0x1c, 0xffffffff); seek.SetDword(0x1c, (uint32_t)strscan3->Matches()[0]);
mask.SetDword(0x20, 0xffffffff); seek.SetDword(0x20, (uint32_t)strscan4->Matches()[0]);
mask.SetDword(0x28, 0xffffffff); seek.SetDword(0x28, (uint32_t)strscan5->Matches()[0]);
CSingleScan scan2(ScanDir::FORWARD, CLibSegBounds(Library::SERVER, ".data"), 4, new CMaskedScanner(ScanResults::ALL, seek, mask));
if (scan2.Matches().size() != 1) { DevMsg("Fail scan2 %u\n", scan2.Matches().size()); return false; }

auto match = (const char **)scan2.Matches()[0];
if (match[1][0] != '\0') { DevMsg("Fail nullstr1\n"); return false; }
if (match[2][0] != '\0') { DevMsg("Fail nullstr2\n"); return false; }
if (match[3][0] != '\0') { DevMsg("Fail nullstr3\n"); return false; }
if (match[5][0] != '\0') { DevMsg("Fail nullstr5\n"); return false; }
if (match[6][0] != '\0') { DevMsg("Fail nullstr6\n"); return false; }
if (match[9][0] != '\0') { DevMsg("Fail nullstr9\n"); return false; }

addr = (uintptr_t)match;
return true;
}
};
static CAddr_pszWpnEntTranslationList addr_pszWpnEntTranslationList;



Expand Down
8 changes: 8 additions & 0 deletions util/buf.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class ByteBuf

void SetAll(uint8_t val);
void SetRange(int idx, int len, uint8_t val);
void SetDword(int idx, uint32_t val);

void CopyFrom(const ByteBuf& that);
void CopyFrom(const uint8_t *arr);
Expand All @@ -31,6 +32,7 @@ inline ByteBuf::ByteBuf(int size) :
m_iSize(size)
{
this->m_Buf = new uint8_t[size];
this->SetAll(0x00);
}

inline ByteBuf::~ByteBuf()
Expand Down Expand Up @@ -66,6 +68,12 @@ inline void ByteBuf::SetRange(int idx, int len, uint8_t val)
}
}

inline void ByteBuf::SetDword(int idx, uint32_t val)
{
assert(idx >= 0 && idx + 4 <= this->m_iSize);
*(uint32_t *)(this->m_Buf + idx) = val;
}


inline void ByteBuf::CopyFrom(const ByteBuf& that)
{
Expand Down

0 comments on commit 1695aa5

Please sign in to comment.