--- includes/module.inc	2010-02-26 14:31:29.000000000 -0400
+++ includes/module.inc	2010-02-27 13:39:58.000000000 -0400
@@ -686,6 +686,35 @@
     return call_user_func_array($module . '_' . $hook, $args);
   }
 }
+
+/**
+ * Invoke a hook in a particular module.  Uses similar syntax to
+ * call_user_func_array() - that way we can offer pass-by-reference.
+ *
+ * @param $module
+ *   The name of the module (without the .module extension).
+ * @param $hook
+ *   The name of the hook to invoke.
+ * @param $args
+ *   Array of arguments to pass to the hook implementation.
+ * @return
+ *   The return value of the hook implementation.
+ */
+function module_invoke_array($module, $hook, $args) {
+  if (!module_hook($module, $hook)) {
+    return;
+  }
+
+  $return = NULL;
+
+  $params = _module_invoke_args_string($args);
+  $func = $module . '_' . $hook;
+  $call = $func . '(' . $params . ');';
+  eval('$return=' . $call);
+
+  return $return;
+}
+
 /**
  * Invoke a hook in all enabled modules that implement it.
  *
@@ -719,6 +748,62 @@
 }
 
 /**
+ * Invoke a hook in all enabled modules that implement it.  Uses similar syntax
+ * to call_user_func_array() - that way we can offer pass-by-reference.
+ *
+ * @param $hook
+ *   The name of the hook to invoke.
+ * @param $args
+ *   Array of arguments to pass to the hook implementation.
+ * @return
+ *   An array of return values of the hook implementations. If modules return
+ *   arrays from their implementations, those are merged into one array.
+ */
+function module_invoke_all_array($hook, $args) {
+  $return = array();
+
+  $params = _module_invoke_args_string($args);
+  foreach (module_implements($hook) as $module) {
+    $func = $module . '_' . $hook;
+    $call = $func . '(' . $params . ');';
+    eval('$result=' . $call);
+
+    if (isset($result) && is_array($result)) {
+      $return = array_merge_recursive($return, $result);
+    }
+    else if (isset($result)) {
+      $return[] = $result;
+    }
+  }
+
+  return $return;
+}
+
+/**
+ * A function to generate the arguments string needed by eval() calls in
+ * module_invoke_array() and module_invoke_all_array().
+ *
+ * @param $hook
+ *   The name of the hook to invoke.
+ * @param ...
+ *   Arguments to pass to the hook.
+ * @return
+ *   An array of return values of the hook implementations. If modules return
+ *   arrays from their implementations, those are merged into one array.
+ */
+function _module_invoke_args_string(&$args) {
+  $params = '';
+
+  $keys = array_keys($args);
+  foreach ($keys as $key) {
+    $params .= '$args[' . $key . '],';
+  }
+  $params = substr($params, 0, -1);
+
+  return $params;
+}
+
+/**
  * @} End of "defgroup hooks".
  */
 
