+ if (lstrlenW(filename) + lstrlenW(path) + ARRAY_SIZE(str_dll) + 4
= filename_size) /* Include blackslash and null-terminator */
This looks like it goes over the needed length. ARRAY_SIZE will include the null terminator from str_dll, and the backslash is only one character.
This looks good otherwise, but unfortunately attempting to run your test with wine-mono master (which has csc) fails due to an unrelated bug. I'll have to fix that before I can verify the test results.