簡體   English   中英

無法弄清楚如何在我的 DLL 中正確使用 memset

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

我想要做的是將一個整數(准確地說-1)寫入模式掃描提供的地址,最好使用模式掃描儀作為DWORD返回的memset 或 memcpy

這是我的代碼:

#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 );

所以你必須寫這樣的東西:

#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;
}

同樣值得指出的是,使用DWORD變量來存儲指針可能是不安全的,因為它可能導致 x64 環境中的指針截斷。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM