@@ -198,6 +198,80 @@ USERSIM_API _Ret_maybenull_ void*
198
198
ExAllocatePoolWithTagCPP (
199
199
_In_ __drv_strictTypeMatch (__drv_typeExpr) POOL_TYPE pool_type, SIZE_T number_of_bytes, ULONG tag);
200
200
201
+ /* *
202
+ * @brief Allocate memory.
203
+ * @param[in] pool_type Pool type to use.
204
+ * @param[in] size Size of memory to allocate.
205
+ * @param[in] tag Pool tag to use.
206
+ * @param[in] initialize False to return "uninitialized" memory.
207
+ * @returns Pointer to memory block allocated, or null on failure.
208
+ */
209
+ __drv_allocatesMem (Mem) _Must_inspect_result_ _Ret_writes_maybenull_(size) void* usersim_allocate_with_tag(
210
+ _In_ __drv_strictTypeMatch (__drv_typeExpr) POOL_TYPE pool_type,
211
+ size_t size,
212
+ uint32_t tag,
213
+ bool initialize);
214
+
215
+ /* *
216
+ * @brief Allocate memory.
217
+ * @param[in] size Size of memory to allocate.
218
+ * @returns Pointer to memory block allocated, or null on failure.
219
+ */
220
+ __drv_allocatesMem (Mem) _Must_inspect_result_ _Ret_writes_maybenull_(size) void* usersim_allocate(size_t size);
221
+
222
+ /* *
223
+ * @brief Reallocate memory.
224
+ * @param[in] memory Allocation to be reallocated.
225
+ * @param[in] old_size Old size of memory to reallocate.
226
+ * @param[in] new_size New size of memory to reallocate.
227
+ * @returns Pointer to memory block allocated, or null on failure.
228
+ */
229
+ __drv_allocatesMem (Mem) _Must_inspect_result_ _Ret_writes_maybenull_(new_size) void* usersim_reallocate(
230
+ _In_ _Post_invalid_ void * memory, size_t old_size, size_t new_size);
231
+
232
+ /* *
233
+ * @brief Reallocate memory with tag.
234
+ * @param[in] memory Allocation to be reallocated.
235
+ * @param[in] old_size Old size of memory to reallocate.
236
+ * @param[in] new_size New size of memory to reallocate.
237
+ * @param[in] tag Pool tag to use.
238
+ * @returns Pointer to memory block allocated, or null on failure.
239
+ */
240
+ __drv_allocatesMem (Mem) _Must_inspect_result_ _Ret_writes_maybenull_(new_size) void* usersim_reallocate_with_tag(
241
+ _In_ _Post_invalid_ void * memory, size_t old_size, size_t new_size, uint32_t tag);
242
+
243
+ /* *
244
+ * @brief Free memory.
245
+ * @param[in] memory Allocation to be freed.
246
+ */
247
+ void
248
+ usersim_free (_Frees_ptr_opt_ void * memory);
249
+
250
+ /* *
251
+ * @brief Allocate memory that has a starting address that is cache aligned.
252
+ * @param[in] size Size of memory to allocate
253
+ * @returns Pointer to memory block allocated, or null on failure.
254
+ */
255
+ USERSIM_API
256
+ __drv_allocatesMem (Mem) _Must_inspect_result_
257
+ _Ret_writes_maybenull_(size) void* usersim_allocate_cache_aligned(size_t size);
258
+
259
+ /* *
260
+ * @brief Allocate memory that has a starting address that is cache aligned with tag.
261
+ * @param[in] size Size of memory to allocate
262
+ * @param[in] tag Pool tag to use.
263
+ * @returns Pointer to memory block allocated, or null on failure.
264
+ */
265
+ __drv_allocatesMem (Mem) _Must_inspect_result_
266
+ _Ret_writes_maybenull_(size) void* usersim_allocate_cache_aligned_with_tag(size_t size, uint32_t tag);
267
+
268
+ /* *
269
+ * @brief Free memory that has a starting address that is cache aligned.
270
+ * @param[in] memory Allocation to be freed.
271
+ */
272
+ void
273
+ usersim_free_cache_aligned (_Frees_ptr_opt_ void * memory);
274
+
201
275
USERSIM_API _Ret_maybenull_ void *
202
276
ExAllocatePoolUninitializedCPP (_In_ POOL_TYPE pool_type, _In_ size_t number_of_bytes, _In_ unsigned long tag);
203
277
@@ -207,4 +281,26 @@ ExRaiseAccessViolationCPP();
207
281
USERSIM_API void
208
282
ExRaiseDatatypeMisalignmentCPP ();
209
283
284
+ void usersim_initialize_ex (bool leak_detector);
285
+ void usersim_clean_up_ex ();
286
+
287
+ #ifdef __cplusplus
288
+ #include < memory>
289
+ namespace usersim_helper {
290
+
291
+ struct _usersim_free_functor
292
+ {
293
+ void
294
+ operator ()(void * memory)
295
+ {
296
+ usersim_free (memory);
297
+ }
298
+ };
299
+
300
+ typedef std::unique_ptr<void , _usersim_free_functor> usersim_memory_ptr;
301
+
302
+ } // namespace usersim_helper
303
+
304
+ #endif
305
+
210
306
#endif
0 commit comments