-- local function findSrc(headStr,maxback) if type(headStr)=='number' and type(maxback)=='number' then -- recall mode local sLen = readInteger(headStr-maxback) local src = readString(headStr,sLen) if sLen~=nil and src~=nil and src:len()==sLen then return src else return '--sry, some thing wrong--' end end maxback = maxback or 256 headStr = {headStr:gsub('\n',string.char(13,10)):byte(1,-1)} local found = {} if #headStr>3 then local aob = {} for i=1,#headStr do aob[i]=string.format('%02X',headStr[i]) end aob = table.concat(aob,' ') aob = AOBScan(aob,'',1,'4') if aob~=nil then local pg = GetMainForm().progressbar1 local ac = aob.Count for k=1,ac do pg.Position = math.floor(k/ac*(pg.Max-pg.Min)+pg.Min) processMessages() local addr = tonumber(aob[k-1],16) local bb = readBytes(addr) while bb~=nil and bb~=0 do addr=addr-1 ; bb= readBytes(addr)end if bb==0 and 0==(addr + 1 )%4 then addr = addr + 1 for i=4,maxback,4 do local maybeLen = readInteger(addr-i) if maybeLen~=nil and maybeLen>10 and maybeLen<0x100000 --[[1M]] then local src = readString(addr,maybeLen) if src~=nil and src:len()==maybeLen then found[1+#found] = string.format("len=%6d, @ (0x%08X,%3d)",maybeLen,addr,i) end end end--for i end end--for k pg.Position = 0 aob.Destroy() end end if #found>0 then return found end end local function ceupd(t,o) for k,v in pairs(o) do if type(v)=='table' then local peek = t[k] if type(peek)=='table' or type(peek)=='userdata' then t[k] = ceupd(peek,v) else t[k] = v end else t[k] = v end end return t end local function callLater(n,f) ceupd(createTimer(),{Interval=n or 1,OnTimer = function(tm) tm.Destroy()pcall(f)end}) end local thisUI local function ui() local fm = ceupd(createForm(),{Caption="Lost n Found Source",Width=400,Height=400,Constraints={MinWidth=360,MinHeight=200},BorderStyle='bsSizeable',OnClose=function(me)--[[me.Destroy();fm=nil]] return caHide end}) local pl = ceupd(createPanel(fm),{Constraints={MinWidth=240,MaxWidth=240},Align=alLeft}) local mm = ceupd(createMemo(fm),{Lines={Text="--full source--"},Align=alClient,ScrollBars=ssAutoBoth,ReadOnly=true,Font={Name='Courier New',Size=8},WordWrap=false}) local bs = ceupd(createButton(pl),{Align=alTop,Caption="Scan"}) local pb = ceupd(createPanel(pl),{Align=alClient}) local mh = ceupd(createMemo(pb),{Lines={Text="[ENABLE]"},Constraints={MinHeight=60,MaxHeight=60},Align=alTop,ScrollBars=ssAutoVertical,Font={Name='Courier New',Size=8}}) local lx = ceupd(createListBox(pb),{Align=alClient,ScrollBars=ssAutoVertical,Font={Name='Courier New',Size=8},MultiSelect=false}) bs.OnClick = function(b) b.Enabled = false local found = findSrc(mh.Lines.Text) if found~=nil then lx.Items.Text = table.concat(found,'\n') else lx.Items.Text = '--not found--' end b.Enabled = true end lx.OnDblClick = function(lb) local idx = lb.ItemIndex if idx>=0 then local addr,back = lb.Items[idx]:match('%(0x(%x+),%s*(%d+)%)$') addr,back = tonumber(addr or '',16),tonumber(back or '') if addr~=nil and back~=nil then mm.Lines.Text = findSrc(addr,back) end end end return fm end local function show() if thisUI==nil then thisUI = ui() end thisUI.show() end local function hide() if thisUI==nil then thisUI = ui() end thisUI.hide() end local function destroy() if thisUI~=nil then thisUI.Destroy() end thisUI=nil end return { show=show,hide=hide,destroy=destroy, Show=show,Hide=hide,Destroy=destroy}