Hi all,
I have a program that loads a dll, uses it for some time and then it unloads it. I have no idea where dll is located or from where it is loaded but I know where dll is unloaded. Loading of the dll is very hardcoded and I simple can't find where it happens. My question is if I find the memory where the loaded dll is stored, can i create the .dll file from that memory. So what I have tried is this:
int main()
{
HMODULE handle = LoadLibrary(TEXT("test.dll"));
std::ofstream file;// can be merged to std::ofstream file("file.txt");
file.open("file.dll");
for(int i = 0;;i++)
file << (unsigned char*)(handle+i);
return 0;
}
Program crashes when it tries to read outside of the loaded library's memory thats why I don't done anything that terminates the loop. If I was doing it right it should put the memory of "handle" in to "file.dll" and that should create a usable dll, but it does not. Anyone know how to create a dll from a loaded dll's memory?
Thanks in advance.