The best practice when building JPE portable application

Discuss anything related to JauntePE, the utlimate utility to help you tame non-portable applications. Share your experience about the apps that work with JauntePE, and the apps that don't.
Post Reply
Message
Author
crownixx
Posts: 403
Joined: Sat May 12, 2007 6:26 am

The best practice when building JPE portable application

#1 Post by crownixx »

i would like to discuss this when
redllar wrote: The more you, meaning the person attempting to portablize a non-portable app, can give the JPE runtime in terms of how the app uses the registry, the better. Because JPE is really, really, stupid. It needs help from you so that it can then skip as much code as possible that takes a lot of time to execute
so my idea for the practise we need to follow was like this

1. portable the application using "portable the registry(redirect the registry)", "keep in memory", and "redirect the Filesystem". Below should be the minimal configuration in appname_JauntePE.ini

Code: Select all

[Registry]
Use=1
Data=.\Registry\%appname%_registry.reg

[Filesystem]
Use=1
Data=.\Files\

[RegistryExclude]
1=HKEY_CURRENT_USER\Software\Microsoft\DirectInput
2=HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32
3=HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2
4=HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
5=HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam
6=HKEY_LOCAL_MACHINE\Software\Microsoft\Direct3D
7=HKEY_LOCAL_MACHINE\Software\Microsoft\DirectDraw
8=HKEY_LOCAL_MACHINE\Software\Microsoft\DirectInput
9=HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
10=HKEY_LOCAL_MACHINE\System\CurrentControlSet

[SpecialFolders]
0=Files\Desktop
1=Files\Internet
2=Files\StartMenu\Programs
3=Files\Computer\Controls
4=Files\Computer\Printers
5=Files\Documents
6=Files\Favorites
7=Files\StartMenu\Programs\Startup
8=Files\RecentDocs
9=Files\SendTo
10=Files\Desktop\RecycleBin
11=Files\StartMenu
12=Files\Documents
13=Files\Documents\Music
14=Files\Documents\Video
15=Files\Unknown
16=Files\Desktop
17=Files\Drives
18=Files\Network
19=Files\NetHood
20=Files\Windows\Fonts
21=Files\Templates
22=Files\StartMenu
23=Files\StartMenu\Programs
24=Files\StartMenu\Programs\Startup
25=Files\Desktop
26=Files\AppData
27=Files\PrintHood
28=Files\AppData
29=Files\Startup
30=Files\Startup
31=Files\Favorites
32=Files\INetCache
33=Files\INetCookies
34=Files\INetHistory
35=Files\AppData
36=Files\Windows
37=Files\Windows\System
38=Files\ProgramFiles
39=Files\Documents\Pictures
40=Files
41=Files\Windows\System
42=Files\ProgramFiles
43=Files\ProgramFiles\Common
44=Files\ProgramFiles\Common
45=Files\Templates
46=Files\Documents
47=Files\StartMenu\Programs\AdminTools
48=Files\StartMenu\Programs\AdminTools
49=Files\Connections
50=Files\Unknown
51=Files\Unknown
52=Files\Unknown
53=Files\Documents\Music
54=Files\Documents\Pictures
55=Files\Documents\Video
56=Files\Windows\Resources
57=Files\Local\Resources
58=Files\OEM
59=Files\AppData\CDBurnArea
60=Files\Unknown
61=Files\ComputersNearMe
62=Files
2. Launch the portable application. Make some exercise to the program like change the option settings, save some files

3. Exit the the program. Take a look into Files folder and the appname_registry.reg(using notepad)

4. Based on your observation in step(3), change/edit again your appname_JauntePE.ini
for example:
If you open the Files folder and there is nothing Filesystem to hook, change the configuration before to this

Code: Select all

[Filesystem]
Use=0
If you open the appname_registry.reg using notepad and found that the program only use
HKEY_CURRENT_USER\software\Appname , change configuration settings to this

Code: Select all

[RegistryExclude]
1=HKEY_CLASSES_ROOT
2=HKEY_CURRENT_CONFIG
3=HKEY_CURRENT_USER
4=HKEY_LOCAL_MACHINE
5=HKEY_USERS

[RegistryInclude]
1=HKEY_CURRENT_USER\software\Appname
5. Done. The portable application should execute faster after we optimizing the appname_JauntePE.ini configuration

*notes:
ok, i'm confius now when trying to give an example in step(4), what is the different [RegistryExclude] configurations between JauntePE_jauntePE.ini and regedit_jauntePE.ini?
but the whole step i think should be ok for the best practise..just need more information on step(4)
Last edited by crownixx on Sun Jul 01, 2007 4:20 pm, edited 1 time in total.

redllar
Posts: 411
Joined: Thu Aug 03, 2006 7:52 pm
Contact:

#2 Post by redllar »

Okay, I've done some preliminary performance testing and the results are interesting. So here's what I think people should do for now as a "best practice:"

1) Only use file system redirection when you absolutely have to. It's the #1 performance killer by far in just about everything the app does. With it turned on the app loads much, much slower, every access to a file or directory is affected, and using any shell (Explorer) related function, such as browsing to select a directory or to open or save a file, is really, really, slowed down.

2) Whether you use file system redirection or not, it looks like using module exclusion in combination with the other types of exclusion provides the best performance, as JPE tests for module exclusion first, so that's the point where the most code is skipped. So, here's what I suggest as a good starting point for an app-specific JPE runtime ini for an app that's already been "installed," i.e., is ready to be portablized (replace <appname> as appropriate):

Code: Select all

;
; Exclude all registry access from redirection except for the keys that
; are specific to the application
;

[RegistryExclude]
1=*

[RegistryInclude]
1=HKEY_CURRENT_USER\Software\%appname%
;2=other app-specific keys as appropriate

;
; Once you figure out what keys should go into the RegistryInclude section,
; and you run the app enough to populate its portable registry, you'll 
; want to duplicate those keys here. The "ignore" section is used to tell
; JPE to tell the app that those keys don't exist in the real system registry,
; even if they do. This does several things for you. It prevents you from
; picking up any other computers settings for those settings that haven't
; yet been set in your portable registry. It also prevents some apps from
; getting into infinite loops when they delete a key in the portable registry,
; look to see if it exists and it does in the real system registry, so loop
; again to delete it again, ad infinitum (stupid lazy programmers).
;

[RegistryIgnore]
;1=HKEY_CURRENT_USER\Software\%appname%
;2=other app-specific keys as appropriate

;
; Exclude all file system access from redirection except for the folders that
; are specific to the application, i.e., the app data folders where most apps
; store their file system data, if any.
;

[FilesystemExclude]
1=*

[FilesystemInclude]
1=26
2=28
3=35

;
; The following are for the shell's "Program Files" folders. Some apps need
; these since they've hardcoded the path to where they were installed.
;
;4=38
;5=42
;6=43
;7=44

[FilesystemIgnore]

;
; Exclude all module access from redirection except for the app's modules.
; This makes shell access run close to normal.
;

[ModuleExclude]
1=*

[ModuleInclude]
1=%appname%.exe
;2=%appname%.dll
;3=%anotherappdll1%.dll
;4=%anotherappdll2%.dll

;
; Normal file system special folder relative paths as needed.
;

[SpecialFolders]
...
...

The "*"s in all of the exclude sections stand for "exclude everything."

I hope the registry include and ignore entries are self expanatory. Post if not.

The first 3 file system includes are for the 3 %appdata% shell folders. The last 4, which I think should be commented out as a default, are for the %programfiles% shell folders. Note here that this means that any other special folders would not be redirected, such as the desktops and "my documents" folders.

Why am I suggesting only these sets of folders be redirected? Because these are the folders that the app itself typically expects its data to be in, if it was written following Microsoft's guidelines. The other folders are typically only used by the user, not the app. So my thinking here is that you prevent the app from modifying the special folders but not the user. Especially the newbies, since they won't understand what's going on. As they gain more experience with how the redirection works, and understand what the limitations are in the current JPE implementation, i.e., they read and understand the docs, then they can go back and add in their own to-be-redirected folders as needed, such as My Documents. There is one caveat to this approach that I explain below.

The lone enabled module inclusion is what makes all of this possible. It basically says "only consider redirecting requests that come from my application." So, anything coming from the shell will be immediately bypassed, meaning things like browsing the file system will be almost as fast as normal.

3) Based on my testing I uncovered a few file system related bugs that I have taken care of. One of the bugs was causing my 2K SP1 system to take a long, long time to browse to folders and files via the shell dialog boxes.

I also found some hastily written code that was causing app load times from flash drives to be much worse than they should be. In fixing that I was able to get MetaPad to load in under 1 second, where it was taking 8 seconds previously. :) So I guess I can say that 7 seconds of load time from flash drives has been eliminated.

I hope to get a 012 version out to Andrew soon that will have the fixes. You'll be able to overlay the 011 files with this version as the only primary difference will be the jauntePE.dll. I'll also add in a few minor bug fixes for the exe.

crownixx
Posts: 403
Joined: Sat May 12, 2007 6:26 am

#3 Post by crownixx »

I hope the registry include and ignore entries are self expanatory. Post if not.
Is there any application example maybe for the program you found that need to ignore the registry?
A soldier who has experience in war do better battling than a soldier who only have theory :mrgreen:

redllar
Posts: 411
Joined: Thu Aug 03, 2006 7:52 pm
Contact:

#4 Post by redllar »

Is there any application example maybe for the program you found that need to ignore the registry?
A soldier who has experience in war do better battling than a soldier who only have theory :mrgreen:
The one that comes to mind is a file manager that Andrew was using. I'm afraid I've forgotten the name though, sorry. It would get into an infinite loop when you closed it. I'll try and go back through the original portapotty thread and see if I can find it.

User avatar
Andrew Lee
Posts: 3052
Joined: Sat Feb 04, 2006 9:19 am
Contact:

#5 Post by Andrew Lee »

The one that comes to mind is a file manager that Andrew was using. I'm afraid I've forgotten the name though, sorry. It would get into an infinite loop when you closed it. I'll try and go back through the original portapotty thread and see if I can find it.
I believe it is xplorer2 lite.

crownixx
Posts: 403
Joined: Sat May 12, 2007 6:26 am

#6 Post by crownixx »

i cannot use "%appname%" (%appname%.exe) in Modules section like i did in Registry section (%appname%_registry.reg)
the JauntePE dont want to hook the module and cause the registry go into my system. However if i use the full name in the Modules section, JauntePE works fine

is this bugs?

redllar
Posts: 411
Joined: Thu Aug 03, 2006 7:52 pm
Contact:

#7 Post by redllar »

crownixx wrote:i cannot use "%appname%" (%appname%.exe) in Modules section like i did in Registry section (%appname%_registry.reg)
the JauntePE dont want to hook the module and cause the registry go into my system. However if i use the full name in the Modules section, JauntePE works fine

is this bugs?
No, it's bad documentation on my part. What's new? :)

All of the %appname%s in my posted .ini example should read as <appname> instead, since that's what I was referring to above when I stated that you should replace <appname> as appropriate.

I also made a change for the 012 version so that you can use %appname% in any of the redirection sections.

redllar
Posts: 411
Joined: Thu Aug 03, 2006 7:52 pm
Contact:

#8 Post by redllar »

Andrew Lee wrote:I believe it is xplorer2 lite.
Thanks Andrew. I'm afraid I lost all of those apps we had tested with when I lost my backup portable drive.

Post Reply