Help with DHCP Server API Reference

  • Thread starter Thread starter Leventon
  • Start date Start date
L

Leventon

I really need help with this.
I'm running on windows 200 server.
I did everything as explained but when I start the DHCP server I get
the following warning message in the system event log:
"The DHCP service has failed to load one or more callout DLLs. The
following error occurred: The specified procedure could not be found."

The code that I'm using for the DLL is:

#include "stdafx.h"
#include <Dhcpssdk.h>

#ifdef __cplusplus
extern "C" {
#endif

DWORD CALLBACK DhcpControlHookTest(DWORD dwControlCode,
LPVOID lpReserved)
{
return 0;
}

DWORD CALLBACK DhcpServerCalloutEntry(LPWSTR ChainDlls,
DWORD CalloutVersion,
LPDHCP_CALLOUT_TABLE CalloutTbl)
{
CalloutTbl->DhcpControlHook = DhcpControlHookTest;

return 0;
}


#ifdef __cplusplus
}
#endif
 
Hi,
I too am stuck at the "1067" error on the DHCP
"DHCPSERVERCALLOUTENTRY".
Nothing is mentioned in "msdn.microsoft.com" too. But, i have to try
it out in Win 2003. Will keep posting till a solution is reached.
Meanwhile, if anybody (like Nick) gets through this, please post it
here.
regards,
Balaji
 
Hi guys,

Here it goes.

I would like to start with encouragement, "First of all it works
absolutely fine in WIN2000 Server."


The reason for this not working for you guys are many. (I encountered
the same issues you all encountered in developing this)

1. The exported function "DhcpServerCalloutEntry" should follow
APIENTRY calling convention to work in the DHCPService.

Though you all attempted this many ways, in every way you all failed
because you have used __delcpec(dllexport). He is the culprit. Though
you call this in side the export "C" block the final function name
that is exported is "_DhcpServerCalloutEntry@12".

How to avid this?

You must use Module definition files. The old way of exporting the
function in the DLL.

1. Create a file named XYZ.DEF which look like this

EXPORTS
DhcpServerCalloutEntry

2. Add this file into your projects linker option as Module
definition file and build your dll.

3. Now using the dumpbin.exe make sure the "DhcpServerCalloutEntry"
function is exported.

Here you go this dll works absolutely fine with the DHCP server.

I happen to find the solution because after miserably failing in 2000
Server (As you all) I tried to do these things in Windows 2003 server.
There before I tried with the DHCP server I tried to call this
function using a test program the system thrown an error saying that
there is a mismatch in the function that is called and the calling
convention of the function in the DLL are different. This made me to
test all the above said steps to find the exact reason.

Hope you all enjoy this.
 
Back
Top