Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"@iconify/vue": "^4.3.0",
"@vueuse/core": "^13.1.0",
"@vueuse/motion": "^2.2.6",
"7zip-bin-full": "^25.1.1",
"apexcharts": "^4.5.0",
"check-disk-space": "^3.4.0",
"consola": "^3.4.2",
Expand Down
93 changes: 93 additions & 0 deletions src/renderer/lib/getIsoType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
const fs: typeof import('fs') = require('fs');
const { spawnSync }: typeof import('child_process') = require('child_process');
const sep = require('path').sep;
const path7zzs = require('7zip-bin-full').path7zzs.replace(`app.asar${sep}`, `app.asar.unpacked${sep}`);

const VOLUME_ID_PATTERNS = [
// Education

/(J_)?CEDN?A_X86FRE_/,
/(J_)?CEDN?A_X64FREE?_/,

// Enterprise
/^(J_)?CEN?A_X86FREV_/,
/^(J_)?CENN?A_X64FREV_/,

// Enterprise LTSB

/(J_)?CESN?N?_X86FREV_/,
/(J_)?CESN?N?_X64FREV_/,

// Enterprise LTSB (Eval)

/CESE_X86FREE_/,
/CESE_X64FREE_/,

// Standard

/^(J_)?CCSN?A_X86FRE_/,
/^(J_)?(CCSN?A|C?CCOMA)_X64FREE?_/
];

function listIso(path: string) {
const result = spawnSync(path7zzs, ['l', '-slt', '-ba', path], {
encoding: 'utf8'
});
return result.stdout;
}

export async function isIsoValid(path: string) {
const fileHandle = await fs.promises.open(path, 'r');

try {
const bootRecordBuffer = Buffer.alloc(2048);
await fileHandle.read(bootRecordBuffer, 0, 2048, 17 * 2048);

const signature = bootRecordBuffer.subarray(1, 6).toString('ascii');
console.log('Sig', signature);

// Check if it is IS9660
if (signature !== 'CD001') {
return false;
}

const pvdBuffer = Buffer.alloc(2048);
await fileHandle.read(pvdBuffer, 0, 2048, 16 * 2048);

const volumeId = pvdBuffer.subarray(40, 72).toString('ascii').trim().replace(/\0/g, '');

const bootCatalogSector = bootRecordBuffer.readUInt32LE(71);
const headerBuffer = Buffer.alloc(64);

await fileHandle.read(headerBuffer, 0, 64, bootCatalogSector * 2048);

const bootIndicator = headerBuffer.readUInt8(32);

if (bootIndicator !== 0x88) {
return false;
}

for (const pattern of VOLUME_ID_PATTERNS) {
if (pattern.test(volumeId)) {
return true;
}
}

const isoFiles = listIso(path);

for (const line of isoFiles.split('\n')) {
if (line.startsWith('Path = ')) {
const cleaned = line.substring(7);
if(cleaned == 'sources/boot.wim') {
return true;
}
}
}

return false;
}

finally {
fileHandle.close();
}
}
22 changes: 16 additions & 6 deletions src/renderer/views/SetupUI.vue
Original file line number Diff line number Diff line change
Expand Up @@ -599,11 +599,11 @@ import { WINDOWS_VERSIONS, WINDOWS_LANGUAGES, type WindowsVersionKey } from "../
import { InstallManager, type InstallState, InstallStates } from '../lib/install';
import { openAnchorLink } from '../utils/openLink';
import license from '../assets/LICENSE.txt?raw'

const path: typeof import('path') = require('path')
const electron: typeof import('electron') = require('electron').remote || require('@electron/remote');
const fs: typeof import('fs') = require('fs');
const os: typeof import('os') = require('os');
import { isIsoValid } from '../lib/getIsoType';
const checkDiskSpace: typeof import('check-disk-space').default = require('check-disk-space').default;

type Step = {
Expand Down Expand Up @@ -779,11 +779,21 @@ function selectIsoFile() {
})
.then(result => {
if (!result.canceled && result.filePaths.length > 0) {
customIsoPath.value = result.filePaths[0];
customIsoFileName.value = path.basename(result.filePaths[0]);
windowsLanguage.value = 'English'; // Language can't be custom
windowsVersion.value = 'custom';
console.log('ISO path updated:', customIsoPath.value);
const filePath = result.filePaths[0]
isIsoValid(filePath)
.then(res => {
if (!res) {
electron.dialog.showErrorBox("Invalid ISO!", "This ISO is not valid!");
}

else {
customIsoPath.value = filePath;
customIsoFileName.value = path.basename(filePath);
windowsLanguage.value = 'English'; // Language can't be custom
windowsVersion.value = 'custom';
console.log('ISO path updated:', customIsoPath.value);
}
})
}
});
}
Expand Down