--[===[ Author: YoucefHam Email: youcefham20@gmail.com Discord: YoucefHam#5634 ADD to AddressList Popup Menu "Create Structure Data", Dissect Data/Structure at the selected Address (more than one, add multiple groups) "Convert Records to Pointer", Convert Records to Pointer (Format "2:30,0x50" 2 offsets, 1=30 dec, 2=0x50 hex) (more than one record) "Copy Address String", => [chrome.exe+28E6E8] "COPY CURRENT ADDRESS", Value of [chrome.exe+28E6E8] => 7FFD2F3D7B80 "COPY ADDRESS Name", Name of [chrome.exe+28E6E8] => KERNEL32.GetSystemTimeAsFileTime "Create Header Spacer", Add Header to the selected record with "------------" "Create AutoAssemble Script", Add Script to the selected record, [Hold CTRL to Input Name] "Disable Without Executing", Disable selected Scripts Without Executing the Disable section. (More than one script) ]===] -- Parse Address String and Offsets local function getAddressWithOffsets(memrec) local mrAddress = memrec.Address if memrec.Offset then for i = memrec.OffsetCount - 1 , 0 , -1 do if memrec.OffsetText[i]:find('^-') then mrAddress = '['..mrAddress..']'..memrec.OffsetText[i] else mrAddress = '['..mrAddress..']+'..memrec.OffsetText[i] end end end if mrAddress:find('+0$') then return mrAddress:gsub('+0$','') else return mrAddress end end -- Parse Address String and Offsets local function SetAddress(PAddress,CAddress) if CAddress:find('^[+-]') then return PAddress..CAddress elseif CAddress:find('^[[][+-]') then return CAddress:gsub('^([[])','%1'..PAddress) elseif CAddress:find('^[[]*[^+-]') then return CAddress:gsub('^(%[*)','%1'..PAddress) end end -- Copy Address String local function getAddressWithChildrenOffsets(memrec) local memrec = memrec or AddressList.SelectedRecord local mrAddress local ParentAddress = memrec if memrec.Address:find('^[+-]') then -- the address is diff pointer mrAddress = getAddressWithOffsets(memrec) -- Record have parent if memrec.Parent then ParentAddress = memrec.Parent -- get First Parent while ParentAddress.Address:match('^[+-]') do mrAddress = SetAddress(getAddressWithOffsets(ParentAddress),mrAddress) -- Replace text if ParentAddress.Parent then ParentAddress = ParentAddress.Parent -- get Next Parent else break end end mrAddress = SetAddress(getAddressWithOffsets(ParentAddress),mrAddress) -- Replace text end writeToClipboard(string.format(mrAddress)) return mrAddress end writeToClipboard(string.format(getAddressWithOffsets(memrec))) return string.format(getAddressWithOffsets(memrec)) end --Copy Current Address local function getMemrecCurrentAddress() local mr=AddressList.SelectedRecord writeToClipboard(string.format('%X',mr.CurrentAddress)) return string.format('%X',mr.CurrentAddress) end --Copy Address Name local function getMemrecAddressName() local mr=AddressList.SelectedRecord writeToClipboard(string.format('%s',getNameFromAddress(mr.CurrentAddress))) return string.format('%s',getNameFromAddress(mr.CurrentAddress)) end --Create AutoAssemble Script local function addNewScript() local Scriptname = translate("AutoAssemble Script") if isKeyPressed(VK_CONTROL) then Scriptname=InputQuery(translate('New AutoAssemble Script'), translate('New AutoAssemble Script Name:'), Scriptname) if Scriptname=='' then Scriptname = "AutoAssemble Script" end end local mr = AddressList.createMemoryRecord() mr.Type = vtAutoAssembler mr.Description = Scriptname mr.Script = [[ {$lua} if syntaxcheck then return end --if not monopipe then if LaunchMonoDataCollector() == 0 then error(MessageDialog('Failed to Launch Mono Data Collector', mtError, mbClose)) end end {$asm} [ENABLE] [DISABLE] ]] if AddressList.SelCount > 0 then mr.appendToEntry(AddressList.SelectedRecord) end end --Create Header Spacer local function addHeaderSpacer() local header=AddressList.createMemoryRecord() header.IsGroupHeader=true header.IsAddressGroupHeader=false header.Description='--------------------------------------------- ----------------------------------------------' if AddressList.SelCount > 0 then header.appendToEntry(AddressList.SelectedRecord) end end --disable Without Executing local function _disableWithoutExecute() for i=0, AddressList.Count-1 do if AddressList[i].Selected and AddressList[i].Type==vtAutoAssembler then AddressList[i].disableWithoutExecute() end end end --create Structure Data local function createStructureData() local rec = 0 local structure for i=0, AddressList.Count-1 do if AddressList[i].Selected and AddressList[i].CurrentAddress~='' and AddressList[i].CurrentAddress~=nil and AddressList[i].CurrentAddress~='0' and AddressList[i].Type ~= vtAutoAssembler then rec = rec + 1 if rec == 1 then structure = createStructureForm(string.format('%X',AddressList[i].CurrentAddress)) elseif rec > 1 then structure.addGroup().addColumn().AddressText = string.format('%X',AddressList[i].CurrentAddress) end end end structure.Menu.Items[2][0].doClick() end --Convert records to pointers local function ConvertRecordsToPointers() local rec = 0 local str = nil local useSameOffset = false for i=0, AddressList.Count-1 do if AddressList[i].Selected and AddressList[i].CurrentAddress~='' and AddressList[i].CurrentAddress~=nil and AddressList[i].CurrentAddress~='0' and AddressList[i].Type ~= vtAutoAssembler then if AddressList[i].OffsetCount == 0 then rec = rec + 1 if rec == 2 then local msg = messageDialog(translate('Use the same offset for all selected Address'), mtConfirmation, mbYes, mbNo,mbCancel) if msg == mrYes then useSameOffset = true elseif msg == mrNo then useSameOffset = false elseif msg == mrCancel then break end end if not(useSameOffset) or rec == 1 then str = inputQuery( 'Memory Record Change to pointer:', [[Format: "2:30,0x50" = 2 offsets, 1=30 dec, 2=0x50 hex]], '1:0' ) end local OffsetCount = tonumber(str:match('^(%d+):'):lower()) local Offset = str:match(':(.*)$'):lower() AddressList[i].OffsetCount = OffsetCount if OffsetCount == 1 then AddressList[i].Offset[0] = Offset or 0 elseif OffsetCount > 1 then local k = OffsetCount - 1 for s in Offset:gmatch("(-*0*x*%x+),*",1) do AddressList[i].Offset[k] = s or 0 k = k - 1 end end end end end end -- Get AddressList PopupMenu Class local pm=AddressList.PopupMenu -- populate menus local function addPopMenuItem(caption, onClick, placeAfter) local newItem = createMenuItem(pm) newItem.Caption = caption newItem.OnClick = onClick if placeAfter==nil then pm.Items.Add(newItem) else pm.Items.insert(placeAfter , newItem) end return newItem end -- Create Menus local miMemrecExtra8 = addPopMenuItem(translate('Create Structure Data'), createStructureData, MainForm.Cut1.MenuIndex) miMemrecExtra8.ImageIndex = MainForm.ComponentByName['miCreateLuaForm'].ImageIndex local miMemrecExtra9 = addPopMenuItem(translate('Convert Records to Pointer'), ConvertRecordsToPointers, MainForm.Cut1.MenuIndex) miMemrecExtra9.ImageIndex = MainForm.ComponentByName['Change1'].ImageIndex local miMemrecExtra1 = addPopMenuItem(translate('Copy Address String'), getAddressWithChildrenOffsets, MainForm.Cut1.MenuIndex) miMemrecExtra1.ImageIndex = MainForm.ComponentByName['Copy1'].ImageIndex local miMemrecExtra2 = addPopMenuItem(translate('Copy Current Address'), getMemrecCurrentAddress, MainForm.Cut1.MenuIndex) miMemrecExtra2.ImageIndex = MainForm.ComponentByName['Copy1'].ImageIndex local miMemrecExtra7 = addPopMenuItem(translate('Copy Address Name'), getMemrecAddressName, MainForm.Cut1.MenuIndex) miMemrecExtra7.ImageIndex = MainForm.ComponentByName['Copy1'].ImageIndex local miMemrecExtra3 = addPopMenuItem('-',nil, MainForm.Cut1.MenuIndex) local miMemrecExtra5 = addPopMenuItem('Create Header Spacer',addHeaderSpacer, MainForm.miGroupconfig.MenuIndex) miMemrecExtra5.ImageIndex=MainForm.CreateGroup.ImageIndex local miMemrecExtra4 = addPopMenuItem('Create AutoAssemble Script',addNewScript, MainForm.miGroupconfig.MenuIndex) miMemrecExtra4.ImageIndex=MainForm.CreateGroup.ImageIndex local miMemrecExtra6 = addPopMenuItem('Disable Without Executing',_disableWithoutExecute, MainForm.miFreezePositive.MenuIndex) --Freezealladdresses2 miMemrecExtra6.ImageIndex=MainForm.New1.ImageIndex -- Get Old Menu to Add new Menus local oldOnPopup = AddressList.PopupMenu.OnPopup AddressList.PopupMenu.OnPopup=function(...) if oldOnPopup then oldOnPopup(...) end miMemrecExtra4.Visible = true miMemrecExtra5.Visible = true miMemrecExtra3.Visible = true for i=0, AddressList.Count-1 do if (AddressList[i].Selected and AddressList[i].CurrentAddress~='' and AddressList[i].CurrentAddress~=nil and AddressList[i].CurrentAddress~='0' and AddressList[i].Type ~= vtAutoAssembler) then visible = true break end visible = false end miMemrecExtra1.Visible = visible and (AddressList.SelCount == 1) if miMemrecExtra1.Visible == true then miMemrecExtra1.Caption = string.format('Copy Address String: %s',getAddressWithChildrenOffsets()) end miMemrecExtra2.Visible = visible and (AddressList.SelCount == 1) if miMemrecExtra2.Visible == true then miMemrecExtra2.Caption = string.format('Copy Current Address: %X',AddressList.SelectedRecord.CurrentAddress) end miMemrecExtra7.Visible = visible and (AddressList.SelCount == 1) if miMemrecExtra7.Visible == true then miMemrecExtra7.Caption = string.format('Copy Address Name: %s',getNameFromAddress(AddressList.SelectedRecord.CurrentAddress)) end miMemrecExtra8.Visible = visible miMemrecExtra9.Visible = visible for i=0, AddressList.Count-1 do if AddressList[i].Selected and AddressList[i].Type==vtAutoAssembler then visible = true break end visible = false end miMemrecExtra6.Visible = visible end