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;
}這些好像根本沒運行的,想不出了, 大哥學過幫看下。