Best JavaScript code snippet using wpt
MDLFile.ts
Source:MDLFile.ts
...43 private readHeader(reader: BinaryReader): void {44 reader.setOffset(0);45 let h = new StudioHeader();46 // check magic47 h.id = reader.readUint32();48 if (h.id != 0x54534449) {49 throw new Error('not studio model file');50 }51 // check version52 h.version = reader.readUint32();53 if (h.version != 0x0A) {54 throw new Error('not supported version');55 }56 h.name = reader.readString(64);57 h.length = reader.readUint32();58 // check file size59 if (h.length != reader.getLength()) {60 throw new Error('invalid file length');61 }62 h.eyeposition = reader.readVec3();63 h.min = reader.readVec3();64 h.max = reader.readVec3();65 h.bbmin = reader.readVec3();66 h.bbmax = reader.readVec3();67 h.flags = reader.readUint32();68 h.numbones = reader.readUint32();69 h.boneindex = reader.readUint32();70 h.numbonecontrollers = reader.readUint32();71 h.bonecontrollerindex = reader.readUint32();72 h.numhitboxes = reader.readUint32();73 h.hitboxindex = reader.readUint32();74 h.numseq = reader.readUint32();75 h.seqindex = reader.readUint32();76 h.numseqgroups = reader.readUint32();77 h.seqgroupindex = reader.readUint32();78 h.numtextures = reader.readUint32();79 h.textureindex = reader.readUint32();80 h.texturedataindex = reader.readUint32();81 h.numskinref = reader.readUint32();82 h.numskinfamilies = reader.readUint32();83 h.skinindex = reader.readUint32();84 h.numbodyparts = reader.readUint32();85 h.bodypartindex = reader.readUint32();86 h.numattachments = reader.readUint32();87 h.attachmentindex = reader.readUint32();88 h.soundtable = reader.readUint32();89 h.soundindex = reader.readUint32();90 h.soundgroups = reader.readUint32();91 h.soundgroupindex = reader.readUint32();92 h.numtransitions = reader.readUint32();93 h.transitionindex = reader.readUint32();94 this.header = h;95 }96 private readBone(reader: BinaryReader): void {97 // read bones98 reader.setOffset(this.header.boneindex);99 this.bones = [];100 // Fix for the name parameter of KeyframeTrack101 // @see https://threejs.org/docs/index.html#api/en/animation/KeyframeTrack.name102 let fixName = (s: string): string => {103 s = s.replaceAll('[', '_');104 s = s.replaceAll(']', '_');105 s = s.replaceAll('.', '_');106 return s;107 }108 for (let i = 0; i < this.header.numbones; i++) {109 let a = new StudioBone();110 a.name = fixName(reader.readString(32));111 a.parent = reader.readInt32();112 a.flags = reader.readUint32();113 a.bonecontroller = reader.readInt32Array(6);114 a.value = reader.readFloatArray(6);115 a.scale = reader.readFloatArray(6);116 this.bones.push(a);117 }118 // read bone controllers119 reader.setOffset(this.header.bonecontrollerindex);120 this.boneControllers = [];121 for (let i = 0; i < this.header.numbonecontrollers; i++) {122 let a = new StudioBoneController();123 a.bone = reader.readUint32();124 a.type = reader.readUint32();125 a.start = reader.readFloat();126 a.end = reader.readFloat();127 a.rest = reader.readUint32();128 a.index = reader.readUint32();129 this.boneControllers.push(a);130 }131 // read attachments132 reader.setOffset(this.header.attachmentindex);133 this.attachments = [];134 for (let i = 0; i < this.header.numattachments; i++) {135 let a = new StudioAttachment();136 a.name = reader.readString(32);137 a.type = reader.readUint32();138 a.bone = reader.readUint32();139 a.org = reader.readVec3();140 a.vectors = [reader.readVec3(), reader.readVec3(), reader.readVec3()];141 this.attachments.push(a);142 }143 // read hit boxes144 reader.setOffset(this.header.hitboxindex);145 this.hitBoxes = [];146 for (let i = 0; i < this.header.numhitboxes; i++) {147 let a = new StudioHitBox();148 a.bone = reader.readUint32();149 a.group = reader.readUint32();150 a.bbmin = reader.readVec3();151 a.bbmax = reader.readVec3();152 this.hitBoxes.push(a);153 }154 }155 private readSequence(reader: BinaryReader): void {156 // read sequences157 reader.setOffset(this.header.seqindex);158 this.sequences = [];159 for (let i = 0; i < this.header.numseq; i++) {160 let a = new StudioSequence();161 a.label = reader.readString(32);162 a.fps = reader.readFloat();163 a.flags = reader.readUint32();164 a.activity = reader.readUint32();165 a.actweight = reader.readUint32();166 a.numevents = reader.readUint32();167 a.eventindex = reader.readUint32();168 a.numframes = reader.readUint32();169 a.numpivots = reader.readUint32();170 a.pivotindex = reader.readUint32();171 a.motiontype = reader.readUint32();172 a.motionbone = reader.readUint32();173 a.linearmovement = reader.readVec3();174 a.automoveposindex = reader.readUint32();175 a.automoveangleindex = reader.readUint32();176 a.bbmin = reader.readVec3();177 a.bbmax = reader.readVec3();178 a.numblends = reader.readUint32();179 a.animindex = reader.readUint32();180 a.blendtype = reader.readUint32Array(2);181 a.blendstart = reader.readFloatArray(2);182 a.blendend = reader.readFloatArray(2);183 a.blendparent = reader.readUint32();184 a.seqgroup = reader.readUint32();185 a.entrynode = reader.readUint32();186 a.exitnode = reader.readUint32();187 a.nodeflags = reader.readUint32();188 a.nextseq = reader.readUint32();189 this.sequences.push(a);190 }191 // read events and pivots192 this.sequences.forEach(seq => {193 // read events194 reader.setOffset(seq.eventindex);195 seq.events = [];196 for (let i = 0; i < seq.numevents; i++) {197 let a = new StudioEvent();198 a.frame = reader.readUint32();199 a.event = reader.readUint32();200 a.type = reader.readUint32();201 a.options = reader.readString(64);202 seq.events.push(a);203 }204 // read pivots205 reader.setOffset(seq.pivotindex);206 seq.pivots = [];207 for (let i = 0; i < seq.numpivots; i++) {208 let a = new StudioPivot();209 a.org = reader.readVec3();210 a.start = reader.readUint32();211 a.end = reader.readUint32();212 seq.pivots.push(a);213 }214 });215 // read sequence groups216 reader.setOffset(this.header.seqgroupindex);217 this.sequenceGroups = [];218 for (let i = 0; i < this.header.numseqgroups; i++) {219 let a = new StudioSequenceGroup();220 a.label = reader.readString(32);221 a.name = reader.readString(64);222 a.cache = reader.readUint32();223 a.data = reader.readUint32();224 this.sequenceGroups.push(a);225 }226 // read transitions227 reader.setOffset(this.header.transitionindex);228 for (let i = 0; i < this.header.numtransitions; i++) {229 for (let j = 0; j < this.header.numtransitions; j++) {230 // TODO:231 reader.readUint8();232 }233 }234 // read animation frames235 this.sequences.forEach(seq => {236 this.readAnimationFrame(reader, seq);237 });238 }239 private readModel(reader: BinaryReader): void {240 // read body parts241 reader.setOffset(this.header.bodypartindex);242 this.bodyParts = [];243 for (let i = 0; i < this.header.numbodyparts; i++) {244 let a = new StudioBodyPart();245 a.name = reader.readString(64);246 a.nummodels = reader.readUint32();247 a.base = reader.readUint32();248 a.modelindex = reader.readUint32();249 this.bodyParts.push(a);250 }251 // read models and mesh252 this.bodyParts.forEach(a => {253 // read models254 reader.setOffset(a.modelindex);255 a.models = [];256 for (let i = 0; i < a.nummodels; i++) {257 let b = new StudioModel();258 b.name = reader.readString(64);259 b.type = reader.readUint32();260 b.boundingradius = reader.readFloat();261 b.nummesh = reader.readUint32();262 b.meshindex = reader.readUint32();263 b.numverts = reader.readUint32();264 b.vertinfoindex = reader.readUint32();265 b.vertindex = reader.readUint32();266 b.numnorms = reader.readUint32();267 b.norminfoindex = reader.readUint32();268 b.normindex = reader.readUint32();269 b.numgroups = reader.readUint32();270 b.groupindex = reader.readUint32();271 a.models.push(b);272 }273 // read mesh, verts, norms274 a.models.forEach(b => {275 // read mesh276 reader.setOffset(b.meshindex);277 b.mesh = [];278 for (let i = 0; i < b.nummesh; i++) {279 let c = new StudioMesh();280 c.numtris = reader.readUint32();281 c.triindex = reader.readUint32();282 c.skinref = reader.readUint32();283 c.numnorms = reader.readUint32();284 c.normindex = reader.readUint32();285 b.mesh.push(c);286 }287 // read verts288 b.verts = [];289 for (let i = 0; i < b.numverts; i++) {290 b.verts.push(new StudioVertexVector());291 }292 reader.setOffset(b.vertinfoindex);293 for (let i = 0; i < b.numverts; i++) {294 b.verts[i].bone = reader.readUint8();295 }296 reader.setOffset(b.vertindex);297 for (let i = 0; i < b.numverts; i++) {298 b.verts[i].vec = reader.readVec3();299 }300 // read norms301 b.norms = [];302 for (let i = 0; i < b.numnorms; i++) {303 b.norms.push(new StudioVertexVector());304 }305 reader.setOffset(b.norminfoindex);306 for (let i = 0; i < b.numnorms; i++) {307 b.norms[i].bone = reader.readUint8();308 }309 reader.setOffset(b.normindex);310 for (let i = 0; i < b.numnorms; i++) {311 b.norms[i].vec = reader.readVec3();312 }313 // rebuild314 this.rebuildModel(reader, b);315 });316 });317 }318 private readTexture(reader: BinaryReader): void {319 // read textures320 reader.setOffset(this.header.textureindex);321 this.textures = [];322 for (let i = 0; i < this.header.numtextures; i++) {323 let a = new StudioTexture();324 a.name = reader.readString(64);325 a.flags = reader.readUint32();326 a.width = reader.readUint32();327 a.height = reader.readUint32();328 a.index = reader.readUint32();329 this.textures.push(a);330 }331 // read skin families332 reader.setOffset(this.header.skinindex);333 this.skinfamilies = [];334 for (let i = 0; i < this.header.numskinfamilies; i++) {335 let skinref: number[] = [];336 for (let j = 0; j < this.header.numskinref; j++) {337 skinref.push(reader.readInt16());338 }339 this.skinfamilies.push(skinref);340 }341 // read texture image data342 this.textures.forEach(a => {...
graphicReader.js
Source:graphicReader.js
1const NodeIPC = require('@fynnix/node-easy-ipc');2const binutils = require("binutils");3const readUtils = require("../../util/readUtils");4const readGraphics = () => {5 const m_graphics_length = 1580;6 const m_graphics_buffer = Buffer.alloc(m_graphics_length);7 const m_graphics = new NodeIPC.FileMapping();8 const FileGraphics_Path = "Local\\acpmf_graphics";9 m_graphics.createMapping(null, FileGraphics_Path, m_graphics_length);10 m_graphics.readInto(0, m_graphics_length, m_graphics_buffer);11 let data = {};12 const reader = new binutils.BinaryReader(m_graphics_buffer, 'little');13 data.packetId = reader.ReadUInt32();14 data.acc_status = reader.ReadUInt32();15 data.acc_session_type = reader.ReadUInt32();16 data.currentTime = readUtils.readWideString(reader, 15);17 data.lastTime = readUtils.readWideString(reader, 15);18 data.bestTime = readUtils.readWideString(reader, 15);19 data.split = readUtils.readWideString(reader, 15);20 data.completedLaps = reader.ReadUInt32();21 data.position = reader.ReadUInt32();22 data.iCurrentTime = reader.ReadUInt32();23 data.iLastTime = reader.ReadUInt32();24 data.iBestTime = reader.ReadUInt32();25 data.sessionTimeLeft = reader.ReadFloat();26 data.distanceTraveled = reader.ReadFloat();27 data.isInPit = reader.ReadUInt32();28 data.currentSectorIndex = reader.ReadUInt32();29 data.lastSectorTime = reader.ReadUInt32();30 data.numberOfLaps = reader.ReadUInt32();31 data.tyreCompund = readUtils.readWideString(reader, 34);32 data.replayTimeMultiplier = reader.ReadFloat();33 data.normalizedCarPosition = reader.ReadFloat();34 data.activeCars = reader.ReadUInt32();35 data.carCoordinates = readUtils.readMatrix(reader, 'float', 60, 3);36 data.carId = readUtils.readArray(reader, 'int', 60);37 data.playerCarId = reader.ReadUInt32();38 data.penaltyTime = reader.ReadFloat();39 data.flag = reader.ReadUInt32();40 data.penalty = reader.ReadUInt32();41 data.idealLineOn = reader.ReadUInt32();42 data.isInPitLane = reader.ReadUInt32();43 data.surfaceGrip = reader.ReadFloat();44 data.mandatoryPitDone = reader.ReadUInt32();45 data.windSpeed = reader.ReadFloat();46 data.windDirection = reader.ReadFloat();47 data.isSetupMenuVisible = reader.ReadUInt32();48 data.mainDisplayIndex = reader.ReadUInt32();49 data.secondaryDisplyIndex = reader.ReadUInt32();50 data.tc = reader.ReadUInt32();51 data.tcCut = reader.ReadUInt32();52 data.engineMap = reader.ReadUInt32();53 data.abs = reader.ReadUInt32();54 data.fuelXLap = reader.ReadFloat();55 data.rainLights = reader.ReadUInt32();56 data.flashingLights = reader.ReadUInt32();57 data.lightsStage = reader.ReadUInt32();58 data.exhaustTemperature = reader.ReadFloat();59 data.wiperLV = reader.ReadUInt32();60 data.driverStintTotalTimeLeft = reader.ReadUInt32();61 data.driverStintTimeLeft = reader.ReadUInt32();62 data.rainTyres = reader.ReadUInt32();63 data.sessionIndex = reader.ReadUInt32();64 data.usedFuel = reader.ReadFloat();65 data.deltaLapTime = readUtils.readWideString(reader, 15);66 data.iDeltaLapTime = reader.ReadUInt32();67 data.estimatedLapTime = readUtils.readWideString(reader, 15);68 data.iEstimatedLapTime = reader.ReadUInt32();69 data.isDeltaPositive = reader.ReadUInt32();70 data.iSplit = reader.ReadUInt32();71 data.isValidLap = reader.ReadUInt32();72 data.fuelEstimatedLaps = reader.ReadFloat();73 data.trackStatus = readUtils.readWideString(reader, 33);74 data.missingMandatoryPits = reader.ReadUInt32();75 data.clock = reader.ReadFloat();76 data.directionLightsLeft = reader.ReadUInt32();77 data.directionLightsRight = reader.ReadUInt32();78 data.globalYellow = reader.ReadUInt32();79 data.globalYellow1 = reader.ReadUInt32();80 data.globalYellow2 = reader.ReadUInt32();81 data.globalYellow3 = reader.ReadUInt32();82 data.globalWhite = reader.ReadUInt32();83 data.globalGreen = reader.ReadUInt32();84 data.globalChequered = reader.ReadUInt32();85 data.globalRed = reader.ReadUInt32()86 data.mfdTyreSet = reader.ReadUInt32();87 data.mfdFuelToAdd = reader.ReadFloat();88 data.mfdTyrePressureLF = reader.ReadFloat();89 data.mfdTyrePressureRF = reader.ReadFloat();90 data.mfdTyrePressureLR = reader.ReadFloat();91 data.mfdTyrePressureRR = reader.ReadFloat();92 data.trackGripStatus = reader.ReadUInt32()93 data.rainIntensity = reader.ReadUInt32();94 data.rainIntensityIn10min = reader.ReadUInt32();95 data.rainIntensityIn30min = reader.ReadUInt32();96 data.currentTyreSet = reader.ReadUInt32();97 data.strategyTyreSet = reader.ReadUInt32();98 data.gapAhead = reader.ReadUInt32();99 data.gapBehind = reader.ReadUInt32();100 return data;101}102const readGraphicsAccFiltered = () => {103 const m_graphics_length = 1580;104 const m_graphics_buffer = Buffer.alloc(m_graphics_length);105 const m_graphics = new NodeIPC.FileMapping();106 const FileGraphics_Path = "Local\\acpmf_graphics";107 m_graphics.createMapping(null, FileGraphics_Path, m_graphics_length);108 m_graphics.readInto(0, m_graphics_length, m_graphics_buffer);109 let data = {};110 const reader = new binutils.BinaryReader(m_graphics_buffer, 'little');111 data.packetId = reader.ReadUInt32();112 data.acc_status = reader.ReadUInt32();113 data.acc_session_type = reader.ReadInt32();114 data.currentTime = readUtils.readWideString(reader, 15);115 data.lastTime = readUtils.readWideString(reader, 15);116 data.bestTime = readUtils.readWideString(reader, 15);117 data.split = readUtils.readWideString(reader, 15);118 data.completedLaps = reader.ReadUInt32();119 data.position = reader.ReadUInt32();120 data.iCurrentTime = reader.ReadUInt32();121 data.iLastTime = reader.ReadUInt32();122 data.iBestTime = reader.ReadUInt32();123 data.sessionTimeLeft = reader.ReadFloat();124 data.distanceTraveled = reader.ReadFloat();125 data.isInPit = reader.ReadUInt32() > 0;126 data.currentSectorIndex = reader.ReadUInt32();127 data.lastSectorTime = reader.ReadUInt32();128 data.numberOfLaps = reader.ReadUInt32();129 data.tyreCompund = readUtils.readWideString(reader, 34);130 reader.ReadFloat(); //replay time multiplier131 data.normalizedCarPosition = reader.ReadFloat();132 data.activeCars = reader.ReadUInt32();133 data.carCoordinates = readUtils.readMatrix(reader, 'float', 60, 3);134 data.carId = readUtils.readArray(reader, 'int', 60);135 data.playerCarId = reader.ReadUInt32();136 data.penaltyTime = reader.ReadFloat();137 data.flag = reader.ReadUInt32();138 data.penalty = reader.ReadUInt32();139 data.idealLineOn = reader.ReadUInt32() > 0;140 data.isInPitLane = reader.ReadUInt32() > 0;141 data.surfaceGrip = reader.ReadFloat();142 data.mandatoryPitDone = reader.ReadUInt32() > 0;143 data.windSpeed = reader.ReadFloat();144 data.windDirection = reader.ReadFloat();145 data.isSetupMenuVisible = reader.ReadUInt32() > 0;146 data.mainDisplayIndex = reader.ReadUInt32();147 data.secondaryDisplyIndex = reader.ReadUInt32();148 data.tc = reader.ReadUInt32();149 data.tcCut = reader.ReadUInt32();150 data.engineMap = reader.ReadUInt32();151 data.abs = reader.ReadUInt32();152 data.fuelXLap = reader.ReadFloat();153 data.rainLights = reader.ReadUInt32() > 0;154 data.flashingLights = reader.ReadUInt32() > 0;155 data.lightsStage = reader.ReadUInt32();156 data.exhaustTemperature = reader.ReadFloat();157 data.wiperLV = reader.ReadUInt32();158 data.driverStintTotalTimeLeft = reader.ReadInt32();159 data.driverStintTimeLeft = reader.ReadInt32();160 data.rainTyres = reader.ReadUInt32() > 0;161 data.sessionIndex = reader.ReadUInt32();162 data.usedFuel = reader.ReadFloat();163 data.deltaLapTime = readUtils.readWideString(reader, 16);164 data.iDeltaLapTime = reader.ReadUInt32();165 data.estimatedLapTime = readUtils.readWideString(reader, 16);166 data.iEstimatedLapTime = reader.ReadUInt32();167 data.isDeltaPositive = reader.ReadUInt32() > 0;168 data.iSplit = reader.ReadUInt32();169 data.isValidLap = reader.ReadUInt32() > 0;170 data.fuelEstimatedLaps = reader.ReadFloat();171 data.trackStatus = readUtils.readWideString(reader, 34);172 data.missingMandatoryPits = reader.ReadUInt32();173 data.clock = reader.ReadFloat();174 data.directionLightsLeft = reader.ReadUInt32() > 0;175 data.directionLightsRight = reader.ReadUInt32() > 0;176 data.globalYellow = reader.ReadUInt32() > 0;177 data.globalYellow1 = reader.ReadUInt32() > 0;178 data.globalYellow2 = reader.ReadUInt32() > 0;179 data.globalYellow3 = reader.ReadUInt32() > 0;180 data.globalWhite = reader.ReadUInt32() > 0;181 data.globalGreen = reader.ReadUInt32() > 0;182 data.globalChequered = reader.ReadUInt32() > 0;183 data.globalRed = reader.ReadUInt32() > 0;184 data.mfdTyreSet = reader.ReadUInt32();185 data.mfdFuelToAdd = reader.ReadFloat();186 data.mfdTyrePressureLF = reader.ReadFloat();187 data.mfdTyrePressureRF = reader.ReadFloat();188 data.mfdTyrePressureLR = reader.ReadFloat();189 data.mfdTyrePressureRR = reader.ReadFloat();190 data.trackGripStatus = reader.ReadUInt32()191 data.rainIntensity = reader.ReadUInt32();192 data.rainIntensityIn10min = reader.ReadUInt32();193 data.rainIntensityIn30min = reader.ReadUInt32();194 data.currentTyreSet = reader.ReadUInt32();195 data.strategyTyreSet = reader.ReadUInt32();196 data.gapAhead = reader.ReadUInt32();197 data.gapBehind = reader.ReadUInt32();198 return data;199}200module.exports = {201 readGraphics,202 readGraphicsAccFiltered...
self.js
Source:self.js
...7}89function readUint64(array) {10 var BigInt = window.BigInt, bigThirtyTwo = BigInt(32), bigZero = BigInt(0);11 var left = BigInt(readUint32(array)>>>0);12 var right = BigInt(readUint32(array)>>>0);1314 var numb = (right<<bigThirtyTwo)|left;15 return Number(numb);16}1718function readUint64At(array,offset) {19 var BigInt = window.BigInt, bigThirtyTwo = BigInt(32), bigZero = BigInt(0);20 var left = BigInt(readUint32At(array,offset)>>>0);21 var right = BigInt(readUint32At(array,offset+4)>>>0);2223 var numb = (right<<bigThirtyTwo)|left;24 return Number(numb);25}2627function readUint32(array)28{29 var Arr = array.slice(ofset, ofset+4);30 uint = new Uint32Array(Arr.buffer)[0];31 ofset += 4;32 return uint;33}3435function readUint32At(array,offset)36{37 var Arr = array.slice(offset, offset+4);38 uint = new Uint32Array(Arr.buffer)[0];39 return uint;40}4142function readUint16(array)43{44 var Arr = array.slice(ofset, ofset+2);45 uint = new Uint16Array(Arr.buffer)[0]46 ofset += 2;47 return uint;48}495051function readStringLen2(array, length)52{53 //First work out how long until \x0054 for(var len = 0; len < length; len++)55 {56 by = array[ofset+len];57 if(by == 0x00)58 {59 break;60 }61 }62 63 var Arr = array.slice(ofset, ofset+len);64 ofset += length;65 return new TextDecoder("utf-8").decode(Arr);66}6768function readStringLen2At2(array, length,offset)69{70 //First work out how long until \x0071 for(var len = 0; len < length; len++)72 {73 by = array[offset+len];74 if(by == 0x00)75 {76 break;77 }78 }79 80 var Arr = array.slice(ofset, ofset+len);81 return new TextDecoder("utf-8").decode(Arr);82}8384function readStringAt2(array, offset)85{86 //First work out how long until \x0087 for(var length = 0; ; length++)88 {89 by = array[offset+length];90 if(by == 0x00)91 {92 break;93 }94 }95 96 //Read the string97 return readStringLen2At2(array,length,offset)98}99100function readBytes(array, len)101{102 var bytes = array.slice(ofset, ofset+len);103 ofset += len104 return bytes;105}106107function get_module_info(selfBytes)108{109 ofset = 0;110 111 var uint8Arr = new Uint8Array(selfBytes)112 113 var SELF_UNCOMPRESSED = 1;114 var SELF_COMPRESSED = 2;115 116 var SELF_ENCRYPTED = 1;117 var SELF_FSELF = 2;118 119 var SceHeader = {120 "magic":readUint32(uint8Arr),121 "version":readUint32(uint8Arr),122 "sdk_type":readUint16(uint8Arr),123 "header_type":readUint16(uint8Arr),124 "metadata_offset":readUint32(uint8Arr),125 "header_len":readUint64(uint8Arr),126 "elf_filesize":readUint64(uint8Arr),127 "self_filesize":readUint64(uint8Arr),128 "unknown":readUint64(uint8Arr),129 "self_offset":readUint64(uint8Arr),130 "appinfo_offset":readUint64(uint8Arr),131 "elf_offset":readUint64(uint8Arr),132 "phdr_offset":readUint64(uint8Arr),133 "shdr_offset":readUint64(uint8Arr),134 "section_info_offset":readUint64(uint8Arr),135 "controlinfo_offset":readUint64(uint8Arr),136 "controlinfo_size":readUint64(uint8Arr),137 "padding":readUint64(uint8Arr)138 }139 140 if(SceHeader.magic == 0x454353) //SCE\x00141 {142 ofset = SceHeader.elf_offset;143 144 var ElfHeader = {145 "e_ident":readBytes(uint8Arr,16),146 "e_type":readUint16(uint8Arr),147 "e_machine":readUint16(uint8Arr),148 "e_version":readUint32(uint8Arr),149 "e_entry":readUint32(uint8Arr),150 "e_phoff":readUint32(uint8Arr),151 "e_shoff":readUint32(uint8Arr),152 "e_flags":readUint32(uint8Arr),153 "e_ehsize":readUint16(uint8Arr),154 "e_ehsize":readUint16(uint8Arr),155 "e_phnum":readUint16(uint8Arr),156 "e_shentsize":readUint16(uint8Arr),157 "e_shnum":readUint16(uint8Arr),158 "e_shstrndx":readUint16(uint8Arr)159 }160 161 162 if(readUint32At(ElfHeader.e_ident,0) == 0x464C457F) { //\x7FELF163 ofset = SceHeader.section_info_offset;164 165 var Segments = []166 for(var i = 0; i < ElfHeader.e_phnum; i++)167 {168 var SegmentHeader = {169 "offset":readUint64(uint8Arr),170 "length":readUint64(uint8Arr),171 "compression":readUint64(uint8Arr),172 "encryption":readUint64(uint8Arr)173 }174 Segments.push(SegmentHeader);175 }176 if(SegmentHeader.encryption == SELF_ENCRYPTED)177 {178 alert("SELF is Encrypted, please use FSELF.");179 }180 ofset = SceHeader.phdr_offset;181 var ProgramHeaders = []182 for(var i = 0; i < ElfHeader.e_phnum; i++)183 {184 185 var ProgramHeader = {186 "p_type":readUint32(uint8Arr),187 "p_offset":readUint32(uint8Arr),188 "p_vaddr":readUint32(uint8Arr),189 "p_paddr":readUint32(uint8Arr),190 "p_filesz":readUint32(uint8Arr),191 "p_memsz":readUint32(uint8Arr),192 "p_flags":readUint32(uint8Arr),193 "p_align":readUint32(uint8Arr)194 }195 ProgramHeaders.push(ProgramHeader); 196 }197 var Seg0 = uint8Arr.slice(Segments[0].offset, Segments[0].offset + ProgramHeaders[0].p_filesz);198 if(Segments[0].compression == SELF_COMPRESSED)199 {200 Seg0 = pako.ungzip(Seg0);201 }202 203 ofset = ElfHeader.e_entry; // SceModuleInfo204 SceModuleInfo = {205 "attr":readUint16(Seg0),206 "ver":readUint16(Seg0),207 "name":readStringLen2(Seg0,27),208 "type":readUint8(Seg0),209 "expTop":readUint32(Seg0),210 "expBtm":readUint32(Seg0),211 "impTop":readUint32(Seg0),212 "impBtm":readUint32(Seg0),213 "nid":readUint32(Seg0),214 "unk":[readUint32(Seg0), readUint32(Seg0), readUint32(Seg0)],215 "start":readUint32(Seg0),216 "stop":readUint32(Seg0),217 "exidxTop":readUint32(Seg0),218 "exidxBtm":readUint32(Seg0),219 "extabTop":readUint32(Seg0),220 "extabBtm":readUint32(Seg0)221 }222 223 return SceModuleInfo;224 }225 else226 {227 alert("Invalid ELF..");228 }229 return ElfHeader;230 }231 else232 {233 alert("Invalid SELF..");234 }
...
Using AI Code Generation
1var wpt = require('./wpt.js');2var buffer = new Buffer(4);3buffer.writeUInt32LE(0x12345678,0);4var value = wpt.readUint32(buffer,0);5console.log(value);6var exports = module.exports = {};7exports.readUint32 = function readUint32(buffer, offset) {8 var value = buffer.readUInt32LE(offset);9 return value;10};11var buffer = new Buffer("Hello World");12var buffer = new Buffer("Hello World");13var buffer = new Buffer("Hello World");14var buffer = new Buffer("Hello World");15var buffer = new Buffer("Hello World");
Using AI Code Generation
1let reader = new WPTReadableStream();2let readResult = reader.readUint32();3let reader = new WPTReadableStream();4let readResult = reader.readUint32();5let reader = new WPTReadableStream();6let readResult = reader.readUint32();7let reader = new WPTReadableStream();8let readResult = reader.readUint32();9let reader = new WPTReadableStream();10let readResult = reader.readUint32();11let reader = new WPTReadableStream();12let readResult = reader.readUint32();13let reader = new WPTReadableStream();14let readResult = reader.readUint32();15let reader = new WPTReadableStream();16let readResult = reader.readUint32();17let reader = new WPTReadableStream();18let readResult = reader.readUint32();19let reader = new WPTReadableStream();20let readResult = reader.readUint32();21let reader = new WPTReadableStream();22let readResult = reader.readUint32();23let reader = new WPTReadableStream();24let readResult = reader.readUint32();25let reader = new WPTReadableStream();
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!