-1

I create vhd in different formats (NTFS, FAT32, FAT16, HFS +), I do not find the way to get the $ Volume_name offset of an NTFS partition, plus I would like to convert a string to $ Volume_name. By observing the $ Volume_name of an NTFS partition I was able to see that the string is cut (after each character there is a null character example what we read in hexadecimal of the volume_name that would be "WIN10EN" and in hexa "57494e3130454e" if we go to the offset of $ volume_name we will read with a hexadecimal editor 570049004e003100300045004e and its representation ascii "W I N 1 0 E N". Hence my question is there a command to obtain the offset of $ Volume_name (the offset is in byte 15776 or 0x3DA0)? Is there a string conversion to name a Volume?

brian d foy
  • 129,424
  • 31
  • 207
  • 592
deek5
  • 367
  • 1
  • 13
  • From the [Virtual Hard Disk Image Format Specification](http://download.microsoft.com/download/f/f/e/ffef50a5-07dd-4cf8-aaa3-442c0673a029/Virtual%20Hard%20Disk%20Format%20Spec_10_18_06.doc), I think volume names are Unicode that been encoded as UTF-16, which would explain the "cut" characters you're seeing in the string. Python has extensive Unicode support (I don't know about all the others). – martineau Dec 01 '16 at 02:11
  • Hello, thank you for the clarification, the problem is not specific to vhd, all Volumes (NTFS) (partitions in NTFS) have the same structure and have a $Volume_name (which is the name of the partition) Get the $ Volume_name offset and the string conversion to rename. Thank you for your time spent on the subject. – deek5 Dec 01 '16 at 08:20

2 Answers2

1

Hello, to rename a Volume with Xcode on Mac, the easiest way is to use The functions of DiskArbitration and more specifically

"void DADiskRename (DADiskRef disk, CFStringRef name, DADiskRenameOptions options, DADiskRenameCallback callback, void * context);
"

With an empty callback. Which can give.

#import <DiskArbitration / DiskArbitration.h>
#import <Cocoa / Cocoa.h>



Void MountCallback (DADiskRef disk, DADitererRef dissenter, void * context);

Void DADiskRename (DADiskRef disk, CFStringRef name, DADiskRenameOptions options, DADiskRenameCallback callback, void * context);
Int rename (char * argv, char * device)
Int renomer ((char * argv, char * device)
{

    Const char * deviceName = device;

    Renom = 1;

    CFStringRef name = CFStringCreateWithCString (NULL, argv, kCFStringEncodingUTF8);



    DASessionRef session = DASessionCreate (kCFAllocatorDefault);

    DADiskRef disk = DADiskCreateFromBSDName (kCFAllocatorDefault, session, deviceName);

    DADiskRename (disk, name, 0x00000000, MountCallback, (void *) deviceName);

    DASessionSetDispatchQueue (session, NULL);

    CFRelease (session);

    Session = NULL;

Return EXIT_SUCCESS;


}



Void MountCallback (DADiskRef disk, DADitererRef dissenter, void * context) {

    Return;
}
deek5
  • 367
  • 1
  • 13
0

In the creation of a Vhd of course there is the formatting of the partition (my Vhd created have a unique MBR partition) formatting with diskutil according to the chosen system the names of the partitions is limited for NTFS according to diskutil the names are In Capital letter, idem for MSDOS FAT. While long for NTFS or FAT partitions you can use names with small letter. So after formatting for NTFS partitions I use "newfs_ufsd_NTFS -v" to rename with Capital letter, and small letter. For FAT, I changed news_msdos (version 226 https://opensource.apple.com/tarballs/msdosfs/msdosfs-226.tar.gz) the newfs_msdos.c file to line 1320 in "mklabel (u_int8_t** * dest, Const char * src) "where we find" c = * src? Toupper (* src ++): '';" Changed to "c = * src? * Src ++: '';" **which makes it possible to use capital letters or small letters. So for my solution, I do not find an answer to how to get the $Volume_name offset from an NTFS partition.

Ashraf Bashir
  • 9,686
  • 15
  • 57
  • 82
deek5
  • 367
  • 1
  • 13