I'm not calling the function every frame, only once (first frame the dll is injected) (using a simple bool check). The CLR seems to handle the calling convention well, the parameters get passed as expected and after returning everything is cleaned up