Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mft.ParseDataRuns returns invalid values #1

Closed
shen1l opened this issue Jul 23, 2020 · 2 comments
Closed

mft.ParseDataRuns returns invalid values #1

shen1l opened this issue Jul 23, 2020 · 2 comments

Comments

@shen1l
Copy link

shen1l commented Jul 23, 2020

  • in "padTo" function , I don't get the point of filling 0xff to the return value. maybe you should jsut remove it
func ParseDataRuns(b []byte) ([]DataRun, error) {
	...
	dataLength := binary.LittleEndian.Uint64(padTo(lengthBytes, 8))
	....
	dataOffset := int64(binary.LittleEndian.Uint64(padTo(offsetBytes, 8)))
}

func padTo(data []byte, length int) []byte {
        ..... 
	if data[len(data)-1]&0b10000000 == 0b10000000 {
		for i := len(data); i < length; i++ {
			result[i] = 0xFF
		}
	}
	return result
}
@shen1l shen1l closed this as completed Jul 24, 2020
@t9t
Copy link
Owner

t9t commented Jul 24, 2020

Hi @shen1l thanks for taking the time to create an issue and I'm sorry that I didn't get the chance to look into it and write a reply. Could you maybe help me and mention what you found out as to close the issue?

The padding is necessary to ensure the byte slice is 8 bytes (64 bits) long before converting from little endian. If you put fewer than 8 bytes into binary.LittleEndian.Uint64 it will produce an error. A lot of the numbers in the MFT are stored in fewer than 8 bytes (sometimes even pretty odd numbers, like 3 bytes).

@haobaojiang
Copy link

@t9t Sorry, I closed the issue coz I endup using any third-part parser to do the thing I am working on, I am now using windows API "DeviceIoControl" with ioctl code "fsctl_get_retrieval_pointers" "fsctl get_ntfs_file record" to do the work.

Here was my trouble case,I used ParseDataRuns->DataRunsToFragments. from the return values I found that on fragment offset is very large which is 60gb ,but my volume is 6gb size only, I don't know where went wrong.

type Fragment struct {
	Offset int64         // the value of this field exceeded the whole volume size 
	Length int64
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants