You should only remove the Detour in DllMain when the DLL is unloading.
DetourAttach() is giving you the function pointer to the original function.
See here:
http://www.codeproject.com/Articles/30140/API-Hooking-with-MS-Detours
DetourAttach(&(PVOID&)pSend, MySend);
int WINAPI MySend(SOCKET s, const char* buf, int len, int flags)
{
fopen_s(&pSendLogFile, "C:\\SendLog.txt", "a+");
fprintf(pSendLogFile, "%s\n", buf);
fclose(pSendLogFile);
return pSend(s, buf, len, flags); // Calling original function obtained via the DetourAttach call, this will NOT cause MySend to be called again.
}
You might have an issue because:
InsertDateTime = (int(__stdcall*)(int))(reinterpret_cast<DWORD>(GetModuleHandleA("notepad.exe")) + 0x978A);
Might be the "wrong" address causing the jmp to be in the wrong place.