Click to See Complete Forum and Search --> : Windows Socket DLL Problem
RedDragon2kx
January 5th, 2005, 05:45 PM
Hi
I've written a DLL that uses Windows Sockets. The DLL gets inject into another process by calling WriteProcessMemory & CreateRemoteThread. The injecting and calling all works fine. The Target App loads the DLL and the Client even gets connected to the Server. But if i try to send something from the Server to the Client nothing happens. I don't know if the Client can send data to the Server. I'm using a multithreaded Server that can accept more than one connection by converting the CSocket Object to a DWORD. I don't know where the problem is.
MFG
RedDragon2kx
P.S. THE SOFTWARE IS NOT USED TO CAUSE DAMAGE TO SOFTWARE OR HARDWARE
kirants
January 5th, 2005, 06:46 PM
nothing happens.
Nothing happens can mean different things in different cases. What exactly do you expect to happen and what do you observe ?
RedDragon2kx
January 5th, 2005, 07:11 PM
The message i sended from the server does not reach the Client. There can't be a problem with the code because i programmed the code in an MFC App and then put it into the DLL(of course with some changes). The whole CMySocket::OnReceive doesn't get called.
kirants
January 5th, 2005, 07:20 PM
Who creates the socket object ?
Is CMySocket derived from an MFC class, if so, which one ?
RedDragon2kx
January 5th, 2005, 07:22 PM
CMySocket is the Socket Object in DLL which gets injected to the process
kirants
January 5th, 2005, 07:30 PM
Well, I think CMySocket is just a class. Well, yes the code is getting injected. But, there should be someone who creates an object of the CMySocket class, right ? Something like
CMySocket oSocket;
or
CMySocket* pSocket = new CMySocket;
RedDragon2kx
January 5th, 2005, 07:33 PM
The Socket gets created and connects successful to the server as i mentioned in my first post
kirants
January 5th, 2005, 08:32 PM
Hm... you may want to debug this.. You said , it works alright with standalone app, right ?
I'm not sure of the architecture of MFC as far as sockets goes, but what you may want to try is debug by putting breakpoints. You can start out by searching for "->OnReceive" in MFC sources, putting breakpoint in there and back tracking to find where it is failing..
I beleive there should a PumpMessages for socket class to do that kind of stuff.
Also, if youa re using Async sockets, you may want to check if you have any window.. It looks from MFC code that the code , sets a WM_SOCKET_NOTIFY message as the message that the socket layer should be using.. So, if there is no window specified, then there is no way for winsock layer to send the message to..
Also, I presume you are calling AsyncSelect on the socket object//
RedDragon2kx
January 6th, 2005, 07:39 AM
Ok i done so. Now it seems my DLL can't execute any function after the connect.
BOOL CDllApp::InitInstance()
{
CWinApp::InitInstance();
if (!AfxSocketInit())
{
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
return FALSE;
}
MessageBox(NULL,"InitInstance","DLL",MB_OK); // Everything works fine and the MessageBox shows up
Connect("192.168.2.244",1400);
....
}
bool CLockDllApp::Connect(CString strHostName, UINT nPort)
{
MessageBox(NULL,"Connect","DLL",MB_OK); //still shows up
m_pClientSocket = new CRescueSocket(this);
m_pClientSocket->Create();
m_pSocketFile = new CSocketFile(m_pClientSocket);
m_pArchiveIn = new CArchive(m_pSocketFile,CArchive::load);
m_pArchiveOut = new CArchive(m_pSocketFile,CArchive::store);
m_pClientSocket->Connect(strHostName,nPort);
MessageBox(NULL,"Connect succed","DLL",MB_OK); // ERROR nothing happens and don't shows up
return true;
}
Any clue ?
MFG
RedDragon2kx
Mick
January 6th, 2005, 02:14 PM
[ moved thread ]
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.