View previous topic :: View next topic |
Author |
Message |
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1751 Location: Space and Time
|
Posted: Tue Jan 12, 2010 6:58 pm Post subject: Extract from an EXE |
|
|
I want to take a text file and append it to a VDS EXE file using Copy /b. How can I extract it from the EXE. I'm sure there is a way using WRITE, but I have not been able to do it.
Thanks!! _________________ Chris
Http://theblindhouse.com |
|
Back to top |
|
|
vdsalchemist Admin Team
Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Tue Jan 12, 2010 11:36 pm Post subject: |
|
|
Why don't you just use a resource? The #RESOURCE directive is really easy to use. I use it all the time to store DLL's in my EXE's. At any rate you could put a special byte or even the name of the file as the first characters of the text file you want to append... The just use read to locate that name and start writing there until the EOF. Warning some virus scanners don't like this sort of thing. _________________ Home of
Give VDS a new purpose!
|
|
Back to top |
|
|
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1751 Location: Space and Time
|
Posted: Tue Jan 12, 2010 11:59 pm Post subject: |
|
|
What I'm trying to do is make a self contained note program. An EXE that is like notepad but saves the text in the EXE file. I have looked at the IO example that comes with VDS 6 but I haven't had any luck getting it to work. _________________ Chris
Http://theblindhouse.com |
|
Back to top |
|
|
Aslan Valued Contributor
Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Wed Jan 13, 2010 3:18 am Post subject: |
|
|
First of all, have you successfully appended a text file to the end of your exe while it's running?
Second, if the above was successful maybe you use the compile byte length of your exe and then extract or read all the bytes remaining starting with the byte above your exe's length with @binfile() or @read().
I'm still not sure you can combine these files while your exe is open.
Last edited by Aslan on Wed Jan 13, 2010 5:55 am; edited 1 time in total |
|
Back to top |
|
|
Aslan Valued Contributor
Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Wed Jan 13, 2010 5:14 am Post subject: |
|
|
Ok just tested this.
You cannot append the file to the exe while its running.
"Copy /b <thisExe> + <SomeTextFile> /a <thisExe>" failed
"Copy /b <thisExe> + <SomeTextFile> /a <NewExe>" success
You might be able to accomplish you desired result by using 2 apps (embed one in the other as a #RESOURCE). One to call the second where the second runs the copy command against the first. You must ensure that the first app has closed before using the copy command. |
|
Back to top |
|
|
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1751 Location: Space and Time
|
Posted: Wed Jan 13, 2010 2:21 pm Post subject: |
|
|
I have copied the exe then appended the text file. I am able to extract the text. The problem I am having is extracting the EXE to append another text file or the changed text. When I extract the EXE from 0 to the length of the EXE, the extracted EXE does not run. _________________ Chris
Http://theblindhouse.com |
|
Back to top |
|
|
Aslan Valued Contributor
Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Sun Jan 17, 2010 1:13 pm Post subject: |
|
|
Chris this works on my Win7 machine with VDS 6
The following is code for the two files needed for this to work.
Compile both of them using the "Integrated VDS 6 Executable" option.
Then join them using "copy /b main.exe + combine.exe main.exe" from a command prompt. Then run main.exe
Main.exe Code: | # main.exe for appending a text file to the end of an executable
# and then readiing it back
Title Main
If %1
File delete,combine.exe
exit
end
%%exeSize = 1874944
%%totalSize = @file(%0,Z)
%F = @new(file,%0,READ)
DIALOG CREATE,Main,-1,0,400,400,CLASS vdsTest
DIALOG ADD,EDIT,EDIT1,7,7,387,346,,,Multi,Wrap
DIALOG ADD,BUTTON,Close,365,329,64,24,Close
DIALOG ADD,BUTTON,Save,366,248,64,24,Save
DIALOG SHOW
List create,1
If @Greater(@file(%0,Z),%%exeSize)
goto ReadFile
end
:evloop
wait event
goto @event()
:Readfile
Seekfile %F,%%exeSize
Dialog set,EDIT1,@read(%F,@diff(%%totalSize,%%exeSize))
goto evloop
:SaveBUTTON
%%Update = 1
goto evloop
:CloseBUTTON
:Close
If @equal(%%Update,1)
List add,1,@dlgtext(EDIT1)
List savefile,1,@path(%0)tmp.txt
# Extract combine.exe and run
%C = @New(File,@Path(%0)combine.exe,WRITE)
Seekfile %F,939520
WRITE %C,@Read(%F,935424)
CLOSEFILE %C
CLOSEFILE %F
Run combine.exe
end
exit |
Combine.exe Code: | ### COMBINE.EXE ###
Title Combine
Wait 1
%%TXT = @New(file,@Path(%0)tmp.txt,READ)
SEEKFILE %%TXT,0
%%EXE = @New(file,@Path(%0)main.exe,READ)
SEEKFILE %%EXE,0
%%MAIN = @New(file,@Path(%0)main1.exe,WRITE)
WRITE %%MAIN,@read(%%EXE,1874944)@read(%%TXT,@File(@Path(%0)tmp.txt,Z))
CLOSEFILE %%TXT
FILE Delete,@Path(%0)tmp.txt
CLOSEFILE %%EXE
File delete,main.exe
CLOSEFILE %%MAIN
File rename,main1.exe,main.exe
Run main.exe cleanup
exit |
|
|
Back to top |
|
|
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1751 Location: Space and Time
|
Posted: Tue Jan 19, 2010 1:41 am Post subject: |
|
|
Thanks! I'll take a look at it. _________________ Chris
Http://theblindhouse.com |
|
Back to top |
|
|
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1751 Location: Space and Time
|
Posted: Tue Jan 19, 2010 1:58 am Post subject: |
|
|
The sizes are different for me when I compile. I get the EXESize, What are the other 2 sizes? Where do they come from? The 939520 and 935424.
I'll keep looking at the code to see if i can figure it out. I may be over looking something.
Thanks. _________________ Chris
Http://theblindhouse.com |
|
Back to top |
|
|
Aslan Valued Contributor
Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Wed Jan 20, 2010 3:16 am Post subject: |
|
|
LiquidCode wrote: | What are the other 2 sizes? Where do they come from? The 939520 and 935424. |
939520 = main.exe size with integrated runtime
935424 = combine.exe size with integrated runtime
Using the integrated runtime was because you stated that you wanted it to be self contained.
Not sure why your compiled sizes would be different except for obviously when you make more changes to main.exe to suite your needs.
1874944 = both exes total
to extract combine.exe you use SEEKFILE <id>,939520 to get to the end of main.exe and then read the next 935424 bytes which is the combine.exe
%%exeSize = sizeOfMain + sizeOfCombine is needed so that you will know where to start reading the appended text.
Premise:
Main.exe runs and first checks to see if its size is larger than the origonal. (%%exeSize)
If larger then there is extra text than needs to be read so read it.
If changes are made then save the text to a file and extract and run combine.exe and close main.exe
Combine.exe waits for a sec to allow main.exe to close.
Then it combines the origonal main.exe with the textfile.
Close the textfile and delete it.
Close main.exe and delete it.
Note: the new exe has to have a different name since the origonal main.exe is open for reading so you just rename it after closing main.exe.
Then run the new main.exe with the "cleanup" switch to delete combine.exe
I hope I made sense of it
My apologies, I should have commented it better but I was running out of time. |
|
Back to top |
|
|
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1751 Location: Space and Time
|
Posted: Wed Jan 20, 2010 8:07 pm Post subject: |
|
|
Ok. thanks. I'll take a look again. I thought that is what they were, but I must not have done it right. I'll be looking again today. Thanks again for the help! _________________ Chris
Http://theblindhouse.com |
|
Back to top |
|
|
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1751 Location: Space and Time
|
Posted: Thu Jan 21, 2010 2:53 pm Post subject: |
|
|
Thank you so much for the help. You get me in the right direction. I was able to make a self contained note using only one exe file based on the code you posted and it's only 343kb! Here is a link to the program. Please give it a test and let me know what you think. You can rename the file and it will still work.
http://dl.dropbox.com/u/137938/web/downloads/Self%20Note.exe _________________ Chris
Http://theblindhouse.com |
|
Back to top |
|
|
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Thu Jan 21, 2010 4:48 pm Post subject: |
|
|
Works fine on Win 7 64 bit. _________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
Back to top |
|
|
Aslan Valued Contributor
Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Thu Jan 21, 2010 9:58 pm Post subject: |
|
|
Chris when you say "self-contained" are you assuming that the user already has the runtime on their machine? I'm asking this since the filesize is small.
BTW - I like the encryption option... Nice |
|
Back to top |
|
|
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1751 Location: Space and Time
|
Posted: Thu Jan 21, 2010 10:54 pm Post subject: |
|
|
The runtime is already in it .
I updated Self Note. It now auto encrypts the file with a PIN number. If it is run for the first time, you get the info text. If it is changed, it asks for a PIN and encrypts the text before it saves. Next time you run it, it asks for the PIN again. if the pin is incorrect the file will not open. Do not forget the PIN, it cannot be retrieved. Use same link as above for the new version. _________________ Chris
Http://theblindhouse.com |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|