Hello @Aaron Liu ,
Thank you for reaching out.
Based on your description, your approach seems correct. For error like InvalidInput, there are a few things you can check for:
- Protected handle validity — ensure you didn’t already close it or lose it due to an oplock break.
- Oplock callbacks — make sure you acknowledge any oplock break promptly.
- Handle lifetime — don’t hold the Win32 handle too long; use it briefly and close it.
- Share/access modes — verify the access flags passed to CfOpenFileWithOplock aren’t conflicting.
- Interference — antivirus or indexing can steal/break the lock.
- Correct cleanup — close the Win32 handle with
CloseHandle, and the protected handle withCfCloseHandle.
I hope this is helpful for your issue. If it does not work, I would appreciate if you can provide me more detail of the issue.