第二步,实现函数,xxx即是注册表里指定的前缀:
/***************************************************************************
*
* Function Name: DllMain
* Purpose: service entrance
* Input:
hinstDLL: Handle to the DLL.
dwReason: Specifies a flag indicating why the DLL entry-point function is being called.
lpvReserved: Specifies further aspects of DLL initialization and cleanup.
* Output:none
* Return:TRUE
***************************************************************************/
BOOL APIENTRY DllMain( HANDLE hinstDLL, DWORD dwReason, LPVOID lpvReserved)
{
switch( dwReason )
{
case DLL_PROCESS_ATTACH:
g_hInst=(HINSTANCE)hinstDLL;
break;
case DLL_PROCESS_DETACH:
{
//..
break;
}
}
return TRUE;
}
/***************************************************************************
*
* Function Name:xxx_Close
* Purpose: This function is implemented by a service and will be called by Services.exe.
* Input:
dwData:Specifies the value returned by xxx_Open (Services.exe) for the given service instance.
* Output:none
* Return:TRUE indicates success. FALSE indicates failure.
* Remarks:This function is called when a service instance is closing during an application's call to CloseHandle.
***************************************************************************/
BOOL xxx_Close(DWORD dwData)
{
//..
//return FALSE;
}
/***************************************************************************
*
* Function Name:xxx_Deinit
* Purpose: This function is to be implemented by a service and will be called by Services.exe.
* Input:
dwData:Specifies the value returned by xxx_Init (Services.exe) for the given service instance.
* Output:none
* Return:TRUE indicates success. FALSE indicates failure.
* Remarks:This function is called during an application's call to DeregisterService.
***************************************************************************/
BOOL xxx_Deinit(DWORD dwData)
{
//..
//return FALSE;
}
/***************************************************************************
*
* Function Name:xxx_IOControl
* Purpose: This function is used to send a control code to a service.
* Input:
dwData: Specifies the value returned by xxx_Init (Services.exe) for the given service instance.
dwCode: Specifies the control code for the operation.
pBufIn: Pointer to a buffer that contains the data required to perform the operation.
dwLenIn: Specifies the size, in bytes, of the buffer pointed to by pBufIn.
dwLenOut: Specifies the size, in bytes, of the buffer pointed to by pBufOut.
* Output:
pBufOut: Pointer to a buffer that receives the output data from the operation.
pdwActualOut:Pointer to a variable that receives the size, in bytes, of the data stored into the buffer pointed to by pBufOut.
* Return:TRUE indicates success. FALSE indicates failure.
* Remarks:The control code specifies the action that the driver is to perform. For example, a control code can ask a service
to return information or direct the service to carry out an action. Windows Embedded CE. NET provides a number of
standard control codes. In addition, a service can define its own service-specific control code.
***************************************************************************/
BOOL xxx_IOControl(
DWORD dwData,
DWORD dwCode,
PBYTE pBufIn,
DWORD dwLenIn,
PBYTE pBufOut,
DWORD dwLenOut,
PDWORD pdwActualOut)
{
//..
//return TRUE;
}
/***************************************************************************
*
* Function Name:xxx_Open
* Purpose: This function is to be implemented by a service and will be called by Services.exe.
* Input:
dwData:Specifies the value returned by xxx_Init (Services.exe) for the given service instance.
dwAccess :Specifies the type of access to the object.
dwShareMode:Specifies how the object can be shared.
* Output:none
* Return:TRUE indicates success. FALSE indicates failure.
* Remarks: This function is called during an application's call to CreateFile. The values for the
dwAccess and dwShareMode parameters are passed directly from the call to CreateFile.
***************************************************************************/
BOOL xxx_Open(
DWORD dwData,
DWORD dwAccess,
DWORD dwShareMode)
{
//..
//return FALSE;
}
/***************************************************************************
*
* Function Name:xxx_Read
* Purpose: This function is to be implemented by a service and will be called by Services.exe. This function need
only be implemented by a streaming service.
* Input:
dwData:Specifies the value returned by xxx_Open (Services.exe) for the given service instance.
dwLen:Specifies the number of bytes to be read.
* Output:
pBuf:Pointer to the storage location for the data that is read.
* Return:Returns the number of bytes read.
* Remarks: This function is called by Services.exe as a result of an application's call to ReadFile.
***************************************************************************/
DWORD xxx_Read(
DWORD dwData,
LPVOID pBuf,
DWORD dwLen)
{
//..
//return 0;
}
/***************************************************************************
*
* Function Name:xxx_Seek
* Purpose: This function is to be implemented by a service and will be called by Services.exe.
This function need only be implemented by a streaming service.
* Input:
dwData:Specifies the value returned by xxx_Open (Services.exe) for the given service instance.
pos:Specifies the number of bytes to move the file pointer. pos is a 32-bit signed value.
type:Specifies the starting point for the file pointer move.
* Output:none
* Return:Returns the current location of the file pointer.
* Remarks: This function is called by Services.exe as a result of an application's call to SetFilePointer.
***************************************************************************/
DWORD xxx_Seek(
DWORD dwData,
long pos,
DWORD type)
{
//..
//return 0;
}
/***************************************************************************
*
* Function Name:xxx_Write
* Purpose: This function is to be implemented by a service and will be called by Services.exe.
Only streaming services need to implement this function.
* Input:
dwData:Specifies the value returned by xxx_Open (Services.exe) for the given service instance.
dwInLen:Specifies the length of data in the buffer to be written.
* Output:
pInBuf: Pointer to the buffer containing data to write.
* Return:Returns the number of bytes actually written.
* Remark: This function is called by Services.exe as a result of an application's call to WriteFile.
***************************************************************************/
DWORD xxx_Write(
DWORD dwData,
LPCVOID pInBuf,
DWORD dwInLen)
{
//..
//return 0;
}
/***************************************************************************
*
* Function Name:xxx_Init
* Purpose:This function is to be implemented by a service and will be called by Services.exe.
* Input:
dwData: Specifies the service-supplied data.
* Output:none
* Return:Returns a value to be used in calls to xxx_Open (Services.exe).
* Remarks: This function is called during RegisterService, in which case dwData will be the fourth parameter
to RegisterService. It is also called during Services.exe initialization, in which case dwData
is the DWORD value set in the registry value HKEY_LOCAL_MACHINE\Services\Service\Context, or zero if this value is not set.
***************************************************************************/
DWORD xxx_Init(DWORD dwData)
{
//..
//return 1;
}