Ok, I'll post some parts of the source code. Some of my own.
Here's the thing that patches a byte at given memory address.
Code:
void PatchByte(DWORD dwAddress, BYTE patch)
{
DWORD dwProt;
VirtualProtect((void*)dwAddress, sizeof(patch), PAGE_EXECUTE_READWRITE, &dwProt);
*(BYTE*)dwAddress=patch;
VirtualProtect((void*)dwAddress, sizeof(patch), dwProt, &dwProt);
}
And another code to patch the floating point or DWORD at given address. (ALL 4 byte data types)
Code:
void PatchDWORD(DWORD dwAddress, DWORD patch)
{
DWORD dwProt;
VirtualProtect((void*)dwAddress, sizeof(patch), PAGE_EXECUTE_READWRITE, &dwProt);
*(BYTE*)dwAddress=patch;
VirtualProtect((void*)dwAddress, sizeof(patch), dwProt, &dwProt);
}
For each data types, depending on the size of them, I have have to call PatchDWORD for patching DWORDs, FLOATS, ints which is equal to 4 bytes.
To write only a single byte/ char I would have to call PatchBYTE.
What I would like to do is:
By typing Patch<DWORD>(MemoryAddress, (DWORD)data) I would like to get DWORD (4 bytes) inserted into the specfic memory address.
And by type Patch<BYTE>(MemoryAddress, (BYTE)data) I would like to get a single byte or char inserted into the specific memory address.
Please don't be harsh on me. I cannot provide the whole source though. But here are some parts of it.
Code:
for(int i = 0; i < 1; i++) CMemory::InstallPatch<DWORD>( ARR_CCoronaStore_63[i], ADDR_CCorona_Store + 0x63);
for(int i = 0; i < 1; i++) CMemory::InstallPatch<DWORD>( ARR_CCoronaStore_64[i], ADDR_CCorona_Store + 0x64);
for(int i = 0; i < 1; i++) CMemory::InstallPatch<DWORD>( ARR_CCoronaStore_65[i], ADDR_CCorona_Store + 0x65);
CMemory::InstallPatch<BYTE>(0x544591, MAX_CORONAS);
CMemory::InstallPatch<BYTE>(0x5425BA, MAX_CORONAS);