fixes to writing to memory on linux

develop
Petr Mrázek 2009-10-29 19:22:12 +00:00
parent f79076054d
commit 851e105556
2 changed files with 22 additions and 3 deletions

@ -110,8 +110,12 @@ inline
void MwriteWord (uint32_t offset, uint16_t data)
{
uint32_t orig = MreadDWord(offset);
orig &= 0xFFFF0000;
orig |= data;
/*
orig |= 0x0000FFFF;
orig &= data;
*/
ptrace(PTRACE_POKEDATA,g_ProcessHandle, offset, orig);
}
@ -119,8 +123,12 @@ inline
void MwriteByte (uint32_t offset, uint8_t data)
{
uint32_t orig = MreadDWord(offset);
orig &= 0xFFFFFF00;
orig |= data;
/*
orig |= 0x000000FF;
orig &= data;
*/
ptrace(PTRACE_POKEDATA,g_ProcessHandle, offset, orig);
}
@ -168,7 +176,7 @@ const std::string MreadCString (uint32_t offset)
r = MreadByte(offset+counter);
temp_c[counter] = r;
counter++;
} while (r);
} while (r && counter < 255);
temp_c[counter] = 0;
temp = temp_c;
return temp;

@ -94,6 +94,9 @@ bool Mread ( uint32_t offset, uint32_t size, uint8_t *target)
return true;
}
/*
* WRITING
*/
inline
void MwriteDWord (uint32_t offset, uint32_t data)
@ -106,8 +109,12 @@ inline
void MwriteWord (uint32_t offset, uint16_t data)
{
uint32_t orig = MreadDWord(offset);
orig &= 0xFFFF0000;
orig |= data;
/*
orig |= 0x0000FFFF;
orig &= data;
*/
ptrace(PTRACE_POKEDATA,g_ProcessHandle, offset, orig);
}
@ -115,8 +122,12 @@ inline
void MwriteByte (uint32_t offset, uint8_t data)
{
uint32_t orig = MreadDWord(offset);
orig &= 0xFFFFFF00;
orig |= data;
/*
orig |= 0x000000FF;
orig &= data;
*/
ptrace(PTRACE_POKEDATA,g_ProcessHandle, offset, orig);
}
@ -164,8 +175,8 @@ const std::string MreadCString (uint32_t offset)
r = MreadByte(offset+counter);
temp_c[counter] = r;
counter++;
} while (r);
} while (r && counter < 255);
temp_c[counter] = 0;
temp = temp_c;
return temp;
}
}