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

Detects possible FAT geometry in fixed VHDs too #4961

Merged
merged 1 commit into from
Apr 14, 2024

Conversation

maxpat78
Copy link
Contributor

Since MBR and FAT CHS geometries may differ even with Windows 11 created VHDs, we attempt to read both of them.

Fixes #4958

Since MBR and FAT CHS geometries may differ even with Windows 11 created VHDs, we attempt to read
vhd->cylinders = sizes[3];
vhd->heads = sizes[2];
vhd->sectors = sizes[1];
vhd->fixedDisk = new imageDisk(file, fileName, vhd->cylinders, vhd->heads, vhd->sectors, 512, true);
Copy link
Contributor

Choose a reason for hiding this comment

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

Does calling new imageDisk() twice safely deletes the previous one?
I think better to check sizes[] and DetectGeometry before new imageDisk

Copy link
Contributor Author

@maxpat78 maxpat78 Apr 13, 2024

Choose a reason for hiding this comment

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

Obviously, it does not (deleting caused an obscure exception). [*]

DetectGeometry actually requires a valid disk image internally to properly read VHD sectors, that's the reason why I avoided that call in previous commits (having tought at least Windows 1x set MBR CHS == BPB CHS).

Perhaps I'll find another way, if you haven't suggestions.

EDIT:
[*] The exception cause: delete vhd->fixedDisk would call fclose(dskimg), where dskimg is an alias for file object, required by following new imageDisk call.

@BridgeHeadland
Copy link

BridgeHeadland commented Apr 13, 2024

Is there really any difference between creating a VHD file in Windows 10 or 11, even with DOSBox-X?

@maxpat78
Copy link
Contributor Author

maxpat78 commented Apr 13, 2024

@BridgeHeadland

Is there really any difference between creating a VHD file in Windows 10 or 11, even with DOSBox-X?

Yes, if you partition or format, different softwares do different calculations of geometry recorded in MBR and boot sector.
It happens that Windows 11 stores a X-255-63 geometry in boot sector, and another one in MBR.

@joncampbell123 joncampbell123 merged commit 21bec95 into joncampbell123:master Apr 14, 2024
20 checks passed
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.

DBX not mounting Windows created VHDs of 8,16,24,32,40, and 48MB?
4 participants