wusa.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /*
  2. * Copyright 2015 Michael Müller
  3. * Copyright 2015 Sebastian Lackner
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2.1 of the License, or (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public
  16. * License along with this library; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  18. */
  19. enum
  20. {
  21. ASSEMBLY_STATUS_NONE,
  22. ASSEMBLY_STATUS_IN_PROGRESS,
  23. ASSEMBLY_STATUS_INSTALLED,
  24. };
  25. struct assembly_identity
  26. {
  27. WCHAR *name;
  28. WCHAR *version;
  29. WCHAR *architecture;
  30. WCHAR *language;
  31. WCHAR *pubkey_token;
  32. };
  33. struct dependency_entry
  34. {
  35. struct list entry;
  36. struct assembly_identity identity;
  37. };
  38. struct fileop_entry
  39. {
  40. struct list entry;
  41. WCHAR *source;
  42. WCHAR *target;
  43. };
  44. struct registrykv_entry
  45. {
  46. struct list entry;
  47. WCHAR *name;
  48. WCHAR *value_type;
  49. WCHAR *value;
  50. };
  51. struct registryop_entry
  52. {
  53. struct list entry;
  54. WCHAR *key;
  55. struct list keyvalues;
  56. };
  57. struct assembly_entry
  58. {
  59. struct list entry;
  60. DWORD status;
  61. WCHAR *filename;
  62. WCHAR *displayname;
  63. struct assembly_identity identity;
  64. struct list dependencies;
  65. struct list fileops;
  66. struct list registryops;
  67. };
  68. void free_assembly(struct assembly_entry *entry) DECLSPEC_HIDDEN;
  69. void free_dependency(struct dependency_entry *entry) DECLSPEC_HIDDEN;
  70. struct assembly_entry *load_manifest(const WCHAR *filename) DECLSPEC_HIDDEN;
  71. BOOL load_update(const WCHAR *filename, struct list *update_list) DECLSPEC_HIDDEN;
  72. static void *heap_alloc(size_t len) __WINE_ALLOC_SIZE(1);
  73. static inline void *heap_alloc(size_t len)
  74. {
  75. return HeapAlloc(GetProcessHeap(), 0, len);
  76. }
  77. static void *heap_alloc_zero(size_t len) __WINE_ALLOC_SIZE(1);
  78. static inline void *heap_alloc_zero(size_t len)
  79. {
  80. return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
  81. }
  82. static void *heap_realloc(void *mem, size_t len) __WINE_ALLOC_SIZE(2);
  83. static inline void *heap_realloc(void *mem, size_t len)
  84. {
  85. return HeapReAlloc(GetProcessHeap(), 0, mem, len);
  86. }
  87. static inline BOOL heap_free(void *mem)
  88. {
  89. return HeapFree(GetProcessHeap(), 0, mem);
  90. }
  91. static inline char *strdupWtoA(const WCHAR *str)
  92. {
  93. char *ret = NULL;
  94. DWORD len;
  95. if (!str) return ret;
  96. len = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
  97. if ((ret = heap_alloc(len)))
  98. WideCharToMultiByte(CP_ACP, 0, str, -1, ret, len, NULL, NULL);
  99. return ret;
  100. }
  101. static inline WCHAR *strdupAtoW(const char *str)
  102. {
  103. WCHAR *ret = NULL;
  104. DWORD len;
  105. if (!str) return ret;
  106. len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
  107. if ((ret = heap_alloc(len * sizeof(WCHAR))))
  108. MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
  109. return ret;
  110. }
  111. static inline WCHAR *strdupW(const WCHAR *str)
  112. {
  113. WCHAR *ret;
  114. if (!str) return NULL;
  115. ret = heap_alloc((lstrlenW(str) + 1) * sizeof(WCHAR));
  116. if (ret) lstrcpyW(ret, str);
  117. return ret;
  118. }
  119. static inline WCHAR *strdupWn(const WCHAR *str, DWORD len)
  120. {
  121. WCHAR *ret;
  122. if (!str) return NULL;
  123. ret = heap_alloc((len + 1) * sizeof(WCHAR));
  124. if (ret)
  125. {
  126. memcpy(ret, str, len * sizeof(WCHAR));
  127. ret[len] = 0;
  128. }
  129. return ret;
  130. }