P/Invoke boolean call always returns true in Release builds
I have a simple boolean function in a native C++ DLL (for keyboard input in my case), which I P/Invoke from C#. In debug builds, everything works fine. But in a release build (of both the C# and C++ projects), the C# side always receives true from the P/Invoke call, even when the native side returns false. I've checked my build settings but I can't figure out what is happening here- any recommendations for how to debug this or what could be the potential cause?
For reference - my code looks a little bit something like this: C++: