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

Feature/buffer mode #3

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

anton-hrytsevich
Copy link

This merge request exist like result of implementing issue dokan-dev/dokany#627.
Add feature to get header/footer as buffer, instead of writing to file. It help to importing header/footer as
a byte buffer for use with memory only implementations.
And refactored code into additional headers and c files.
Base class does not assume a full image exists, includes only capability for generating header/footer.

Dan Walkes added 4 commits October 17, 2018 14:28
To support use of the VHD and VHDX classes for other uses besides
the ConvertImage function.
Base class does not assume a full image exists, includes only capability
for generating header/footer.
Instead of writing to file, support importing header/footer as
a byte buffer for use with memory only implementations.
@0xbadfca11 0xbadfca11 self-requested a review October 19, 2018 10:59
Copy link
Owner

@0xbadfca11 0xbadfca11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When VHD[X]_Image::ConstructHeader(is_fixed == false), will call SetFileInformationByHandle with an uninitialized value, and abort.

@anton-hrytsevich
Copy link
Author

@0xbadfca11, can you mark this place in code and say little more about this situation? I can't understood about witch place you are talking.

@0xbadfca11
Copy link
Owner

void VHD_Image::ConstructHeader(UINT64 disk_size, UINT32 block_size, UINT32 sector_size, bool is_fixed)
{
  // 1. eof_info is uninitialized memory.
  FILE_END_OF_FILE_INFO eof_info;
  VHD::ConstructHeader(disk_size, block_size, sector_size, is_fixed, eof_info);
  // 3. eof_info still uninitialized.
  if (!SetFileInformationByHandle(image, FileEndOfFileInfo, &eof_info, sizeof eof_info))
  {
    die();
  }
}
void VHD::ConstructHeader(UINT64 disk_size, UINT32 block_size, UINT32 sector_size, bool is_fixed, FILE_END_OF_FILE_INFO &eof_info)
{
  if (is_fixed)
  {
    eof_info.EndOfFile.QuadPart = disk_size + sizeof vhd_footer;
  }
  else
  {
    // 2. Nothing to did to eof_info.
  }
}

VHDX_Image::ConstructHeader same too.

@0xbadfca11
Copy link
Owner

To be honest, features creating an image in memory is not needs for this tool.

@anton-hrytsevich
Copy link
Author

@0xbadfca11, pleace look at Dokan project. We're using buffered makevhdx and Dokan mirroring functionality create tool that can mirror some drive to vhdx file, then this disk attaching to OS file system. It tool can be used for real time decrypt disks. You insert encrypted disk, real disk hidden, and in file system appear after authentication virtual regular disk.
Cool?

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

Successfully merging this pull request may close these issues.

2 participants