如何根据内存地址改写其值(不用WriteProcessMemory的方法)

Eddie780 2016-02-29 02:15:25


int abc = 50;
void mytest2()
{
int add;
add = (int)&abc;
//若不用WriteProcessMemory方法,可以操作add这个地址,改写abc的值吗?
}

...全文
96 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Eddie780 2016-02-29
  • 打赏
  • 举报
回复
谢谢各位,刚接触指针,还不会活学活用
赵4老师 2016-02-29
  • 打赏
  • 举报
回复
IsBadWritePtr The IsBadWritePtr function verifies that the calling process has write access to the specified range of memory. BOOL IsBadWritePtr( LPVOID lp, // address of memory block UINT ucb // size of block ); Parameters lp Pointer to the first byte of the memory block. ucb Specifies the size, in bytes, of the memory block. If this parameter is zero, the return value is zero. Return Values If the calling process has write access to all bytes in the specified memory range, the return value is zero. If the calling process does not have write access to all bytes in the specified memory range, the return value is nonzero. To get extended error information, call GetLastError. If the application is compiled as a debugging version, and the process does not have write access to all bytes in the specified memory range, the function causes an assertion and breaks into the debugger. Leaving the debugger, the function continues as usual, and returns a nonzero value This behavior is by design, as a debugging aid. Remarks If the calling process has write access to some, but not all, of the bytes in the specified memory range, the return value is nonzero. In a preemptive multitasking environment, it is possible for some other thread to change the process's access to the memory being tested. Even when the function indicates that the process has write access to the specified memory, you should use structured exception handling when attempting to access the memory. Use of structured exception handling enables the system to notify the process if an access violation exception occurs, giving the process an opportunity to handle the exception. QuickInfo Windows NT: Requires version 3.1 or later. Windows: Requires Windows 95 or later. Windows CE: Requires version 1.0 or later. Header: Declared in winbase.h. Import Library: Use kernel32.lib. See Also Memory Management Overview, Memory Management Functions, IsBadCodePtr, IsBadHugeReadPtr, IsBadHugeWritePtr, IsBadReadPtr
小灸舞 2016-02-29
  • 打赏
  • 举报
回复
int abc = 50; void main() { int *add = &abc; *add = 20; }
dustpg 2016-02-29
  • 打赏
  • 举报
回复
不知道lz怎么学的,这不是基本的基本么。
int a = 0;
int* b = &a;
*b = 1;
Eddie780 2016-02-29
  • 打赏
  • 举报
回复
*add = 20; 这样编译器会报错,无法直接操作内存地址

33,311

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧