REPARSE_DATA_BUFFER and user space

Hi,

I would like to use elements of the REPARSE_DATA_BUFFER structure returned by FSCTL_GET_REPARSE_POINT in my user-space program. Since REPARSE_DATA_BUFFER seems to only be defined in ntifs.h and this is part of the IFS kit, my initial feeling is to stay away from this kernel header file and include the structure locally in my program. Is it advisable to include ntifs.h in a user-space program?

Thank you in advance,
~Elisabeth

This may help. Just replace my helper SimpleFile class appropriately.
Actually winioctl has everything you need.

// test.cpp
#define _WIN32_WINNT 0x0400 // at least, for RETRIEVAL_POINTERS_BUFFER
#define _CRT_SECURE_NO_DEPRECATE
#undef _CRT_SECURE_NO_DEPRECATE
// ----------------------------------------------------------------------------
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <winioctl.h>
#include “…\ClientServer\SimpleFile.h”
// ----------------------------------------------------------------------------
int TellMeWhereFileOnAVolumeIs() {
bool ctorWasOk;
SimpleFile hFile(ctorWasOk, “test.fle”, FILE_READ_ATTRIBUTES, GENERIC_READ,
0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL);
if(!ctorWasOk) {
return 101;
}
PRETRIEVAL_POINTERS_BUFFER pFileRetrievalPointers = 0;
STARTING_VCN_INPUT_BUFFER startingVcnBuffer;
startingVcnBuffer.StartingVcn.QuadPart = 0;
ULONG numberOfExtents = 0;
BOOL brc;
// try 1, 2, 3 etc. extents until success:
do {
++numberOfExtents;
//printf(“trying numberOfExtents=%u\n”, numberOfExtents);
if(pFileRetrievalPointers) {
free(pFileRetrievalPointers);
}
// one instance of Extents is embedded in RETRIEVAL_POINTERS_BUFFER struct,
// so numberOfExtents is decremented by one:
SIZE_T allocationSize = sizeof(RETRIEVAL_POINTERS_BUFFER)
+ (numberOfExtents - 1) * 2 * sizeof(LARGE_INTEGER);
//printf(“trying numberOfExtents=%u allocationSize=%u\n”, numberOfExtents,
allocationSize);
pFileRetrievalPointers = (PRETRIEVAL_POINTERS_BUFFER)malloc(allocationSize);
//printf(" pFileRetrievalPointers=0x%x\n",
(UINT_PTR)pFileRetrievalPointers);
if(!pFileRetrievalPointers) {
printf(“Failed to allocate retr ptrs buffer; size=%d, numberOfExtents=%d\n”,
allocationSize, numberOfExtents);
return 104;
}
pFileRetrievalPointers->ExtentCount = numberOfExtents;
DWORD bytesReturned;
brc = DeviceIoControl(hFile, FSCTL_GET_RETRIEVAL_POINTERS,
&startingVcnBuffer,
sizeof(startingVcnBuffer),
pFileRetrievalPointers,
(DWORD)allocationSize,
&bytesReturned, 0);
} while(FALSE == brc && ERROR_MORE_DATA == GetLastError());
if(TRUE == brc) {
printf(" ExtentCount=%d\n", pFileRetrievalPointers->ExtentCount);
unsigned __int64 prevStartVcn = startingVcnBuffer.StartingVcn.QuadPart;
for(DWORD currExtent = 0; currExtent < pFileRetrievalPointers->ExtentCount;
++currExtent) {
printf(“extent #%u: VCNs %I64u - %I64u starts at volume LCN %I64u\n”,
currExtent,
prevStartVcn, pFileRetrievalPointers->Extents[currExtent].NextVcn.QuadPart -
1,
pFileRetrievalPointers->Extents[currExtent].Lcn.QuadPart);
prevStartVcn = pFileRetrievalPointers->Extents[currExtent].NextVcn.QuadPart;
}
}
free(pFileRetrievalPointers);
pFileRetrievalPointers = 0;
return 0;
}
// ----------------------------------------------------------------------------
int main(int argc, char* argv) {
int irc = 0;
irc = TellMeWhereFileOnAVolumeIs();
return irc;
}
// ----------------------------------------------------------------------------

----- Original Message -----
From:
To: “Windows File Systems Devs Interest List”
Sent: Thursday, April 20, 2006 10:59 AM
Subject: [ntfsd] REPARSE_DATA_BUFFER and user space

> Hi,
>
> I would like to use elements of the REPARSE_DATA_BUFFER structure returned
> by FSCTL_GET_REPARSE_POINT in my user-space program. Since
> REPARSE_DATA_BUFFER seems to only be defined in ntifs.h and this is part
> of the IFS kit, my initial feeling is to stay away from this kernel header
> file and include the structure locally in my program. Is it advisable to
> include ntifs.h in a user-space program?
>
> Thank you in advance,
> ~Elisabeth
>
> —
> Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@comcast.net
> To unsubscribe send a blank email to xxxxx@lists.osr.com
></winioctl.h></stdlib.h></stdio.h></windows.h>