Click here to Skip to main content
11,717,883 members (82,344 online)
Click here to Skip to main content
Add your own
alternative version

Windows 2000 Junction Points

, 5 Jan 2000 369.7K 2.6K 83
Explains how reparse points are used to create filesystem links
junctionpoints_src.zip
JunctionPoints
FSLinks
FSLinks.dsp
MakeLink
MakeLink.dsp
MakeLink.dsw
MakeLink.exe
// Copyright 2000 Mikael Nordell (tamlin@algonet.se)
// Distributed without warranties. Use as you see fit, except for
// commercial purposes.
#include "FSLinks.h"

bool TMN_REPARSE_DATA_BUFFER::Init(LPCSTR szJunctionPoint)
{
	if (!szJunctionPoint || !*szJunctionPoint) {
		return false;
	}

	const size_t cchDest = lstrlenA(szJunctionPoint) + 1;
	if (cchDest > 512) {
		return false;
	}
	wchar_t wszDestMountPoint[512];
	if (!MultiByteToWideChar(CP_THREAD_ACP,
							MB_PRECOMPOSED,
							szJunctionPoint,
							cchDest,
							wszDestMountPoint,
							cchDest))
	{
		return false;
	}

	return Init(wszDestMountPoint);
}

bool TMN_REPARSE_DATA_BUFFER::Init(LPCWSTR wszJunctionPoint)
{
	if (!wszJunctionPoint || !*wszJunctionPoint) {
		return false;
	}

	const size_t nDestMountPointBytes = lstrlenW(wszJunctionPoint) * 2;

	ReparseTag           = IO_REPARSE_TAG_MOUNT_POINT;
	ReparseDataLength    = nDestMountPointBytes + 12;
	Reserved             = 0;
	SubstituteNameOffset = 0;
	SubstituteNameLength = nDestMountPointBytes;
	PrintNameOffset      = nDestMountPointBytes + 2;
	PrintNameLength      = 0;
	lstrcpyW(PathBuffer, wszJunctionPoint);

	return true;
}

int TMN_REPARSE_DATA_BUFFER::BytesForIoControl() const
{
	return ReparseDataLength + TMN_REPARSE_DATA_BUFFER_HEADER_SIZE;
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Mike Nordell
Architect
Sweden Sweden
No Biography provided

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150901.1 | Last Updated 6 Jan 2000
Article Copyright 2000 by Mike Nordell
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid