On Wed Feb 19 18:41:31 2025 +0000, Jacek Caban wrote:
While placing it here avoids duplicating the `LdrUnloadDll` call in this commit, that won't be the case once the entire series is committed. In the end, it’s only useful in the branch handling the `!proc` case. I’d suggest moving it to the `!proc` branch (next to the `ERR`), duplicating it in the branch that handles process_attach failure, and removing the latter in the commit that eliminates the process_attach call. That way, you could also remove the need to reset `wm_owned_ref` above, simplifying the logic.
Thanks for the insight.
The intention of `wm_owned_ref` is to explicitly document where exactly the ownership of `wm` is acquired, stolen, and released. It's a compromise between "full AddRef/Release-like smart pointer management" and "implicit refcount management not too visible in code, and may subtly break if the developer is unaware of the rules."
I guess it's "only after successful resolution" part that's initiating the complexity. Let me drop it, and maybe re-introduce it in another MR with proper tests.