编译DLL注入器时生成失败
Build fails when compiling DLL Injector
我是一个c++编程新手。我一直在尝试从一个网络教程中编译我自己的DLL Injector
。
下面是我的代码:
#include <windows.h>
#include <tlhelp32.h>
#include <shlwapi.h>
#include <conio.h>
#include <stdio.h>
#include <iostream>
#define WIN32_LEAN_AND_MEAN
#define CREATE_THREAD_ACCESS (PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION | PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_VM_READ)
BOOL Inject(DWORD pID, const char * DLL_NAME);
DWORD GetTargetThreadIDFromProcName(const char * ProcName);
using namespace std;
int main(int argc, char * argv[])
{
// The name of the process you want to inject
DWORD pID = GetTargetThreadIDFromProcName("notepad.exe");
// Get the dll's full path name
char buf[MAX_PATH] = {0};
GetFullPathName("Project1.dll", MAX_PATH, buf, NULL); // On the place where is Project1.dll you can put the name of your dll
printf(buf);
printf("n");
// Inject our main dll
if(!Inject(pID, buf))
{
printf("Not loaded!"); // If injection is not sucsessfull
}
else
{
printf("Loaded!"); // If injection is sucsessfull
}
_getch();
return 0;
}
BOOL Inject(DWORD pID, const char * DLL_NAME)
{
HANDLE Proc;
HMODULE hLib;
char buf[50] = {0};
LPVOID RemoteString, LoadLibAddy;
if(!pID)
return false;
Proc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pID);
if(!Proc)
{
sprintf(buf, "OpenProcess() failed: %d", GetLastError());
//MessageBox(NULL, buf, "Loader", MB_OK);
printf(buf);
return false;
}
LoadLibAddy = (LPVOID)GetProcAddress(GetModuleHandle("kernel32.dll"), "LoadLibraryA");
// Allocate space in the process for our DLL
RemoteString = (LPVOID)VirtualAllocEx(Proc, NULL, strlen(DLL_NAME), MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
// Write the string name of our DLL in the memory allocated
WriteProcessMemory(Proc, (LPVOID)RemoteString, DLL_NAME, strlen(DLL_NAME), NULL);
// Load our <strong class="highlight">DLL</strong>
CreateRemoteThread(Proc, NULL, NULL, (LPTHREAD_START_ROUTINE)LoadLibAddy, (LPVOID)RemoteString, NULL, NULL);
CloseHandle(Proc);
return true;
}
DWORD GetTargetThreadIDFromProcName(const char * ProcName)
{
PROCESSENTRY32 pe;
HANDLE thSnapShot;
BOOL retval, ProcFound = false;
thSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if(thSnapShot == INVALID_HANDLE_VALUE)
{
//MessageBox(NULL, "Error: Unable to create toolhelp snapshot!", "2MLoader", MB_OK);
printf("Error: Unable to create toolhelp snapshot!");
return false;
}
pe.dwSize = sizeof(PROCESSENTRY32);
retval = Process32First(thSnapShot, &pe);
while(retval)
{
if(StrStrI(pe.szExeFile, ProcName))
{
return pe.th32ProcessID;
}
retval = Process32Next(thSnapShot, &pe);
}
return 0;
}
我一直得到错误:
" 1>喷射器。在函数"unsigned long __cdecl GetTargetThreadIDFromProcName(char const *)"中引用的未解析的外部符号__imp__StrStrIA@8(? GetTargetThreadIDFromProcName@@YAKPBD@Z)
1>C:UsersRizkerdocumentsvisual studio 2010ProjectsInjectorDebugInjector.exe:致命错误LNK1120: 1 unresolved externals"
任何帮助都是感激的。哦,是的,在我格式化我的电脑之前,这个代码曾经工作过,但在那之后,我想这不知何故坏了。
原文:http://www.mpgh.net/forum/showthread.php?t=209479
链接器找不到StrStrI函数,你应该在你的文件中添加Shlwapi.lib
。
#pragma comment(lib, "Shlwapi.lib")
相关文章:
- 链接到自行创建的dll失败
- 为什么使用 P/Invoke 调用 dll 时,某些计算机中的 LoadLibrary 失败?
- 为什么 LoadLibrary 失败,而 LoadLibraryA 成功加载 DLL?
- 从 C#-DLL 调用函数的 C++ 失败
- 代码在 msvcrt .dll函数上设置断点失败
- 用户DLL/EXE中的堆分配失败
- DLL 注入不断失败,出现不一致的错误
- JNI 不满意链接错误: 动态链接库 (DLL) 初始化例程失败
- Dll 注入 - LoadLibraryA 失败
- jvm.dll 上的加载库失败,错误代码为 183
- 库调用失败 c++ dll
- 无法在 Python 3.5 上导入 cv2 DLL 加载失败
- 如何查找 dll 注册失败的原因
- 添加新对话框后,MFC 应用程序启动失败并"DLL Initialization Failed"
- 通过功能指针通过DLL进行回调功能,运行时检查失败#0错误
- 显式DLL 1函数失败
- 在Windows 7下可以从C#调用C DLL,但在Windows 10下失败
- 包装DLL-了解导入失败的原因
- 延迟加载opengl32.dll失败,出现Qt5
- 使用签证编译 dll / exe - 链接失败