dll文件怎么注入,简单的dll注入教程

首页 > 教育 > 作者:YD1662023-11-03 12:58:47

然后再在dllmain.cpp设置DLL_PROCESS_ATTACH,然后编译生成Golbal.dll

// dllmain.cpp : 定义 DLL 应用程序的入口点。 #include "pch.h" HMODULE g_hDllModule = NULL; BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: { g_hDllModule = hModule; break; } case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DETACH: break; } return TRUE; }

dll文件怎么注入,简单的dll注入教程(5)

再创建一个控制台项目

dll文件怎么注入,简单的dll注入教程(6)

使用LoadLibrabryW加载dll,生成GolbalInjectDll.cpp文件

// GolbalInjectDll.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。 // #include <iostream> #include <Windows.h> int main() { typedef BOOL(*typedef_SetGlobalHook)(); typedef BOOL(*typedef_UnsetGlobalHook)(); HMODULE hDll = NULL; typedef_SetGlobalHook SetGlobalHook = NULL; typedef_UnsetGlobalHook UnsetGlobalHook = NULL; BOOL bRet = FALSE; do { hDll = ::LoadLibraryW(TEXT("F:\\C \\GolbalDll\\Debug\\GolbalDll.dll")); if (NULL == hDll) { printf("LoadLibrary Error[%d]\n", ::GetLastError()); break; } SetGlobalHook = (typedef_SetGlobalHook)::GetProcAddress(hDll, "SetHook"); if (NULL == SetGlobalHook) { printf("GetProcAddress Error[%d]\n", ::GetLastError()); break; } bRet = SetGlobalHook(); if (bRet) { printf("SetGlobalHook OK.\n"); } else { printf("SetGlobalHook ERROR.\n"); } system("pause"); UnsetGlobalHook = (typedef_UnsetGlobalHook)::GetProcAddress(hDll, "UnsetHook"); if (NULL == UnsetGlobalHook) { printf("GetProcAddress Error[%d]\n", ::GetLastError()); break; } UnsetGlobalHook(); printf("UnsetGlobalHook OK.\n"); } while (FALSE); system("pause"); return 0; }

执行即可注入GolbalDll.dll

dll文件怎么注入,简单的dll注入教程(7)

dll文件怎么注入,简单的dll注入教程(8)

上一页12345下一页

栏目热文

文档排行

本站推荐

Copyright © 2018 - 2021 www.yd166.com., All Rights Reserved.