FindNextFile failing with error ERROR_INVALID_FUNCTION

Hi,

I have been using FindNextFile() to enumerate all files in a folder. It will enumerate all the files until FindNextFile() fails with error ERROR_NO_MORE_FILES.
There has been no changes in this part of code and it has been working fine all these years, but in one of my customers’ machine (windows server 2016) it returns error (getlasterror) ERROR_INVALID_FUNCTION. What does it mean and how should I handle it?

Thanks,
Kunal

> What does it mean and how should I handle it?

Your filter (or whatever) or something else has started returning
STATUS_INVALID_FUNCTION.

Promon is your friend. Fire that up, find the precise IRP that causes the
problem and start reading code (or debugging it)

Rod

Rod is spot on about running Process Monitor. However, just wanted to point
out that multiple native status codes can translate to
ERROR_INVALID_FUNCTION. According to winerror.exe:

1 ERROR_INVALID_FUNCTION <–> 0xc0000002 STATUS_NOT_IMPLEMENTED
1 ERROR_INVALID_FUNCTION <–> 0xc0000010 STATUS_INVALID_DEVICE_REQUEST
1 ERROR_INVALID_FUNCTION <–> 0xc000001c STATUS_INVALID_SYSTEM_SERVICE
1 ERROR_INVALID_FUNCTION <–> 0xc00000af STATUS_ILLEGAL_FUNCTION
1 ERROR_INVALID_FUNCTION <–> 0xc000029c STATUS_VOLUME_NOT_UPGRADED
1 ERROR_INVALID_FUNCTION <–> 0xc0000710
STATUS_CALLBACK_RETURNED_WHILE_IMPERSONATING
1 ERROR_INVALID_FUNCTION <–> 0xc0000711
STATUS_APC_RETURNED_WHILE_IMPERSONATING
1 ERROR_INVALID_FUNCTION <–> 0xc000071b
STATUS_CALLBACK_RETURNED_THREAD_PRIORITY
1 ERROR_INVALID_FUNCTION <–> 0xc000071d
STATUS_CALLBACK_RETURNED_TRANSACTION
1 ERROR_INVALID_FUNCTION <–> 0xc000071e STATUS_CALLBACK_RETURNED_LDR_LOCK
1 ERROR_INVALID_FUNCTION <–> 0xc000071f STATUS_CALLBACK_RETURNED_LANG
1 ERROR_INVALID_FUNCTION <–> 0xc0000720 STATUS_CALLBACK_RETURNED_PRI_BACK
1 ERROR_INVALID_FUNCTION <–> 0xc0000721
STATUS_CALLBACK_RETURNED_THREAD_AFFINITY
1 ERROR_INVALID_FUNCTION <–> 0xc0010001 DBG_NO_STATE_CHANGE

So you’ll want to look for any of those in the Process Monitor output.

-scott
OSR
@OSRDrivers