Compare commits

...

18 Commits

Author SHA1 Message Date
37cefa11c6 1.49.0 2025-03-28 13:41:39 +01:00
862d157672 Update branch builds 2025-03-28 13:22:59 +01:00
e433df62cf Add ge_prerelease as acceptable 2025-03-28 12:49:48 +01:00
1933521e0d Disable some safety features in the development mode 2025-03-28 12:48:59 +01:00
7b3cd4eb10 1.48.0 2024-10-22 23:28:00 +02:00
c1f00cecbd Merge pull request 'Add support for NetFX updates' (#1) from abbodi1406/api:master into master
Reviewed-on: #1
2024-10-22 23:27:34 +02:00
8b576e4496 Add support for NetFX updates 2024-10-21 17:24:10 +03:00
21b1500490 Fix warning 2024-06-22 18:50:39 +02:00
fb2c89b2f8 Remove DesktopDeployment from appx sets 2024-06-21 21:07:17 +02:00
846feb2629 Update WU parameters 2024-06-21 15:37:16 +02:00
5e31a6f724 Add additional appx presence checks 2024-06-21 13:31:41 +02:00
faa3b7fa45 Add Appx presence check 2024-06-19 13:29:23 +02:00
42b1091c0b Save architecture used to fetch the build to fileinfo 2024-05-09 22:22:29 +02:00
aa2dbd2938 Add ProfessionalCountrySpecific 2024-04-19 23:01:21 +02:00
42c1c12405 Update auto branch detection for 26100 2024-04-17 21:35:02 +02:00
092e968f0c Initial WNC support
The value was revealed to me in a dream
2024-03-18 20:16:47 +01:00
d58f53de42 Fix broken minor support 2024-03-12 20:50:07 +01:00
ca81835609 Branch selection support 2024-02-28 18:38:42 +01:00
8 changed files with 183 additions and 31 deletions

View File

@ -50,6 +50,61 @@ function uupApiPrivateGetLatestBuild() {
return $build;
}
function uupApiPrivateIsAcceptableBranch($branch) {
if(!uupApiConfigIsTrue('production_mode')) {
return true;
}
$branches = [
'auto',
'rs2_release',
'rs3_release',
'rs4_release',
'rs5_release',
'rs5_release_svc_hci',
'19h1_release',
'vb_release',
'fe_release_10x',
'fe_release',
'co_release',
'ni_release',
'zn_release',
'ge_release',
'ge_prerelease',
'rs_prerelease',
];
return in_array($branch, $branches);
}
function uupApiPrivateNormalizeFetchParams($params) {
$np = array_replace([
'arch' => 'amd64',
'ring' => 'WIF',
'flight' => 'Active',
'branch' => 'ge_release',
'build' => 'latest',
'minor' => 0,
'sku' => 48,
'type' => 'Production',
'flags' => [],
], $params);
if(!is_array($np['flags'])) $np['flags'] = [];
$np['arch'] = strtolower($np['arch']);
$np['ring'] = strtoupper($np['ring']);
$np['flight'] = ucwords(strtolower($np['flight']));
$np['branch'] = strtolower($np['branch']);
$np['build'] = strtolower($np['build']);
$np['minor'] = intval($np['minor']);
$np['sku'] = intval($np['sku']);
$np['type'] = ucwords(strtolower($np['type']));
$np['flags'] = array_map('strtolower', $np['flags']);
return $np;
}
function uupFetchUpd(
$arch = 'amd64',
$ring = 'WIF',
@ -60,14 +115,37 @@ function uupFetchUpd(
$type = 'Production',
$cacheRequests = 0
) {
[$build, $flags] = uupApiPrivateParseFlags($build);
$params = [
'arch' => $arch,
'ring' => $ring,
'flight' => $flight,
'build' => $build,
'minor' => $minor,
'sku' => $sku,
'type' => $type,
'flags' => $flags,
];
return uupFetchUpd2($params, $cacheRequests);
}
function uupFetchUpd2($params, $cacheRequests = 0) {
uupApiPrintBrand();
$arch = strtolower($arch);
$ring = strtoupper($ring);
$flight = ucwords(strtolower($flight));
$flight = 'Active';
$np = uupApiPrivateNormalizeFetchParams($params);
$arch = $np['arch'];
$ring = $np['ring'];
$flight = 'Active';
$branch = $np['branch'];
$build = $np['build'];
$minor = $np['minor'];
$sku = $np['sku'];
$type = $np['type'];
$flags = $np['flags'];
[$build, $flags] = uupApiPrivateParseFlags($build);
$flagsStr = implode(',', $flags);
if(strtolower($build) == 'latest' || (!$build)) {
@ -77,7 +155,6 @@ function uupFetchUpd(
$build = explode('.', $build);
if(isset($build[1])) $minor = intval($build[1]);
$build = intval($build[0]);
$sku = intval($sku);
if(!($arch == 'amd64' || $arch == 'x86' || $arch == 'arm64' || $arch == 'arm' || $arch == 'all')) {
return array('error' => 'UNKNOWN_ARCH');
@ -103,6 +180,9 @@ function uupFetchUpd(
return array('error' => 'ILLEGAL_MINOR');
}
if(!uupApiPrivateIsAcceptableBranch($branch))
$branch = 'auto';
if($ring == 'DEV') $ring = 'WIF';
if($ring == 'BETA') $ring = 'WIS';
if($ring == 'RELEASEPREVIEW') $ring = 'RP';
@ -116,13 +196,13 @@ function uupFetchUpd(
$type = 'Production';
}
$res = "api-fetch-$arch-$ring-$flight-$build-$flagsStr-$minor-$sku-$type";
$res = "api-fetch-$arch-$ring-$flight-$branch-$build-$flagsStr-$minor-$sku-$type";
$cache = new UupDumpCache($res);
$fromCache = $cache->get();
if($fromCache !== false) return $fromCache;
consoleLogger('Fetching information from the server...');
$composerArgs = [$arch, $flight, $ring, $build, $sku, $type, $flags];
$composerArgs = [$arch, $flight, $ring, $build, $sku, $type, $flags, $branch];
$out = sendWuPostRequestHelper('client', 'composeFetchUpdRequest', $composerArgs);
if($out === false || $out['error'] != 200) {
consoleLogger('The request has failed');
@ -150,7 +230,7 @@ function uupFetchUpd(
$num++;
consoleLogger("Checking build information for update {$num} of {$updatesNum}...");
$info = parseFetchUpdate($val, $out, $arch, $ring, $flight, $build, $sku, $type, $flags);
$info = parseFetchUpdate($val, $out, $arch, $ring, $flight, $build, $sku, $type, $flags, $branch);
if(isset($info['error'])) {
$errorCount++;
continue;
@ -180,7 +260,7 @@ function uupFetchUpd(
return $data;
}
function parseFetchUpdate($updateInfo, $out, $arch, $ring, $flight, $build, $sku, $type, $flags) {
function parseFetchUpdate($updateInfo, $out, $arch, $ring, $flight, $build, $sku, $type, $flags, $branch) {
$updateNumId = preg_replace('/<UpdateInfo><ID>|<\/ID>.*/i', '', $updateInfo);
$updates = preg_replace('/<Update>/', "\n<Update>", $out);
@ -222,6 +302,15 @@ function parseFetchUpdate($updateInfo, $out, $arch, $ring, $flight, $build, $sku
$foundBuild = @$info[3];
}
$isNet = 0;
if(strpos($foundArch, 'netfx') !== false) {
$isNet = 1;
preg_match('/ProductReleaseInstalled Name\=".*\.(.*?)\.(.*?)" Version\=".*\.\d{5}\.(.*?)"/', $updateInfo, $info);
$foundType = @strtolower($info[1]);
$foundArch = @strtolower($info[2]);
$foundBuild = @$info[3];
}
$updateTitle = preg_grep('/<Title>.*<\/Title>/', $updateMeta);
sort($updateTitle);
@ -241,7 +330,11 @@ function parseFetchUpdate($updateInfo, $out, $arch, $ring, $flight, $build, $sku
$isCumulativeUpdate = 0;
if(preg_match('/\d{4}-\d{2}.+Update|Cumulative Update|Microsoft Edge|Windows Feature Experience Pack|Cumulative security Hotpatch/i', $updateTitle)) {
$isCumulativeUpdate = 1;
$updateTitle = preg_replace('/ for .{3,5}-based systems| \(KB.*?\)/i', '', $updateTitle);
if($isNet) {
$updateTitle = preg_replace("/3.5 and 4.8.1 |3.5 and 4.8 | for $foundArch| for x64| \(KB.*?\)/i", '', $updateTitle);
} else {
$updateTitle = preg_replace('/ for .{3,5}-based systems| \(KB.*?\)/i', '', $updateTitle);
}
}
$updateTitle = preg_replace("/ ?\d{4}-\d{2}\D ?| ?$foundArch ?| ?x64 ?/i", '', $updateTitle);
@ -358,7 +451,9 @@ function parseFetchUpdate($updateInfo, $out, $arch, $ring, $flight, $build, $sku
$temp['title'] = $updateTitle;
$temp['ring'] = $ring;
$temp['flight'] = $flight;
$temp['branch'] = $branch;
$temp['arch'] = $foundArch;
$temp['fetchArch'] = $arch == 'all' ? 'amd64' : $arch;
$temp['build'] = $foundBuild;
$temp['checkBuild'] = $build;
$temp['sku'] = $sku;

View File

@ -76,6 +76,8 @@ function uupGetFiles(
$info['sku'] = 48;
}
$genPack = [];
if($usePack) {
$genPack = uupApiGetPacks($updateId);
if(empty($genPack)) return array('error' => 'UNSUPPORTED_COMBINATION');
@ -298,7 +300,7 @@ function uupGetFiles(
$temp = preg_grep('/Windows(10|11)\.0-KB.*-baseless/i', $filesInfoKeys, PREG_GREP_INVERT);
if($appEdition) {
$temp = preg_grep('/.*?AggregatedMetadata.*?\.cab|.*?DesktopDeployment.*?\.cab/i', $temp);
$temp = preg_grep('/.*?AggregatedMetadata.*?\.cab/i', $temp);
} else if($build > 21380) {
$temp = preg_grep('/Windows(10|11)\.0-KB|SSU-.*?\....$|.*?AggregatedMetadata.*?\.cab|.*?DesktopDeployment.*?\.cab/i', $temp);
} else {
@ -372,6 +374,7 @@ function uupGetFiles(
'build' => $updateBuild,
'sku' => $updateSku,
'hasUpdates' => $hasUpdates,
'appxPresent' => uupAreAppxPresent($genPack),
'files' => $files,
];

View File

@ -40,6 +40,7 @@ function uupListLangsInternal($updateId) {
return [
'langList' => $langList,
'langFancyNames' => $langListFancy,
'appxPresent' => uupAreAppxPresent($genPack),
];
}
@ -51,11 +52,10 @@ function uupListLangs($updateId = 0, $returnInfo = true) {
$langList = uupListLangsInternal($updateId);
$response = [
'apiVersion' => uupApiVersion(),
'langList' => $langList['langList'],
'langFancyNames' => $langList['langFancyNames'],
];
$response = array_merge(
['apiVersion' => uupApiVersion()],
$langList
);
if($returnInfo) $response['updateInfo'] = $info;

View File

@ -35,6 +35,10 @@ class UupDumpCache {
}
public function get() {
if(!uupApiConfigIsTrue('production_mode')) {
return false;
}
$cacheFile = $this->cacheFile;
if(!file_exists($cacheFile)) {
@ -58,6 +62,10 @@ class UupDumpCache {
}
public function put($content, $validity) {
if(!uupApiConfigIsTrue('production_mode')) {
return false;
}
$cacheFile = $this->cacheFile;
$expires = $validity ? time() + $validity : false;

View File

@ -16,7 +16,7 @@ limitations under the License.
*/
function uupApiVersion() {
return '1.43.5';
return '1.49.0';
}
require_once dirname(__FILE__).'/auths.php';

View File

@ -83,6 +83,7 @@ function uupGetInfoTexts() {
'PPIPRO' => 'Windows Team',
'PROFESSIONAL' => 'Windows Pro',
'PROFESSIONALN' => 'Windows Pro N',
'PROFESSIONALCOUNTRYSPECIFIC' => 'Windows Pro China Only',
'SERVERSTANDARD' => 'Windows Server Standard',
'SERVERSTANDARDCORE' => 'Windows Server Standard, Core',
'SERVERDATACENTER' => 'Windows Server Datacenter',

View File

@ -16,8 +16,10 @@ limitations under the License.
*/
// Composes DeviceAttributes parameter needed to fetch data
function composeDeviceAttributes($flight, $ring, $build, $arch, $sku, $type, $flags) {
$branch = branchFromBuild($build);
function composeDeviceAttributes($flight, $ring, $build, $arch, $sku, $type, $flags, $branch) {
if($branch == 'auto')
$branch = branchFromBuild($build);
$blockUpgrades = 0;
$flightEnabled = 1;
$isRetail = 0;
@ -31,12 +33,14 @@ function composeDeviceAttributes($flight, $ring, $build, $arch, $sku, $type, $fl
$dvcFamily = 'Windows.Desktop';
$insType = 'Client';
$prodType = 'WinNT';
if($sku == 119) {
$dvcFamily = 'Windows.Team';
}
if(uupApiIsServer($sku)) {
$dvcFamily = 'Windows.Server';
$insType = 'Server';
$prodType = 'ServerNT';
$blockUpgrades = 1;
}
/*/ Hololens
@ -112,7 +116,7 @@ function composeDeviceAttributes($flight, $ring, $build, $arch, $sku, $type, $fl
$attrib = array(
'App=WU_OS',
'AppVer='.$build,
'AttrDataVer=247',
'AttrDataVer=281',
'AllowInPlaceUpgrade=1',
'AllowOptionalContent=1',
'AllowUpgradesWithUnsupportedTPMOrCPU=1',
@ -120,6 +124,8 @@ function composeDeviceAttributes($flight, $ring, $build, $arch, $sku, $type, $fl
'BranchReadinessLevel=CB',
'CIOptin=1',
'CurrentBranch='.$branch,
'DataExpDateEpoch_GE24H2='.(time()+82800),
'DataExpDateEpoch_GE24H2Setup='.(time()+82800),
'DataExpDateEpoch_CU23H2='.(time()+82800),
'DataExpDateEpoch_CU23H2Setup='.(time()+82800),
'DataExpDateEpoch_NI22H2='.(time()+82800),
@ -142,13 +148,15 @@ function composeDeviceAttributes($flight, $ring, $build, $arch, $sku, $type, $fl
//'FlightContent='.$fltContent,
'FlightRing='.$fltRing,
'Free=gt64',
'GStatus_GE24H2=2',
'GStatus_GE24H2Setup=2',
'GStatus_CU23H2=2',
'GStatus_CU23H2Setup=2',
'GStatus_NI23H2=2',
'GStatus_NI22H2=2',
'GStatus_NI22H2Setup=2',
'GStatus_CO21H2=2',
'GStatus_CO21H2Setup=2',
'GStatus_23H2=2',
'GStatus_22H2=2',
'GStatus_21H2=2',
'GStatus_21H1=2',
@ -164,6 +172,7 @@ function composeDeviceAttributes($flight, $ring, $build, $arch, $sku, $type, $fl
'IsDeviceRetailDemo=0',
'IsFlightingEnabled='.$flightEnabled,
'IsRetailOS='.$isRetail,
'LCUVer=0.0.0.0',
'MediaBranch=',
'MediaVersion='.$build,
'CloudPBR=1',
@ -179,18 +188,21 @@ function composeDeviceAttributes($flight, $ring, $build, $arch, $sku, $type, $fl
'ProcessorIdentifier=Intel64 Family 6 Model 186 Stepping 3',
'ProcessorManufacturer=GenuineIntel',
'ProcessorModel=13th Gen Intel(R) Core(TM) i7-1355U',
'ProductType='.$prodType,
'ReleaseType='.$type,
'SdbVer_20H1=2000000000',
'SdbVer_19H1=2000000000',
'SecureBootCapable=1',
'TelemetryLevel=3',
'TimestampEpochString_GE24H2='.(time()-3600),
'TimestampEpochString_GE24H2Setup='.(time()-3600),
'TimestampEpochString_CU23H2='.(time()-3600),
'TimestampEpochString_CU23H2Setup='.(time()-3600),
'TimestampEpochString_NI23H2='.(time()-3600),
'TimestampEpochString_NI22H2='.(time()-3600),
'TimestampEpochString_NI22H2Setup='.(time()-3600),
'TimestampEpochString_CO21H2='.(time()-3600),
'TimestampEpochString_CO21H2Setup='.(time()-3600),
'TimestampEpochString_23H2='.(time()-3600),
'TimestampEpochString_22H2='.(time()-3600),
'TimestampEpochString_21H2='.(time()-3600),
'TimestampEpochString_21H1='.(time()-3600),
@ -199,7 +211,10 @@ function composeDeviceAttributes($flight, $ring, $build, $arch, $sku, $type, $fl
'TPMVersion=2',
'UpdateManagementGroup=2',
'UpdateOfferedDays=0',
'UpgEx_GE24H2Setup=Green',
'UpgEx_GE24H2=Green',
'UpgEx_CU23H2=Green',
'UpgEx_NI23H2=Green',
'UpgEx_NI22H2=Green',
'UpgEx_CO21H2=Green',
'UpgEx_23H2=Green',
@ -212,6 +227,7 @@ function composeDeviceAttributes($flight, $ring, $build, $arch, $sku, $type, $fl
'UpgradeAccepted=1',
'UpgradeEligible=1',
'UserInPlaceUpgrade=1',
'VBSState=2',
'Version_RS5=2000000000',
'WuClientVer='.$build,
);
@ -282,6 +298,7 @@ function branchFromBuild($build) {
case 22621:
case 22631:
case 22635:
$branch = 'ni_release';
break;
@ -289,6 +306,12 @@ function branchFromBuild($build) {
$branch = 'zn_release';
break;
case 26100:
case 26120:
case 26200:
$branch = 'ge_release';
break;
default:
$branch = 'rs_prerelease';
break;
@ -308,16 +331,23 @@ function composeFileGetRequest($updateId, $info, $rev = 1, $type = 'Production')
$created = gmdate(DATE_W3C, $createdTime);
$expires = gmdate(DATE_W3C, $expiresTime);
//$branch = branchFromBuild($info['checkBuild']);
$arch = 'amd64';
if(isset($info['fetchArch'])) {
$arch = $info['fetchArch'];
} elseif(isset($info['arch'])) {
$arch = $info['arch'];
}
$deviceAttributes = composeDeviceAttributes(
isset($info['flight']) ? $info['flight'] : 'Active',
isset($info['ring']) ? $info['ring'] : 'RETAIL',
isset($info['checkBuild']) ? $info['checkBuild'] : '10.0.19041.1',
isset($info['arch']) ? $info['arch'] : 'amd64',
$arch,
isset($info['sku']) ? $info['sku'] : 48,
$type,
isset($info['flags']) ? $info['flags'] : [],
isset($info['branch']) ? $info['branch'] : 'auto',
);
return <<<XML
@ -361,7 +391,7 @@ XML;
}
// Composes POST data for fetching the latest update information from Windows Update
function composeFetchUpdRequest($arch, $flight, $ring, $build, $sku = 48, $type = 'Production', $flags = []) {
function composeFetchUpdRequest($arch, $flight, $ring, $build, $sku = 48, $type = 'Production', $flags = [], $branch = 'auto') {
$encData = uupEncryptedData();
if($encData === false)
return false;
@ -377,7 +407,8 @@ function composeFetchUpdRequest($arch, $flight, $ring, $build, $sku = 48, $type
$expires = gmdate(DATE_W3C, $expiresTime);
$cookieExpires = gmdate(DATE_W3C, $cookieExpiresTime);
$branch = branchFromBuild($build);
if($branch == 'auto')
$branch = branchFromBuild($build);
$mainProduct = 'Client.OS.rs2';
if(uupApiIsServer($sku)) {
@ -399,6 +430,10 @@ function composeFetchUpdRequest($arch, $flight, $ring, $build, $sku = 48, $type
if($sku == 189) {
$mainProduct = 'WCOSDevice0.OS';
}
// WNC
if($sku == 210) {
$mainProduct = 'WNC.OS';
}
if($arch == 'all') {
$arch = array(
@ -418,7 +453,7 @@ function composeFetchUpdRequest($arch, $flight, $ring, $build, $sku = 48, $type
$products[] = "PN=$mainProduct.$currArch&Branch=$branch&PrimaryOSProduct=1&Repairable=1&V=$build&ReofferUpdate=1";
$products[] = "PN=Adobe.Flash.$currArch&Repairable=1&V=0.0.0.0";
$products[] = "PN=Microsoft.Edge.Stable.$currArch&Repairable=1&V=0.0.0.0";
$products[] = "PN=Microsoft.NETFX.$currArch&V=2018.12.2.0";
$products[] = "PN=Microsoft.NETFX.$currArch&V=0.0.0.0";
$products[] = "PN=Windows.Autopilot.$currArch&Repairable=1&V=0.0.0.0";
$products[] = "PN=Windows.AutopilotOOBE.$currArch&Repairable=1&V=0.0.0.0";
$products[] = "PN=Windows.Appraiser.$currArch&Repairable=1&V=$build";
@ -453,7 +488,8 @@ function composeFetchUpdRequest($arch, $flight, $ring, $build, $sku = 48, $type
$arch,
$sku,
$type,
$flags
$flags,
$branch
);
$syncCurrent = in_array('thisonly', $flags) ? 'true' : 'false';
@ -538,6 +574,7 @@ function composeFetchUpdRequest($arch, $flight, $ring, $build, $sku = 48, $type
<int>2359977</int>
<int>24513870</int>
<int>28880263</int>
<int>296374060</int>
<int>3</int>
<int>30077688</int>
<int>30486944</int>

View File

@ -64,8 +64,12 @@ function sendWuPostRequestInternal($url, $postData, $saveCookie = true) {
curl_setopt($req, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($req, CURLOPT_ENCODING, '');
curl_setopt($req, CURLOPT_POSTFIELDS, $postData);
curl_setopt($req, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($req, CURLOPT_TIMEOUT, 15);
if(uupApiConfigIsTrue('production_mode')) {
curl_setopt($req, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($req, CURLOPT_TIMEOUT, 15);
}
curl_setopt($req, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($req, CURLOPT_HTTPHEADER, array(
'User-Agent: Windows-Update-Agent/10.0.10011.16384 Client-Protocol/2.50',
@ -199,3 +203,7 @@ function getAllowedFlags() {
return $flags;
}
function uupAreAppxPresent($genPack) {
return isset($genPack['neutral']['APP']);
}