#define MOONSHOT_INSTALL_PATH_KEY "Software\\Moonshot"
void *__RPC_USER MIDL_user_allocate (size_t size) {
- return malloc (size);
+ return malloc (size);
}
void __RPC_USER MIDL_user_free (void *data) {
- free (data);
+ if (data == NULL)
+ return;
+
+ free (data);
+}
+
+void moonshot_free (void *data)
+{
+ free (data);
}
static MoonshotError *moonshot_error_new_from_status (MoonshotErrorCode code,
rpc_async_call_init (&call);
+ if (nai == NULL) nai = "";
+ if (password == NULL) password = "";
+ if (service == NULL) service = "";
+
*nai_out = NULL;
*password_out = NULL;
*server_certificate_hash_out = NULL;
return TRUE;
};
+
+int moonshot_install_id_card (const char *display_name,
+ const char *user_name,
+ const char *password,
+ const char *realm,
+ char *rules_patterns[],
+ int rules_patterns_length,
+ char *rules_always_confirm[],
+ int rules_always_confirm_length,
+ char *services[],
+ int services_length,
+ const char *ca_cert,
+ const char *subject,
+ const char *subject_alt,
+ const char *server_cert,
+ MoonshotError **error)
+{
+ int success = FALSE;
+
+ init_rpc (error);
+
+ if (user_name == NULL) user_name = "";
+ if (password == NULL) password = "";
+ if (realm == NULL) realm = "";
+ if (ca_cert == NULL) ca_cert = "";
+ if (subject == NULL) subject = "";
+ if (subject_alt == NULL) subject_alt = "";
+ if (server_cert == NULL) server_cert = "";
+
+ RPC_TRY_EXCEPT {
+ success = moonshot_install_id_card_rpc (display_name,
+ user_name,
+ password,
+ realm,
+ rules_patterns,
+ rules_patterns_length,
+ rules_always_confirm,
+ rules_always_confirm_length,
+ services,
+ services_length,
+ ca_cert,
+ subject,
+ subject_alt,
+ server_cert);
+ }
+ RPC_EXCEPT {
+ *error = moonshot_error_new_from_status (MOONSHOT_ERROR_IPC_ERROR,
+ RPC_GET_EXCEPTION_CODE ());
+ }
+ RPC_END_EXCEPT
+
+ return success;
+}
+
+BOOL WINAPI DllMain (HINSTANCE hinst,
+ DWORD reason,
+ void *reserved)
+{
+ if (reason == DLL_PROCESS_DETACH) {
+ /* Process exiting/DLL being unloaded. This is a good
+ * opportunity to free the RPC binding.
+ *
+ * FIXME: we can't use the msrpc-mingw routine for this in case
+ * it was already unloaded. I'd love to work out how to link
+ * that library statically into libmoonshot-0.dll.
+ */
+ RpcBindingFree (&moonshot_binding_handle);
+ }
+
+ return TRUE;
+}