 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
blackmorpheus Expert Cheater
Reputation: 0
Joined: 05 Apr 2008 Posts: 159
|
Posted: Sat Aug 01, 2009 9:34 am Post subject: String manipulation c++ |
|
|
Hello.
i need to generate an array that looks like this:
| Code: |
005EF568 B0 9C 5A 00 FF FF FF 7F °œZ.ÿÿÿ
005EF570 0D 00 00 00 4D 00 6F 00 ....M.o.
005EF578 72 00 65 00 20 00 53 00 r.e. .S.
005EF580 65 00 74 00 74 00 69 00 e.t.t.i.
005EF588 6E 00 67 00 73 n.g.s
|
the B0 9C 5A 00 FF FF FF 7F 0D 00 00 00 are always there.
0D resembles the length of the string "More Settings" and is variable.
This array needs to be made at runtime because i want to insert my own string instead of "More Settings" and the array size and the 9th byte depend on the size of that string.
Moreover, the string needs to be stored as an unicode string as you can see.
Can anyone help me out?
FYI:
The game that i play uses this kind of string storage, and then calls the address of the array to draw it.
a bit like this:
int __cdecl drawText_t(int address, float x, float y)
{
}
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Sat Aug 01, 2009 12:42 pm Post subject: |
|
|
Hex edit the address or hook the function and filter for that specific address then replace the address with yours.
_________________
|
|
| Back to top |
|
 |
Jani Grandmaster Cheater
Reputation: 2
Joined: 29 Dec 2006 Posts: 804
|
Posted: Sun Aug 02, 2009 12:28 am Post subject: |
|
|
C++ you want, C++ you shall have. I'd done this with some lower level stuff, like C.
| Code: | #include <iostream>
#include <string>
#include <sstream>
namespace GameX
{
class String
{
private:
static const unsigned char m_header[8];
std::string m_str;
public:
String(std::wstring ws)
{ this->Assign( ws ); }
String(const String &s)
{ this->m_str = s.m_str; }
/* Note, Data() will leave 0x00 0x00 in the end,
* but shouldn't matter, it just requires a little more space,
* but I'm being lazy.
*/
void* Data()
{ return (void*)this->m_str.c_str(); }
String& Assign(std::wstring ws);
String& operator=(std::wstring ws)
{ return this->Assign(ws); }
};
const unsigned char String::m_header[8] = { 0xB0, 0x9C, 0x5A, 0x00, 0xFF, 0xFF, 0xFF, 0x7F };
String& String::Assign(std::wstring ws)
{
int i = ws.length();
this->m_str.assign( (const char*)this->m_header, sizeof( this->m_header ) );
this->m_str.append( (const char*)&i, sizeof(int) );
this->m_str.append( (const char*)ws.c_str(), i*sizeof(wchar_t) );
return *this;
}
} // namespace GameX
int main(int argc, char *argv[])
{
GameX::String str( L"More Settings" );
std::cout << std::hex << str.Data() << std::endl;
str.Assign( L"Even More Settings" );
std::cout << std::hex << str.Data() << std::endl;
str = L"All the Setting";
std::cout << std::hex << str.Data() << std::endl;
GameX::String str2( str );
std::cout << std::hex << str2.Data() << std::endl;
return EXIT_SUCCESS;
}
| If it's worth doing, it's worth over doing!
|
|
| Back to top |
|
 |
blackmorpheus Expert Cheater
Reputation: 0
Joined: 05 Apr 2008 Posts: 159
|
Posted: Sun Aug 02, 2009 9:20 am Post subject: |
|
|
Thanks! this is exactly what i wanted. I will love you forever
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|