Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sat Sep 21, 2019 8:51 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 39 posts ]  Go to page Previous  1, 2, 3
Author Message
 Post subject: Re: MBS Plugins - Compression plugin
PostPosted: Sat Aug 27, 2011 12:52 am 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
How do you specify the location? And does it work from a virtual volume? It's a little hard to follow your post.


Top
 Profile  
Reply with quote  
 Post subject: Re: MBS Plugins - Compression plugin
PostPosted: Sat Aug 27, 2011 2:31 am 
Offline

Joined: Fri Sep 30, 2005 10:01 am
Posts: 283
Location: Germany, Munich
In the declares. Where you specify the lib name you can also include its path with the name.

Also, I believe that if you put the DLL into specific locations relative to your app, then it'll be found without the need for a path with the name. Need to try that, but maybe if the DLL is right next to the EXE, or inside that Lib folder that RB creates for plugins.

_________________
User of RB since first version. Provider of many free and outdated plugins.
Code for sharing: http://www.tempel.org/RB/Resources
Arbed, a unique tool for editing projects: http://www.tempel.org/Arbed
Zip compression classes: http://www.tempel.org/RB/ZipPackage


Top
 Profile  
Reply with quote  
 Post subject: Re: MBS Plugins - Compression plugin
PostPosted: Sat Aug 27, 2011 4:08 am 
Offline

Joined: Wed May 20, 2009 11:02 am
Posts: 423
timhare wrote:
That's the way RB *used to* handle dll's - load them directly into memory - back when they created a single .exe with no .dll lib folder. They abandoned the practice and went to on-disk dll files. So it can be done, but isn't recommended.


Yes, although I came across RB after the single exe was dropped, I have heard about it and the in-memory dlls a few times here in the forums. Do you know why it is not done anymore? Other then a (maybe?) longer launch time, I can't think of any drawback... maybe security issues?

tempel wrote:
In the declares. Where you specify the lib name you can also include its path with the name.

Also, I believe that if you put the DLL into specific locations relative to your app, then it'll be found without the need for a path with the name. Need to try that, but maybe if the DLL is right next to the EXE, or inside that Lib folder that RB creates for plugins.


The dll does work if it's next to the application or in the Lib folder, but we are considering locating it in a virtual volume, so the path must be passed in the declare.

Matthew, can you show us how you did it?

This would be a way for people to make their single exe builts, which is requested regurlarly in these forums.

Pixe.

_________________
Using RS2011r4.3 on Windows7.


Top
 Profile  
Reply with quote  
 Post subject: Re: MBS Plugins - Compression plugin
PostPosted: Sat Aug 27, 2011 4:33 am 
Offline

Joined: Fri Sep 30, 2005 10:01 am
Posts: 283
Location: Germany, Munich
pixe656 wrote:
The dll does work if it's next to the application or in the Lib folder, but we are considering locating it in a virtual volume, so the path must be passed in the declare.

Impossible. VVs use a proprietary format that is not understood by Windows. And since it's Windows, not the RB Runtime, that needs to locate the DLL, this can't work with items inside a VV file.
There's only two ways: Load the DLL into RAM and use special Windows API calls to make it known that way, or place it somewhere as a file and tell Windows the path via the declare as you know it.

_________________
User of RB since first version. Provider of many free and outdated plugins.
Code for sharing: http://www.tempel.org/RB/Resources
Arbed, a unique tool for editing projects: http://www.tempel.org/Arbed
Zip compression classes: http://www.tempel.org/RB/ZipPackage


Top
 Profile  
Reply with quote  
 Post subject: Re: MBS Plugins - Compression plugin
PostPosted: Sat Aug 27, 2011 9:46 am 
Offline
User avatar

Joined: Sun Aug 12, 2007 10:10 am
Posts: 1086
Location: Boiling Springs, SC
simulanics wrote:
simulanics wrote:
Could the dlls be embeded into the executable and written to a VirtualVolume and called from there? Afterall, vv's are flushed once the application ends.. So it would be just like loading them into memory without the wasted ram and proprietary dlls couldn't be "reused" by others ? Havnt tried it but definitely interested now.. I will attemp it and let you know my findings in a few minutes :-)

I love UPX!!!.. If you can find a previous version (not sure will have to look) it actually packs the executable even smaller..(so I dunno what they Did to the code to add the small bloat) Definitely a big help with RB apps and a must have :-) I wrote a utility that recursively scans my compiled projects and uses shell execute to compress the dll/exes :-) I wonder why RB hasn't thought of prepacking the dlls before distributing them? Maybe they don't know about UPX? .. Anyway some vv dll testing is underway..



So after some monkeying around...I have discovered that you can infact embed a dll directly into your app (which I though was possible just didn't know how until now..so kudos to you for making us think!) but from your application..create a virtual volume and 'extract' the dll it... usually the dll MUST be in your system directory or same path as your application...UNLESS you specify the exact location to the dll

SEE this forum post for details...I had to search quite a bit but found it :-)
viewtopic.php?f=6&t=40290&p=224177&hilit=declare+lib#p224177

So yes, after compiling a little dll and packing it and testing it...it works..and it's much easier than loading it into memory and accessing it there...



after doing this I had one of those "Duh!" moments... in the plugin sdk folder the plugin creator and converter do just this already :-)

_________________
Matthew A. Combatti
Real Studio 2012 r1.2

Visit Xojo Developer's Spot!
Systems I Use:
Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8
Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/
Windows Server 2011/CentOS 5.4 /ReactOS/SimOS

~All Xojo Compatible~


Top
 Profile  
Reply with quote  
 Post subject: Re: MBS Plugins - Compression plugin
PostPosted: Sat Aug 27, 2011 10:20 am 
Offline
User avatar

Joined: Sun Aug 12, 2007 10:10 am
Posts: 1086
Location: Boiling Springs, SC
Load using rundll.exe on windows...for loading from memory..have to load the complete file from the vv and write to memory to load using rundll.exe..but if you google it, that's where i found how to do it...write me if you need help and i'll regenerate the code :-)

_________________
Matthew A. Combatti
Real Studio 2012 r1.2

Visit Xojo Developer's Spot!
Systems I Use:
Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8
Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/
Windows Server 2011/CentOS 5.4 /ReactOS/SimOS

~All Xojo Compatible~


Top
 Profile  
Reply with quote  
 Post subject: Re: MBS Plugins - Compression plugin
PostPosted: Sat Aug 27, 2011 10:31 am 
Offline
User avatar

Joined: Sun Aug 12, 2007 10:10 am
Posts: 1086
Location: Boiling Springs, SC
tempel wrote:
I have no easy answer to optimizing the code, you'll have to figure out the math yourself.

Binhex? Did I write binhex? If I did - I meant Base64. just try it out: use encodebase64 and decodebase64 to create the encoded strings instead of doing the hex-encoding you do now. i bet that'll compress the data better because you do not need to add a space between each byte as you do now. simply create base64 segments of 64 chars or something like that, line by line.

To make your decompression code much faster do this:
1. first create a memoryblock with the size of the resulting file
2. instead of writing each byte into the binaryfile, put them into the memoryblock
3. write the memoryblock to the file.

Also, it's not efficient to concatenate lots of strings to each other with "+". That gets slower and slower the more strings you add up that way. instead, define a array and append the single strings to that array. then, when done with all the appending, get the resulting added-up string by calling the join(array,"") function.

so much for simple optimizations.



Base64 definitely worked better (faster and smaller) will post updated code later today for whoever can use it for reference :-)

_________________
Matthew A. Combatti
Real Studio 2012 r1.2

Visit Xojo Developer's Spot!
Systems I Use:
Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8
Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/
Windows Server 2011/CentOS 5.4 /ReactOS/SimOS

~All Xojo Compatible~


Top
 Profile  
Reply with quote  
 Post subject: Re: MBS Plugins - Compression plugin
PostPosted: Sat Aug 27, 2011 1:07 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
pixe656 wrote:
Yes, although I came across RB after the single exe was dropped, I have heard about it and the in-memory dlls a few times here in the forums. Do you know why it is not done anymore? Other then a (maybe?) longer launch time, I can't think of any drawback... maybe security issues?

Random crashes. :( Ie., it didn't work 100%.


Top
 Profile  
Reply with quote  
 Post subject: Re: MBS Plugins - Compression plugin
PostPosted: Mon Sep 05, 2011 3:22 pm 
Offline

Joined: Wed May 20, 2009 11:02 am
Posts: 423
I did some googling on the topics discussed here regarding the possibility of using dlls from a location in memory, not in the hard disk. I thought I would share the info I found, since this might be interesting for others too.

The possibilities that were mentioned here were, using a virtual volume, a ramdisk and putting the dll in memory (maybe a memoryblock) and then execute it from there.

VirtualVolume: As far as I understood from the LR, a virtual volume requires a file on the hard disk to which it is linked, doesn't it? If so, then you are tight to a HD anyway, so this is not the way to go.

Ramdisk: This could work, create a ramdisk, copy the dlls there and run them from there. It's built in for Mac and Linux. For the rest of us, Windows users, good luck next time. On Windows an additional driver is required, which must be installed on the system, and thus using the hard drive is necessary. For Linux and Mac this is a good route, I would say. There might be a problem with this because the path to the dll is hard coded in the declare, so the ramdrive should always be on the same drive letter (or maybe there is another workaround for this I am not aware of). There is a nice driver for Windows that can be installed, run and unistalled without restarting the computer, but it must be installed on the hard drive: http://www.ltr-data.se/opencode.html/#ImDisk. I didn't know about this, Matthew form simulanics told me about it.

Using the dll from the memory: This can be done (RB used to do it), but I don't know how. I found some info on the net but it is far too advanced for me. Here it is: http://www.joachim-bauch.de/tutorials/loading-a-dll-from-memory/. The code there is C/C++, so maybe it cannot be done in RB exclusively, and maybe the only way to implement is by using a plugin... so a dll would be required to load the other dlls.

Can anyone think of any alternative? Is anything I wrote wrong? I still would love to see this done on Windows.

Pixe

_________________
Using RS2011r4.3 on Windows7.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 39 posts ]  Go to page Previous  1, 2, 3

All times are UTC - 5 hours


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

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group