Author Topic: Resources  (Read 3564 times)

0 Members and 1 Guest are viewing this topic.

efgee

  • Guest
Resources
« on: January 03, 2011, 12:22:30 PM »
Hello Charles,

I can see there is a "o2reso.bas" in the src directory but it's only some comments for now.
Did you already think it through how to incorporate resources into the code?

IMHO the only things that are really needed would be the inclusion of a single application icon and a manifest file (for XP/Vista/W7 theme controls).

Bitmaps, Cursors, Strings etc. would be nice too, but it's so Windows-OS specific that maybe the additional work is not worth it - especially if in the future Oxygen will not only generate PE files but also ELF files (hope, hope...).

Anyway, thanks for reading...

bye


Charles Pegge

  • Guest
Re: Resources
« Reply #1 on: January 04, 2011, 05:47:58 AM »

Icons, unfortunately are the most complex of the resources. James Fuller has a utility for patching compiled resources into EXE files. There also is REShacker. All resource access is then via the OS.

But I would like to integrate this facility into Oxygen so that scripts can access resources without precompiling.

Charles

efgee

  • Guest
Re: Resources
« Reply #2 on: January 04, 2011, 10:39:48 AM »
Charles,
the problem with REShacker is that every time the executable is recompiled by Oxygen a new run of REShacker is necessary.

I would be glad to help, but looking at the oxygen source code it's obvious to me that our brains don't code alike (you are way to intelligent... I can't keep up).

What would be needed are 2 compiler directives (like #manifest "mymanifest_file.xml" and #appicon "my_icon.ico") these would get the file names, read them into separate blocks of memory and keep them until the PE file needs to be build (and then written at their proper location).

The icon - without the icon header (the first 18 bytes if I recall correctly) - can be mapped byte by byte into the designated resource section RT_ICON.
Also the application icon needs to be the first in the icon resource list and be listed twice (RT_ICON and RT_GROUP_ICON) otherwise it will not show up in the left-top corner of a window.

In the RT_GROUP_ICON section you copy the header of the icon (the first 18 bytes of the icon file) followed by the ordinal number of the icon (in this case a 1) and a $0; so 20 bytes in total.

The manifest file can also be mapped byte by byte into his location (RT_MANIFEST).
Here an example of a minimal manifest file (can be used as it is).

For newer Windows OS (Vista and W7) more stuff can be build into the manifest file to make sure the application works as expected (admin rights and such...)

As a resource language ZERO (0) could be used instead of 1033 (english) or any other language because ZERO works on any Windows OS (any language).
For icons it's not important anyhow (unless you add strings or menues to the resources it's not an issue).

Anyway, enough rambling... suppose you knew all this stuff already.

Take care
efgee


EDIT: Added more information...
« Last Edit: January 04, 2011, 01:08:34 PM by efgee »

Charles Pegge

  • Guest
Re: Resources
« Reply #3 on: January 04, 2011, 02:18:54 PM »

Thanks Efgee,

The documentation on resource formats (especially icons) is not great. What I have seen is fuzzy when it comes to some of the critical details. A little reverse engineering will help but if you see any good links do let us know.

Charles.

PS: some links I found helpful but no clinchers.


http://msdn.microsoft.com/en-us/library/ms997538.aspx
http://www.skynet.ie/~caolan/publink/winresdump/winresdump/doc/pefile2.html
http://www.codeproject.com/KB/cs/IconLib.aspx
http://www.rohitab.com/discuss/index.php?showtopic=35282
http://www.codeguru.com/csharp/.net/net_general/graphics/article.php/c12787__2/
New PE format?
http://www.itee.uq.edu.au/~csmweb/decompilation/new_exe.html

efgee

  • Guest
Re: Resources
« Reply #4 on: January 04, 2011, 02:33:16 PM »
A while back I posted this: http://www.oxygenbasic.org/forum/index.php?topic=26.0

The CFF explorer helped me a lot in the past.

In the hex view (there are a lot of them hidden in CFF - just play around...) you can even select a portion of code and disassemble it and see the asm code.