Microsoft KB Archive/130562

= PRB: SNMP Extension Agent Gives Exception on Windows NT 3.51 =

ID: Q130562

The information in this article applies to:


 * Microsoft Win32 Software Development Kit (SDK) for Windows NT versions 3.5, 3.51

SYMPTOMS
An SNMP extension agent built using Windows NT version 3.5 SDK headers and libraries generates an exception when run under Windows NT version 3.51.

For example, the SDK toaster sample (\MSTOOLS\SAMPLES\WIN32\SNMP\TESTDLL) works under Windows NT version 3.5 but generates an exception under Windows NT version 3.51.

CAUSE
The SNMP.LIB SDK library has changed between the release of Windows NT version 3.5 and the release of Windows NT version 3.51. Memory is now allocated dynamically with the Win32 API GlobalAlloc rather than the c-runtime malloc. See the SNMP.H SDK header file for details.

An SNMP application that is allocating (or freeing) memory that is passed to a function in SNMP.LIB should use SNMP_malloc (or SNMP_free). The sample code for the extension DLL provided with the Windows NT version 3.51 beta SDK incorrectly uses malloc.

RESOLUTION
Rebuild the extension agent with the Win32 SDK headers and libraries for Windows NT version 3.51. Please make sure that the Win32 SDK headers and libraries are used before Visual C++ headers and libraries.

Also, to allocate and free any memory, use the SNMP_malloc and SNMP_free macros. Both are defined in SNMP.H.

NOTE: If you are using a beta version of Windows NT version 3.51, please change all references to malloc and free in the samples to SNMP_malloc and SNMP_free. This is a known problem with the testdll sample (MSTOOLS\SAMPLES\WIN32\WINNT\SNMP\TESTDLL).

STATUS
This behavior is by design.