|
Packit Service |
384592 |
/*
|
|
Packit Service |
384592 |
* ModSecurity for Apache 2.x, http://www.modsecurity.org/
|
|
Packit Service |
384592 |
* Copyright (c) 2004-2013 Trustwave Holdings, Inc. (http://www.trustwave.com/)
|
|
Packit Service |
384592 |
*
|
|
Packit Service |
384592 |
* You may not use this file except in compliance with
|
|
Packit Service |
384592 |
* the License. You may obtain a copy of the License at
|
|
Packit Service |
384592 |
*
|
|
Packit Service |
384592 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
Packit Service |
384592 |
*
|
|
Packit Service |
384592 |
* If any of the files related to licensing are missing or if you have any
|
|
Packit Service |
384592 |
* other questions related to licensing please contact Trustwave Holdings, Inc.
|
|
Packit Service |
384592 |
* directly using the email address security@modsecurity.org.
|
|
Packit Service |
384592 |
*/
|
|
Packit Service |
384592 |
|
|
Packit Service |
384592 |
#define WIN32_LEAN_AND_MEAN
|
|
Packit Service |
384592 |
|
|
Packit Service |
384592 |
#undef inline
|
|
Packit Service |
384592 |
#define inline inline
|
|
Packit Service |
384592 |
|
|
Packit Service |
384592 |
// IIS7 Server API header file
|
|
Packit Service |
384592 |
#include "httpserv.h"
|
|
Packit Service |
384592 |
|
|
Packit Service |
384592 |
// Project header files
|
|
Packit Service |
384592 |
#include "mymodule.h"
|
|
Packit Service |
384592 |
#include "mymodulefactory.h"
|
|
Packit Service |
384592 |
|
|
Packit Service |
384592 |
// Global server instance
|
|
Packit Service |
384592 |
IHttpServer * g_pHttpServer = NULL;
|
|
Packit Service |
384592 |
|
|
Packit Service |
384592 |
// Global module context id
|
|
Packit Service |
384592 |
PVOID g_pModuleContext = NULL;
|
|
Packit Service |
384592 |
|
|
Packit Service |
384592 |
// The RegisterModule entrypoint implementation.
|
|
Packit Service |
384592 |
// This method is called by the server when the module DLL is
|
|
Packit Service |
384592 |
// loaded in order to create the module factory,
|
|
Packit Service |
384592 |
// and register for server events.
|
|
Packit Service |
384592 |
HRESULT
|
|
Packit Service |
384592 |
__stdcall
|
|
Packit Service |
384592 |
RegisterModule(
|
|
Packit Service |
384592 |
DWORD dwServerVersion,
|
|
Packit Service |
384592 |
IHttpModuleRegistrationInfo * pModuleInfo,
|
|
Packit Service |
384592 |
IHttpServer * pHttpServer
|
|
Packit Service |
384592 |
)
|
|
Packit Service |
384592 |
{
|
|
Packit Service |
384592 |
HRESULT hr = S_OK;
|
|
Packit Service |
384592 |
CMyHttpModuleFactory * pFactory = NULL;
|
|
Packit Service |
384592 |
//IHttpModuleRegistrationInfo2 * pModuleInfo2;
|
|
Packit Service |
384592 |
|
|
Packit Service |
384592 |
if ( pModuleInfo == NULL || pHttpServer == NULL )
|
|
Packit Service |
384592 |
{
|
|
Packit Service |
384592 |
hr = HRESULT_FROM_WIN32( ERROR_INVALID_PARAMETER );
|
|
Packit Service |
384592 |
goto Finished;
|
|
Packit Service |
384592 |
}
|
|
Packit Service |
384592 |
|
|
Packit Service |
384592 |
/*hr = HttpGetExtendedInterface( g_pGlobalInfo,
|
|
Packit Service |
384592 |
pModuleInfo,
|
|
Packit Service |
384592 |
&pModuleInfo2 );
|
|
Packit Service |
384592 |
if ( FAILED ( hr ) )
|
|
Packit Service |
384592 |
{
|
|
Packit Service |
384592 |
goto Finished;
|
|
Packit Service |
384592 |
}*/
|
|
Packit Service |
384592 |
|
|
Packit Service |
384592 |
// step 1: save the IHttpServer and the module context id for future use
|
|
Packit Service |
384592 |
//
|
|
Packit Service |
384592 |
g_pModuleContext = pModuleInfo->GetId();
|
|
Packit Service |
384592 |
g_pHttpServer = pHttpServer;
|
|
Packit Service |
384592 |
|
|
Packit Service |
384592 |
// step 2: create the module factory
|
|
Packit Service |
384592 |
//
|
|
Packit Service |
384592 |
pFactory = new CMyHttpModuleFactory();
|
|
Packit Service |
384592 |
if ( pFactory == NULL )
|
|
Packit Service |
384592 |
{
|
|
Packit Service |
384592 |
hr = HRESULT_FROM_WIN32( ERROR_NOT_ENOUGH_MEMORY );
|
|
Packit Service |
384592 |
goto Finished;
|
|
Packit Service |
384592 |
}
|
|
Packit Service |
384592 |
|
|
Packit Service |
384592 |
// step 3: register for server events
|
|
Packit Service |
384592 |
//
|
|
Packit Service |
384592 |
hr = pModuleInfo->SetRequestNotifications( pFactory, /* module factory */
|
|
Packit Service |
384592 |
RQ_BEGIN_REQUEST | RQ_SEND_RESPONSE /* server event mask */,
|
|
Packit Service |
384592 |
RQ_END_REQUEST /* server post event mask */);
|
|
Packit Service |
384592 |
if ( FAILED( hr ) )
|
|
Packit Service |
384592 |
{
|
|
Packit Service |
384592 |
goto Finished;
|
|
Packit Service |
384592 |
}
|
|
Packit Service |
384592 |
|
|
Packit Service |
384592 |
hr = pModuleInfo->SetPriorityForRequestNotification(RQ_BEGIN_REQUEST, PRIORITY_ALIAS_FIRST);
|
|
Packit Service |
384592 |
hr = pModuleInfo->SetPriorityForRequestNotification(RQ_SEND_RESPONSE, PRIORITY_ALIAS_LAST); // reverted!
|
|
Packit Service |
384592 |
//hr = pModuleInfo2->SetPriorityForPostRequestNotification(RQ_END_REQUEST, PRIORITY_ALIAS_LAST);
|
|
Packit Service |
384592 |
|
|
Packit Service |
384592 |
pFactory = NULL;
|
|
Packit Service |
384592 |
|
|
Packit Service |
384592 |
Finished:
|
|
Packit Service |
384592 |
|
|
Packit Service |
384592 |
/* if ( pFactory != NULL )
|
|
Packit Service |
384592 |
{
|
|
Packit Service |
384592 |
delete pFactory;
|
|
Packit Service |
384592 |
pFactory = NULL;
|
|
Packit Service |
384592 |
} */
|
|
Packit Service |
384592 |
|
|
Packit Service |
384592 |
return hr;
|
|
Packit Service |
384592 |
}
|