Skip to content

Instantly share code, notes, and snippets.

@singleghost2
Created August 30, 2024 06:55
Show Gist options
  • Save singleghost2/bbcab3ca75425e6c49c9a0bf2e6d36db to your computer and use it in GitHub Desktop.
Save singleghost2/bbcab3ca75425e6c49c9a0bf2e6d36db to your computer and use it in GitHub Desktop.
进程启动时注入DLL,等待调试器连接
// dllmain.cpp : 定义 DLL 应用程序的入口点。
#include "pch.h"
#include <Windows.h>
#include <tchar.h>
#include <stdio.h>
TCHAR EXE_PATH[MAX_PATH];
BOOL APIENTRY DllMain(HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
int ret;
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
ret = GetModuleFileName(NULL, EXE_PATH, MAX_PATH);
if (ret == 0) {
break;
}
if (_tcsicmp(L"C:\\Program Files (x86)\\Ant Group\\starpoint\\1.9.3.615\\Mobius.exe", EXE_PATH) != 0) {
break;
}
//死循环,直到有debugger attach
while (true) {
if (IsDebuggerPresent()) break;
Sleep(100);
}
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment