Working with DMA - PCIe Screamer

04/07/2021 17:07 AcTiViSioN911#1
Hi guys. I have a PCIe Screamer and I am writing a program like Cheat Engine. So far I have implemented search and filtering, but already ran into some questions. I tried to google and figure it out myself, but it didn't give much results. I hope someone can give me a hint and help with a solution.
For example, I took the Terraria game, found a 4 byte number and then repeated it in my program. It took a lot longer, since I either searched all over my memory, or grabbed a lot of unnecessary things, I don't really know. Now in more detail:
I am using MemProcFS with Dokany. I find the game at "M:\name\Terraria.exe-*", there is a 256 TB memory.vmem file. There is a pte.txt file in the memmap folder where the address ranges are listed and I go through each one. Here is the content of this file:
Code:
   #    PID    Pages      Range Start-End              FLAGS   Description                                                     
--------------------------------------------------------------------------                                                     
0000   8564        1 00000000001c0000-00000000001c0fff -r-- 32 Terraria.exe
0001   8564        1 00000000001c2000-00000000001c2fff -r-- 32 Terraria.exe
***
0017   8564        1 00000000013c0000-00000000013c0fff -r--
0018   8564        8 00000000013e0000-00000000013e7fff -rw-
***                                                                
006c   8564        1 0000000003870000-0000000003870fff -r-- 32 _DATA-0x3870000.dll
006d   8564        5 0000000003872000-0000000003876fff -r-- 32 _DATA-0x3870000.dll
etc...
[Only registered and activated users can see links. Click Here To Register...]

I noticed that I can skip lines containing .dll in the Description as they are clearly not related to game memory. However, this is still a lot. For example, a Cheat Engine search for a 4 byte took 1 second and found 884 addresses, ranging from 01A79AD4 to 5923B7BC. My program scanned for 24 seconds (I admit that my methods are not as perfect as those of CE + I use only one thread), but I found 1408 addresses with a range from 001E72A3 to 76555294.
And here my first question is, how does CE find the beginning and end of the memory related to the game, or how does the CE skip everything unnecessary? Probably need to skip 1-2 page / -r-- / -rw- / -rwx ranges, but I'm not sure about that, and I don't want to accidentally skip the addresses I need.
Then I would like to know how to search for pointers to addresses in order to find the correct address after a restart. I think this is also related to my first question. I know how to do this in CE, but have not yet figured out how to implement it myself.
Perhaps someone has already asked similar questions somewhere on the forum, and I would be very grateful for a tip, or at least a hint where to look. I'm not as advanced as the guys on this forum, but I want to learn.
PS: not for sale, purely for my own use.
04/09/2021 03:29 elmarcia#2
Quote:
Originally Posted by AcTiViSioN911 View Post
Hi guys. I have a PCIe Screamer and I am writing a program like Cheat Engine. So far I have implemented search and filtering, but already ran into some questions. I tried to google and figure it out myself, but it didn't give much results. I hope someone can give me a hint and help with a solution.
For example, I took the Terraria game, found a 4 byte number and then repeated it in my program. It took a lot longer, since I either searched all over my memory, or grabbed a lot of unnecessary things, I don't really know. Now in more detail:
I am using MemProcFS with Dokany. I find the game at "M:\name\Terraria.exe-*", there is a 256 TB memory.vmem file. There is a pte.txt file in the memmap folder where the address ranges are listed and I go through each one. Here is the content of this file:
Code:
   #    PID    Pages      Range Start-End              FLAGS   Description                                                     
--------------------------------------------------------------------------                                                     
0000   8564        1 00000000001c0000-00000000001c0fff -r-- 32 Terraria.exe
0001   8564        1 00000000001c2000-00000000001c2fff -r-- 32 Terraria.exe
***
0017   8564        1 00000000013c0000-00000000013c0fff -r--
0018   8564        8 00000000013e0000-00000000013e7fff -rw-
***                                                                
006c   8564        1 0000000003870000-0000000003870fff -r-- 32 _DATA-0x3870000.dll
006d   8564        5 0000000003872000-0000000003876fff -r-- 32 _DATA-0x3870000.dll
etc...
[Only registered and activated users can see links. Click Here To Register...]

I noticed that I can skip lines containing .dll in the Description as they are clearly not related to game memory. However, this is still a lot. For example, a Cheat Engine search for a 4 byte took 1 second and found 884 addresses, ranging from 01A79AD4 to 5923B7BC. My program scanned for 24 seconds (I admit that my methods are not as perfect as those of CE + I use only one thread), but I found 1408 addresses with a range from 001E72A3 to 76555294.
And here my first question is, how does CE find the beginning and end of the memory related to the game, or how does the CE skip everything unnecessary? Probably need to skip 1-2 page / -r-- / -rw- / -rwx ranges, but I'm not sure about that, and I don't want to accidentally skip the addresses I need.
Then I would like to know how to search for pointers to addresses in order to find the correct address after a restart. I think this is also related to my first question. I know how to do this in CE, but have not yet figured out how to implement it myself.
Perhaps someone has already asked similar questions somewhere on the forum, and I would be very grateful for a tip, or at least a hint where to look. I'm not as advanced as the guys on this forum, but I want to learn.
PS: not for sale, purely for my own use.
Cheat engine filter writable/readable memory regions to speed up the process and use multithreading for scans so its even faster.

Here is the logic it follows:

1) Query Mem regions and filter valid ones (store in a struct (baseAddress, size))
For each valid region increment totalMemorySize
2) Obtain scan block size (totalMemorySize / threadCount), last block will be a bit longer, so don't forget to append rest.
3) Make scan threads structs
3.a) Read process memory is super slow so don't call it on a loop for reading lets say (4 bytes), call it to read a fixed buffer size, (CE uses 1024*4 buffer size for dword scans i think) then perform your "mini scan" in that buffer.
3.b) Make scan functions that works for you, when searching for aligned memory you will skip a lot but scan speed is increased.
4) Start and wait for scan threads to end.


1)

2)

3)

3.a)
3.b)

4)

You can look at CE code its a bit messy but better than nothing
[Only registered and activated users can see links. Click Here To Register...]
04/09/2021 07:32 AcTiViSioN911#3
Quote:
Originally Posted by elmarcia View Post
Cheat engine filter writable/readable memory regions to speed up the process and use multithreading for scans so its even faster.
Thanks a lot for the tips, I really have a lot to change. Apart from optimization, I'm stuck on the question of pointers and offsets. In the example of the game Terraria, I searched for a static address using CE, but I never found it. Instead, I found something similar, with the start of [Only registered and activated users can see links. Click Here To Register...] + 6 offsets to the address I needed. This THREADSTACK0 is constantly changing (only CE can work with it) and I have no idea how to find it. It looks like I'm missing something, but I reviewed many CE guides and did not find an explanation of what to do if a static address such as Terraria.exe + ** cannot be found. Perhaps this game is more complicated than the one used in the examples and where in 2 scans it was possible to find a static address ... I cannot use debuggers or any other programs, only the functionality that pcileech + memprocfs gives. I heard that it is possible to use WinDBG, but only a small amount of functionality without breakpoints, and I'm not sure if that will help me with anything. Also, I don't quite understand how to find offsets, because as I understand it, CE uses debugger with breakpoints, but I can't. So far, I manually find the addresses I need and try to identify a pattern by which I can repeat the search like a sequence of bytes before the start of the part I need), but I think this is not the best method. If you have any ideas, please share with me.
04/12/2021 16:25 AcTiViSioN911#4
I am almost satisfied with the performance of the program, and most likely this is the maximum DMA speed. The question of finding pointers and offsets is still open...

[Only registered and activated users can see links. Click Here To Register...]
03/26/2022 04:47 iflores#5
Why not just use Cheat Engine with PCILeech directly? There's no need to write a new Cheat Engine. [Only registered and activated users can see links. Click Here To Register...]
02/20/2023 05:00 miserymodz#6
sorry to bump this threat. the pcileech is down and just wondering if you ever made what you were working on or what
01/10/2024 10:10 StrawGuy#7
Quote:
Originally Posted by miserymodz View Post
sorry to bump this threat. the pcileech is down and just wondering if you ever made what you were working on or what
I'm exactly on the same boat as you. So far I've found these;
[Only registered and activated users can see links. Click Here To Register...]
[Only registered and activated users can see links. Click Here To Register...]

They both "work" for me. But the speed of searching a value is below par even though my DMA speed is over 180MB/s
02/06/2024 22:31 ltMorlock#8
Quote:
Originally Posted by StrawGuy View Post
I'm exactly on the same boat as you. So far I've found these;
[Only registered and activated users can see links. Click Here To Register...]
[Only registered and activated users can see links. Click Here To Register...]

They both "work" for me. But the speed of searching a value is below par even though my DMA speed is over 180MB/s
Hey maybe you can help me ?
i installed server from the Rep. and copied pcileech.dll in the folder. When i want to start server with connectet PCISquirrell card i get an error:
[22:27:10.591] ServerMain: Initializing PCILeech...
java.lang.RuntimeException: Unable to initialize PCILeech.
at iflores.ceserver.pcileech.ServerMain.main(ServerMa in.java:71)
*** Server died with exit code -1
Mayber you can help me?

Quote:
Originally Posted by AcTiViSioN911 View Post
I am almost satisfied with the performance of the program, and most likely this is the maximum DMA speed. The question of finding pointers and offsets is still open...

[Only registered and activated users can see links. Click Here To Register...]
Awesome... did you plan a release for this?