1
mirror of https://github.com/rapid7/metasploit-payloads synced 2025-03-24 18:16:24 +01:00

66 lines
1.3 KiB
C
Raw Normal View History

#include "metsrv.h"
#ifdef _WIN32
// see ReflectiveLoader.c...
extern HINSTANCE hAppInstance;
#endif
/**************************
* Core dispatch routines *
**************************/
LIST * extension_list = NULL;
// Dispatch table
Command custom_commands[] =
{
{
"core_loadlib",
{ request_core_loadlib, { 0 }, 0 },
{ EMPTY_DISPATCH_HANDLER },
},
// Terminator
{ NULL,
{ EMPTY_DISPATCH_HANDLER },
{ EMPTY_DISPATCH_HANDLER },
},
};
/*
* Registers custom command handlers
*/
VOID register_dispatch_routines()
{
DWORD index;
extension_list = list_create();
for( index=0 ; custom_commands[index].method ; index++ )
command_register( &custom_commands[index] );
}
/*
* Deregisters previously registered custom commands and loaded extensions.
*/
VOID deregister_dispatch_routines( Remote * remote )
{
DWORD index;
while( TRUE )
{
EXTENSION * extension = list_pop( extension_list );
if( !extension )
break;
extension->deinit( remote );
free( extension );
}
for( index=0 ; custom_commands[index].method ; index++ )
command_deregister( &custom_commands[index] );
list_destroy( extension_list );
}