So don't ask me how, but I found something amazing, after wasting my time clicking everywhere without knowing why.
I searched the source code of the PB editor and the entire forum, and nothing
DOBRO once asked the same question, and FRED's answer was that the protocol wasn't public.
viewtopic.php?t=56610&hilit=Communication
But me...I found a way to read its contents without upsetting FRED.
i want to thanks a lot INFRATEC+NICO+AI for help me in this galley
I think everyone probably knows what I found by chance, but I'm amazed by my discovery.
I was trying to ask the debugger to give me its variables, but when I talked to the AI, he told me I wasn't looking in the right place, that the debugger had finished its work, it had created a modified executable with a ton of stuff in it

, and that it was the keyholder (well, not exactly his exact words

).
So I tackled this famous executable and discovered this.
Create a folder everywhere, and put this 2 codes inside, like this only this 2 files is here, to avoid another "PureBasic_Compilation0.exe"
Obviously your PB must be set for creating the temporary executable beside of the "source.pb"
Run this code first
Code: Select all
Global NewMap MapKccExample()
MapKccExample("MAP KCC 1") = 0
MapKccExample("MAP KCC 2") = 0
MapKccExample("MAP KCC 3") = 0
MapKccExample("MAP KCC 4") = 0
MapKccExample("MAP KCC 5") = 0
MapKccExample("MAP KCC 6") = 0
MapKccExample("MAP KCC 7") = 0
a$ = "VARIABLE KCC 1"
b$ = "VARIABLE KCC 2"
Dim ArrayOfKcc.s(2)
ArrayOfKcc(1) = "Element of KCC array 1"
ArrayOfKcc(2) = "Element of KCC array 2"
IdFenetre = OpenWindow(#PB_Any, x, y, 800, 400, "Try to read my variables", #PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_ScreenCentered)
Repeat
Evenement = WaitWindowEvent()
EvenementGadget = EventGadget()
EvenementType = EventType()
If Evenement = #PB_Event_Gadget
EndIf
Until Evenement = #PB_Event_CloseWindow
A "PureBasic_Compilation0.exe" have be created in the folder
Secondly run this code
Code: Select all
Structure RunProgramExtendedStructure
ProgramID.i
WindowHandle.i
EndStructure
Debug "=============================================="
Debug " PureBasic Console Debugger"
Debug "=============================================="
Debug ""
Debug "Type 'help' for command options."
Debug "DEBUGGER:: help"
Debug "Type 'help <command>' for more detailed help."
Debug ""
Debug "arrayshow print parts of arrays"
Debug "mapshow print parts of maps"
Debug "arrays print all array names"
Debug "memory print a memory dump"
Debug "breakclear remove all breakpoints"
Debug "memoryraw output raw memory"
Debug "breakpoints list all breakpoints"
Debug "saveconfig saves debugger settings"
Debug "breakremove remove a breakpoint"
Debug "set set a variable value"
Debug "breakset set a breakpoint"
Debug "shell open a command shell"
Debug "databreak set a data breakpoint"
Debug "show show Array, List Or Map"
Debug "dec decimal output"
Debug "stack print a stack trace"
Debug "debug print variable value"
Debug "step execute one code step"
Debug "exit end the program"
Debug "redirect redirect debugger output"
Debug "errors set error action"
Debug "report print a detailed report"
Debug "file redirect console command"
Debug "registers print processor registers"
Debug "files list included sources"
Debug "registerset set a register value"
Debug "help print available commands"
Debug "run continue the program"
Debug "hex hexadecimal output"
Debug "variables print variables"
Debug "history print procedure history"
Debug "warnings set warning action"
Debug "line print current line & file"
Debug "linkedlists print all linkedlist names"
Debug "listshow print parts of linkedlists"
Debug "maps print all map names" + #CRLF$ + #CRLF$
Procedure SendCommand(Command.s)
hwndConsole = FindWindow_(0,"PureBasic Console Debugger (press Ctrl+C to stop program)")
For i = 1 To Len(Command)
Carac$ = Mid(Command, i,1)
SendMessage_(hwndConsole, #WM_CHAR, Asc(Carac$), 0)
Delay(10)
Next
Delay(10)
SendMessage_(hwndConsole, #WM_CHAR, 13, 0)
SendMessage_(hwndConsole, #WM_CHAR, 10, 0)
EndProcedure
Procedure Command(*Value)
MessageRequester("Read variables", "Ask for the array")
SendCommand("arrayshow ArrayOfKcc")
MessageRequester("Read variables", "Ask for the MAP")
SendCommand("arrayshow ArrayOfKcc")
MessageRequester("Read variables", "Ask for the variable a$")
SendCommand("debug a$")
Repeat
Command$ = InputRequester("Talk to runtime", "What you want to know ?", "")
SendCommand(Command$)
ForEver
EndProcedure
Procedure.i EnumWindowsCallBack(hwnd.i, param.l)
Protected Result.i, PID.l, Length.i, *RunProgramExtended.RunProgramExtendedStructure
Result = #True
*RunProgramExtended = param
If GetWindowThreadProcessId_(hwnd, @PID)
If PID = *RunProgramExtended\ProgramID
*RunProgramExtended\WindowHandle = hwnd
Result = #False
EndIf
EndIf
ProcedureReturn Result
EndProcedure
Define Compiler.i, *Buffer, Length.i, Title$, NewTitle$
Define RunProgramExtended.RunProgramExtendedStructure
Compiler = RunProgram("PureBasic_Compilation0.exe", "", GetPathPart(ProgramFilename()), #PB_Program_Open|#PB_Program_Read)
Delay(300)
If Compiler
CreateThread(@Command(), 0)
*Buffer = AllocateMemory(1000, #PB_Memory_NoClear)
If *Buffer
hwndConsole = FindWindow_(0,"PureBasic Console Debugger (press Ctrl+C to stop program)")
SetForegroundWindow_(hwndConsole)
#INPUT_KEYBOARD = 1
#KEYEVENTF_KEYUP = 2
#VK_CONTROL = $11
#VK_C = $43
Dim IN.INPUT(3)
in(0)\type = #INPUT_KEYBOARD : in(0)\ki\wVk = #VK_CONTROL
in(1)\type = #INPUT_KEYBOARD : in(1)\ki\wVk = #VK_C
in(2)\type = #INPUT_KEYBOARD : in(2)\ki\wVk = #VK_C : in(2)\ki\dwFlags = #KEYEVENTF_KEYUP
in(3)\type = #INPUT_KEYBOARD : in(3)\ki\wVk = #VK_CONTROL : in(3)\ki\dwFlags = #KEYEVENTF_KEYUP
SendInput_(4, @in(0), SizeOf(INPUT))
RunProgramExtended\ProgramID = ProgramID(Compiler)
Delay(500)
While ProgramRunning(Compiler)
If RunProgramExtended\WindowHandle = 0
EnumWindows_(@EnumWindowsCallBack(), @RunProgramExtended)
Else
Length = GetWindowText_(RunProgramExtended\WindowHandle, *Buffer, 1000)
If Length
NewTitle$ = PeekS(*Buffer, Length)
If Title$ <> NewTitle$
Title$ = NewTitle$
Debug "Title: " + Title$
EndIf
EndIf
EndIf
Length = AvailableProgramOutput(Compiler)
If Length
If ReadProgramData(Compiler,*Buffer, Length)
Debug PeekS(*Buffer, Length, #PB_UTF8|#PB_ByteLength) + #CRLF$
EndIf
EndIf
Wend
FreeMemory(*Buffer)
EndIf
CloseProgram(Compiler) ; Close the connection to the program
EndIf
At the begining three msgbox ask for reading MAP/Array/a$ in the RUNTIME "MyProgram.exe"
But after you can enter all the commands that FRED have created
ATTENTION !!!, like it's KCC the creator, this code is really buggy (It's KCC quality

)
But it's mainly for show the method
Then if a MASTER, want help me to improve it, he is WELCOME
It just goes to show, even donkeys can find amazing things with Purebasic.
That's what we call the ...
"FRED" effect. 