Solved, Ty <3
Dies habe ich versucht, leider gibt er mir immer 00 bytes, daher denke ich, ich mache etwas falsch.Quote:
Verstehe das Problem nicht ganz. Wenn du die Originalbyte wiederherstellen möchtest, kopier sie halt vorher in ein eigenes Puffer, bevor du sie mit NOPs überschreibst. Dann kannst du jederzeit die Originaldaten aus deinem Puffer wieder an ihren korrekten Platz kopieren.
Ferner schlägt dein zweiter VirtualProtect-Aufruf in WriteToMemory zwingend fehl, weil du als letztes Argument NULL übergibst, s. [Only registered and activated users can see links. Click Here To Register...].
Viele Grüße
char testbytes[6];
void CopyToMemory(uintptr_t addressToStore, void const* valueToRead, int byteNum)
{
unsigned long OldProtection;
VirtualProtect((LPVOID)(addressToStore), byteNum, PAGE_EXECUTE_READWRITE, &OldProtection);
memcpy((LPVOID)addressToStore, valueToRead, byteNum);
VirtualProtect((LPVOID)(addressToStore), byteNum, OldProtection, &OldProtection);
}
CopyToMemory(test, &testbytes, 6); und nach dem ich die Checkbox unchecke -> WriteToMemory(test, testbytes, 6);
Quote:
Du hast Quell- und Ziel-Pointer vertauscht. Statt von der Originaladresse in den Puffer kopierst du von deinem Puffer zur Adresse, s. [Only registered and activated users can see links. Click Here To Register...].
Viele Grüße
void CopyToMemory(void* addressToStore, void const* valueToRead, int byteNum)
{
unsigned long OldProtection;
VirtualProtect((LPVOID)(addressToStore), byteNum, PAGE_EXECUTE_READWRITE, &OldProtection);
memcpy((LPVOID)addressToStore, valueToRead, byteNum);
VirtualProtect((LPVOID)(addressToStore), byteNum, OldProtection, &OldProtection);
}
CopyToMemory(&testbytes, &test, 6);
Quote:
Habe es nun so probiert, Problem ist, er schreibt nun irgendwelche Random Bytes rein und nicht die "Default" Bytes.Code:void CopyToMemory(void* addressToStore, void const* valueToRead, int byteNum) { unsigned long OldProtection; VirtualProtect((LPVOID)(addressToStore), byteNum, PAGE_EXECUTE_READWRITE, &OldProtection); memcpy((LPVOID)addressToStore, valueToRead, byteNum); VirtualProtect((LPVOID)(addressToStore), byteNum, OldProtection, &OldProtection); } CopyToMemory(&testbytes, &test, 6);
void CopyToMemory(void* addressToStore, void const* valueToRead, int byteNum)
{
unsigned long OldProtection;
VirtualProtect((LPVOID)(addressToStore), byteNum, PAGE_EXECUTE_READWRITE, &OldProtection);
memcpy((LPVOID)addressToStore, valueToRead, byteNum);
VirtualProtect((LPVOID)(addressToStore), byteNum, OldProtection, &OldProtection);
}
bool TestMyFunc()
{
unsigned int dummy = 0x12345678;
unsigned int _i_need_to_be_dummy = 0;
CopyToMemory(&_i_need_to_be_dummy, &dummy, sizeof(dummy));
return _i_need_to_be_dummy == dummy;
}
if (!TestMyFunc())
{
// nope i did something wrong
}
Habe ich 1:1 so probiert, resultat von &dummy sowie &_i_need_to_be_dummy über coutQuote:
Code:void CopyToMemory(void* addressToStore, void const* valueToRead, int byteNum) { unsigned long OldProtection; VirtualProtect((LPVOID)(addressToStore), byteNum, PAGE_EXECUTE_READWRITE, &OldProtection); memcpy((LPVOID)addressToStore, valueToRead, byteNum); VirtualProtect((LPVOID)(addressToStore), byteNum, OldProtection, &OldProtection); } bool TestMyFunc() { unsigned int dummy = 0x12345678; unsigned int _i_need_to_be_dummy = 0; CopyToMemory(&_i_need_to_be_dummy, &dummy, sizeof(dummy)); return _i_need_to_be_dummy == dummy; } if (!TestMyFunc()) { // nope i did something wrong }
Es macht auch keinen Sinn die beiden Adressen zu vergleichen.Quote:
Habe ich 1:1 so probiert, resultat von &dummy sowie &_i_need_to_be_dummy über cout
ergeben leider aber wieder nicht die richtigen bytes :/
Quote:
Es macht auch keinen Sinn die beiden Adressen zu vergleichen.
Poste mal deinen kompletten Code, du machst wahrscheinlich nur irgendwo einen recht dummen Fehler.
void WriteToMemory(uintptr_t addressToWrite, void const* valueToWrite, int byteNum)
{
unsigned long OldProtection;
VirtualProtect((LPVOID)(addressToWrite), byteNum, PAGE_EXECUTE_READWRITE, &OldProtection);
memcpy((LPVOID)addressToWrite, valueToWrite, byteNum);
VirtualProtect((LPVOID)(addressToWrite), byteNum, OldProtection, &OldProtection);
}
char origbytes[6] = {0};
DWORD test = FindPattern(testmodule, testsig, testmask);
if (test != 0)
{
WriteToMemory((uintptr_t)origbytes, test, 6);
}
private: System::Void checkBox1_CheckedChanged(System::Object^ sender, System::EventArgs^ e) {
if (checkBox1->Checked == true)
{
char nopbytes[] = "\x90\x90\x90\x90\x90\x90";
WriteToMemory(test, nopbytes, 6);
}
else
{
WriteToMemory(test, origbytes, 6);
}
}
Hat geklappt, musste zwar test von dword noch konvertieren, da er nicht mit void will, aber es geht nun! :DQuote:
Müsste so gehen:
Code:void WriteToMemory(uintptr_t addressToWrite, void const* valueToWrite, int byteNum) { unsigned long OldProtection; VirtualProtect((LPVOID)(addressToWrite), byteNum, PAGE_EXECUTE_READWRITE, &OldProtection); memcpy((LPVOID)addressToWrite, valueToWrite, byteNum); VirtualProtect((LPVOID)(addressToWrite), byteNum, OldProtection, &OldProtection); } char origbytes[6] = {0}; DWORD test = FindPattern(testmodule, testsig, testmask); if (test != 0) { WriteToMemory((uintptr_t)origbytes, test, 6); } private: System::Void checkBox1_CheckedChanged(System::Object^ sender, System::EventArgs^ e) { if (checkBox1->Checked == true) { char nopbytes[] = "\x90\x90\x90\x90\x90\x90"; WriteToMemory(test, nopbytes, 6); } else { WriteToMemory(test, origbytes, 6); } }
WriteToMemory((uintptr_t)&origbytes, (uint32_t*)test, 6);