NtCreateFile fails
First of all, pardon my ignorance, I am new to wine and winapi. I am trying to implement apphelp.dll and I ran into issues with NtCreateFile: It always returns 0xc103, STATUS_NOT_A_DIRECTORY, and I am not sure what that means. Here is code: /* This function is not in API, but written for internal use */ HANDLE WINAPI SdbOpenFile( LPCWSTR path, PATH_TYPE type ) { /* SNIP */ if (type == DOS_PATH) if (!RtlDosPathNameToNtPathName_U(path, str, NULL, NULL)) return NULL; InitializeObjectAttributes(attr, str, OBJ_CASE_INSENSITIVE, NULL, NULL); status = NtCreateFile(file, GENERIC_READ | SYNCHRONIZE | FILE_READ_ATTRIBUTES, attr, io, NULL, FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ, FILE_OPEN, FILE_DIRECTORY_FILE, NULL, 0); /* SNIP */ return file; } Function is called like this: WCHAR szFileName[1024] = {0}; ExpandEnvironmentStringsW(L%SystemRoot%\\sample.sdb, szFileName, 1024); // for testing purposes SdbOpenFile(szFileName, DOS_PATH); Compiled with winegcc. I am sure that C:\windows\sample.sdb exists. What am I doing wrong?
Re: NtCreateFile fails
On 7/29/2013 18:02, Mislav Blazevic wrote: First of all, pardon my ignorance, I am new to wine and winapi. I am trying to implement apphelp.dll and I ran into issues with NtCreateFile: It always returns 0xc103, STATUS_NOT_A_DIRECTORY, and I am not sure what that means. Here is code: /* This function is not in API, but written for internal use */ HANDLE WINAPI SdbOpenFile( LPCWSTR path, PATH_TYPE type ) { /* SNIP */ if (type == DOS_PATH) if (!RtlDosPathNameToNtPathName_U(path, str, NULL, NULL)) return NULL; InitializeObjectAttributes(attr, str, OBJ_CASE_INSENSITIVE, NULL, NULL); status = NtCreateFile(file, GENERIC_READ | SYNCHRONIZE | FILE_READ_ATTRIBUTES, attr, io, NULL, FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ, FILE_OPEN, FILE_DIRECTORY_FILE, NULL, 0); /* SNIP */ return file; } Function is called like this: WCHAR szFileName[1024] = {0}; ExpandEnvironmentStringsW(L%SystemRoot%\\sample.sdb, szFileName, 1024); // for testing purposes SdbOpenFile(szFileName, DOS_PATH); Compiled with winegcc. I am sure that C:\windows\sample.sdb exists. What am I doing wrong? Probably you don't need FILE_DIRECTORY_FILE if it's not a directory?
Re: NtCreateFile fails
On Mon, Jul 29, 2013 at 04:02:03PM +0200, Mislav Blazevic wrote: First of all, pardon my ignorance, I am new to wine and winapi. I am trying to implement apphelp.dll and I ran into issues with NtCreateFile: It always returns 0xc103, STATUS_NOT_A_DIRECTORY, and I am not sure what that means. Here is code: /* This function is not in API, but written for internal use */ HANDLE WINAPI SdbOpenFile( LPCWSTR path, PATH_TYPE type ) { /* SNIP */ if (type == DOS_PATH) if (!RtlDosPathNameToNtPathName_U(path, str, NULL, NULL)) return NULL; InitializeObjectAttributes(attr, str, OBJ_CASE_INSENSITIVE, NULL, NULL); status = NtCreateFile(file, GENERIC_READ | SYNCHRONIZE | FILE_READ_ATTRIBUTES, attr, io, NULL, FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ, FILE_OPEN, FILE_DIRECTORY_FILE, NULL, 0); /* SNIP */ return file; } Function is called like this: WCHAR szFileName[1024] = {0}; ExpandEnvironmentStringsW(L%SystemRoot%\\sample.sdb, szFileName, 1024); // for testing purposes SdbOpenFile(szFileName, DOS_PATH); Compiled with winegcc. I am sure that C:\windows\sample.sdb exists. What am I doing wrong? Try printing out the expanded string. It will probably just print C Lstring does not work to specify WCHAR*, as the Linux L strings are differently sized than the Windows L strings. Ciao, Marcus