-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Wdf* APIs required by ebpf-for-windows #76
Conversation
dthaler
commented
Aug 4, 2023
•
edited
Loading
edited
- Add Wdf* APIs required by ebpf-for-windows (fixes Etw* API support #70)
- Fix bug in ke.cpp where wrong function was used to free memory allocated by C++ allocator
- Add cache-aligned allocations (fixes Add cache-aligned allocation #31)
- Add stub for IofCompleteRequest (addresses part of IofCompleteRequest support #69)
- Add error check for freeing unallocated memory in leak_detector.cpp
- Move usersim_allocate functions from platform_user.cpp to ex.cpp where the other allocation functions are
- Make Ndis* and usersim_fwp_* functions callable from C code
- Fix bug in dll skeleton where DRIVER_OBJECT was freed during driver entry because it was on the stack. It needs to survive until unload.
Add cache-aligned allocations (fixes #31) Signed-off-by: Dave Thaler <[email protected]>
inc/usersim/ex.h
Outdated
* @param[in] initialize False to return "uninitialized" memory. | ||
* @returns Pointer to memory block allocated, or null on failure. | ||
*/ | ||
__drv_allocatesMem(Mem) _Must_inspect_result_ _Ret_writes_maybenull_(size) void* usersim_allocate_with_tag( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: what is the difference between usersim_allocate_with_tag()
with PoolType NonPagedPoolNxCacheAligned
and usersim_allocate_cache_aligned()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't done cleanup, but usersim_allocate_cache_aligned doesn't do anything with the tag, so I think it should be removed. usersim_allocate_cache_aligned_with_tag and usersim_allocate_with_tag() with PoolType NonPagedPoolNxCacheAligned are similar, but usersim_allocate_with_tag should really detect any cache-aligned pool type (it doesn't yet). I suspect in the DLL form, nothing calls usersim_allocate_cache_aligned or usersim_allocate_cache_aligned_with_tag, but will check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will clean this up in a separate PR as part of the work for microsoft/ebpf-for-windows#2677. In the meantime, I have added some TODO comments in the code.
Also make more kernel functions callable from C code Signed-off-by: Dave Thaler <[email protected]>
Signed-off-by: Dave Thaler <[email protected]>
src/platform_user.cpp
Outdated
@@ -204,9 +201,9 @@ usersim_platform_initiate() | |||
try { | |||
_usersim_platform_maximum_group_count = GetMaximumProcessorGroupCount(); | |||
_usersim_platform_maximum_processor_count = GetMaximumProcessorCount(ALL_PROCESSOR_GROUPS); | |||
auto fault_injection_stack_depth = | |||
bool fault_injection_stack_depth = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is size_t, not bool.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, thanks
Signed-off-by: Dave Thaler <[email protected]>