I have written a dll and injector in C++. The dll code is given below:
#include <cstdio>
#include <stdio.h>
#include <windows.h>
#include <string>
#include <fstream>
#include <winsock.h>
using namespace std;
#pragma comment(lib, "wsock32.lib")
extern "C" __declspec(dllexport) void UploadFile()
{
.....
}
INT APIENTRY DLLMain(HMODULE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
{
switch(fdwReason)
{
case DLL_PROCESS_ATTACH:
MessageBox(0,"Process Attach","Info",MB_OK);
UploadFile();
break;
case DLL_THREAD_ATTACH:
MessageBox(0,"Thread Attach","Info",MB_OK);
UploadFile();
break;
case DLL_PROCESS_DETACH:
break;
case DLL_THREAD_DETACH:
break;
default:
break;
}
return TRUE;
}
The dll uploads a particular file to the server. I am successfully able to inject the dll into "notepad.exe" using LoadLibrary() and CreateRemoteThread() but it is not being executed. Not even the dllmain() function. Dont know what is wrong.