WiredWX Hobby Weather ToolsLog in

 


descriptionSolvedCorrupt MSWSOCK.dll

more_horiz
In trying to learn Winsock2 programming with Visual C++ 2005 Pro on Windows XP Pro SP3, I've run into a problem with an apparently corrupt MSWSOCK.dll.

Here's what I've tried so far:

// This is my second attempt at Winsock2 programming
// A console program built from the code given at
// http://www.tenouk.com/Winsock/visualstudio2008ncnwinsock2.html
// MDJ 2010/09/22

// Run on Windows XP Pro machine, version 2002, SP 2
// C++ from Visual Studio 2008 Pro Edition
#include "stdio.h"
#include "winsock2.h"

// MDJ added the include below to further implement Winsock2

// Also added WS2_32.LIB and MSWSOCK.DLL under
// Project|Windock2Test002 Properties|
// Configuration Properties|Linker|Input|
// Additional Dependencies

// Also set Project|Windock2Test002 Properties|
// Configuration Properties|C/C++|Advanced|Compile As
// to Compile as C Code (/TC).

// Got error message:
// 1>LINK : fatal error LNK1104: cannot open file 'MSWSOCK.DLL'
// Therefore: commented out the following include and
// removed the MSWSOCK.DLL from the Additional
// Dependencies list.

// [Build] succeded.
// [Debug|Start Without Debugging] worked.

// Searched system to find MSWSOCK.DLL - 2/6/2010 at:
// C:\WINDOWS\ServicePackFiles\i386\MSWSOCK.DLL.
// Added complete path to Additional Dependencies list.
// Uncommented the following include. Got:
// 1>C:\WINDOWS\ServicePackFiles\i386\MSWSOCK.DLL : fatal error LNK1107: invalid or corrupt file: cannot read at 0x2A8
// Tried earlier 8/4/2004 version at:
// C:\WINDOWS\system32\MSWSOCK.DLL.
// Got same result. Tried 2/6/2010 version at:
// C:\WINDOWS\$NtServicePackUninstall$\MSWSOCK.DLL.
// Got same result.

// Renamed MSWSOCK.DLL to MSWSOCKOld.DLL at:
// C:\WINDOWS\ServicePackFiles\i386\MSWSOCK.DLL and at:
// C:\WINDOWS\system32\MSWSOCK.DLL.
// Downloaded new MSWSOCK.dll from:
// http://www.dll-files.com/dllindex/dll-files.shtml?mswsock
// to C:\downloadsHold\DLLs\mswsock then unzipped.
// Version 11/18/2004 - copied to:
// C:\WINDOWS\ServicePackFiles\i386\MSWSOCK.DLL and
// C:\WINDOWS\system32\MSWSOCK.DLL.
// Changed Additional Dependencies list to:
// C:\WINDOWS\system32\MSWSOCK.DLL. Got:
// 1>C:\WINDOWS\system32\MSWSOCK.DLL : fatal error LNK1107: invalid or corrupt file: cannot read at 0x2A8

#include "mswsock.h"

int main()
{
WORD wVersionRequested;
WSADATA wsaData;
int wsaerr;

// Using MAKEWORD macro, Winsock version request 2.2
wVersionRequested = MAKEWORD(2, 2);
wsaerr = WSAStartup(wVersionRequested, &wsaData);

if (wsaerr != 0)
{
/* Tell the user that we could not find a usable */
/* WinSock DLL.*/
printf("The Winsock dll not found!\n");
return 0;
}
else
{
printf("The Winsock dll found!\n");
printf("The status: %s.\n", wsaData.szSystemStatus);
}

/* Confirm that the WinSock DLL supports 2.2. */
/* Note that if the DLL supports versions greater */
/* than 2.2 in addition to 2.2, it will still return */
/* 2.2 in wVersion since that is the version we */
/* requested. */

if (LOBYTE(wsaData.wVersion) != 2 || HIBYTE(wsaData.wVersion) != 2 )
{
/* Tell the user that we could not find a usable */
/* WinSock DLL.*/
printf("The dll do not support the Winsock version %u.%u!\n", LOBYTE(wsaData.wVersion),HIBYTE(wsaData.wVersion));
WSACleanup();
return 0;
}
else
{
printf("The dll supports the Winsock version %u.%u!\n", LOBYTE(wsaData.wVersion),HIBYTE(wsaData.wVersion));
printf("The highest version this dll can support: %u.%u\n", LOBYTE(wsaData.wHighVersion), HIBYTE(wsaData.wHighVersion));
}

/* More task... */
return 0;
}

I've also searched the forum here and at the SocialMSDNVisualC++Forum and found no help on this issue.

Any suggestions would be appreciated.

M. David Johnson



Last edited by mdavidjohnson on 22nd September 2010, 5:13 pm; edited 1 time in total (Reason for editing : The include filenames inside the left and right carets don't show up)

descriptionSolvedRe: Corrupt MSWSOCK.dll

more_horiz
How irritating!

The edit function on this site doesn't appear to work.

Also the include statements in the code above don't show the left and right carets nor the filenames between them. Shown here are the correct statements without the carets - You'll have to mentally add the carets yourself.

#include stdio.h
#include winsock2.h
.
.
.
#include mswsock.h

M. David Johnson

descriptionSolvedCorrupt MSWSOCK.dll

more_horiz
Hmmmm. The edit function doesn't seem to be working.
The Quick reply doesn't appear to be working either.

The above code somehow lost the include statement's target filenames included within left and right carets when the code was copied. The correct entries without the carets are shown below. You'll have to mentally supply the carets yourself.

#include stdio.h
#include winsock2.h
.
.
.
#include mswsock.h

M. David Johnson

descriptionSolvedRe: Corrupt MSWSOCK.dll

more_horiz
Hi mdavidjohnson

By your first post it seems you're using Visual Studio 2005 Pro, but the guide uses Visual Studio 2008 Pro. More then likely they are using the .net framework 3.5 which includes newer features/changes unavailable to the previous. You can still download the 2008 express edition free here.

descriptionSolvedSolved Corrupt MSWSOCK.dll

more_horiz
Thanks -

I already have both the 2008 and 2010 express editions. I have simply found that the 2005 Pro version has some features I like which the two newer versions do not.

Meanwhile, back at the ranch...

Banfa at bytes.com wrote that I should link on mswsock.lib instead of mswsock.dll,

I tried that and it worked.

M. David Johnson

descriptionSolvedRe: Corrupt MSWSOCK.dll

more_horiz
You're welcome.

I see.

I wouldn't recommend downloading free .dll files. If you have the Windows disk you can do a repair.😉

descriptionSolvedRe: Corrupt MSWSOCK.dll

more_horiz
privacy_tip Permissions in this forum:
You cannot reply to topics in this forum