normalize general framework events to be like other events
git-svn-id: file:///home/svn/framework3/trunk@4307 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
378101697e
commit
cbd0a8ca35
|
@ -36,8 +36,19 @@ module Framework
|
|||
|
||||
end
|
||||
|
||||
#
|
||||
# We extend modules when we're created, and we do it by registering a
|
||||
# general event subscriber.
|
||||
#
|
||||
include GeneralEventSubscriber
|
||||
|
||||
#
|
||||
# Simplifies module instances when they're created.
|
||||
#
|
||||
def on_module_created(instance)
|
||||
Msf::Simple::Framework.simplify_module(instance)
|
||||
end
|
||||
|
||||
ModuleSimplifiers =
|
||||
{
|
||||
MODULE_ENCODER => Msf::Simple::Encoder,
|
||||
|
@ -100,12 +111,6 @@ module Framework
|
|||
framework.modules.add_module_path(Msf::Config.user_module_directory)
|
||||
end
|
||||
|
||||
# Set the on_module_created procedure to simplify any module
|
||||
# instance that is created
|
||||
framework.on_module_created_proc = Proc.new { |instance|
|
||||
simplify_module(instance)
|
||||
}
|
||||
|
||||
# Register the framework as its own general event subscriber in this
|
||||
# instance
|
||||
framework.events.add_general_subscriber(framework)
|
||||
|
|
|
@ -12,11 +12,14 @@ module GeneralEventSubscriber
|
|||
#
|
||||
# Called when a module is loaded
|
||||
#
|
||||
attr_accessor :on_module_load_proc
|
||||
def on_module_load(refname, klass)
|
||||
end
|
||||
|
||||
#
|
||||
# Called when a new module instance is created
|
||||
#
|
||||
attr_accessor :on_module_created_proc
|
||||
def on_module_created(instance)
|
||||
end
|
||||
end
|
||||
|
||||
###
|
||||
|
@ -128,9 +131,7 @@ class EventDispatcher
|
|||
def on_module_load(name, mod)
|
||||
subscribers_rwlock.synchronize_read {
|
||||
general_event_subscribers.each { |subscriber|
|
||||
next if (!subscriber.on_module_load_proc)
|
||||
|
||||
subscriber.on_module_load_proc.call(name, mod)
|
||||
subscriber.on_module_load(name, mod)
|
||||
}
|
||||
}
|
||||
end
|
||||
|
@ -142,9 +143,7 @@ class EventDispatcher
|
|||
def on_module_created(instance)
|
||||
subscribers_rwlock.synchronize_read {
|
||||
general_event_subscribers.each { |subscriber|
|
||||
next if (!subscriber.on_module_created_proc)
|
||||
|
||||
subscriber.on_module_created_proc.call(instance)
|
||||
subscriber.on_module_created(instance)
|
||||
}
|
||||
}
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue