local useGroupMenu = true local extGroupMenuCaption = 'Extra Extensions' local extItemCaption = 'GenFromStructName' local mf = getMainForm() local mm = mf.Menu local extMenu = nil if useGroupMenu then for i=0,mm.Items.Count-1 do if mm.Items.Item[i].Caption == extGroupMenuCaption then extMenu = mm.Items.Item[i] break end end if not extMenu then extMenu = createMenuItem(mm) extMenu.Caption = extGroupMenuCaption mm.Items.add(extMenu) end else extMenu = mm.Items end local extMenuItem = createMenuItem(extMenu) extMenuItem.Caption = extItemCaption extMenu.add(extMenuItem) extMenuItem.OnClick = function(sender) genStructFromName() end function genStructFromName() local memrecSelected = getAddressList().getSelectedRecord() local structName = inputQuery("Input structure name:","",nil) if memrecSelected.IsGroupHeader and memrecSelected.Address == "" then printf("ERROR:\nSelected memrec should be header or group with address") return end if not memrecSelected.IsGroupHeader and memrecSelected.Address == "" then printf("ERROR:\nSelected memrec should be header or group with address") return end if memrecSelected == nil or structName == nil then return end if memrecSelected.IsGroupHeader and memrecSelected.Address == "" then return end while memrecSelected.Count>0 do memrecSelected[0].destroy() end local foundStruct for i=0,getStructureCount()-1 do if getStructure(i).Name==structName then foundStruct=getStructure(i) break end end if not foundStruct then error('structure "'..structName..'" not found') end generateMemoryRecords(memrecSelected,foundStruct) end function generateMemoryRecords(memrec,struct) for i=0,struct.Count-1 do local elemStruct = struct.Element[i] local elementMemRec = AddressList.createMemoryRecord() elementMemRec.Address = '+'..string.format("%X",elemStruct.Offset) elementMemRec.Description = elemStruct.Name elementMemRec.Type = elemStruct.Vartype if elemStruct.CustomType then elementMemRec.CustomTypeName = elemStruct.CustomType.name end if elemStruct.Vartype==vtString then elementMemRec.String.Size = elemStruct.Bytesize end if elemStruct.Vartype==vtUnicodeString then elementMemRec.Type = vtString elementMemRec.String.Size = elemStruct.Bytesize elementMemRec.String.Unicode = true end if elemStruct.Vartype==vtByteArray then elementMemRec.Aob.Size = elemStruct.Bytesize end if elemStruct.Vartype == vtPointer then elementMemRec.Type = targetIs64Bit() and vtQword or vtDword elementMemRec.OffsetCount = 1 elementMemRec.OffsetText[0] = 0 end elementMemRec.ShowAsHex = elemStruct.DisplayMethord == 'dtHexadecimal' elementMemRec.ShowAsSigned = elemStruct.DisplayMethod == 'dtSignedInteger' elementMemRec.appendToEntry(memrec) elementMemRec.Options = 'moHideChildren' if elemStruct.childStruct then generateMemoryRecords(elementMemRec,elemStruct.childStruct) end end end