/*************************************************************
// 声明头文件
#ifndef LyShark__h
#define LyShark__h
#pragma comment(lib,"LyShark.lib");
extern "C"__declspec(dllexport) int GetProcessID(char *Name);
extern "C"__declspec(dllexport) int GetIntMemory_One(int Pid,long Base,int One);
extern "C"__declspec(dllexport) int GetIntMemory_Two(int Pid,long Base,int One,int Two);
extern "C"__declspec(dllexport) int GetIntMemory_Three(int Pid,long Base,int One,int Two,int Three);
extern "C"__declspec(dllexport) int GetIntMemory_Four(int Pid,long Base,int One,int Two,int Three,int Four);
extern "C"__declspec(dllexport) int GetIntMemory_Five(int Pid,long Base,int One,int Two,int Three,int Four,int Five);
extern "C"__declspec(dllexport) int GetIntMemory_Six(int Pid,long Base,int One,int Two,int Three,int Four,int Five,int Six);
extern "C"__declspec(dllexport) int SetIntMemory_One(int Pid,long Base,int One,int WriteValue);
extern "C"__declspec(dllexport) int SetIntMemory_Two(int Pid,long Base,int One,int Two,int WriteValue);
extern "C"__declspec(dllexport) int SetIntMemory_Three(int Pid,long Base,int One,int Two,int Three,int WriteValue);
extern "C"__declspec(dllexport) int SetIntMemory_Four(int Pid,long Base,int One,int Two,int Three,int Four,int WriteValue);
extern "C"__declspec(dllexport) int SetIntMemory_Five(int Pid,long Base,int One,int Two,int Three,int Four,int Five,int WriteValue);
extern "C"__declspec(dllexport) int SetIntMemory_Six(int Pid,long Base,int One,int Two,int Three,int Four,int Five,int Six,int WriteValue);
#endif LyShark__h
*/
//*************************************************************
#include <windows.h>
bool APIENTRY DllMain(HANDLE handle,DWORD dword,LPVOID lpvoid)
{
return true;
}
//*************************************************************
// 打开进程,取进程PID
extern "C"__declspec(dllexport) int GetProcessID(char *Name)
{
HWND Pid=::FindWindow(NULL,Name);
DWORD Retn;
::GetWindowThreadProcessId(Pid,&Retn);
return Retn;
}
//*************************************************************
// 读取内存偏移整数型
extern "C"__declspec(dllexport) int GetIntMemory_One(int Pid,long Base,int One)
{
DWORD byread;
int Value=0;
HANDLE proce=::OpenProcess(PROCESS_ALL_ACCESS,false,Pid);
LPCVOID pbase=(LPCVOID)Base;
LPVOID rbuffer=(LPVOID)&Value;
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + One);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
return Value;
}
extern "C"__declspec(dllexport) int GetIntMemory_Two(int Pid,long Base,int One,int Two)
{
DWORD byread;
int Value=0;
HANDLE proce=::OpenProcess(PROCESS_ALL_ACCESS,false,Pid);
LPCVOID pbase=(LPCVOID)Base;
LPVOID rbuffer=(LPVOID)&Value;
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + Two);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + One);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
return Value;
}
extern "C"__declspec(dllexport) int GetIntMemory_Three(int Pid,long Base,int One,int Two,int Three)
{
DWORD byread;
int Value=0;
HANDLE proce=::OpenProcess(PROCESS_ALL_ACCESS,false,Pid);
LPCVOID pbase=(LPCVOID)Base;
LPVOID rbuffer=(LPVOID)&Value;
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + Three);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + Two);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + One);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
return Value;
}
extern "C"__declspec(dllexport) int GetIntMemory_Four(int Pid,long Base,int One,int Two,int Three,int Four)
{
DWORD byread;
int Value=0;
HANDLE proce=::OpenProcess(PROCESS_ALL_ACCESS,false,Pid);
LPCVOID pbase=(LPCVOID)Base;
LPVOID rbuffer=(LPVOID)&Value;
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + Four);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + Three);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + Two);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + One);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
return Value;
}
extern "C"__declspec(dllexport) int GetIntMemory_Five(int Pid,long Base,int One,int Two,int Three,int Four,int Five)
{
DWORD byread;
int Value=0;
HANDLE proce=::OpenProcess(PROCESS_ALL_ACCESS,false,Pid);
LPCVOID pbase=(LPCVOID)Base;
LPVOID rbuffer=(LPVOID)&Value;
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + Five);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + Four);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + Three);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + Two);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + One);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
return Value;
}
extern "C"__declspec(dllexport) int GetIntMemory_Six(int Pid,long Base,int One,int Two,int Three,int Four,int Five,int Six)
{
DWORD byread;
int Value=0;
HANDLE proce=::OpenProcess(PROCESS_ALL_ACCESS,false,Pid);
LPCVOID pbase=(LPCVOID)Base;
LPVOID rbuffer=(LPVOID)&Value;
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + Six);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + Five);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + Four);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + Three);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + Two);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + One);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
return Value;
}
//*************************************************************
// 写入内存偏移整数型
extern "C"__declspec(dllexport) int SetIntMemory_One(int Pid,long Base,int One,int WriteValue)
{
DWORD byread;
int Value=0;
HANDLE proce=::OpenProcess(PROCESS_ALL_ACCESS,false,Pid);
LPCVOID pbase=(LPCVOID)Base;
LPVOID rbuffer=(LPVOID)&Value;
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + One);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
DWORD bywrite;
LPVOID wbuffer = (LPVOID)&WriteValue;
WriteProcessMemory(proce,(LPVOID)pbase,wbuffer,4,&bywrite);
return 1;
}
extern "C"__declspec(dllexport) int SetIntMemory_Two(int Pid,long Base,int One,int Two,int WriteValue)
{
DWORD byread;
int Value=0;
HANDLE proce=::OpenProcess(PROCESS_ALL_ACCESS,false,Pid);
LPCVOID pbase=(LPCVOID)Base;
LPVOID rbuffer=(LPVOID)&Value;
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + Two);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + One);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
DWORD bywrite;
LPVOID wbuffer = (LPVOID)&WriteValue;
WriteProcessMemory(proce,(LPVOID)pbase,wbuffer,4,&bywrite);
return 1;
}
extern "C"__declspec(dllexport) int SetIntMemory_Three(int Pid,long Base,int One,int Two,int Three,int WriteValue)
{
DWORD byread;
int Value=0;
HANDLE proce=::OpenProcess(PROCESS_ALL_ACCESS,false,Pid);
LPCVOID pbase=(LPCVOID)Base;
LPVOID rbuffer=(LPVOID)&Value;
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + Three);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + Two);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + One);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
DWORD bywrite;
LPVOID wbuffer = (LPVOID)&WriteValue;
WriteProcessMemory(proce,(LPVOID)pbase,wbuffer,4,&bywrite);
return 1;
}
extern "C"__declspec(dllexport) int SetIntMemory_Four(int Pid,long Base,int One,int Two,int Three,int Four,int WriteValue)
{
DWORD byread;
int Value=0;
HANDLE proce=::OpenProcess(PROCESS_ALL_ACCESS,false,Pid);
LPCVOID pbase=(LPCVOID)Base;
LPVOID rbuffer=(LPVOID)&Value;
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + Four);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + Three);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + Two);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + One);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
DWORD bywrite;
LPVOID wbuffer = (LPVOID)&WriteValue;
WriteProcessMemory(proce,(LPVOID)pbase,wbuffer,4,&bywrite);
return 1;
}
extern "C"__declspec(dllexport) int SetIntMemory_Five(int Pid,long Base,int One,int Two,int Three,int Four,int Five,int WriteValue)
{
DWORD byread;
int Value=0;
HANDLE proce=::OpenProcess(PROCESS_ALL_ACCESS,false,Pid);
LPCVOID pbase=(LPCVOID)Base;
LPVOID rbuffer=(LPVOID)&Value;
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + Five);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + Four);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + Three);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + Two);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + One);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
DWORD bywrite;
LPVOID wbuffer = (LPVOID)&WriteValue;
WriteProcessMemory(proce,(LPVOID)pbase,wbuffer,4,&bywrite);
return 1;
}
extern "C"__declspec(dllexport) int SetIntMemory_Six(int Pid,long Base,int One,int Two,int Three,int Four,int Five,int Six,int WriteValue)
{
DWORD byread;
int Value=0;
HANDLE proce=::OpenProcess(PROCESS_ALL_ACCESS,false,Pid);
LPCVOID pbase=(LPCVOID)Base;
LPVOID rbuffer=(LPVOID)&Value;
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + Six);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + Five);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + Four);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + Three);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + Two);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
pbase = (LPCVOID)(Value + One);
::ReadProcessMemory(proce,pbase,rbuffer,4,&byread);
DWORD bywrite;
LPVOID wbuffer = (LPVOID)&WriteValue;
WriteProcessMemory(proce,(LPVOID)pbase,wbuffer,4,&bywrite);
return 1;
}
版权声明:本文内容来自第三方投稿或授权转载,原文地址:https://my.oschina.net/lyshark/blog/5550630,作者:LyShark,版权归原作者所有。本网站转在其作品的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如因作品内容、版权等问题需要同本网站联系,请发邮件至ctyunbbs@chinatelecom.cn沟通。