简体   繁体   English

无法弄清楚如何在我的 DLL 中正确使用 memset

[英]Cant figure out how to properly use memset inside of my DLL

What I'm trying to do is write an integer (-1, to be exact) to the address provided by the pattern scan preferably using memset or memcpy which is returned by the pattern scanner as a DWORD我想要做的是将一个整数(准确地说-1)写入模式扫描提供的地址,最好使用模式扫描仪作为DWORD返回的memset 或 memcpy

Here is my code:这是我的代码:

#include <iostream>
#include "memory.h"

DWORD paranoid = sigScan("\x00\x00\x70\x41\x01\x00\x00\x00","xxxxxxxx");

void initiate() {
std::cout<<paranoid<<std::endl;
memset(paranoid,-1,8);//were I'm having issues at (I don't understand this function)
std::cout<<"toggled paranoid"<<std::endl;
}

void * memset ( void * ptr, int value, size_t num ); void * memset ( void * ptr, int value, size_t num );

So you have to write something like that:所以你必须写这样的东西:

#include <iostream>
#include "memory.h"

void* paranoid = (void*)sigScan("\x00\x00\x70\x41\x01\x00\x00\x00","xxxxxxxx");

void initiate() {

if(paranoid)
    memset(paranoid,-1, sizeof(int));//were I'm having issues at (I don't understand this function)
std::cout<<"toggled paranoid"<<std::endl;
}

Also its worth pointing out, that use of the DWORD variable to store pointer is potentially unsafe, because it could lead to the pointer truncation in the x64 environment.同样值得指出的是,使用DWORD变量来存储指针可能是不安全的,因为它可能导致 x64 环境中的指针截断。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM