/*************************************************************
// 声明头文件
#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; }

C++内存读写例子的更多相关文章

  1. 最简单的基于FFmpeg的内存读写的例子:内存转码器

    ===================================================== 最简单的基于FFmpeg的内存读写的例子系列文章列表: 最简单的基于FFmpeg的内存读写的 ...

  2. 最简单的基于FFmpeg的内存读写的例子:内存播放器

    ===================================================== 最简单的基于FFmpeg的内存读写的例子系列文章列表: 最简单的基于FFmpeg的内存读写的 ...

  3. (转)最简单的基于FFmpeg的内存读写的例子:内存播放器

    ffmpeg内存播放解码 目录(?)[+] ===================================================== 最简单的基于FFmpeg的内存读写的例子系列文章 ...

  4. Java直接内存读写的例子

    在Hotspot JVM上,我们能够直接对内存进行读写操作.该类的allocateMemory方法用于申请分配内存,putAddress和getAddress方法用于对直接内存进行读写. 本文将通过s ...

  5. C#操作内存读写方法的主要实现代码

    C#操作内存读写方法是什么呢?让我们来看看具体的实例实现: using System.Runtime.InteropServices; using System.Text; publicclass F ...

  6. Memory Ordering (注意Cache带来的副作用,每个CPU都有自己的Cache,内存读写不再一定需要真的作内存访问)

    Memory Ordering   Background 很久很久很久以前,CPU忠厚老实,一条一条指令的执行我们给它的程序,规规矩矩的进行计算和内存的存取. 很久很久以前, CPU学会了Out-Of ...

  7. 基于最简单的FFmpeg采样读取内存读写:存储转

    ===================================================== 基于最简单的FFmpeg样品系列读写内存列表: 最简单的基于FFmpeg的内存读写的样例:内 ...

  8. 基于最简单的FFmpeg采样读取内存读写:内存玩家

    ===================================================== 基于最简单的FFmpeg样品系列读写内存列表: 最简单的基于FFmpeg的内存读写的样例:内 ...

  9. VC++ 共享内存读写操作

    此解决方案含两个工程文件,一个是写操作工程文件,即把任意字符串写入创建的共享内存里,另外一个读操作工程文件,则是读取共享内存里的数据,从而实现了进程之间的共享内存读写操作. 源码下载

随机推荐

  1. CSS中的字体描边

    兴趣使然,突然看见网上的一些带有描边的字体,觉得有点意思,便尝试去做了下 不是什么很厉害的技巧,当然也有参考张鑫旭大神写的文章 只能感叹,css的世界还很大,很广阔 直入主题: 对于文字的描边,一般都 ...

  2. Centos7 出现Welcome to emergency mode!

    做mount挂载时,修改了  /etc/fstab 文件,导致Centos7重启时出现如下图所示错误: Welcome to emergency mode! After logging in, typ ...

  3. 矩阵游戏(game)

    矩阵游戏(game) --九校联考24OI__D1T1 问题描述 LZK发明一个矩阵游戏,大家一起来玩玩吧,有一个N行M列的矩阵.第一行的数字是1,2,-M,第二行的数字是M+1,M+2-2*M,以此 ...

  4. POJ 2368 Buttons

    题目链接:http://poj.org/problem?id=2368 Bash game (巴什博弈):当K是(L+1)的倍数时可以确保second player赢.所以这道题要找的就是在K的因子中 ...

  5. pycharm:terminal中显示乱码的解决方式

    pycharm:terminal中显示乱码的解决方式

  6. linux下maven的安装

    上传安装包到相应路径 进行解压 tar -zxvf apache-maven-3.0.5-bin.tar.gz -C /export/servers/ 修改环境变量 vim /etc/profile ...

  7. adb安装apk

    1.    安装配置 1.1安装包 下载adb.zip,解压至本机 1.2环境配置 将adb安装路径加入path中 2.    安装apk 使用数据线将Android手机与电脑连接,打开手机usb调试 ...

  8. 2019.03.26 bzoj4448: [Scoi2015]情报传递(归并排序+树链剖分)

    传送门 题意简述: 给一棵nnn个点的树,树上每个点表示一个情报员,一共有mmm天,每天会派发以下两种任务中的一个任务: 1.搜集情报:指派T号情报员搜集情报 2.传递情报:将一条情报从X号情报员传递 ...

  9. C语言函数指针与 c#委托和事件对比

    C语言: 函数指针可以节省部分代码量,写类似具有多态的函数,比如要比较最大值,如果不用函数指针就只能写比较某一类型比如int类型的max函数,这个max无法比较string的大小.函数指针的意义就不多 ...

  10. 对excel文件的读取

    poi上传文件,准备 <dependencies><dependency> <groupId>org.apache.poi</groupId> < ...