Hi Stefan, On 05/18/17 13:33, Stefan Dösinger wrote:
+/* ??_Open_dir(a)sys@tr2(a)std@@YAPAXPA_WPB_WAAHAAW4file_type(a)123@@Z */ +/* ??_Open_dir(a)sys@tr2(a)std@@YAPEAXPEA_WPEB_WAEAHAEAW4file_type(a)123@@Z */ +void* __cdecl tr2_sys__Open_dir_wchar(wchar_t* target, wchar_t const* dest, int* err_code, enum file_type* type) { HANDLE handle; - WIN32_FIND_DATAA data; - char temppath[MAX_PATH]; - - TRACE("(%p %s %p %p)\n", target, debugstr_a(dest), err_code, type); - if(strlen(dest) > MAX_PATH - 3) { + WIN32_FIND_DATAW data; + wchar_t temppath[MAX_PATH]; + static const wchar_t dot[] = {'.', 0}; + static const wchar_t dotdot[] = {'.', '.', 0}; + static const wchar_t asterisk[] = {'\\', '*', 0}; + + TRACE("(%p %s %p %p)\n", target, debugstr_w(dest), err_code, type); + if(wcslen(dest) > MAX_PATH - 3) { *err_code = ERROR_BAD_PATHNAME; return NULL; } Could you please check if there really is such a length limit in wchar version of the function?
+/* ?_Open_dir(a)sys@tr2(a)std@@YAPAXAAY0BAE(a)DPBDAAHAAW4file_type@123@@Z */ +/* ?_Open_dir(a)sys@tr2(a)std@@YAPEAXAEAY0BAE(a)DPEBDAEAHAEAW4file_type@123@@Z */ +void* __cdecl tr2_sys__Open_dir(char* target, char const* dest, int* err_code, enum file_type* type) +{ + void *handle; + size_t len; + wchar_t target_w[MAX_PATH]; + wchar_t *dest_w = NULL; + + TRACE("(%p %s %p %p)\n", target, debugstr_a(dest), err_code, type); + + if (dest) + { + len = strlen(dest) + 1; + dest_w = malloc(sizeof(*dest_w) * len); You don't need to allocate dest_w dynamically. Its length is limited to ~MAX_PATH anyway.
Thanks, Piotr