V
V
Viktor Dubrov2019-12-17 15:28:18
C++ / C#
Viktor Dubrov, 2019-12-17 15:28:18

Debugging denied. The process is rejecting the dll. What to do?

Good day to all.
Please help.
The goal is to call the functions of a foreign process (from the process itself, of course).
When DLL injection using CreateRemoteThread (code below), the injection succeeds, but it does not exist in loaded DLLs (check Process Explorer ).
The code itself is working (injected anywhere)
DLL is empty - does nothing, created through DillMain

bool Inject(DWORD pID, char* path) {
  
  HANDLE proc_handle;
  LPVOID RemoteString;
  LPVOID LoadLibAddy;
  if (pID == 0) {
    return false;
  }
  proc_handle = OpenProcess(PROCESS_ALL_ACCESS, false, pID);
  if (proc_handle == 0) {
    return false;
  }
  
  RemoteString = VirtualAllocEx(proc_handle, NULL, strlen(path), MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE);
  WriteProcessMemory(proc_handle, RemoteString, path, strlen(path), NULL);
  LoadLibAddy = (LPVOID)GetProcAddress(GetModuleHandle("kernel32.dll"), "LoadLibraryA");
  CreateRemoteThread(proc_handle, NULL, NULL, (LPTHREAD_START_ROUTINE)LoadLibAddy, RemoteString, NULL, NULL);
  CloseHandle(proc_handle);
  return true;
}

When trying to debug a process via JIT, access is denied.
Software like Cheat Engine , immediately die in the presence of the desired process.
Any advice will do, in which direction to think, in order to somehow move in the right direction.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question