MOVEFILE_DESCRIPTOR or MOVE_FILE_DATA

Hi all:

I am using FSCTL_MOVE_FILE to move a file on disk. I notice that
defrag.h from sysinternels use

typedef struct {
HANDLE FileHandle;
ULONG Reserved;
LARGE_INTEGER StartVcn;
LARGE_INTEGER TargetLcn;
ULONG NumVcns;
ULONG Reserved1;
} MOVEFILE_DESCRIPTOR, *PMOVEFILE_DESCRIPTOR;

While ntifs.h use

typedef struct {

HANDLE FileHandle;

LARGE_INTEGER StartingVcn;

LARGE_INTEGER StartingLcn;

ULONG ClusterCount;

} MOVE_FILE_DATA, *PMOVE_FILE_DATA;

I try them on both x32 and x64 platforms. The MOVEFILE_DESCRIPTOR works only
on x32 and MOVE_FILE_DATA works on both. I makes sense that MOVE_FILE_DATA
is the right choice, since it is from ddk. But why MOVEFILE_DESCRIPTOR works
on x32 platform? The “Reserved” field makes the two structs ABSOLUTELY
different!

I am really puzzled L

> I am using FSCTL_MOVE_FILE to move a file on disk. I notice
that

defrag.h from sysinternels use

typedef struct {
HANDLE FileHandle;
ULONG Reserved;
LARGE_INTEGER StartVcn;
LARGE_INTEGER TargetLcn;
ULONG NumVcns;
ULONG Reserved1;
} MOVEFILE_DESCRIPTOR, *PMOVEFILE_DESCRIPTOR;

While ntifs.h use

typedef struct {

HANDLE FileHandle;

LARGE_INTEGER StartingVcn;

LARGE_INTEGER StartingLcn;

ULONG ClusterCount;

} MOVE_FILE_DATA, *PMOVE_FILE_DATA;

I try them on both x32 and x64 platforms. The MOVEFILE_DESCRIPTOR
works only
on x32 and MOVE_FILE_DATA works on both. I makes sense that
MOVE_FILE_DATA is
the right choice, since it is from ddk. But why MOVEFILE_DESCRIPTOR
works on
x32 platform? The “Reserved” field makes the two structs ABSOLUTELY
different!

Not necessarily. If the compiler aligns everything to a LARGE_INTEGER
boundary then the two structures will be exactly the same in terms of
byte offset. Could x64 be aligning to LARGE_INTEGER boundary?

Try printing out the sizeof() of both structs in both cases.

James

gotcha!
compiler aligns everything to a LARGE_INTEGER boundary in both platforms

xxxxx@hotmail.com wrote:

gotcha!
compiler aligns everything to a LARGE_INTEGER boundary in both platforms

Well, not everything – it aligns the LARGE_INTEGER to a LARGE_INTEGER
boundary. That’s the key.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

>MOVE_FILE_DATA works on both. I makes sense that MOVE_FILE_DATA is the right choice

Yes.

But why MOVEFILE_DESCRIPTOR works on x32 platform

On 32bit, given the alignment padding, MOVEFILE_DESCRIPTOR is the same as MOVE_FILE_DATA.

Not so on 64bit.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com