Page 1 of 1

EXE with parameters embeded [Resolved]

Posted: Wed May 23, 2012 4:56 pm
by Kwai chang caine
Hello at all :D

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 :oops:

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 :shock:

So i need your advice for know if i have not created a monster and if my solution is safe :oops:

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 :D

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
Have a good day

Re: EXE with paramters embeded

Posted: Wed May 23, 2012 5:03 pm
by Foz
Although the method is safe, it may be flagged up as a potential virus by virus scanners, as that's what a lot of viruses do - rewrite themselves.

For yourself, it shouldn't be any trouble, for the users? Tread lightly.

Re: EXE with parameters embeded

Posted: Wed May 23, 2012 5:08 pm
by Kwai chang caine
FOZ you are more rapid than FlashGordon :shock:

Image

I have not ending to posing the question...i have already the answer :lol:
it may be flagged up as a potential virus by virus scanners
I don't know again how create a good program...but i found how create a virus ..if it's not the reverse world :oops: :lol: :lol:

Thanks to your advice i do care, and try if the antivirus detect it.
Perhaps no, if the parameters is only ascii text ????

Thanks a lot FOZ and have a good day

Re: EXE with parameters embeded

Posted: Wed May 23, 2012 5:14 pm
by Kwai chang caine
For the moment i have testing my exe and Norton is not hangry :mrgreen:

Re: EXE with parameters embeded

Posted: Wed May 23, 2012 5:19 pm
by Kwai chang caine
Testing on the site VirusTotal
This is encouraging, only one say i'm a bad boy :mrgreen:

AhnLab-V3
AntiVir
Antiy-AVL
Avast
AVG
BitDefender
ByteHero
CAT-QuickHeal
ClamAV
Commtouch
Comodo
DrWeb
Emsisoft
eSafe
F-Prot
F-Secure
Fortinet
GData
Ikarus
Jiangmin
K7AntiVirus
Kaspersky
McAfee
McAfee-GW-Edition
Microsoft
NOD32
Norman
nProtect
Panda
PCTools
Rising Suspicious
Sophos
SUPERAntiSpyware
Symantec
TheHacker
TotalDefense
TrendMicro
TrendMicro-HouseCall
VBA32
VIPRE
ViRobot
VirusBuster

Again thanks for your precious advice 8)

Re: EXE with parameters embeded

Posted: Wed May 23, 2012 11:22 pm
by Foz
There is of course one more potential issue - if your program is installed to "Program Files", if you are not running as the administrator, then you cannot write/change files in there - including itself (an issue more prevalent since Vista).

Google have gotten around this by installing in the users home directory "\Local Settings\Application Data\" and that way the silent updater can stay absolutely silent and not worry the user.

You may want to take a leaf out of Googles book :)

Re: EXE with parameters embeded

Posted: Thu May 24, 2012 8:23 am
by Kwai chang caine
The protection are more and more annoying...
One day will come when protections are more annoying than viruses :?
A little bit like the key and the lock :lol:

Re: EXE with parameters embeded [Resolved]

Posted: Thu May 24, 2012 9:29 am
by Foz
Someone who is willing to trade their freedom for temporary security deserve neither and will lose both

Re: EXE with parameters embeded [Resolved]

Posted: Thu May 24, 2012 9:33 am
by GeBonet
Eric, Perfect, but we must not forget to compile without Unicode flag ... 8)

Re: EXE with parameters embeded [Resolved]

Posted: Thu May 24, 2012 9:51 am
by Kwai chang caine
Perfect
Thanks a lot :wink:
But Perfect is not a word create for me :oops: , it's easy to see you are my friend :lol:
but we must not forget to compile without Unicode flag ...
Ok, i don't know that :oops:
But no problem, i don't like use UNICODE :D
I always try to not use it, if i'm not forced :mrgreen:
And for the moment, thanks to the gods...i'm never forced :lol:

Re: EXE with parameters embeded [Resolved]

Posted: Thu May 24, 2012 10:40 am
by GeBonet
Kwaï chang caïne wrote:
Perfect
Thanks a lot :wink:
But Perfect is not a word create for me :oops: , it's easy to see you are my friend :lol:
Not worry, nobody is perfect, and one who certainly believe in big trouble! 8)

And yes, I think I have the honour of being a friend! :lol:
Until next time,
Abraços.

Re: EXE with parameters embeded [Resolved]

Posted: Thu May 24, 2012 10:49 am
by Kwai chang caine
It's not every day easy programming with a little brain :oops:
These kinds words encourage me, thanks a lot 8)

Have a very good day, and perhaps a little bit of sun you love so much :D
Grosses bises :wink: