Home > Software engineering >  Vb traversal memory slowly what method (read repeatedly with ReadProcessMemory memory)
Vb traversal memory slowly what method (read repeatedly with ReadProcessMemory memory)

Time:10-29

The "1" in the search for a laptop from & amp; H000000 to & amp; HFFFFFF similar CE search

IhWnd=FindWindow (vbNullString, "1 - notepad")
GetWindowThreadProcessId ihWnd, the iPid
HProcess=OpenProcess (PROCESS_ALL_ACCESS, False, the iPid)
For I="& amp; H "& amp; 0000000 To "& amp; H "& amp; FFFFFF
ReadProcessMemory hProcess, I, ByVal adrValue, 10, 0 & amp;
Next


But vb notepad "1" takes a few minutes in
The ce memory viewer from & amp; H000000 to & amp; HFFFFFF only about 0.5 seconds

CodePudding user response:

One-time all read in an array, and then loop through,

You are so consumes a lot of function call overhead,

CodePudding user response:

reference 1st floor caozhy response:
disposable all read into the array, then loop through,

You are so consumes a lot of function call overhead,

Yes, you repeat the For loop invokes the ReadProcessMemory hProcess is time,

CodePudding user response:

Sweat, this how quickly and VB have what relation, just you read memory algorithm problem, you pass a ReadProcessMemory, read once a N megabytes to array is more appropriate,

CodePudding user response:

A) into A block read
B) by KMP algorithm to search

CodePudding user response:

For example????????

CodePudding user response:

.
For I="& amp; H "& amp; 0000000 To "& amp; H "& amp; FFFFFF
ReadProcessMemory hProcess, I, ByVal adrValue, 10, 0 & amp;
Next

A program memory, 100% of all cases there will not be I="& amp; H "& amp; 0000000 To "& amp; H "& amp; FFFFFF
This address range is occupied

Program memory, are realized with the concept of heap

Can understand into a tree control structure

Process is the top node, the secondary node is all memory heap
Different memory storage data have different meaning, some are stored code, some is to save resources and some is to save the user data

So,,,
You should find some task manager code, all of the memory heap to the enumeration process analysis the significance of each pile
To find the corresponding data may be stored memory range to search again, a smaller range, speed up naturally, don't superstitious so-called first algorithm
  • Related