-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from tuxuser/for_emoose
Filesystem extraction (fixed disks, to raw or vhd), Xvd mount arguments
- Loading branch information
Showing
12 changed files
with
460 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System; | ||
|
||
namespace LibXboxOne.Vhd | ||
{ | ||
public struct VhdDiskGeometry | ||
{ | ||
public ushort Cylinder; | ||
public byte Heads; | ||
public byte SectorsPerCylinder; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using System; | ||
|
||
namespace LibXboxOne.Vhd | ||
{ | ||
public static class VhdUtils | ||
{ | ||
const uint VHD_SECTOR_LENGTH = 512; | ||
static readonly DateTime VhdEpoch = new DateTime(2000, 1, 1, 1, 0, 0, DateTimeKind.Utc); | ||
public static uint GetTimestamp(DateTime dateTime) | ||
{ | ||
return (uint)dateTime.Subtract(VhdEpoch).TotalSeconds; | ||
} | ||
|
||
// Source: https://github.com/ctatoiu/PS-Azure/blob/master/src/ServiceManagement/Compute/VhdManagement/Model/DiskGeometry.cs | ||
public static VhdDiskGeometry CalculateDiskGeometry(ulong driveSize) | ||
{ | ||
long totalSectors = (long)(driveSize / VHD_SECTOR_LENGTH); | ||
if (totalSectors > 65535 * 16 * 255) | ||
{ | ||
totalSectors = 65535 * 16 * 255; | ||
} | ||
|
||
int sectorsPerTrack; | ||
int heads; | ||
long cylinderTimesHeads; | ||
if (totalSectors >= 65535 * 16 * 63) | ||
{ | ||
sectorsPerTrack = 255; | ||
heads = 16; | ||
cylinderTimesHeads = totalSectors / sectorsPerTrack; | ||
} | ||
else | ||
{ | ||
sectorsPerTrack = 17; | ||
cylinderTimesHeads = totalSectors / sectorsPerTrack; | ||
|
||
heads = (int)((cylinderTimesHeads + 1023) / 1024); | ||
|
||
if (heads < 4) | ||
{ | ||
heads = 4; | ||
} | ||
if (cylinderTimesHeads >= (heads * 1024) || heads > 16) | ||
{ | ||
sectorsPerTrack = 31; | ||
heads = 16; | ||
cylinderTimesHeads = totalSectors / sectorsPerTrack; | ||
} | ||
if (cylinderTimesHeads >= (heads * 1024)) | ||
{ | ||
sectorsPerTrack = 63; | ||
heads = 16; | ||
cylinderTimesHeads = totalSectors / sectorsPerTrack; | ||
} | ||
} | ||
long cylinders = cylinderTimesHeads / heads; | ||
|
||
return new VhdDiskGeometry() | ||
{ | ||
Cylinder = (ushort)cylinders, | ||
Heads = (byte)heads, | ||
SectorsPerCylinder = (byte)sectorsPerTrack | ||
}; | ||
} | ||
} | ||
} |
Oops, something went wrong.