mirror of
				https://github.com/lordfriky/web-cfw-loader.git
				synced 2025-10-30 18:59:40 +00:00 
			
		
		
		
	Use standard payload files instead of hardcoded byte arrays
It's been 84 years...
This commit is contained in:
		
							parent
							
								
									e0c077ff81
								
							
						
					
					
						commit
						bba919dbe5
					
				| @ -118,9 +118,6 @@ | |||||||
| 
 | 
 | ||||||
|             <div class="col-xs-6"> |             <div class="col-xs-6"> | ||||||
|               <select class="pull-right"    id="payloadSelect" onchange="onSelectChange()"> |               <select class="pull-right"    id="payloadSelect" onchange="onSelectChange()"> | ||||||
|                 <option value="Hekate" id="optionHekate" >Hekate 5.8.0</option> |  | ||||||
|                 <option value="Atmosphere" id="optionFuseePrimary" >Atmosphère 1.3.2</option> |  | ||||||
|                 <option value="uploaded"    id="optionUpload"   >Upload payload</option> |  | ||||||
|               </select> |               </select> | ||||||
|             </div> |             </div> | ||||||
|           </div> |           </div> | ||||||
| @ -161,9 +158,6 @@ | |||||||
|     </div> |     </div> | ||||||
|   </div> |   </div> | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|   <script src="./payloads/hekate.js"></script> |  | ||||||
|   <script src="./payloads/fusee_ams.js"></script> |  | ||||||
|   <script src="./main.js"></script> |   <script src="./main.js"></script> | ||||||
| </body> | </body> | ||||||
| 
 | 
 | ||||||
|  | |||||||
							
								
								
									
										85
									
								
								main.js
									
									
									
									
									
								
							
							
						
						
									
										85
									
								
								main.js
									
									
									
									
									
								
							| @ -1,3 +1,51 @@ | |||||||
|  | function logOutput(...message) { | ||||||
|  |   document.getElementById("output").innerHTML = document.getElementById("output").innerHTML + message.join(" ") + "<br>"; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | function clearLog() { | ||||||
|  |   document.getElementById("output").innerHTML = ""; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | async function getPayloadList(){ | ||||||
|  |   return fetch("payloads/payloads.json") | ||||||
|  |   .then((response) => { | ||||||
|  |     if(!response.ok) | ||||||
|  |       throw new Error(response.status); | ||||||
|  |     return response.json(); | ||||||
|  |   }) | ||||||
|  |   .then((data) => { | ||||||
|  |     return data.payloads; | ||||||
|  |   }); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | (async () => { | ||||||
|  |   const payloadSelect = document.getElementById("payloadSelect"); | ||||||
|  | 
 | ||||||
|  |   try { | ||||||
|  |     const payloadList = await getPayloadList(); | ||||||
|  |      | ||||||
|  |     payloadList.forEach((payload) => { | ||||||
|  |       const payloadOption = document.createElement("option"); | ||||||
|  | 
 | ||||||
|  |       payloadOption.value = payload.path; | ||||||
|  |       payloadOption.innerHTML = payload.name; | ||||||
|  | 
 | ||||||
|  |       payloadSelect.appendChild(payloadOption); | ||||||
|  |     }); | ||||||
|  |   } catch (error) { | ||||||
|  |     logOutput("There was a problem retreiving the payload list. HTTP error code: " + error) | ||||||
|  |   } | ||||||
|  | })() | ||||||
|  | 
 | ||||||
|  | async function getPayload(payloadSrc){ | ||||||
|  | 	return fetch(payloadSrc) | ||||||
|  | 	.then((response) => { | ||||||
|  | 		if(!response.ok) | ||||||
|  | 			throw new Error(response.status); | ||||||
|  | 		return response.arrayBuffer(); | ||||||
|  | 	}); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| const intermezzo = new Uint8Array([ | const intermezzo = new Uint8Array([ | ||||||
|   0x44, 0x00, 0x9F, 0xE5, 0x01, 0x11, 0xA0, 0xE3, 0x40, 0x20, 0x9F, 0xE5, 0x00, 0x20, 0x42, 0xE0, |   0x44, 0x00, 0x9F, 0xE5, 0x01, 0x11, 0xA0, 0xE3, 0x40, 0x20, 0x9F, 0xE5, 0x00, 0x20, 0x42, 0xE0, | ||||||
|   0x08, 0x00, 0x00, 0xEB, 0x01, 0x01, 0xA0, 0xE3, 0x10, 0xFF, 0x2F, 0xE1, 0x00, 0x00, 0xA0, 0xE1, |   0x08, 0x00, 0x00, 0xEB, 0x01, 0x01, 0xA0, 0xE3, 0x10, 0xFF, 0x2F, 0xE1, 0x00, 0x00, 0xA0, 0xE1, | ||||||
| @ -7,14 +55,10 @@ const intermezzo = new Uint8Array([ | |||||||
|   0x5C, 0xF0, 0x01, 0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x01, 0x40 |   0x5C, 0xF0, 0x01, 0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x01, 0x40 | ||||||
| ]); | ]); | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| const RCM_PAYLOAD_ADDRESS = 0x40010000; | const RCM_PAYLOAD_ADDRESS = 0x40010000; | ||||||
| const INTERMEZZO_LOCATION = 0x4001F000; | const INTERMEZZO_LOCATION = 0x4001F000; | ||||||
| const PAYLOAD_LOAD_BLOCK = 0x40020000; | const PAYLOAD_LOAD_BLOCK = 0x40020000; | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| function createRCMPayload(intermezzo, payload) { | function createRCMPayload(intermezzo, payload) { | ||||||
|   const rcmLength = 0x30298; |   const rcmLength = 0x30298; | ||||||
| 
 | 
 | ||||||
| @ -78,24 +122,8 @@ function readFileAsArrayBuffer(file) { | |||||||
|   }); |   }); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| function logOutput(...message) { |  | ||||||
|   document.getElementById("output").innerHTML = document.getElementById("output").innerHTML + message.join(" ") + "<br>"; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| function clearLog() { |  | ||||||
|   document.getElementById("output").innerHTML = ""; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| let device; | let device; | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| async function launchPayload(payload) { | async function launchPayload(payload) { | ||||||
|   await device.open(); |   await device.open(); | ||||||
|   logOutput(`Connected to ${device.manufacturerName} ${device.productName}`); |   logOutput(`Connected to ${device.manufacturerName} ${device.productName}`); | ||||||
| @ -135,7 +163,7 @@ async function launchPayload(payload) { | |||||||
| document.getElementById("goButton").addEventListener("click", async () => { | document.getElementById("goButton").addEventListener("click", async () => { | ||||||
|   clearLog(); |   clearLog(); | ||||||
|   var debugCheckbox = document.getElementById("shouldDebug"); |   var debugCheckbox = document.getElementById("shouldDebug"); | ||||||
|   const payloadType = document.getElementById("payloadSelect").value; |   const payloadPath = document.getElementById("payloadSelect").value; | ||||||
| 
 | 
 | ||||||
|   if(!debugCheckbox.checked) { |   if(!debugCheckbox.checked) { | ||||||
| 
 | 
 | ||||||
| @ -150,13 +178,7 @@ document.getElementById("goButton").addEventListener("click", async () => { | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   let payload; |   let payload; | ||||||
|   if (payloadType === "Hekate") { |   if (payloadPath === "uploaded") { | ||||||
|     payload = hekate; |  | ||||||
| 
 |  | ||||||
|   } else if (payloadType === "Atmosphere") { |  | ||||||
|     payload = fusee_ams; |  | ||||||
| 
 |  | ||||||
|   } else if (payloadType === "uploaded") { |  | ||||||
|     const file = document.getElementById("payloadUpload").files[0]; |     const file = document.getElementById("payloadUpload").files[0]; | ||||||
|     if (!file) { |     if (!file) { | ||||||
|       alert("You need to upload a file, to use an uploaded file."); |       alert("You need to upload a file, to use an uploaded file."); | ||||||
| @ -166,9 +188,13 @@ document.getElementById("goButton").addEventListener("click", async () => { | |||||||
|     payload = new Uint8Array(await readFileAsArrayBuffer(file)); |     payload = new Uint8Array(await readFileAsArrayBuffer(file)); | ||||||
| 
 | 
 | ||||||
|   } else { |   } else { | ||||||
|     logOutput("<span style='color:red'>You're trying to load a payload type that doesn't exist.</span>"); |     try { | ||||||
|  |       payload = new Uint8Array(await getPayload(payloadPath)); | ||||||
|  |     } catch (error) { | ||||||
|  |       logOutput("There was a problem retreiving the payload. HTTP error code: " + error) | ||||||
|       return; |       return; | ||||||
|     } |     } | ||||||
|  |   } | ||||||
| 
 | 
 | ||||||
|   if(debugCheckbox.checked) { |   if(debugCheckbox.checked) { | ||||||
|     logOutput("Logging payload bytes..."); |     logOutput("Logging payload bytes..."); | ||||||
| @ -179,7 +205,6 @@ document.getElementById("goButton").addEventListener("click", async () => { | |||||||
|     } |     } | ||||||
|     payloadToLog = payloadToLog; |     payloadToLog = payloadToLog; | ||||||
|     logOutput(payloadToLog); |     logOutput(payloadToLog); | ||||||
|     console.log(document.getElementById("payloadUpload").files[0]); |  | ||||||
|     return; |     return; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  | |||||||
							
								
								
									
										
											BIN
										
									
								
								payloads/ams-1.5.3.bin
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								payloads/ams-1.5.3.bin
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								payloads/hekate-v6.0.3.bin
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								payloads/hekate-v6.0.3.bin
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										21
									
								
								payloads/payloads.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								payloads/payloads.json
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,21 @@ | |||||||
|  | { | ||||||
|  |   "payloads": [ | ||||||
|  |     { | ||||||
|  |       "name": "Atmosphère 1.5.3", | ||||||
|  |       "path": "payloads/ams-1.5.3.bin" | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |       "name": "Hekate v6.0.3", | ||||||
|  |       "path": "payloads/hekate-v6.0.3.bin" | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |       "name": "TegraExplorer 4.0.1-hotfix4", | ||||||
|  |       "path": "payloads/tegraexplorer-4.0.1-hotfix4.bin" | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |       "name": "Upload payload", | ||||||
|  |       "path": "uploaded" | ||||||
|  |     } | ||||||
|  |   ] | ||||||
|  | } | ||||||
|  | 
 | ||||||
							
								
								
									
										
											BIN
										
									
								
								payloads/tegraexplorer-4.0.1-hotfix4.bin
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								payloads/tegraexplorer-4.0.1-hotfix4.bin
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user