posts - 9, comments - 0, trackbacks - 0, articles - 0
  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理
re: sizeof&strlen 魏尚堂 2012-08-31 11:13
I am wrong!

有个问题请教下,我从C++语言上看到,说数组内存地址是编译时分配的,但我写了个TEST,只编译一次,每次RUN结果都不一样哟,我不理解。
0xbfb0f444
a.out
0xbfbc70c4
a.out
0xbff311e4


#include <iostream>

using std::cout;
using std::endl;

int main()
{
int art[][4] = {1,2,3,4,5,6,7,8,9,10,11,12};
cout << art << endl;
}
re: 游戏内存修改 魏尚堂 2007-09-09 19:08
#include<windows.h>
#include<stdio.h>
#include<iostream.h>

BOOL CompareAPage(DWORD dwBaseAddr,DWORD dwValue);
BOOL FindFirst(DWORD dwValue);
BOOL CompareAPage(DWORD dwBaseAddr,DWORD dwValue);
void ShowList();

BOOL FindFirst(DWORD dwValue); //在目标进程空间进行第1次查找
BOOL FindNext(DWORD dwValue); //在目标进程地址空间进行第2,3,……次查找
DWORD g_arList[1024]; //地址列表
int g_nListCnt=0; //有效地址个数
HANDLE g_hProcess; //目标进程句柄
int main(int argc,char argv[])
{
char szFileName[]="..\\hao005\\debug\\hao005.exe";
STARTUPINFO si={sizeof(si)};
PROCESS_INFORMATION pi;
::CreateProcess(NULL,szFileName,NULL,
NULL,FALSE,CREATE_NEW_CONSOLE,NULL,NULL,&si,&pi);
::CloseHandle(pi.hThread);
g_hProcess=pi.hProcess;
int iVal;
printf("Input val=");
scanf("%d",&iVal);
BOOL a=FindFirst(iVal);
ShowList();
::CloseHandle(g_hProcess);
cout<<"a="<<a<<endl;
return 0;
}

BOOL CompareAPage(DWORD dwBaseAddr,DWORD dwValue)
{//读一页
BYTE arBytes[4096];
if(!::ReadProcessMemory(g_hProcess,(LPVOID)dwBaseAddr,arBytes,4096,NULL))
{return FALSE;
cout<<"22222222222"<<endl;}



//此页不可读
//在这一页中读
DWORD* pdw;
for(int i=0;i<(int)1024*4-3;i++);
{
pdw=(DWORD*)&arBytes[i];
if(pdw[0]==dwValue) //等于要找的值
{
if(g_nListCnt>=1024)
return FALSE;
cout<<"找到了"<<endl;
//添加到全局变量
g_arList[g_nListCnt++]=dwBaseAddr+i;
}
}

return TRUE;
}
BOOL FindFirst(DWORD dwValue)
{
const DWORD dwOneGB=1024*1024*1024;
const DWORD dwOnePage=4*1024;
if(g_hProcess==NULL)
return FALSE;
DWORD dwBase;
OSVERSIONINFO vi={sizeof(vi)};
::GetVersionEx(&vi);
if(vi.dwPlatformId==VER_PLATFORM_WIN32_WINDOWS)
{dwBase=4*1024*1024;
cout<<"0000000"<<endl;}

else
{ dwBase=640*1024;
cout<<"111111111111"<<endl;}
//开始地址到2GB的地址空间进行查找
for(;dwBase<2*dwOneGB;dwBase+=dwOnePage)
CompareAPage(dwBase,dwValue);
printf("g_nListCnt=%d\n",g_nListCnt);
return TRUE;
}
void ShowList()
{
for(int i=0;i<g_nListCnt;i++)
printf("%8x\n",g_arList[i]);
}

我的就是查不到哟,if(pdw[0]==dwValue) //等于要找的值
{
if(g_nListCnt>=1024)
return FALSE;
cout<<"找到了"<<endl;
//添加到全局变量
g_arList[g_nListCnt++]=dwBaseAddr+i;
}这些好像根本没运行的,想不出了, 大哥学过帮看下。