0

I'm reading a struct of a game. Then I modifiy this struct and write it back (Using RPM and WPM). If I write back the whole struct, I get crashes in the game I'm trying to hack. That's why I want to write only a part of a struct. How can this be achieved? (Ex. float r till float b)

struct GlowStruct
{
void* m_pEntity;
float r;
float g;
float b;
float m_flGlowAlpha;
unsigned char _0x0014[16];
bool m_bShouldGlow;
bool m_bUnknown;
bool m_bFullBloomRender;
unsigned char _0x0027[13];
}GlowStructA;

// Where I'm writing to. I read my struct from the same place.
WriteProcessMemory(hProcess, (LPVOID)(GlowPointer + (Glowindex * 0x38)), &GlowStructA, sizeof(GlowStruct), NULL);
  • Adjust `lpBaseAddress` by adding the offset of the variable you wish to start writing at (`&((struct GlowStruct)NULL)->m_flGlowAlpha` for example), pass in the address of the variable you want to start writing at, and reduce the number of bytes written to the number of bytes you want to write. After that, you just need to be sure your compiler and the compiler used to built the program you're hacking both agree on what `struct GlowStruct` looks like. – user4581301 Sep 16 '16 at 21:11
  • Is this also possible when I want to write multiple things at once, so for ex. from float r to float m_flGlowAlhpa? – Sebastian Speekenbrink Sep 17 '16 at 06:14

1 Answers1

0

If you only want to write the 3 floats which represent r, g and b you only want to write 12 bytes because each float is 4 bytes. You want to use the 12 bytes starting at member variable r which is at offset 0x4 of your glow struct.

That code equates to this:

WriteProcessMemory(hProcess, (LPVOID)(GlowPointer + (Glowindex * 0x38)), (void*)(&GlowStructA + 4), 12, NULL);
GuidedHacking
  • 3,628
  • 1
  • 9
  • 59