Various compilation scripts & patches for Linux programs.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.5 KiB

7 years ago
  1. --- a/dlls/msi/action.c
  2. +++ a/dlls/msi/action.c
  3. @@ -7862,6 +7862,59 @@ static UINT ACTION_PerformActionSequence(MSIPACKAGE *package, UINT seq)
  4. return rc;
  5. }
  6. +/* Dummy thread just to initialize an MTA for the benefit of custom action DLLs */
  7. +static HANDLE dummy_thread_sync_event = NULL;
  8. +static HANDLE dummy_thread_stop_event = NULL;
  9. +static HANDLE dummy_thread_handle = NULL;
  10. +
  11. +DWORD WINAPI dummy_thread_proc(void *arg)
  12. +{
  13. + HRESULT hr;
  14. + DWORD dwWaitResult;
  15. +
  16. + hr = CoInitializeEx(0, COINIT_MULTITHREADED);
  17. + if (FAILED(hr))
  18. + WARN("CoInitializeEx failed %u\n", hr);
  19. +
  20. + SetEvent(dummy_thread_sync_event);
  21. + dwWaitResult = WaitForSingleObject(dummy_thread_stop_event, INFINITE);
  22. +
  23. + if (dwWaitResult != WAIT_OBJECT_0)
  24. + ERR("WaitForSingleObject failed?\n");
  25. +
  26. + CoUninitialize();
  27. + return 0;
  28. +}
  29. +
  30. +static void start_dummy_thread(void)
  31. +{
  32. + if (dummy_thread_handle) return;
  33. +
  34. + dummy_thread_sync_event = CreateEventA(NULL, TRUE, FALSE, "DummyThreadUpAndRunning");
  35. + if (dummy_thread_sync_event == NULL)
  36. + ERR("Can't create dummy thread sync event\n");
  37. + dummy_thread_stop_event = CreateEventA(NULL, TRUE, FALSE, "DummyThreadStop");
  38. + if (dummy_thread_stop_event == NULL)
  39. + ERR("Can't create dummy thread stop event\n");
  40. + dummy_thread_handle = CreateThread(NULL, 0, dummy_thread_proc, NULL, 0, NULL);
  41. + if (dummy_thread_handle == NULL)
  42. + ERR("Can't create dummy thread\n");
  43. +
  44. + WaitForSingleObject(dummy_thread_sync_event, INFINITE);
  45. +}
  46. +
  47. +static void end_dummy_thread(void)
  48. +{
  49. + SetEvent(dummy_thread_stop_event);
  50. + WaitForSingleObject(dummy_thread_handle, INFINITE);
  51. +
  52. + CloseHandle(dummy_thread_sync_event);
  53. + CloseHandle(dummy_thread_stop_event);
  54. + CloseHandle(dummy_thread_handle);
  55. +
  56. + dummy_thread_handle = NULL;
  57. +}
  58. +
  59. /****************************************************
  60. * TOP level entry points
  61. *****************************************************/
  62. @@ -7938,6 +7991,8 @@ UINT MSI_InstallPackage( MSIPACKAGE *package, LPCWSTR szPackagePath,
  63. msi_adjust_privilege_properties( package );
  64. msi_set_context( package );
  65. + start_dummy_thread();
  66. +
  67. productcode = msi_dup_property( package->db, szProductCode );
  68. if (strcmpiW( productcode, package->ProductCode ))
  69. {
  70. @@ -7985,6 +8040,8 @@ UINT MSI_InstallPackage( MSIPACKAGE *package, LPCWSTR szPackagePath,
  71. /* finish up running custom actions */
  72. ACTION_FinishCustomActions(package);
  73. +
  74. + end_dummy_thread();
  75. if (package->need_rollback && !reinstall)
  76. {