Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (540)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (603)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Tool to inject data into class files  (Read 5576 times)
0 Members and 1 Guest are viewing this topic.
Offline moogie

JGO Ninja


Medals: 15
Projects: 6
Exp: 10 years


Java games rock!


« Posted 2007-12-10 01: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

Java4k RIP 2014
Offline tom
« Reply #1 - Posted 2007-12-10 07:34:30 »

Thanks!!!

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

Offline moogie

JGO Ninja


Medals: 15
Projects: 6
Exp: 10 years


Java games rock!


« Reply #2 - Posted 2007-12-10 08:28:12 »

glad it helped Smiley

Java4k RIP 2014
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline moogie

JGO Ninja


Medals: 15
Projects: 6
Exp: 10 years


Java games rock!


« Reply #3 - Posted 2007-12-10 20: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.


Java4k RIP 2014
Offline Morre

JGO Knight


Medals: 2
Projects: 10


I'm Dragonene on IRC.


« Reply #4 - Posted 2007-12-18 22: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 Ninja


Medals: 15
Projects: 6
Exp: 10 years


Java games rock!


« Reply #5 - Posted 2007-12-19 01: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.

Java4k RIP 2014
Offline Morre

JGO Knight


Medals: 2
Projects: 10


I'm Dragonene on IRC.


« Reply #6 - Posted 2007-12-19 09:33:08 »

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

Offline moogie

JGO Ninja


Medals: 15
Projects: 6
Exp: 10 years


Java games rock!


« Reply #7 - Posted 2007-12-19 09: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.


Java4k RIP 2014
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Mr.CodeIt (20 views)
2014-12-23 03:34:11

rwatson462 (53 views)
2014-12-15 09:26:44

Mr.CodeIt (45 views)
2014-12-14 19:50:38

BurntPizza (83 views)
2014-12-09 22:41:13

BurntPizza (110 views)
2014-12-08 04:46:31

JscottyBieshaar (78 views)
2014-12-05 12:39:02

SHC (89 views)
2014-12-03 16:27:13

CopyableCougar4 (93 views)
2014-11-29 21:32:03

toopeicgaming1999 (155 views)
2014-11-26 15:22:04

toopeicgaming1999 (151 views)
2014-11-26 15:20:36
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!