Java-Gaming.org Java4K winners: [ by our judges | by the community ]         
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  Print  
  Tool to inject data into class files  (Read 3966 times)
0 Members and 1 Guest are viewing this topic.
Offline moogie

JGO Strike Force
***

Posts: 775
Medals: 5


Java games rock!


« on: 2007-12-09 20:05:10 »

Here is the tool i created for injecting byte data directly into the class file for my 2007 entry.

It reduces the overhead that embedding data as a Hexadecimal String in the source creates.

The tool creates a new Attribute in which the data is embedded. This Attribute is then injected at an valid point into the class file.

Feel free to use it or modify it just let me know if it is useful or if you make beneficial changes Smiley

http://www.cuteandcuddlypet.com.au/moogie/DataInjector.zip

http://unlimited.woogley.net/hosted/moogie/DataInjector.zip

p.s. the source is not very well commented, read at your own peril Tongue
Offline tom

JGO Neuromancer
****

Posts: 1113
Medals: 5



« Reply #1 on: 2007-12-10 02:34:30 »

Thanks!!!

This is great. Reduced the jar by over 50 bytes.

Offline moogie

JGO Strike Force
***

Posts: 775
Medals: 5


Java games rock!


« Reply #2 on: 2007-12-10 03:28:12 »

glad it helped Smiley
Games published by our own members! Go get 'em!
Offline moogie

JGO Strike Force
***

Posts: 775
Medals: 5


Java games rock!


« Reply #3 on: 2007-12-10 15:49:38 »

If the data you are injecting has some logically different components, e.g. different images, etc, then you might find by re-arranging the order of these data components may yield a few extra bytes.

Offline Morre

JGO Ninja
***

Posts: 507


I'm Dragonene on IRC.


« Reply #4 on: 2007-12-18 17:50:06 »

Tried, but to no avail. It never finds the || with the loop you provided in the readme. If changed to the actual two first characters it worked, dunno what's wrong.

Offline moogie

JGO Strike Force
***

Posts: 775
Medals: 5


Java games rock!


« Reply #5 on: 2007-12-18 20:42:07 »

Ah, i just realised that the magic symbols (i.e. ||) are actually part of the image data payload of the sprites i had embedded in my game last year!

So yes, currently you have to append || to the start of your data that you are embedding. Or you could change it to what ever you want... just make sure you change the code looking for the magic symbols.
Offline Morre

JGO Ninja
***

Posts: 507


I'm Dragonene on IRC.


« Reply #6 on: 2007-12-19 04:33:08 »

Problem is adding || makes java say the program's been altered :/

Offline moogie

JGO Strike Force
***

Posts: 775
Medals: 5


Java games rock!


« Reply #7 on: 2007-12-19 04:40:39 »

when you say add || where are you adding it to?

are you adding it as part of the data you are embedding or injecting it before embedding your data into the class file?

if you do the later then you will need to increase the size of the attribute payload by two to incorporate the two extra bytes. By adding it as part of the data you are going to embed, there is no need to increase the size of the attribute payload.

Pages: [1]
  Print  
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.108 seconds with 22 queries.