Add p/invoke signatures and necessary safe handles.