diff --git a/zefie_wtvp_minisrv/ServiceVault/http_pc/viewergen/index.js b/zefie_wtvp_minisrv/ServiceVault/http_pc/viewergen/index.js index fb7647d7..314523f9 100644 --- a/zefie_wtvp_minisrv/ServiceVault/http_pc/viewergen/index.js +++ b/zefie_wtvp_minisrv/ServiceVault/http_pc/viewergen/index.js @@ -30,6 +30,7 @@ var viewer_stock_md5s = { "WebTVIntel--2.5-HE.exe": "64edab977ec19a663c5842176bec306a" } +/* var modpacks = { 0: { "name": "Background Sound", @@ -38,6 +39,30 @@ var modpacks = { "default": true } } +*/ + +var modpacks = {}; + + +var feature_bits = { + 2: { + 0: { + "offset": 2063881, + "name": "Background Sound", + "description": "Enables the Viewer to continue playing sound when it is not the currently active window.", + "value": Buffer.from("\x80", 'ascii') + } + }, + 4: { + 0: { + "offset": 2063881, + "name": "Background Sound", + "description": "Enables the Viewer to continue playing sound when it is not the currently active window.", + "value": Buffer.from("\x80", 'ascii') + } + } +} + var patch_defaults = { @@ -250,13 +275,19 @@ function getPatchData(fname, client_data_obj, start_url = "client:GoToConn", def return customized_patch_data; } +function applyPatch(data, patch_data, offset) { + var data_length = patch_data.byteLength || patch_data.length; + var data = data.fill(patch_data, offset, data_length + offset); + return data; +} + function patchBinary(patchDataObject) { + var patched_file = patchDataObject.data; Object.keys(patchDataObject.patch_data).forEach(function (idx) { idx = parseInt(idx); - data_length = patchDataObject.patch_data[idx].byteLength || patchDataObject.patch_data[idx].length - patchDataObject.data.fill(patchDataObject.patch_data[idx], idx, data_length + idx); + patched_file = applyPatch(patched_file, patchDataObject.patch_data[idx], idx); }) - return patchDataObject.data; + return patched_file; } function generateSSID() { @@ -382,6 +413,19 @@ if (request_headers.query.viewer && data = errpage[1]; } else { var patched_file = patchBinary(patchDataObject); + var enabled_feature_bits = []; + Object.keys(request_headers.query).forEach((k) => { + if (k.substring(0, 12) === "feature_bit_") { + enabled_feature_bits.push(parseInt(k.substring(12))); + } + }); + Object.keys(enabled_feature_bits).forEach((k) => { + var bit = feature_bits[request_headers.query.viewer][enabled_feature_bits[k]]; + if (bit) { + patched_file = applyPatch(patched_file, bit.value, bit.offset); + } + }); + headers = `200 OK Content-Type: application/octet-stream Content-Disposition: attachment; filename="${viewer_file.replace(".exe", ".zip")}"` @@ -464,8 +508,9 @@ td {