implizit geladenen DLLs austauschen bzw. entfernen



  • Mmmh, wie kann ich das unterbinden?

    During initial process startup or after a call to LoadLibrary, the system scans the list of loaded DLLs for the process. For each DLL that has not already been called with the DLL_PROCESS_ATTACH value, the system calls the DLL's entry-point function. This call is made in the context of the thread that caused the process address space to change, such as the primary thread of the process or the thread that called LoadLibrary. Access to the entry point is serialized by the system on a process-wide basis. Threads in DllMain hold the loader lock so no additional DLLs can be dynamically loaded or initialized.



  • Was willst Du denn da unterbinden?



  • Ich will ja letzendlich die DINPUT.DLL durch meine eigene ersetzen. Wenn ich nun wenn ich das Programm im suspended-modus starte und meine dll injiziere, wird vorher automatisch, dadurch dass die dllmain meiner dll aufgerufen wurde, die DINPUT.DLL geladen. Das wollte ich irgendwie verhindern 😕



  • ich hatte jetzt auch erstmal probiert, die DLL zu injizieren, ohne dass die DllMain aufgeruft wird. Leider klappt dies so nicht

    void* pLibFileRemote;
    	pLibFileRemote = reinterpret_cast<char*>(VirtualAllocEx(ProcessInformation.hProcess,
    		NULL,
    		strlen(acDllFileName)+1+sizeof(void*)+sizeof(unsigned long),
    		MEM_COMMIT,
    		PAGE_READWRITE));
    
    	WriteProcessMemory(ProcessInformation.hProcess, pLibFileRemote, acDllFileName, strlen(acDllFileName)+1, NULL);
    	unsigned long lFlags=DONT_RESOLVE_DLL_REFERENCES;
    	WriteProcessMemory(ProcessInformation.hProcess, reinterpret_cast<unsigned char*>(pLibFileRemote)+strlen(acDllFileName)+1+sizeof(void*), &lFlags, sizeof(unsigned long), NULL);
    
    	void* hThread = CreateRemoteThread(ProcessInformation.hProcess, NULL, 0, reinterpret_cast<LPTHREAD_START_ROUTINE>(GetProcAddress(GetModuleHandle("Kernel32"), "LoadLibraryExA")), pLibFileRemote, CREATE_SUSPENDED, NULL);
    

    Die DLL wird injiziert und die DllMain wird aufgerufen



  • Warum tust Du nicht *Deine* DLL in das Verzeichnis der EXE??? Wenn Du eh das gleiche Interface zur Verfügung stellst, dann tausch doch einfach die DLL aus... das ist ja schliesslich der Sinn einer DLL!



  • Das ist aus vorgegebenen Gründen nicht möglich 😞



  • Die einzige "saubere" Lösung ist das Hooken der Funktionen auf Deine eigenen...
    Da besteht dann keine notwendigkeit die DLL zu entladen...



  • Mmmmh, ok, als letze Möglichkeit theoretisch denkbar 😞



  • Ok, ich mach das mit dem hooken. Denoch möchte ich aber die alte DINPUT.DLL entladen. Wie geht nun dies?



  • Die alte DLL kannst Du nicht entladen. Damit musst Du Dich abfinden...
    Das Hooken ist relativ simpel, da Du ja nur die Funktion "umleiten" musst auf Deine; d.h. nur ein JMP Befehl in der ersten Addresse auf die GetProcAddress zeigt...



  • 😞 😞 😞 😞 😞 😞 😞 😞 😞 😞
    Naja, egal


Anmelden zum Antworten