+static gboolean
+mono_w32handle_ref_core (gpointer handle, MonoW32HandleBase *handle_data);
+
+static gboolean
+mono_w32handle_unref_core (gpointer handle, MonoW32HandleBase *handle_data);
+
+static void
+w32handle_destroy (gpointer handle);
+
+gpointer
+mono_w32handle_duplicate (gpointer handle)
+{
+ MonoW32HandleBase *handle_data;
+
+ if (handle == INVALID_HANDLE_VALUE)
+ return handle;
+ if (!mono_w32handle_lookup_data (handle, &handle_data))
+ return INVALID_HANDLE_VALUE;
+ if (handle == (gpointer) 0 && handle_data->type != MONO_W32HANDLE_CONSOLE)
+ return handle;
+
+ if (!mono_w32handle_ref_core (handle, handle_data))
+ g_error ("%s: failed to ref handle %p", __func__, handle);
+
+ return handle;
+}
+