You are here

Making an application portable: Hooking?

44 posts / 0 new
Last post
ThievingSix
Offline
Last seen: 16 years 7 months ago
Joined: 2008-05-25 22:49
Making an application portable: Hooking?

I used to use PortableApps software a while back and enjoyed the flexibility it gave. Over the past couple weeks I have been doing a lot of computer fix ups and needed a solution with portable applications.

I needed a few of my own programs to be portable as well as some freeware programs. I was looking through here at how it was done but I already had some ideas in my head. I actually program in Delphi(I was happy when I saw PortableApps was coded in the same thing) and was wondering why API hooks were never done in the process of making applications portable(I might have missed exactly how it was done here, skimmed through the template).

Windows API such as RegOpenKey() RegOpenKeyEx() RegSetValue() RegSetValueEx() LoadLibrary() can be caught before they are sent to windows. Hooking them will there by make your own "mini-registry" for each program.

I was just wondering why applications aren't make like this because they can be turned into single files with no need for anything else.

Patrick Patience
Offline
Last seen: 5 years 1 week ago
DeveloperModerator
Joined: 2007-02-20 19:26
Sounds Cool

The PortableApps.com Menu is actually the only thing coded in Delphi. Even so, if that works, the menu could set it, and then programs launched while the menu is running could use it, but we would still have to accommodate for those not using the menu, as the launchers for the applications are coded in NSIS.

I hope I'm understanding correctly, it sounds cool to me.

ThievingSix
Offline
Last seen: 16 years 7 months ago
Joined: 2008-05-25 22:49
I understand that the menu is

I understand that the menu is the only thing coded in Delphi. What I am proposing is that the applications that are made portable can be made into a single executable instead of multiple folders for it.

This way the menu can create it's own registry that the applications can use, since the windows registry is just files as well. Everything can be emulated, in this fashion the PortableApps menu will be like it's own mini windows because all the API that the applications that are made portable are being redirected to the menu Smile

Patrick Patience
Offline
Last seen: 5 years 1 week ago
DeveloperModerator
Joined: 2007-02-20 19:26
Yes

That's basically what I understood. The one big problem is that many people to not use the menu and we would therefore have to have an alternative route. It does sound quite awesome however.

ThievingSix
Offline
Last seen: 16 years 7 months ago
Joined: 2008-05-25 22:49
The menu isn't required, it's

The menu isn't required, it's optional. The executables that are being made portable will check it the menu is running; if not, they will do the same thing on their own level.

Patrick Patience
Offline
Last seen: 5 years 1 week ago
DeveloperModerator
Joined: 2007-02-20 19:26
Ahh

Sorry, still not following fully. This would mean the applications are still developed in NSIS, or would have to be switched to Delphi?

ThievingSix
Offline
Last seen: 16 years 7 months ago
Joined: 2008-05-25 22:49
They wouldn't be developed in

They wouldn't be developed in NSIS or Delphi. There would be an application that takes the application and it's files the application and wraps it.

Let me show you an example(This would be an "as hard as it could get example"):

Autocad 2008:
When installed it has the main executable and files(dll's other files to make the program work) and files it puts in the windows system folder and registry entries.

The easiest way to track all of this would be to have the Portable Program Maker(PPM) run with it and track exactly what happens with File Creation hooks and registry hooks.

It records everything done and once the installation is complete it shows you what has happened. You then can choose what is needed and not needed. The needed stuff is then compressed and put into a single executable.

Now, when this new portable program is run, a dll is run with it. When the original program is looking for a certain file(We know this with API hooks) we extract it out of the executable and point it to the file we have instead of the one it thinks is on the disk.

Of course this is all null if the program doesn't need to be installed and in that case there can be an option for that as well.

Tim Clark
Tim Clark's picture
Offline
Last seen: 13 years 8 months ago
Joined: 2006-06-18 13:55
This sounds amazingly like

This sounds amazingly like "Thinstall",
or shouldn't I mention that Blum

Tim

Things have got to get better, they can't get worse, or can they?

Patrick Patience
Offline
Last seen: 5 years 1 week ago
DeveloperModerator
Joined: 2007-02-20 19:26
Ahh

Now I finally understand (I think :P). Haha, I'm with Tim. Blum But umm, it does sound new and interesting. We'll see what John thinks. It's a pretty massive change and may have some issues.

ThievingSix
Offline
Last seen: 16 years 7 months ago
Joined: 2008-05-25 22:49
It's supposed to sound

It's supposed to sound amazingly like Thinstall but much less expensive and easier to use. Smile

And on the point of it having to change anything: The menu doesn't have to be changed at all, it would help; but doesn't have to be. The new system can be program only.

Reason I'm pointing all this out is because things can be made easier and more efficient. I only know this is possible because I done similar things in hooking and Process from memory(no hard disk).

digitxp
digitxp's picture
Offline
Last seen: 13 years 3 months ago
Joined: 2007-11-03 18:33
I just thought of something.

What about %appdata%? Not all programs support redirecting it...

Insert original signature here with Greasemonkey Script.

Dagenham
Dagenham's picture
Offline
Last seen: 1 year 12 months ago
Joined: 2007-03-23 06:19
JauntePE

You may want to check out JauntePE - http://portablefreeware.com/forums/viewforum.php?f=10.

ThievingSix
Offline
Last seen: 16 years 7 months ago
Joined: 2008-05-25 22:49
Not really what I had in mind

Not really what I had in mind at all. My idea was to have a virtual windows(VW) surrounding the PAM or each Portable App. This VW will be complete with it's own API thanks to api redirection and it's own registry.

Chris Morgan
Chris Morgan's picture
Offline
Last seen: 9 years 6 months ago
Joined: 2007-04-15 21:08
JauntePE can do that. And

JauntePE can do that. And Ryan McCue is working on an open source hooking thing for it (its MadHook.dll is closed source) and then the author (Reddlar) may make it open source.

See https://portableapps.com/node/7707 for the most recent discussion of it.

I was at school and no one had replied when I saw this - I thought, "Ah hah! JauntePE to a tee!"

Dagenham: thanks for suggesting it!

I am a Christian and a developer and moderator here.

“A soft answer turns away wrath, but a harsh word stirs up anger.” – Proverbs 15:1

ThievingSix
Offline
Last seen: 16 years 7 months ago
Joined: 2008-05-25 22:49
MadHook as in madshi Code

MadHook as in madshi Code Hooking? No, that will never be open source. Plus, there are already hooking thing that are open source.

rab040ma
Offline
Last seen: 6 months 5 days ago
Joined: 2007-08-27 13:35
Right. Hooking the API is

Right. Hooking the API is hooking the API, and madshi's is one way to do it. I understand he has a very good reason for not making it more widely available -- it is too easy to misuse.

If you want to see how a more commercial program does it, look at Mojopac. Thinstall is another.

API hooking is not something for novice programmers to do. I wouldn't be surprised if it could be done in Delphi. Most think in terms of C or perhaps Assembler.

Coming up with an Open Source way to do it would be ideal, as long as it didn't give the script kiddies ideas for messing with other people's computers.

MC

ThievingSix
Offline
Last seen: 16 years 7 months ago
Joined: 2008-05-25 22:49
fyi Madshi's codehook was

fyi Madshi's codehook was made in delphi. Smile

I've used Thinstall and am disappointment in its hardness of use..I already have delphi hooking code that is partly mine, partly madshi's. The plan was not to have the code itself be open source but a application that bundles the portable apps. The nitty gritty that can be misused can be put elsewhere besides somewhere where people can see it.

Tim Clark
Tim Clark's picture
Offline
Last seen: 13 years 8 months ago
Joined: 2006-06-18 13:55
The problem...

The plan was not to have the code itself be open source but a application that bundles the portable apps. The nitty gritty that can be misused can be put elsewhere besides somewhere where people can see it.

Using Closed Source Software to make Open Source Software where people can't see how to do it themselves? Has a strange taste to it Blum

Tim

Things have got to get better, they can't get worse, or can they?

ThievingSix
Offline
Last seen: 16 years 7 months ago
Joined: 2008-05-25 22:49
Yes, but this isn't a

Yes, but this isn't a portable app, it's an app to make a portable app. Everything will be open source except the hooking code. Even that can be open source if you really want it to be.

Tim Clark
Tim Clark's picture
Offline
Last seen: 13 years 8 months ago
Joined: 2006-06-18 13:55
Thieving,

Thieving,

I think it would have to be open source if we were to use it.

And I'm pretty sure we couldn't do it with our Flag Ship Mozilla Products.

Tim

Things have got to get better, they can't get worse, or can they?

ThievingSix
Offline
Last seen: 16 years 7 months ago
Joined: 2008-05-25 22:49
Why wouldn't it work? The

Why wouldn't it work?

The precedence on how it works is simple: All programs use WinAPI to complish tasks having to do with Windows. The registry, for example, is just a file on your hard drive.

My idea comes in where you have the programs that are made portable all being hooked to have things like the registry not go to the real Windows.

Example:
Portable App A Runs and starts writing to the registry.
The hooks catches this and writes it to its own file called PortableAppA.preg.
If the App A starts reading from the registry it will be given information gotten from PortableAppA.preg.

Tim Clark
Tim Clark's picture
Offline
Last seen: 13 years 8 months ago
Joined: 2006-06-18 13:55
Sorry

Sorry

I meant "couldn't" as in "Not Allowed To".
Not "couldn't" in the "Technical" sense.

That's why I mentioned them as our "Mozilla" Flagship Products.

Tim

Things have got to get better, they can't get worse, or can they?

ZachHudock
ZachHudock's picture
Offline
Last seen: 1 year 12 months ago
Developer
Joined: 2006-12-06 18:07
I don't think he was saying

I don't think he was saying there would be functionality issues. I think Tim meant legality issues. Bundling open source software with a closed source product often isn't legally feasible.

The developer formerly known as ZGitRDun8705

ThievingSix
Offline
Last seen: 16 years 7 months ago
Joined: 2008-05-25 22:49
"Bundling open source

"Bundling open source software with a closed source product often isn't legally feasible."

Why is it illegal. I might be missing something but I don't see why it would be.

ZachHudock
ZachHudock's picture
Offline
Last seen: 1 year 12 months ago
Developer
Joined: 2006-12-06 18:07
It could break the terms of

It could break the terms of the license. For example, under the GPL, any derivative works must also be under the GPL. Repackaging, or wrapping with a closed component violates this.

The developer formerly known as ZGitRDun8705

ThievingSix
Offline
Last seen: 16 years 7 months ago
Joined: 2008-05-25 22:49
Ok, I think I am missing

Ok, I think I am missing something. Firefox is close sourced is what your saying?

[edit by Mod Tim]
Replies should pick up here:
https://portableapps.com/node/13623#comment-83965
This space is getting too tight

Zach Thibeau
Zach Thibeau's picture
Offline
Last seen: 2 years 2 months ago
Developer
Joined: 2006-05-26 12:08
Hi

ThievingSix, Just to let you know I am working on my own alternative of application hooking and it's based off the idea of JauntePE and Steve Lamertons Lapwing, I was wondering are you interested in working on the project with me Smile

your friendly neighbourhood moderator Zach Thibeau

ThievingSix
Offline
Last seen: 16 years 7 months ago
Joined: 2008-05-25 22:49
I am actually. My idea right

I am actually. My idea right now for me is a portable windows shell that I am starting on.

Zach Thibeau
Zach Thibeau's picture
Offline
Last seen: 2 years 2 months ago
Developer
Joined: 2006-05-26 12:08
Well

Well lets put it this way
"You scratch my back and I'll scratch yours" Smile I'll help you if you help me Biggrin just let me know your answer Wink

your friendly neighbourhood moderator Zach Thibeau

ThievingSix
Offline
Last seen: 16 years 7 months ago
Joined: 2008-05-25 22:49
Fine with me, what kind of

Fine with me, what kind of help will you be needing?

Zach Thibeau
Zach Thibeau's picture
Offline
Last seen: 2 years 2 months ago
Developer
Joined: 2006-05-26 12:08
Well

email me at thibeaz_-([at])-_gmail_-([dot])com and I'll let you know

your friendly neighbourhood moderator Zach Thibeau

Tim Clark
Tim Clark's picture
Offline
Last seen: 13 years 8 months ago
Joined: 2006-06-18 13:55
This is a SHIFT TO THE LEFT

This is a SHIFT TO THE LEFT Wink of the conversation
from:
https://portableapps.com/node/13623#comment-83962
"Ok, I think I am missing"
It's getting too tight over there.

No FireFox is not Closed Source but we can't repackage it with a Closed Source App.
[Additionally FF has very strict trademark issues that give them a lot of control over anything "called" Firefox"]

Tim

Things have got to get better, they can't get worse, or can they?

ThievingSix
Offline
Last seen: 16 years 7 months ago
Joined: 2008-05-25 22:49
So if it's made with an open

So if it's made with an open source application that is wrapped around it is there a problem?

*Thanks god for the shift to the left*

Tim Clark
Tim Clark's picture
Offline
Last seen: 13 years 8 months ago
Joined: 2006-06-18 13:55
Yes

That is why I said:
[Additionally FF has very strict trademark issues that give them a lot of control over anything "called" Firefox"]

Same applies for Thunderbird by the way.

Tim

Things have got to get better, they can't get worse, or can they?

ThievingSix
Offline
Last seen: 16 years 7 months ago
Joined: 2008-05-25 22:49
So how is the current

So how is the current FFPorable going along fine?
(Take that as a question, not a smart ass remark please =P)

Tim Clark
Tim Clark's picture
Offline
Last seen: 13 years 8 months ago
Joined: 2006-06-18 13:55
John has special permission

John has special permission to package FF as a Portable program and still use the FireFox name. And even that has limitations

Things have got to get better, they can't get worse, or can they?

ThievingSix
Offline
Last seen: 16 years 7 months ago
Joined: 2008-05-25 22:49
Ahh, I see. What kind of

Ahh, I see. What kind of limitations? And how hard would that be just to transfer the permissions to a different type of Portability. Lastly, we can just not apply this technique to FF at all.

Tim Clark
Tim Clark's picture
Offline
Last seen: 13 years 8 months ago
Joined: 2006-06-18 13:55
Don't want to be rude but I

Don't want to be rude but I am going to cut this short soon, so if I don't answer your next reply I'm sure someone else will pick this up.

What kind of limitations?

See:
https://portableapps.com/support/firefox_portable#modifications
for some of the modifications that have been made with Mozilla's permission.

Currently we have a problem with the AutoUpdate Check for updates. We are not allowed to turn it off.


how hard would that be just to transfer the permissions to a different type of Portability

That question is beyond me.

Lastly, we can just not apply this technique to FF at all.
Again, that question is beyond me.

Things have got to get better, they can't get worse, or can they?

ThievingSix
Offline
Last seen: 16 years 7 months ago
Joined: 2008-05-25 22:49
I do thank you for explaining

I do thank you for explaining everything to me. Hopefully we can proceed with this on some level but not now at least.

ohowson
Offline
Last seen: 16 years 7 months ago
Joined: 2008-05-28 05:07
Just to put my 2p in...

I'm currently writing a virtual registry program, using madshi. So far I've setup hooks for nearly all the registry calls (there are a LOT!). Then I'm going to test it with the first program I want to be portable (cMud or zMud in this case), see which calls it's making, and program them first. Interesting project (far more advanced than anything else I've done!!!)

rab040ma
Offline
Last seen: 6 months 5 days ago
Joined: 2007-08-27 13:35
A few clarifications might be

A few clarifications might be in order:

  • Open Source licenses make it hard to (legally) distribute applications and libraries if you bundle them with closed source code or (in some cases) modify the original. That's not the same thing as saying you can't do it, just that it's not legal to distribute them in certain forms, or with closed source modifications.
  • Nobody is saying that you can't distribute a closed source application that hooks the API's, just that licensing terms won't let you bundle and distribute it with most open source applications.
  • I don't think there is anything that prevents you from distributing a closed source program that provides a portable environment for other programs, as long as you don't try to bundle things in ways that violate those other programs' distribution licenses.
  • There are some copy prevention schemes whose licensing do not allow the end user to change the environment much. Otherwise, end users are pretty much able to create any environment they want to run programs.
  • Open Source is not the same as "freeware". In particular, while you can do lots of things with freeware, you can't distribute it using the SourceForge servers. That's not saying freeware is bad, just that SourceForge wants to use its servers for other things.
  • It might be easier and more elegant to take Open Source programs and modify them to "be portable" -- that is, store settings and data in a location and format of the user's choice, as an option. In the case of Mozilla products, if the Mozilla folks don't adopt the design changes, you can still make the changes and distribute the result, you just can't use their registered names and graphics.
  • The real benefit of "hooking" would be in closed source programs where the maintainers do not want to make their programs "portable". Of course, it is even less likely that you would legally be able to distribute a "bundle" of a hooking environment with a closed source program.
  • A lot of people might hope for a hooking/portability environment that allows them to overcome restrictive licensing provisions, such as provisions that tie a software license to a particular machine. It might be difficult to distribute such a portable environment if that is its main purpose. The PortableApps.com site might prefer to avoid associating itself with such software, especially if that is its primary purpose, or even if it is an un-stated benefit.

Mostly, it is a matter of details (and the devil that is in them). I think there are legal ways of creating a portable environment that uses hooking. I would be delighted to see it happen. There are several details that might make it difficult to happen on this site, but that is not to say that it is a bad idea, or that this is a bad site.

MC

Art100
Art100's picture
Offline
Last seen: 6 years 2 months ago
Joined: 2008-05-28 08:04
BoxedApp SDK?...

BoxedApp SDK (founded at here link to sdk web-site ) could be used to make probably almost any application portable, if you can modify source code of course. It's for developers... For example, you can register embedded DLLs in a virtual registry, ActiveX, I mean. Even .NET runtime can be embedded. It seems that even 64 bit system is supported, but I haven't tested it yet. There are a few examples for Delphi.

I think, with this SDK it's possible to create a sandbox, in which you launch an installer, all changes are saved in virtual environment ("registry" and "file system")... Not sure, but I hope Smile

rab040ma
Offline
Last seen: 6 months 5 days ago
Joined: 2007-08-27 13:35
300 euros

And the cost is only 300 euros.

MC

ThievingSix
Offline
Last seen: 16 years 7 months ago
Joined: 2008-05-25 22:49
<--

I've done a lot with hooking, first with madshi, then with my own hooking functions and wanted to make applications portable with this in a different sense. More a long the lines of a portable windows shell if you get my drift.

Log in or register to post comments