 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
Pantaleon Newbie cheater
Reputation: 0
Joined: 08 Mar 2009 Posts: 17 Location: New York
|
Posted: Fri Mar 27, 2009 11:46 am Post subject: How to Write Whith Pointers In Visual C++ 2008? |
|
|
Hello again , I encounter a problem, and is as follows:
I have a code to edit the memory of a process "WriteProcessMemory", but only produces static address, but not dynamic, here is my problem, I need to edit an address that is "points".
Well that's my problem, I need to edit an address that has 3 pointers, and another that is 1 pointer ... There is some code for this? hope can help me, sorry for the inconvenience, thank you later.
Here My Problems:
| Description: |
|
| Filesize: |
9.85 KB |
| Viewed: |
4015 Time(s) |

|
| Description: |
|
| Filesize: |
14.77 KB |
| Viewed: |
4017 Time(s) |

|
|
|
| Back to top |
|
 |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Fri Mar 27, 2009 11:59 am Post subject: Re: How to Write Whith Pointers In Visual C++ 2008? |
|
|
| Pantaleon wrote: | Hello again , I encounter a problem, and is as follows:
I have a code to edit the memory of a process "WriteProcessMemory", but only produces static address, but not dynamic, here is my problem, I need to edit an address that is "points".
Well that's my problem, I need to edit an address that has 3 pointers, and another that is 1 pointer ... There is some code for this? hope can help me, sorry for the inconvenience, thank you later.
Here My Problems: |
push eax
mov eax,[variablecontainingthebase]
mov eax,[eax]
mov eax,[eax+offset]
mov eax,[eax+offset]
...etc
mov eax,[eax+offset]
mov outvar,eax
pop eax
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Fri Mar 27, 2009 3:29 pm Post subject: |
|
|
Example...
Read 025069BC, in your picture it holds 03C319BC. Add 7C to it and you end up at 03C31A38... repeat until you can't go any further.
Just use ReadProcessMemory, easy.
|
|
| Back to top |
|
 |
Pantaleon Newbie cheater
Reputation: 0
Joined: 08 Mar 2009 Posts: 17 Location: New York
|
Posted: Fri Mar 27, 2009 5:52 pm Post subject: |
|
|
| slovach wrote: | Example...
Read 025069BC, in your picture it holds 03C319BC. Add 7C to it and you end up at 03C31A38... repeat until you can't go any further.
Just use ReadProcessMemory, easy. |
Oh thanks for the clarification, I did but I see that you have to read 4 bytes just as I do?, Must be type "DWORD"? I hope that, soon, thanks for the help.
|
|
| Back to top |
|
 |
BanMe Master Cheater
Reputation: 0
Joined: 29 Nov 2005 Posts: 375 Location: Farmington NH, USA
|
|
| Back to top |
|
 |
Pantaleon Newbie cheater
Reputation: 0
Joined: 08 Mar 2009 Posts: 17 Location: New York
|
Posted: Sat Mar 28, 2009 9:29 pm Post subject: WTF...!!! |
|
|
| BanMe wrote: | Coded by Irwin(ReadPointer).. All Credits To Him for the Read Pointer.
It is to be used from injected code or module within a process.. it cannot be used remotely on a process..
Coded by BanMe(WritePointer) heavily influencedd by irwins design so most credits also goto him on this one to .. :]
I would greatly appreciate opinions or fixs as it took me a lil while to understand SAL enough to have a decent solution. hopefuly appoved by irwin.. :{no high hopes here though}
| Code: |
#include <stdarg.h>
#define OFFSETS_END 0xDEADBEEF
__checkReturn BOOL _ReadPointer(__out PULONG_PTR pulValue, __in LPCVOID lpcvBase, ...)
{
ULONG_PTR ulTemp;
va_list pArguments;
BOOL bRET;
int iOffset;
__try {
ulTemp = (ULONG_PTR)lpcvBase;
va_start(pArguments, lpcvBase);
while ((iOffset = va_arg(pArguments, int)) != OFFSETS_END)
ulTemp = *(ULONG_PTR*)((*(ULONG_PTR*)ulTemp) + iOffset);
va_end(pArguments);
*pulValue = ulTemp == (ULONG_PTR)lpcvBase ? *(ULONG_PTR*)ulTemp : ulTemp;
bRET = TRUE;
}
__except(EXCEPTION_EXECUTE_HANDLER) {
bRET = FALSE;
}
return bRET;
}
__checkReturn BOOL _WritePointer(__in_bcount(bLength) LPCVOID Buffer,int bLength, __in LPCVOID lpcvBase,...)
{
LONG_PTR ulTemp;
BYTE *WriteCache;
BYTE BTest,TByte;
va_list pArguments;
BOOL bRet = FALSE;
int iOffset,bOffset = 0;
__try {
ulTemp = (ULONG_PTR)lpcvBase;
va_start(pArguments,lpcvBase);
while((iOffset =va_arg(pArguments,int) != OFFSET_END))
{
ulTemp = *(ULONG_PTR*)((*(ULONG_PTR*)ulTemp)+iOffset);
}
va_end(pArguments);
WriteCache = (bLength > 0) ? (BYTE*)ulTemp: 0;
do
{
BTest = *(BYTE*)Buffer;
TByte = *WriteCache;
bRet = (BTest == TByte) ? TRUE:FALSE;
if(!bRet)
{
*(BYTE*)ulTemp = BTest;
Buffer = (LPCVOID)((DWORD*)Buffer+1);
}
}while(!bRet);
}
__except(EXCEPTION_EXECUTE_HANDLER) {
bRet = FALSE;
}
return bRet;
}
#define WritePointer(x,y,...)_WritePointer(x,y,__VA_ARGS__,OFFSETS_END)
#define ReadPointer(x, y, ...) _ReadPointer(x, y, __VA_ARGS__, OFFSETS_END)
|
kind regards BanMe |
in than language this done?... Amazing very good code, the question is: Does it work? xD!
Can be moved to Visual C++ 2008? or Delphi 7?.
Thanks for your help, I expect a prompt answer =D!
|
|
| Back to top |
|
 |
BanMe Master Cheater
Reputation: 0
Joined: 29 Nov 2005 Posts: 375 Location: Farmington NH, USA
|
Posted: Sun Mar 29, 2009 11:25 am Post subject: |
|
|
well as it turned out my code for _WritePointer was dead wrong...that was writing to the addressof the pointer..not writing to teh value of the pointer...so my mistake..sorry for any confusion..but here is a working sample of WritePointer and WriteOffset...next to come is ReadOffset ..but that'll wait til later.. again sorry for any confusion caused on my part..
| Code: |
#include <windows.h>
#include <stdarg.h>
#define OFFSET_END 0xDEADBEEF
__checkReturn BOOL _WriteAtOffset(__in_bcount(bLength) LPCVOID Buffer,__in size_t bLength, __in LPCVOID lpcvBase,...);
__checkReturn BOOL _WritePointer(__in_bcount(bLength) LPCVOID Buffer,__in size_t bLength, __in LPCVOID lpcvBase,...);
__checkReturn BOOL _ReadPointer(__out PULONG_PTR pulValue, __in LPCVOID lpcvBase, ...);
#define WriteOffset(x,y,z,...)_WriteAtOffset(x,y,z,__VA_ARGS__,OFFSET_END)
#define WritePointer(x,y,z,...)_WritePointer(x,y,z,__VA_ARGS__,OFFSET_END)
#define ReadPointer(x, y, ...) _ReadPointer(x, y, __VA_ARGS__, OFFSET_END)
int _main()
{
char* szString = "SomeExe.exe\0";
char* szFile = "SomeDll.dll\0";
WritePointer(szFile,strlen(szFile),(ULONG_PTR*)szString);
return 0;
}
__checkReturn BOOL _ReadPointer(__out PULONG_PTR pulValue, __in LPCVOID lpcvBase, ...)
{
ULONG_PTR ulTemp;
va_list pArguments;
BOOL bRET;
int iOffset;
__try {
ulTemp = (ULONG_PTR)lpcvBase;
va_start(pArguments, lpcvBase);
while ((iOffset = va_arg(pArguments, int)) != OFFSET_END)
ulTemp = *(ULONG_PTR*)((*(ULONG_PTR*)ulTemp) + iOffset);
va_end(pArguments);
*pulValue = ulTemp == (ULONG_PTR)lpcvBase ? *(ULONG_PTR*)ulTemp : ulTemp;
bRET = TRUE;
}
__except(EXCEPTION_EXECUTE_HANDLER) {
bRET = FALSE;
}
return bRET;
}
__checkReturn BOOL _WritePointer(__in_bcount(bLength) LPCVOID Buffer,__in size_t bLength, __in LPCVOID lpcvBase,...)
{
ULONG oProt,oProtect;
ULONG_PTR ulTemp;
va_list pArguments;
BOOL bRet = FALSE;
MEMORY_BASIC_INFORMATION mbi;
int iOffset;
if(!bLength)
{
return bRet;
}
__try
{
ulTemp = (ULONG_PTR)lpcvBase;
va_start(pArguments,lpcvBase);
while((iOffset =va_arg(pArguments,int) != OFFSET_END))
{
ulTemp = *(ULONG_PTR*)((*(ULONG_PTR*)ulTemp)+iOffset);
}
va_end(pArguments);
memset(&mbi,0,sizeof(MEMORY_BASIC_INFORMATION));
if(VirtualQuery((LPCVOID)ulTemp,&mbi,sizeof(mbi)) > 0)
{
if(mbi.AllocationProtect & PAGE_EXECUTE_READWRITE)
{
memcpy((void*)ulTemp,(void*)Buffer,bLength);
}
else
{
if(VirtualProtect((LPVOID)ulTemp,bLength,PAGE_EXECUTE_READWRITE,&oProtect))
{
memcpy((void*)ulTemp,(void*)Buffer,bLength);
if(VirtualProtect((LPVOID)ulTemp,bLength,mbi.AllocationProtect,&oProt))
{
bRet = TRUE;
}
else
{
bRet = FALSE;
}
}
else
{
bRet = FALSE;
}
}
}
else
{
bRet = FALSE;
}
}
__except(EXCEPTION_EXECUTE_HANDLER) {
bRet = FALSE;
}
return bRet;
}
__checkReturn BOOL _WriteAtOffset(__in_bcount(bLength) LPCVOID Buffer,__in size_t bLength, __in LPCVOID lpcvBase,...)
{
ULONG oProt,oProtect;
ULONG_PTR ulTemp;
BYTE *WriteCache;
BYTE *BTest;
va_list pArguments;
BOOL bRet = FALSE;
MEMORY_BASIC_INFORMATION mbi;
int iOffset;
__try
{
ulTemp = (ULONG_PTR)lpcvBase;
va_start(pArguments,lpcvBase);
while((iOffset =va_arg(pArguments,int) != OFFSET_END))
{
ulTemp = *(ULONG_PTR*)((*(ULONG_PTR*)ulTemp)+iOffset);
}
va_end(pArguments);
memset(&mbi,0,sizeof(MEMORY_BASIC_INFORMATION));
if(VirtualQuery((LPCVOID)ulTemp,&mbi,sizeof(mbi)) > 0)
{
if(mbi.AllocationProtect & PAGE_EXECUTE_READWRITE)
{
WriteCache = (bLength > 0) ? (BYTE*)ulTemp: 0;
BTest = (BYTE*)Buffer;
for(UINT_PTR i = 0;i<bLength;i++)
{
*(BYTE*)WriteCache = *BTest;
WriteCache++;
BTest++;
}
bRet = (*BTest == *WriteCache) ? TRUE : FALSE;
}
else
{
if(VirtualProtect((LPVOID)ulTemp,bLength,PAGE_EXECUTE_READWRITE,&oProtect))
{
WriteCache = (bLength > 0) ? (BYTE*)ulTemp: 0;
BTest = (BYTE*)Buffer;
for(UINT_PTR i = 0;i<bLength;i++)
{
*(BYTE*)WriteCache = *BTest;
WriteCache++;
BTest++;
}
if(VirtualProtect((LPVOID)ulTemp,bLength,mbi.AllocationProtect,&oProt))
{
bRet = (*BTest == *WriteCache) ? TRUE : FALSE;
}
else
{
bRet = FALSE;
}
}
else
{
bRet = FALSE;
}
}
}
else
{
bRet = FALSE;
}
}
__except(EXCEPTION_EXECUTE_HANDLER) {
bRet = FALSE;
}
return bRet;
}
|
_________________
don't +rep me..i do not wish to have "status" or "recognition" from you or anyone.. thank you. |
|
| 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
|
|