記憶體載入Dll

2021-08-21 20:08:15 字數 1235 閱讀 3270

分享乙份自己之前總結以前的**寫的dll記憶體載入庫c++版本:

專案要自行編譯生成lib檔案

支援:

1. win32標準dll

2. mfc dll

3. 易語言dll

4. 其他環境下生成的dll

不能加殼加密

file: include/ldr.h

/* __ldr_header__ */

#ifndef __ldr_h__

#define __ldr_h__

#ifdef _debug

#pragma comment(lib, "image.d.lib")

#else

#pragma comment(lib, "image.lib")

#endif

#ifdef _win32

#include

#include

#include

#include

#include

#else

#error current platform is not supported

#endif

typedefpvoid (__stdcall *malloc_t) (ulong);

typedefvoid (__stdcall *free_t) (pvoid);

pvoid ldrloadimage (pvoid buffer,dword size, malloc_t m = null, free_t f = null);

pvoid ldrgetprocaddress (pvoid addr,lpcstr name);

void ldrfreeimage (pvoid addr);

#endif

dll處理介面

pvoid   ldrloadimage        (pvoid buffer, dword size, malloc_t m = null, free_t f = null);

pvoid ldrgetprocaddress (pvoid addr, lpcstr name);

void ldrfreeimage (pvoid addr);

DLL記憶體載入

動態載入dll 功能 把乙個處於記憶體裡的dll直接載入並且使用。用途 免殺 靜態檔案查殺 外掛程式 防止遊戲自己hook了loadlibrary等函式 以及其他。原理 假設目前處於記憶體裡的dll是a,然後開闢乙個新的記憶體空間b,根據a的檔案頭等相關資訊,把b看做是載入記憶體。然後把資料拷貝到b...

靜態載入dll和動態載入dll

一,首先編寫dll 建win32空dll工程 標頭檔案.h extern c declspec dllexport int max int a,int b extern c 解決函式名由於不同編譯器造成的名字匹配問題,通常c 編譯器編譯時會對函式進行改名,而c編譯器不會 extern c decls...

靜態載入dll和動態載入dll

一,首先編寫dll 建win32空dll工程 標頭檔案.h extern c declspec dllexport int max int a,int b extern c 解決函式名由於不同編譯器造成的名字匹配問題,通常c 編譯器編譯時會對函式進行改名,而c編譯器不會 extern c decls...