资源简介
使用MemoryModule开源方案,内存加载DLL,替代LoadLibrary,不需要把文件存放在磁盘上

代码片段和文件信息
/*
* Memory DLL loading code
* Version 0.0.4
*
* Copyright (c) 2004-2014 by Joachim Bauch / mail@joachim-bauch.de
* http://www.joachim-bauch.de
*
* The contents of this file are subject to the Mozilla Public License Version
* 2.0 (the “License“); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an “AS IS“ basis
* WITHOUT WARRANTY OF ANY KIND either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is MemoryModule.c
*
* The Initial Developer of the Original Code is Joachim Bauch.
*
* Portions created by Joachim Bauch are Copyright (C) 2004-2014
* Joachim Bauch. All Rights Reserved.
*
*/
#ifndef __GNUC__
// disable warnings about pointer <-> DWORD conversions
#pragma warning( disable : 4311 4312 )
#endif
#ifdef _WIN64
#define POINTER_TYPE ULONGLONG
#else
#define POINTER_TYPE DWORD
#endif
#include
#include
#include
#ifdef DEBUG_OUTPUT
#include
#endif
#ifndef IMAGE_SIZEOF_base_RELOCATION
// Vista SDKs no longer define IMAGE_SIZEOF_base_RELOCATION!?
#define IMAGE_SIZEOF_base_RELOCATION (sizeof(IMAGE_base_RELOCATION))
#endif
#include “MemoryModule.h“
typedef struct {
PIMAGE_NT_HEADERS headers;
unsigned char *codebase;
HCUSTOMMODULE *modules;
int numModules;
int initialized;
CustomLoadLibraryFunc loadLibrary;
CustomGetProcAddressFunc getProcAddress;
CustomFreeLibraryFunc freeLibrary;
void *userdata;
} MEMORYMODULE *PMEMORYMODULE;
typedef BOOL (WINAPI *DllEntryProc)(HINSTANCE hinstDLL DWORD fdwReason LPVOID lpReserved);
#define GET_HEADER_DICTIONARY(module idx) &(module)->headers->OptionalHeader.DataDirectory[idx]
#ifdef DEBUG_OUTPUT
static void
OutputLastError(const char *msg)
{
LPVOID tmp;
char *tmpmsg;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS
NULL GetLastError() MAKELANGID(LANG_NEUTRAL SUBLANG_DEFAULT) (LPTSTR)&tmp 0 NULL);
tmpmsg = (char *)LocalAlloc(LPTR strlen(msg) + strlen(tmp) + 3);
sprintf(tmpmsg “%s: %s“ msg tmp);
OutputDebugString(tmpmsg);
LocalFree(tmpmsg);
LocalFree(tmp);
}
#endif
static void
CopySections(const unsigned char *data PIMAGE_NT_HEADERS old_headers PMEMORYMODULE module)
{
int i size;
unsigned char *codebase = module->codebase;
unsigned char *dest;
PIMAGE_SECTION_HEADER section = IMAGE_FIRST_SECTION(module->headers);
for (i=0; iheaders->FileHeader.NumberOfSections; i++ section++) {
if (section->SizeOfRawData == 0) {
// section doesn‘t contain data in the dll itself but may define
// uninitialized data
size = old_headers->OptionalHeader.SectionAlignment;
if (size > 0) {
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1669 2014-09-29 00:53 DllLoader\DllLoader.cpp
文件 4775 2014-09-29 01:10 DllLoader\DllLoader.vcxproj
文件 1532 2014-09-29 00:41 DllLoader\DllLoader.vcxproj.filters
文件 165 2014-09-23 00:46 DllLoader\DllLoader.vcxproj.user
文件 26724 2014-09-25 22:35 DllLoader\MemoryModule.cpp
文件 3237 2014-09-22 00:34 DllLoader\MemoryModule.h
文件 1729 2014-06-08 23:26 DllLoader\ReadMe.txt
文件 296 2014-06-08 23:26 DllLoader\stdafx.cpp
文件 340 2014-09-25 22:33 DllLoader\stdafx.h
文件 314 2014-06-08 23:26 DllLoader\targetver.h
文件 455 2014-09-24 00:02 MemDllTest\dllmain.cpp
文件 45 2014-09-29 00:44 MemDllTest\Export.def
文件 476 2014-09-29 00:52 MemDllTest\ImgFunc.cpp
文件 97 2014-09-29 00:44 MemDllTest\ImgFunc.h
文件 461 2014-09-29 00:43 MemDllTest\MemDllTest.cpp
文件 6301 2014-09-29 00:45 MemDllTest\MemDllTest.vcxproj
文件 1731 2014-09-23 23:57 MemDllTest\MemDllTest.vcxproj.filters
文件 165 2014-09-25 22:22 MemDllTest\MemDllTest.vcxproj.user
文件 2189 2014-09-23 22:29 MemDllTest\ReadMe.txt
文件 297 2014-09-23 22:29 MemDllTest\stdafx.cpp
文件 1232 2014-09-23 23:58 MemDllTest\stdafx.h
文件 314 2014-09-23 22:29 MemDllTest\targetver.h
文件 1442 2014-09-29 00:55 DllLoader.sln
..A..H. 26624 2014-09-29 01:10 DllLoader.v12.suo
文件 25524 2014-09-21 05:24 MemoryModule.c
文件 2743 2014-09-21 05:24 MemoryModule.h
目录 0 2015-06-09 17:38 Debug
目录 0 2015-05-16 23:37 DllLoader
目录 0 2015-05-16 23:37 MemDllTest
----------- --------- ---------- ----- ----
............此处省略2个文件信息
相关资源
- Micron颗粒详解
- 三星DDR800内存条PCB文件和原理图
- VNCX
- Adobe Illustrator CS5原版amtlib.dll文件
-
分别适用于.NET fr
amework 2.0和4.0的E - U盘强力修复器SD_MMC等内存卡超强修复
- mtrace 源码
- vmnetbridge.dll,vmnet.sys等文件
- delphi版在内存中运行exe
- 模拟首次适应动态分区存储管理方案
- 通用注入工具无驱版(HOOK注入、远程
- dll依赖项查看工具DLL DEPENDS
- zlib 最新 1.2.8 win32 win64 编译好的dll
- 操作系统共享内存实验
- 一个可以由SVCHost.exe服务调用的dll模块
- 探讨研华32位DLL驱动程序
- Delphi中融合Dll中的窗口的解决办法详
- Delphi中制作DLL中回调函数的应用
- inject.rar
- 图文手把手教你一步步用VC 2010编写通
- 图文手把手教你一步步用VC 2010编写通
- 超强内存卡格式化工具uFormat
- 易语言实现DLL的注入 与 隐藏源码
- 解决Y470/Y570更新2.12BIOS后无法识别8G内
- 基于numa架构的tcmalloc内存管理算法
- DDR4台式机内存条原理图.pdf
- 美松打印机SDK MsPrintSDK-Demo-DLL-CShare-
- Tidy2.dll安装
- VS2012OpenGL配置所需要的全部libdllh文件
- Kvsc3.exe、Kvsc3.dll病毒查杀清除方法
评论
共有 条评论