Is it possible for a program to detect that another is directly reading its memory (using for example ReadProcessMemory)?

Solution 1:

No.

The problem here is that this "readme" file, was created with the idea to distribute "A". And after "A" was distributed around long enough, "B" became aware that "A" exists, so it started looking specifically for "A".

IF "B" is not aware that "A" exist, It will have very hard time to detect "A", even harder time to distinguish it from "C","D","E" and "F", and it will be nearly impossible to understand what "A" is doing and take actions based on this.

Technically "A" can operate on many other levels, and read "B" memory by many other ways, than simple API call.

If anything, "A" can freeze "B", read what feels interesting, and just kill "B" after, preventing "B" from taking any actions. (This is why "B" is usually guarded by "X", "Y" and "Z", running at the same time)

"B" can make it harder for "A", but there is NOTHING it can do to stop or detect it, considering the same amount of effort is put into both of them.