Netfinity Patch

From EMule Wiki
Revision as of 10:33, 15 March 2007 by Leuk he (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

edit wspiapiu.h

A mod based compiled with VS.Net 2003 cannot run without this fix on Microsoft WindowsXP without SP2 installed. This is an official bug in Windows and has to do with the Windows dll WS2_32.dll.

Without the patch the application will not start and display the the following error message:

 The procedure entry point "FreeAddrInfoW" in "WS2_32.dll" could no be found

e.g. the Webcache-Mod has in version 2.0a Beta 1 not been compiled with the NetF patch.

The patched "wspiapi.h" file has to be used only for compilation of the eMule project. Other sub-projects of eMule, especially the upnplib project (C-based), won't compile at all or don't need to be compiled with the patched version "wspiapi.h", see below for the patch for such C-programs.

In order to compile with VC++ .NET 2003 and to be able to run on older Windows versions, you need to add the following lines at the end of the "wspiapi.h" file.

You can find "wspiapi.h" here: (Drive-letter you installed VC++):\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include


The patch

// Workaround for missing DLL entries
#define GetAddrInfoW _GetAddrInfoW
#define FreeAddrInfoW _FreeAddrInfoW



__inline
int
WSAAPI
_GetAddrInfoW(
IN PCWSTR pNodeName,
IN PCWSTR pServiceName,
IN const ADDRINFOW * pHints,
OUT PADDRINFOW * ppResult
)
{
return getaddrinfo(CStringA(pNodeName), CStringA(pServiceName), reinterpret_cast<const ADDRINFOA *>(pHints),    reinterpret_cast<addrinfo **>(ppResult));
}

__inline
void
WSAAPI
_FreeAddrInfoW(
IN PADDRINFOW pAddrInfo
)
{
freeaddrinfo(reinterpret_cast<addrinfo *>(pAddrInfo));
}

The patch for C programs

A workaround so C programs (like the UPnP library...) can still compile with this include file:

// start netf patch
#ifdef __cplusplus
__inline
int
WSAAPI
_GetAddrInfoW(
IN PCWSTR pNodeName,
IN PCWSTR pServiceName,
IN const ADDRINFOW * pHints,
OUT PADDRINFOW * ppResult
)
{
#ifdef __cplusplus
return getaddrinfo(CStringA(pNodeName), CStringA(pServiceName), reinterpret_cast<const ADDRINFOA *>(pHints),    reinterpret_cast<addrinfo **>(ppResult));
#else 
return getaddrinfo((TCHAR *)pNodeName,(TCHAR *) pServiceName, reinterpret_cast<const ADDRINFOA *>(pHints),    reinterpret_cast<addrinfo **>(ppResult));
#endif
}



__inline
void
WSAAPI
_FreeAddrInfoW(
IN PADDRINFOW pAddrInfo
)
{
freeaddrinfo(reinterpret_cast<addrinfo *>(pAddrInfo));
}
#endif
// end netf patch


developed by : Netfinity AKA: NetF-Fix, WS2_32.dll-Workaround

Other

Simply adding WS2_32.dll to Project->emule properties->Linker->Input->Delay Loaded DLLs will allow you to start your application [source (http://forum.emule-project.net/index.php?showtopic=103239&view=findpost&p=734988)] BUT if you ever send a notification eMail then your application will crash. Best solution in case you don't even need the eMail support is to compile without the HAVE_SAPI pre-processor macro.

SP1

MS also supplied a fix for this in vs2003 sp1. http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=69d2219f-ce82-46a5-8aec-072bd4bb955e#QuickInfoContainer http://support.microsoft.com/kb/909141/

Personal tools