You do not have to create your own translation tables. Just translate the NTSTATUS into an error code, similar to how its done in kernel32:
SetLastError(RtlNtStatusToDosError(status));
I found SetLastError(RltNtStatusToDosError(status)) behaved not correct , when the file length is very long , It give the error code ERROR_INVALID_PARAMETER
but Windows give the ERROR_FILENAME_EXCED_RANGE
should I omit this and just use SetLastError(RtlNtStatusToDosError(status)) or maullay set the error code to ERROR_FILENAME_EXCED_RANGE?