C ++ - 删除注入的DLL

时间:2014-06-25 13:50:59

标签: c++ winapi dll inject

我使用了我在互联网上找到的代码:

    void InjectDLL()
{
    char *dllName = "C:\\Project2.dll";

    HANDLE proc = OpenProcess(PROCESS_VM_READ | PROCESS_VM_WRITE | PROCESS_SET_INFORMATION | PROCESS_QUERY_INFORMATION | PROCESS_VM_OPERATION | PROCESS_CREATE_THREAD, FALSE, PID);

    LPVOID LoadLibAddr = (LPVOID)GetProcAddress(GetModuleHandleA("kernel32.dll"), "LoadLibraryA");
    LPVOID dereercomp = VirtualAllocEx(proc, NULL, strlen(dllName) + 1, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
    WriteProcessMemory(proc, dereercomp, dllName, strlen(dllName) + 1, NULL);
    HANDLE asdc = CreateRemoteThread(proc, NULL, NULL, (LPTHREAD_START_ROUTINE)LoadLibAddr, dereercomp, 0, NULL);

    WaitForSingleObject(asdc, INFINITE);
    VirtualFreeEx(proc, dereercomp, strlen(dllName) + 1, MEM_RELEASE);
    CloseHandle(asdc);
    CloseHandle(proc);
}

一切都工作得非常好,但是在完成了我必须做的事情之后,我想要从注入dll或dll本身的程序中删除注入的dll。

0 个答案:

没有答案