المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : SetFilePointerEx not moving pointer



C# Programming
01-01-2011, 02:15 PM
Hey there,

I'm working on an NTFS Master File Table reader as part of a project for University. I've already got a Console API working in C++ which reads the current $MFT file/table, and i've begun work on porting the code over to C# (as per my requirements), however my version of SetFilePointerEx doesn't seem to move the file buffer pointer.

My C++ code:

BOOL __stdcall SetFileBlock********(HANDLE address, LARGE_INTEGER position)
{
return SetFilePointerEx(address, position, NULL, FILE_BEGIN);
}
My C# code:

public bool AssignPointerPosition(Int64 position, EFileMove movement)
{
if (this.IsBufferReady == false)
return false;

if (Win32API.SetFilePointerEx(this.block, (long)position, IntPtr.Zero, movement) == false)
{
this.errorcode = Marshal.GetLastWin32Error();
this.errorpos = MFTHaltPosition.MoveFile;
return false;
}

return true;
}
Where EFileMove is set to EFileMove.FileBegin (aka. 0)
When I run another ReadFile, it continues to read out the same block of data into the buffer (the first four bytes should be FILE, but instead reads the beginning of the NTFS block).

Does anyone have an idea why it wouldn't move the pointer forward (position is a value far above 0), and is there a solution?

Thank you,
Chris