Microsoft KB Archive/232585

{|
 * width="100%"|

PRB: AddMonitor Occasionally Returns Error 87: ERROR_INVALID_PARAMETER

 * }

Q232585

-

The information in this article applies to:


 * Microsoft Windows 95 Driver Development Kit (DDK)
 * Microsoft Windows 98 Driver Development Kit (DDK)

-

SYMPTOMS
The AddMonitor function installs a local port monitor and links the configuration, data, and monitor files. Users may sporadically experience error code 87, "ERROR_INVALID_PARAMETER," on some computers and not on others. This article explains the problem and presents the solution.

MORE INFORMATION
The code below would normally successfully install the Microsoft Windows 95 or Windows 98 language monitor into the system.

AddMyMonitor {   MONITOR_INFO_2      m2; DWORD              dwErr;

m2.pName = "MyMonitor"; m2.pEnvironment = "Windows 4.0"; m2.pDLLName = "localmon.dll";

if( !AddMonitor(NULL, 2, (LPBYTE)&m2) ) {      dwErr = GetLastError; } } If AddMonitor instead returns error code 87, "ERROR_INVALID_PARAMETER," the problem might not be due to an invalid parameter but instead due to the DLL that is to be loaded, Localmon.dll in this case.

AddMonitor attempts to load the DLL via LoadLibrary. If the DLL does not contain a relocation table, LoadLibrary will fail and the DLL will not be successfully loaded.

32-bit Windows operating systems, especially those that coexist with MS-DOS, must frequently relocate a program. Therefore, the program must be linked so that a relocation table is built. The /FIXED Linker option prevents the linker from creating a relocation section in the program, and therefore the operating system attempts to load the program only at its preferred base address. If the preferred base address is unavailable at run-time, the operating system returns an error and does not load the program. This results in AddMonitor returning Error 87: ERROR_INVALID_PARAMETER.

Therefore, add the option /FIXED:NO on the link line to force the linker to build a relocation section and ensure the program gets loaded.

Additional query words:

Keywords : kbDDK kbOSWin95 kbOSWin98

Issue type : kbprb

Technology : kbAudDeveloper kbWin95search kbWin98search kbWin95DDKSearch kbWinDDKSearch kbWin98DDKSearch kbWin95DDK kbWin98DDK