mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
implemented CreateSymbolicLink() (not tested/verified yet!)
svn path=/trunk/; revision=17559
This commit is contained in:
parent
ead53e0588
commit
20e728bbac
2 changed files with 100 additions and 3 deletions
|
@ -359,15 +359,109 @@ HANDLE STDCALL CreateFileW (LPCWSTR lpFileName,
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @unimplemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
BOOL STDCALL
|
BOOL STDCALL
|
||||||
CreateSymbolicLinkW(IN LPCWSTR lpSymlinkFileName,
|
CreateSymbolicLinkW(IN LPCWSTR lpSymlinkFileName,
|
||||||
IN LPCWSTR lpTargetFileName,
|
IN LPCWSTR lpTargetFileName,
|
||||||
IN DWORD dwFlags)
|
IN DWORD dwFlags)
|
||||||
{
|
{
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
UNICODE_STRING NtSymLink, NtTargetName;
|
||||||
return FALSE;
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
HANDLE hTarget, hSymbolicLink;
|
||||||
|
NTSTATUS Status;
|
||||||
|
BOOL Ret = FALSE;
|
||||||
|
|
||||||
|
if(!lpSymlinkFileName || !lpTargetFileName)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!RtlDosPathNameToNtPathName_U((LPWSTR)lpSymlinkFileName,
|
||||||
|
&NtSymLink,
|
||||||
|
NULL,
|
||||||
|
NULL))
|
||||||
|
{
|
||||||
|
/* FIXME - right error code? */
|
||||||
|
SetLastError(ERROR_PATH_NOT_FOUND);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!RtlDosPathNameToNtPathName_U((LPWSTR)lpTargetFileName,
|
||||||
|
&NtTargetName,
|
||||||
|
NULL,
|
||||||
|
NULL))
|
||||||
|
{
|
||||||
|
/* FIXME - right error code? */
|
||||||
|
SetLastError(ERROR_PATH_NOT_FOUND);
|
||||||
|
goto Cleanup2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Try to open the target
|
||||||
|
*/
|
||||||
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
|
&NtTargetName,
|
||||||
|
OBJ_CASE_INSENSITIVE,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if (dwFlags == SYMLINK_FLAG_DIRECTORY)
|
||||||
|
{
|
||||||
|
Status = NtOpenDirectoryObject(&hTarget,
|
||||||
|
SYNCHRONIZE,
|
||||||
|
&ObjectAttributes);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IO_STATUS_BLOCK IoStatusBlock;
|
||||||
|
|
||||||
|
Status = NtOpenFile(&hTarget,
|
||||||
|
SYNCHRONIZE,
|
||||||
|
&ObjectAttributes,
|
||||||
|
&IoStatusBlock,
|
||||||
|
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
|
||||||
|
FILE_SYNCHRONOUS_IO_NONALERT | FILE_OPEN_REPARSE_POINT);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
SetLastErrorByStatus(Status);
|
||||||
|
goto Cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
NtClose(hTarget);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create the symbolic link
|
||||||
|
*/
|
||||||
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
|
&NtSymLink,
|
||||||
|
OBJ_PERMANENT,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
Status = NtCreateSymbolicLinkObject(&hSymbolicLink,
|
||||||
|
SYMBOLIC_LINK_ALL_ACCESS,
|
||||||
|
&ObjectAttributes,
|
||||||
|
&NtTargetName);
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
NtClose(hSymbolicLink);
|
||||||
|
Ret = TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetLastErrorByStatus(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
Cleanup:
|
||||||
|
RtlFreeUnicodeString(&NtTargetName);
|
||||||
|
Cleanup2:
|
||||||
|
RtlFreeUnicodeString(&NtSymLink);
|
||||||
|
|
||||||
|
return Ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -504,6 +504,9 @@ extern "C" {
|
||||||
#define QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX 0x00000004
|
#define QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX 0x00000004
|
||||||
#define QUERY_ACTCTX_FLAG_ACTCTX_IS_HMODULE 0x00000008
|
#define QUERY_ACTCTX_FLAG_ACTCTX_IS_HMODULE 0x00000008
|
||||||
#define QUERY_ACTCTX_FLAG_ACTCTX_IS_ADDRESS 0x00000010
|
#define QUERY_ACTCTX_FLAG_ACTCTX_IS_ADDRESS 0x00000010
|
||||||
|
#if (_WIN32_WINNT >= 0x0600)
|
||||||
|
#define SYMLINK_FLAG_DIRECTORY 0x1
|
||||||
|
#endif
|
||||||
#endif /* (_WIN32_WINNT >= 0x0501) */
|
#endif /* (_WIN32_WINNT >= 0x0501) */
|
||||||
#if (_WIN32_WINNT >= 0x0500)
|
#if (_WIN32_WINNT >= 0x0500)
|
||||||
#define REPLACEFILE_WRITE_THROUGH 0x00000001
|
#define REPLACEFILE_WRITE_THROUGH 0x00000001
|
||||||
|
|
Loading…
Reference in a new issue