View previous topic :: View next topic |
Author |
Message |
mgr.inz.Player I post too much Reputation: 218
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Fri Jan 17, 2020 6:02 pm Post subject: |
|
|
DrackenDarck wrote: | seems like 134.000 reslts was too much?^^ |
That's Too Much, Man! Narrow it to at least 50'000
Here, more responsive version with progressbar:
Code: | local SortedFoundListForm
local SortedFoundListListView
local SortedFoundListProgressBar
local SortedFoundListMenuItem
local function doTheHeavyJob(thread)
thread.Name = 'SortedFoundListThread'
local ms=getCurrentMemscan()
local fl=ms.FoundList
local results = {}
local addItems = SortedFoundListListView.Items.add
if fl.Count>0 then
SortedFoundListListView.beginUpdate()
SortedFoundListProgressBar.Max = fl.Count * 2
for i = 0, fl.Count-1 do
results[1+#results] = {Address=fl.getAddress(i),Value=fl.getValue(i)}
SortedFoundListProgressBar.Position = i
end
local base = ms.isHexadecimal and 16 or nil
table.sort(results, function (a,b)
local aN,bN = tonumber(a.Value,base) or (-1/0),tonumber(b.Value,base) or (-1/0)
local aA,bA = tonumber(a.Address,16),tonumber(b.Address,16)
local res = aN==bN and aA<bA or aN<bN
if SortedFoundList_reverseSort then res = not res end
return res
end)
for i,v in ipairs(results) do
local item = addItems()
item.Caption = v.Address
item.SubItems.add(v.Value)
SortedFoundListProgressBar.Position = #results + i
end
SortedFoundListListView.endUpdate()
end
SortedFoundListForm.Caption = 'Sorted FoundList'
SortedFoundListProgressBar.Position = 0
SortedFoundListMenuItem.Enabled = true
SortedFoundListForm.OnClose = function (sender) return caFree end
end
local function showSortedFoundList()
SortedFoundListForm = createForm(false)
SortedFoundListForm.OnClose = function (sender) return caNone end
SortedFoundListForm.BorderStyle = bsSizeable
SortedFoundListForm.Position = 'poWorkAreaCenter'
SortedFoundListForm.PopupMode = 'pmNone'
SortedFoundListForm.Caption = 'Sorted FoundList (wait)'
SortedFoundListForm.Width = (MainForm.Width * 0.75) // 1
SortedFoundListForm.Height = (MainForm.Height * 0.75) // 1
SortedFoundListForm.show()
local pm = createPopupMenu(SortedFoundListForm)
SortedFoundListForm.PopupMenu = pm
local mi = createMenuItem(pm)
pm.Items.add(mi)
mi.Caption = 'Reverse sort'
mi.Enabled = false
mi.OnClick = function (sender)
SortedFoundList_reverseSort = not SortedFoundList_reverseSort
MainForm.btnShowSortedFoundList.doClick()
sender.Owner.Owner.close()
end
SortedFoundListMenuItem = mi
SortedFoundListListView = createListView(SortedFoundListForm)
SortedFoundListListView.Align = alClient
SortedFoundListListView.ViewStyle = vsReport
SortedFoundListListView.AutoSort = false
SortedFoundListListView.RowSelect = true
SortedFoundListListView.BorderSpacing.Around = 5
SortedFoundListListView.AutoWidthLastColumn = true
SortedFoundListProgressBar = createProgressBar(SortedFoundListForm)
SortedFoundListProgressBar.Align = alBottom
SortedFoundListProgressBar.Height = 10
SortedFoundListProgressBar.BorderSpacing.Around = 5
local addColumns = SortedFoundListListView.Columns.add
local addItems = SortedFoundListListView.Items.add
local addrCol = addColumns()
addrCol.Caption = "Address"
addrCol.Width = SortedFoundListListView.Canvas.getTextWidth(' DDDDDDDDDDDDDDDD ')
local valCol = addColumns()
valCol.Caption = "Value"
createNativeThread(doTheHeavyJob)
end
local function addBtnShowSortedFoundList()
local btn
if not MainForm.btnShowSortedFoundList then
addSortButtonAdded = true
btn = createButton(MainForm)
btn.Parent = MainForm.Panel5
btn.Name = 'btnShowSortedFoundList'
end
btn = MainForm.btnShowSortedFoundList
btn.Caption = 'Show Sorted'
btn.AutoSize = true
btn.AutoSize = false
btn.Height = MainForm.btnMemoryView.Height
btn.AnchorSideLeft.Control = MainForm.btnMemoryView
btn.AnchorSideLeft.Side = asrRight
btn.AnchorSideTop.Control = MainForm.btnMemoryView
btn.AnchorSideTop.Side = asrTop
btn.OnClick = function() showSortedFoundList() end
end
addBtnShowSortedFoundList()
|
PS:
looks like the most time consuming is this part:
Code: |
for i,v in ipairs(results) do
local item = addItems()
item.Caption = v.Address
item.SubItems.add(v.Value)
end |
_________________
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 457
Joined: 09 May 2003 Posts: 25262 Location: The netherlands
|
Posted: Sat Jan 18, 2020 2:50 am Post subject: |
|
|
try an OwnerData listview and use OnData to fill in the visible entries
also, i don't recommend adding entries to a gui object from a thread without the use of queue() or synchronize()
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
mgr.inz.Player I post too much Reputation: 218
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Sat Jan 18, 2020 5:08 am Post subject: |
|
|
Quote: | I don't recommend adding entries to a gui object from a thread without the use of queue() or synchronize() |
I'm using those:
SortedFoundListListView.beginUpdate()
...
SortedFoundListListView.endUpdate()
While SortedFoundListListView is in "update" state this shouldn't be a problem?
Anyway, yes, OwnerData ListView should work much better. I'll try it.
_________________
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 457
Joined: 09 May 2003 Posts: 25262 Location: The netherlands
|
Posted: Sat Jan 18, 2020 5:18 am Post subject: |
|
|
Don't forget that the foundlist object is not thread safe, so do not use the same foundlist that the ce gui uses for the list , that will break (CE tries to update the values while the thread is reading through it, the internal buffer then gets split up)
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
mgr.inz.Player I post too much Reputation: 218
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Sat Jan 18, 2020 5:39 am Post subject: |
|
|
Quote: | CE tries to update the values while the thread is reading through it, the internal buffer then gets split up |
So, it would be better to read GUIFoundList data with a bunch of readPointerLocal and readStringLocal?
(with getCEVersion() to set correct offsets)
_________________
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 457
Joined: 09 May 2003 Posts: 25262 Location: The netherlands
|
Posted: Sat Jan 18, 2020 5:43 am Post subject: |
|
|
No, you have to copy the results before you spawn a thread, because there are also other tools that access the foundlist, and creating a new foundlist overwrites the one designated in memscan
here's my version with some changes
Code: |
local SortedFoundListForm
local SortedFoundListListView
local SortedFoundListProgressBar
local SortedFoundListMenuItem
local results={}
local function doTheHeavyJob(thread, base)
thread.Name = 'SortedFoundListThread'
if #results>0 then
print("sorting results")
table.sort(results, function (a,b)
local aN,bN = tonumber(a.Value,base) or (-1/0),tonumber(b.Value,base) or (-1/0)
local aA,bA = tonumber(a.Address,16),tonumber(b.Address,16)
local res = aN==bN and aA<bA or aN<bN
if SortedFoundList_reverseSort then res = not res end
return res
end)
print("done sorting")
end
sortedlist=results
thread.synchronize(function()
SortedFoundListForm.Caption = 'Sorted FoundList'
SortedFoundListProgressBar.Position = 0
SortedFoundListMenuItem.Enabled = true
SortedFoundListListView.Items.Count=#sortedlist
SortedFoundListForm.OnClose = function (sender) return caFree end
MainForm.btnShowSortedFoundList.Enabled=true
end)
end
local function showSortedFoundList()
MainForm.btnShowSortedFoundList.Enabled=false
SortedFoundListForm = createForm(false)
SortedFoundListForm.OnClose = function (sender) return caNone end
SortedFoundListForm.BorderStyle = bsSizeable
SortedFoundListForm.Position = 'poWorkAreaCenter'
SortedFoundListForm.PopupMode = 'pmNone'
SortedFoundListForm.Caption = 'Sorted FoundList (wait)'
SortedFoundListForm.Width = (MainForm.Width * 0.75) // 1
SortedFoundListForm.Height = (MainForm.Height * 0.75) // 1
SortedFoundListForm.show()
local pm = createPopupMenu(SortedFoundListForm)
SortedFoundListForm.PopupMenu = pm
local mi = createMenuItem(pm)
pm.Items.add(mi)
mi.Caption = 'Reverse sort'
mi.Enabled = false
mi.OnClick = function (sender)
SortedFoundList_reverseSort = not SortedFoundList_reverseSort
MainForm.btnShowSortedFoundList.doClick()
sender.Owner.Owner.close()
end
SortedFoundListMenuItem = mi
SortedFoundListListView = createListView(SortedFoundListForm)
SortedFoundListListView.Align = alClient
SortedFoundListListView.ViewStyle = vsReport
SortedFoundListListView.AutoSort = false
SortedFoundListListView.RowSelect = true
SortedFoundListListView.BorderSpacing.Around = 5
SortedFoundListListView.HideSelection = false
SortedFoundListListView.AutoWidthLastColumn = true
SortedFoundListListView.OwnerData=true
SortedFoundListListView.OnData=function(sender, ListItem)
ListItem.Caption=sortedlist[ListItem.Index+1].Address
ListItem.SubItems.Add(sortedlist[ListItem.Index+1].Value)
end
SortedFoundListProgressBar = createProgressBar(SortedFoundListForm)
SortedFoundListProgressBar.Align = alBottom
SortedFoundListProgressBar.Height = 10
SortedFoundListProgressBar.BorderSpacing.Around = 5
local addColumns = SortedFoundListListView.Columns.add
local addItems = SortedFoundListListView.Items.add
local addrCol = addColumns()
addrCol.Caption = "Address"
addrCol.Width = SortedFoundListListView.Canvas.getTextWidth(' DDDDDDDDDDDDDDDD ')
local valCol = addColumns()
valCol.Caption = "Value"
local ms=getCurrentMemscan()
local fl=ms.FoundList
print("loading results")
results={}
for i = 0, fl.Count-1 do
results[1+#results] = {Address=fl.getAddress(i),Value=fl.getValue(i)}
if i%50000==0 then
processMessages()
end
end
createNativeThread(doTheHeavyJob, ms.isHexadecimal and 16 or nil)
end
local function addBtnShowSortedFoundList()
local btn
if not MainForm.btnShowSortedFoundList then
addSortButtonAdded = true
btn = createButton(MainForm)
btn.Parent = MainForm.Panel5
btn.Name = 'btnShowSortedFoundList'
end
btn = MainForm.btnShowSortedFoundList
btn.Caption = 'Show Sorted'
btn.AutoSize = true
btn.AutoSize = false
btn.Height = MainForm.btnMemoryView.Height
btn.AnchorSideLeft.Control = MainForm.btnMemoryView
btn.AnchorSideLeft.Side = asrRight
btn.AnchorSideTop.Control = MainForm.btnMemoryView
btn.AnchorSideTop.Side = asrTop
btn.OnClick = function() showSortedFoundList() end
end
addBtnShowSortedFoundList()
|
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping
Last edited by Dark Byte on Sat Jan 18, 2020 7:58 am; edited 3 times in total |
|
Back to top |
|
|
mgr.inz.Player I post too much Reputation: 218
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Sat Jan 18, 2020 5:48 am Post subject: |
|
|
Instead of copy, maybe parsing current "ADDRESSES.TMP" and "MEMORY.TMP" inside the thread would be better.
With disabling "new scan" "next scan" buttons, enabled after sorting is finished.
_________________
Last edited by mgr.inz.Player on Sat Jan 18, 2020 5:57 am; edited 3 times in total |
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 457
Joined: 09 May 2003 Posts: 25262 Location: The netherlands
|
Posted: Sat Jan 18, 2020 5:53 am Post subject: |
|
|
Perhaps, but it only takes 1 second to copy 400000 results(on a 3.2GHz cpu), so it's not that slow
and perhaps every 50000 results do processMessages call
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping
Last edited by Dark Byte on Sat Jan 18, 2020 5:56 am; edited 1 time in total |
|
Back to top |
|
|
mgr.inz.Player I post too much Reputation: 218
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Sat Jan 18, 2020 5:56 am Post subject: |
|
|
There can be a problem that CE is still writing to those files. Can we safely call getCurrentMemscan().waitTillDone() inside "Lua" thread?
_________________
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 457
Joined: 09 May 2003 Posts: 25262 Location: The netherlands
|
Posted: Sat Jan 18, 2020 5:56 am Post subject: |
|
|
yes, that is fine
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
mgr.inz.Player I post too much Reputation: 218
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Sat Jan 18, 2020 6:06 am Post subject: |
|
|
Dark Byte wrote: | yes, that is fine |
OK. Thank you.
_________________
|
|
Back to top |
|
|
Csimbi I post too much Reputation: 92
Joined: 14 Jul 2007 Posts: 3102
|
Posted: Sat Jan 18, 2020 7:51 am Post subject: |
|
|
So, which version you recommend? I am leaning towards DB's.
|
|
Back to top |
|
|
mgr.inz.Player I post too much Reputation: 218
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Sat Jan 18, 2020 10:27 am Post subject: |
|
|
For now, use DB's. I didn't know that GUI_FoundList methods: getAddress() and getValue(), are not thread safe.
After opening the window, you can rightclick to get reversed order.
EDIT:
updated more polished script:
Code: | local function showSortedFoundList()
local form = createForm(false)
form.OnClose = function (sender) return caNone end
form.BorderStyle = bsSizeable
form.Position = 'poWorkAreaCenter'
form.PopupMode = 'pmNone'
form.Caption = 'Sorted FoundList (wait)'
form.Width = (MainForm.Width * 0.75) // 1
form.Height = (MainForm.Height * 0.75) // 1
form.show()
_reverseSort = false
local ListView = createListView(form)
ListView.Align = alClient
ListView.ViewStyle = vsReport
ListView.AutoSort = false
ListView.RowSelect = true
ListView.BorderSpacing.Around = 5
ListView.HideSelection = false
ListView.AutoWidthLastColumn = true
ListView.OwnerData=true
local results = {}
ListView.OnData=function (sender, ListItem)
if not _reverseSort then
ListItem.Caption=results[ListItem.Index+1].Address
ListItem.SubItems.Add(results[ListItem.Index+1].Value)
else
ListItem.Caption=results[#results - ListItem.Index].Address
ListItem.SubItems.Add(results[#results - ListItem.Index].Value)
end
end
local pm = createPopupMenu(form)
form.PopupMenu = pm
local MenuItem = createMenuItem(pm)
pm.Items.add(MenuItem)
MenuItem.Caption = 'Reverse sort'
MenuItem.OnClick = function (sender)
_reverseSort = not _reverseSort
if _reverseSort then form.Caption = 'Sorted FoundList (reversed)'
else form.Caption = 'Sorted FoundList' end
ListView.repaint()
end
local function formOnClose(sender)
ListView.OnData = nil -- so garbage collector can free it
collectgarbage'collect'
return caFree
end
ProgressBar = createProgressBar(form)
ProgressBar.Align = alBottom
ProgressBar.Height = 10
ProgressBar.BorderSpacing.Around = 5
local addColumns = ListView.Columns.add
local addItems = ListView.Items.add
local addrCol = addColumns()
addrCol.Caption = "Address"
addrCol.Width = ListView.Canvas.getTextWidth(' DDDDDDDDDDDDDDDD ')
local valCol = addColumns()
valCol.Caption = "Value"
local ms=getCurrentMemscan()
local fl=ms.FoundList
local base = ms.isHexadecimal and 16 or nil
local function doTheHeavyJob(thread)
thread.Name = 'SortedFoundListThread'
if #results>0 then
table.sort(results, function (a,b)
local aN,bN = tonumber(a.Value,base) or (-1/0),tonumber(b.Value,base) or (-1/0)
local aA,bA = tonumber(a.Address,16),tonumber(b.Address,16)
local res = aN==bN and aA<bA or aN<bN
return res
end)
end
thread.synchronize(function()
form.Caption = 'Sorted FoundList'
ProgressBar.Position = 0
MenuItem.Enabled = true
MainForm.btnNewScan.Enabled = true
MainForm.btnNextScan.Enabled = true
ListView.Items.Count=#results
form.OnClose = formOnClose
form.Width = form.Width + 1
end)
end
ProgressBar.Max = fl.Count - 1
MenuItem.Enabled = false
MainForm.btnNewScan.Enabled = false
MainForm.btnNextScan.Enabled = false
for i = 0, fl.Count-1 do
results[1+#results] = {Address=fl.getAddress(i),Value=fl.getValue(i)}
if i%1000==0 then
ProgressBar.Position = i
processMessages()
end
end
form.Caption = 'Sorted FoundList (almost there)'
createNativeThread(doTheHeavyJob)
end
local function addBtnShowSortedFoundList()
local btn
if not MainForm.btnShowSortedFoundList then
btn = createButton(MainForm)
btn.Parent = MainForm.Panel5
btn.Name = 'btnShowSortedFoundList'
end
btn = MainForm.btnShowSortedFoundList
btn.Caption = 'Show Sorted'
btn.AutoSize = true
btn.AutoSize = false
btn.Height = MainForm.btnMemoryView.Height
btn.AnchorSideLeft.Control = MainForm.btnMemoryView
btn.AnchorSideLeft.Side = asrRight
btn.AnchorSideTop.Control = MainForm.btnMemoryView
btn.AnchorSideTop.Side = asrTop
btn.OnClick = function() showSortedFoundList() end
end
addBtnShowSortedFoundList()
|
_________________
|
|
Back to top |
|
|
DrackenDarck Newbie cheater Reputation: 0
Joined: 23 Aug 2019 Posts: 14
|
|
Back to top |
|
|
Csimbi I post too much Reputation: 92
Joined: 14 Jul 2007 Posts: 3102
|
Posted: Mon Jan 20, 2020 10:40 am Post subject: |
|
|
DrackenDarck wrote: | when I got maybe 500+ results and I didnt wanted to filter again and again. |
I have never really needed that. And I use CE a lot.
Sorry to say, but you really need to do the legwork...
500+ results are way too much.
You should have <50.
There's a range, a 'not' search, you can even specify memory range to bring that 500+ down to 50.
|
|
Back to top |
|
|
|