I search to create an EXE with a section who i can write everything in it (Parameters, data, etc...)
For have only one file to send at a client
A little bit like the MDB of ACCESS...but i'm not BG
I search in my head, and think it's perhaps possible to add this data at the end of the EXE without disturb the EXE.
Apparently that works
So i need your advice for know if i have not created a monster and if my solution is safe
1/ Create the "AddingDatas.exe" with the code
2/ Run "AddingDatas.exe" (Your EXE is empty, without DataSection, so the EditorGadget is empty too)
3/ Click on the several msgbox saying the different step of the writing data
4/ The program end alone (Now the data is writing)
5/ Run another time "AddingDatas.exe" this time you see the data in EditorGadget
The data is writing just one time, after the exe just read each time the data
Code: Select all
Procedure.s ReadDatas()
Define Caractere.s = Space(1)
Pos = 0
*Mem = AllocateMemory(6)
If ReadFile(1, "AddingDatas.exe")
Repeat
ReadData(1, @Caractere, 1)
If Caractere = "["
FileSeek(1, Loc(1) - 1)
ReadData(1, *Mem, 6)
If PeekC(*Mem) = 91 And PeekC(*Mem + 1) = 68 And PeekC(*Mem + 2) = 68 And PeekC(*Mem + 3) = 83 And PeekC(*Mem + 4) = 80 And PeekC(*Mem + 5) = 93
Pos = Loc(1)
MessageRequester("", "Found DataSection !")
Break
EndIf
EndIf
Until Eof(1) Or Pos
*MemData = AllocateMemory(Lof(1) - Pos)
ReadData(1, *MemData, Lof(1) - Pos - 6)
CloseFile(1)
ProcedureReturn PeekS(*MemData)
Else
MessageRequester("AddingDatas", "Can't open EXE !")
EndIf
EndProcedure
Dim ArrayDatas.s(3)
If FileSize("Temp.exe") <> -1
DeleteFile("Temp.exe")
EndIf
OpenWindow(0, 100, 100, 800, 300, "")
EditorGadget(0, 5, 5, 790, 290)
Texte$ = ReadDatas()
SetGadgetText(0, Texte$)
If Trim(Texte$) = ""
If Not RenameFile("AddingDatas.exe", "Temp.exe")
MessageRequester("AddingDatas", "Rename not works !")
Else
MessageRequester("AddingDatas", "Rename works !")
EndIf
Delay(500)
If Not CopyFile("Temp.exe", "AddingDatas.exe")
MessageRequester("AddingDatas", "Copy not works !")
Else
MessageRequester("AddingDatas", "Copy works !")
EndIf
ArrayDatas(1) = "PureBasic is a native 32 bit and 64 bit programming language based on established BASIC rules. The key features of PureBasic are portability (Windows, Linux, MacOS X and AmigaOS are currently supported), the production of very fast and highly optimized executables and, of course, the very simple BASIC syntax. PureBasic has been created for the beginner and expert alike. We have put a lot of effort into its realization to produce a fast, reliable system friendly language." + #CRLF$
ArrayDatas(2) = "In spite of its beginner-friendly syntax, the possibilities are endless with PureBasic's advanced features such as pointers, structures, procedures, dynamically linked lists and much more. Experienced coders will have no problem gaining access to any of the legal OS structures or API objects and PureBasic even allows inline ASM."+ #CRLF$
ArrayDatas(3) = "Yes. All has been optimized To give maximum speed And compactness To the programs created With PureBasic. The execution speed match almost any professional compiler like Visual C++ And the executable size is smaller, without the need For any runtime (small programmes are typically between 5 kb And 10 kb)."
SizeOfDatas = Len(ArrayDatas(1)) + Len(ArrayDatas(2)) + Len(ArrayDatas(3))
*Mem = AllocateMemory(SizeOfDatas)
Tag$ = "{DDSP}"
Temp$ = ReplaceString(ReplaceString(Tag$, "}", "]"), "{", "[") ; [DDSP] DebutDataSectionPatchable
For i = 1 To ArraySize(ArrayDatas())
Temp$ + ArrayDatas(i)
Next
Temp$ + ReplaceString(Tag$, "[", "[/") ; [/DDSP] FinDataSectionPatchable
If OpenFile(0, "AddingDatas.exe")
FileSeek(0, Lof(0))
WriteData(0, @Temp$, Len(Temp$))
MessageRequester("", "Write DATA !")
CloseFile(0)
End
Else
MessageRequester("AddingDatas", "Can't open EXE !")
EndIf
EndIf
Repeat
Evenement = WaitWindowEvent()
Until Evenement = #PB_Event_CloseWindow
End




