/*************************************************************
// 声明头文件
#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. Java多线程02(线程安全、线程同步、等待唤醒机制)

    Java多线程2(线程安全.线程同步.等待唤醒机制.单例设计模式) 1.线程安全 如果有多个线程在同时运行,而这些线程可能会同时运行这段代码.程序每次运行结果和单线程运行的结果是一样的,而且其他的变量 ...

  2. 机器学习--Lasso回归和岭回归

    之前我们介绍了多元线性回归的原理, 又通过一个案例对多元线性回归模型进一步了解, 其中谈到自变量之间存在高度相关, 容易产生多重共线性问题, 对于多重共线性问题的解决方法有: 删除自变量, 改变数据形 ...

  3. PHPEXCEL读出数据是PHPExcel_RichText类型

    今天在做导入EXCEL数据时,而且单元格里的数据类型改成文本类型后,在PHPEXCEL读出来的是PHPExcel_RichText类型的,这类型使getValue()是不管用了,因为这时候getVal ...

  4. selenium+java定位163/126邮箱元素显示定位失败解决

    开始在没有进入iframe时,用任何方法定位163/126邮箱登录页面的元素都不可能定位到,eclipse工作台会显示Unable to locate element:…… 这种情况我遇到了两种原因: ...

  5. 将IP转换为16进制,用于IPv4-IPv6

    # --*-- coding: utf-8 --*--# create by xiaocaiji while 1: str_ip = input("input a IP:") li ...

  6. 图解Golang的GC算法

    虽然Golang的GC自打一开始,就被人所诟病,但是经过这么多年的发展,Golang的GC已经改善了非常多,变得非常优秀了. 以下是Golang GC算法的里程碑: v1.1 STW v1.3 Mar ...

  7. TwinStickShooter的一些问题

    TwinStickShooter模板应该是比较好的了解UE基本Pawn和Projectile的一个C++例子.以下是一些问题. 一.这个模板以纯C++编写,没有蓝图,所以第一步,我想测试下如何引用蓝图 ...

  8. Java和C++的数组比较

    Java:数组的定义:如下两种方式都可以:int array[];int[] array; 注意:数组在定义后,不能直接使用.必须在初始化后才能使用.初始化有两种方式:1.静态初始化:int arra ...

  9. 前端js收藏

    1 爱心特效 <script type="text/javascript"> (function(window,document,undefined){ var hea ...

  10. Jmeter监控服务器-CPU,Memory,Disk,Network性能指标

    本文主要说一下如何通过JMeter插件来监控服务器CPU.内存.磁盘.网络等相关资源. 一.下载 首先进入网址https://jmeter-plugins.org/downloads/old/  下载 ...