const ModuleSections &WindowsImage::GetSections(S2EExecutionState *s) { if (!m_sectionsInited) { InitSections(s); m_sectionsInited = true; } return m_Sections; }
static void SetHeaders( ElfHdr *hdr ) /***********************************/ { memcpy( hdr->eh.e_ident, ELF_SIGNATURE, ELF_SIGNATURE_LEN ); hdr->eh.e_ident[EI_CLASS] = ELFCLASS32; #ifdef __BIG_ENDIAN__ hdr->eh.e_ident[EI_DATA] = ELFDATA2MSB; #else hdr->eh.e_ident[EI_DATA] = ELFDATA2LSB; #endif hdr->eh.e_ident[EI_VERSION] = EV_CURRENT; hdr->eh.e_ident[EI_OSABI] = FmtData.u.elf.abitype; hdr->eh.e_ident[EI_ABIVERSION] = FmtData.u.elf.abiversion; memset( &hdr->eh.e_ident[EI_PAD], 0, EI_NIDENT - EI_PAD ); hdr->eh.e_type = ET_EXEC; if( LinkState & HAVE_PPC_CODE ) { hdr->eh.e_machine = EM_PPC; } else if( LinkState & HAVE_MIPS_CODE ) { hdr->eh.e_machine = EM_MIPS; } else if( LinkState & HAVE_X64_CODE ) { hdr->eh.e_machine = EM_X86_64; } else { hdr->eh.e_machine = EM_386; } hdr->eh.e_version = EV_CURRENT; if( StartInfo.type == START_UNDEFED ) { hdr->eh.e_entry = 0; } else { hdr->eh.e_entry = FindLinearAddr2( &StartInfo.addr ); } hdr->eh.e_flags = 0; hdr->eh.e_ehsize = sizeof(Elf32_Ehdr); hdr->eh.e_phentsize = sizeof(Elf32_Phdr); hdr->eh.e_shentsize = sizeof(Elf32_Shdr); hdr->eh.e_phnum = NumGroups + 1; hdr->eh.e_phoff = sizeof(Elf32_Ehdr); hdr->ph_size = sizeof(Elf32_Phdr) * hdr->eh.e_phnum; _ChkAlloc( hdr->ph, hdr->ph_size ); hdr->ph->p_type = PT_PHDR; hdr->ph->p_offset = sizeof(Elf32_Ehdr); hdr->ph->p_vaddr = sizeof(Elf32_Ehdr) + FmtData.base; hdr->ph->p_paddr = 0; hdr->ph->p_filesz = hdr->ph_size; hdr->ph->p_memsz = hdr->ph_size; hdr->ph->p_flags = PF_R | PF_X; hdr->ph->p_align = 0; InitStringTable( &hdr->secstrtab, FALSE ); AddCharStringTable( &hdr->secstrtab, '\0' ); InitSections( hdr ); hdr->curr_off = hdr->eh.e_ehsize + hdr->ph_size; hdr->curr_off = ROUND_UP( hdr->curr_off, 0x100 ); SeekLoad( hdr->curr_off ); }
void ClassicLadder_InitAllDatas( void ) { InitVars(); #ifdef OLD_TIMERS_MONOS_SUPPORT InitTimers(); InitMonostables(); #endif InitCounters(); InitTimersIEC(); InitArithmExpr(); InitRungs(); InitSections( ); #ifdef SEQUENTIAL_SUPPORT InitSequential( ); #endif InitSymbols( ); }
void USkeletalMesh::ConvertMesh() { guard(USkeletalMesh::ConvertMesh); CSkeletalMesh *Mesh = new CSkeletalMesh(this); ConvertedMesh = Mesh; Mesh->BoundingBox = BoundingBox; Mesh->BoundingSphere = BoundingSphere; Mesh->RotOrigin = RotOrigin; Mesh->MeshScale = CVT(MeshScale); Mesh->MeshOrigin = CVT(MeshOrigin); Mesh->Lods.Empty(LODModels.Num()); #if DEBUG_SKELMESH appPrintf(" Base : Points[%d] Wedges[%d] Influences[%d] Faces[%d]\n", Points.Num(), Wedges.Num(), VertInfluences.Num(), Triangles.Num() ); #endif // some games has troubles with LOD models ... #if TRIBES3 if (GetGame() == GAME_Tribes3) goto base_mesh; #endif #if SWRC if (GetGame() == GAME_RepCommando) goto base_mesh; #endif if (!LODModels.Num()) { base_mesh: guard(ConvertBaseMesh); // create CSkelMeshLod from base mesh CSkelMeshLod *Lod = new (Mesh->Lods) CSkelMeshLod; Lod->NumTexCoords = 1; Lod->HasNormals = false; Lod->HasTangents = false; if (Points.Num() && Wedges.Num() && VertInfluences.Num()) { InitSections(*Lod); ConvertWedges(*Lod, Points, Wedges, VertInfluences); BuildIndices(*Lod); } else { appPrintf("ERROR: bad base mesh\n"); } goto skeleton; unguard; } // convert LODs for (int lod = 0; lod < LODModels.Num(); lod++) { guard(ConvertLod); const FStaticLODModel &SrcLod = LODModels[lod]; #if DEBUG_SKELMESH appPrintf(" Lod %d: Points[%d] Wedges[%d] Influences[%d] Faces[%d] Rigid(Indices[%d] Verts[%d]) Smooth(Indices[%d] Verts[%d] Stream[%d])\n", lod, SrcLod.Points.Num(), SrcLod.Wedges.Num(), SrcLod.VertInfluences.Num(), SrcLod.Faces.Num(), SrcLod.RigidIndices.Indices.Num(), SrcLod.VertexStream.Verts.Num(), SrcLod.SmoothIndices.Indices.Num(), SrcLod.SkinPoints.Num(), SrcLod.SkinningData.Num() ); #endif // if (SrcLod.Faces.Num() == 0 && SrcLod.SmoothSections.Num() > 0) // continue; CSkelMeshLod *Lod = new (Mesh->Lods) CSkelMeshLod; Lod->NumTexCoords = 1; Lod->HasNormals = false; Lod->HasTangents = false; if (IsCorrectLOD(SrcLod)) { InitSections(*Lod); ConvertWedges(*Lod, SrcLod.Points, SrcLod.Wedges, SrcLod.VertInfluences); BuildIndicesForLod(*Lod, SrcLod); } else { appPrintf("WARNING: bad LOD#%d mesh, switching to base\n", lod); if (lod == 0) { Mesh->Lods.Empty(); goto base_mesh; } else { Mesh->Lods.RemoveAt(lod); break; } } unguard; } skeleton: // copy skeleton guard(ProcessSkeleton); Mesh->RefSkeleton.Empty(RefSkeleton.Num()); for (int i = 0; i < RefSkeleton.Num(); i++) { const FMeshBone &B = RefSkeleton[i]; CSkelMeshBone *Dst = new (Mesh->RefSkeleton) CSkelMeshBone; Dst->Name = B.Name; Dst->ParentIndex = B.ParentIndex; Dst->Position = CVT(B.BonePos.Position); Dst->Orientation = CVT(B.BonePos.Orientation); } unguard; // ProcessSkeleton // copy sockets int NumSockets = AttachAliases.Num(); Mesh->Sockets.Empty(NumSockets); for (int i = 0; i < NumSockets; i++) { CSkelMeshSocket *DS = new (Mesh->Sockets) CSkelMeshSocket; DS->Name = AttachAliases[i]; DS->Bone = AttachBoneNames[i]; DS->Transform = CVT(AttachCoords[i]); } Mesh->FinalizeMesh(); unguard; }