I believe it's impossible, but i prefer put when even this question for be sure i have good understand the behaviour of memory
Each EXE have his personal space memory, so an EXE can't read a structure of another application..it's that ???
It's possible! Reading and writing to another process is definitely possible. But not the way you tried it, though.
You need to use the special API functions ReadProcessMemory and WriteProcessMemory (in case you want to write).
Outside of of MSIL, MSVRT, MSVCRT PEs it's as simple as some structs and endian sorting. Also resource and reloc structures have to be handled.
PE, even fully documented, is extremely time consuming to work with, this is why software protections are a easy market once you have a stable product. You can do updates every few months and still keep clients..
Just use the existing structs and build from there, the relocation and resource sections are also documented.
EDIT: Also at runtime you have to handle stack frames and heap allocations which are surprisingly simple thanks to API..
If a structure includes a string field, then reading the string is somewhat complicated.
And if both Program.exe and TestProgram.pb are not the same compilation(both ascii or both unicode), it cannot read the string properly.
See the code below.
Structure Kcc
a.l
b.s
EndStructure
Global Variable.Kcc
hProcess = RunProgram("Program.exe", "", "", #PB_Program_Hide|#PB_Program_Open|#PB_Program_Read)
ProcessID=ProgramID(hProcess)
ProcessHandle = OpenProcess_(#PROCESS_ALL_ACCESS, #False, ProcessID)
Delay(100)
Sortie$ = ""
If hProcess
While ProgramRunning(hProcess)
If AvailableProgramOutput(hProcess)
Sortie$ + ReadProgramString(hProcess) + Chr(13)
Else
Break
EndIf
Debug "Adresse of pointer return by the EXE : " + Sortie$
Wend
*PointeurTablo = Val(Sortie$)
;get the long type value of the structure.
ReadProcessMemory_(ProcessHandle, *PointeurTablo, @Variable\a, SizeOf(Long), @NbBit)
;get the real string address.
ReadProcessMemory_(ProcessHandle, *PointeurTablo + SizeOf(Long), @*String, SizeOf(Integer), @NbBit)
;get the string.
If *String
tmp$ = ""
;read the characters one by one.
For i = 0 To 1024 Step SizeOf(Character)
ReadProcessMemory_(ProcessHandle, *String + i, @Char, SizeOf(Character), @NbBit)
If Char ;if not null
tmp$ + Chr(Char)
Else
Variable\b = tmp$
Break
EndIf
Next
EndIf
Debug "Number of bit received : " + Str(NbBit)
Debug "Size of structure KCC :" + Str(SizeOf(Kcc))
Debug Variable\a
Debug Variable\b
CloseHandle_(ProcessHandle)
KillProgram(hProcess)
CloseProgram(hProcess)
EndIf
Adresse of pointer return by the EXE : 4211448
Number of bit received : 24
Size of structure KCC :24
123456
¨
So thanks to have try to help me
@breeze4me Wouuuaaahh !!! great !!!
You are my saver...that works perfectly
I was not ready to find myself
It's very precious code
Thanks a lot for your precious help