Add InterlockedExchangeAdd to kernel32 API stubs#292
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Code Review
This pull request implements the InterlockedExchangeAdd API hook in kernel32.py, which performs an atomic addition to a memory address and returns the original value. The feedback suggests explicitly masking the input value to 32 bits before the addition to ensure the operation remains consistent, particularly in 64-bit environments where registers might contain extraneous data in the upper bits.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
williballenthin
left a comment
There was a problem hiding this comment.
thanks @dinis-cruz-bs!
InterlockedExchangeAddis a commonly usedkernel32export for atomicaddition (CRT, COM, and many third-party runtimes call it). Without a stub,
emulation hits an
unsupported_apierror duringDLL_PROCESS_ATTACHandterminates before any subsequent API calls can be captured.
Implementation reads the current DWORD at
Addend, addsValue, writesthe result back, and returns the original value — matching the documented
Windows behaviour.
Placed alongside the existing
InterlockedIncrement/InterlockedDecrementstubs inkernel32.py.