Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (487)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (552)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2
  ignore  |  Print  
  .dll  (Read 4841 times)
0 Members and 1 Guest are viewing this topic.
Offline ENC

Junior Member





« Posted 2006-04-18 14:49:18 »

Hi I would like to know if it is possible to use java to create files of extensions .dll

and storing images ?  Huh

Cause I want to protect my images but yet to need to use it in the game i am creating... is it possible by any chance?

or is there other methods ?  Grin

Cheers!  Smiley
Offline Kova

Senior Member





« Reply #1 - Posted 2006-04-18 14:58:36 »

Hi I would like to know if it is possible to use java to create files of extensions .dll
and storing images ?  Huh

Sure it's possible... heck, you can even create .exe, .com files also, just they won't work as user expects  Grin

Cause I want to protect my images but yet to need to use it in the game i am creating... is it possible by any chance?
or is there other methods ?  Grin

other then JARs I don't know. Maybe you can put all image data into array in the class itself and load it that way... source code would look horrible Smiley
Maybe puting all images into a single file and then grabing them out one by one as raw data... of course then load that data as image or something.
Offline ENC

Junior Member





« Reply #2 - Posted 2006-04-18 15:42:18 »

oh? so we are able to create a .dll file with java? but according to what you say...  using codes.. is it possible?  as in it can really work..

cause i have seen some .dll files contain images and it is deeply compares which saves on the disk space..

but if i am not wrong the extraction process is also fast according to the remainding RAM left for usage...

so other than JAR files there is not other way??

Can any one else suggest other methods if any?

THANKS !  Grin Grin Grin Grin Grin Grin

Cheers.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Kova

Senior Member





« Reply #3 - Posted 2006-04-18 15:56:43 »

Actually I don't know a thing about dlls, I just ironicly staded you can create file with any name you like and put data (image) in it. I'm not sure about image data in array from start, other guys will need to help you on this.
Offline cylab

JGO Ninja


Medals: 43



« Reply #4 - Posted 2006-04-18 16:37:23 »

You could encrypt your images and load them via a FilterInputStream.

Write a tool to create encrypted files using the following FilterOutputStream:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
public class ObfuscatedOutputStream extends FilterOutputStream
{
   // This is the encryption "password".
  private static final byte[] keyBytes= new byte[]{ 104, 22, -95, -63, 59, 100, 49, -101};
   public static final int DECRYPT_MODE= Cipher.DECRYPT_MODE;
   public static final int ENCRYPT_MODE= Cipher.ENCRYPT_MODE;
   private static final String algorithm="DES";

   public ObfuscatedOutputStream(OutputStream outputStream)
   {
      this(outputStream,Cipher.ENCRYPT_MODE);
   }

   public ObfuscatedOutputStream(OutputStream outputStream, int cipherMode)
   {
      super(new CipherOutputStream(outputStream,getCipher(cipherMode)));
   }

   private static Cipher getCipher(int cipherMode)
   {
      Cipher cipher;
      SecretKey key= new SecretKeySpec(keyBytes,algorithm);
      try
      {
         cipher= Cipher.getInstance(algorithm);
         cipher.init(cipherMode,key);
      }
      catch (Throwable t)
      {
         throw new RuntimeException("Could not initialize ObfuscatedInputStream!",t);
      }
      return cipher;
   }
}


And wrap the following FilterInputStream around the InputStream to read your Image:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
public class ObfuscatedInputStream extends FilterInputStream
{
   // This is the encryption "password".
  private static final byte[] keyBytes= new byte[]{ 104, 22, -95, -63, 59, 100, 49, -101};
   public static final int DECRYPT_MODE= Cipher.DECRYPT_MODE;
   public static final int ENCRYPT_MODE= Cipher.ENCRYPT_MODE;
   private static final String algorithm="DES";

   public ObfuscatedInputStream(InputStream inputStream)
   {
      this(inputStream,Cipher.DECRYPT_MODE);
   }

   public ObfuscatedInputStream(InputStream inputStream, int cipherMode)
   {
      super(new CipherInputStream(inputStream,getCipher(cipherMode)));
   }

   private static Cipher getCipher(int cipherMode)
   {
      Cipher cipher;
      SecretKey key= new SecretKeySpec(keyBytes,algorithm);
      try
      {
         cipher= Cipher.getInstance(algorithm);
         cipher.init(cipherMode,key);
      }
      catch (Throwable t)
      {
         throw new RuntimeException("Could not initialize ObfuscatedInputStream!",t);
      }
      return cipher;
   }
}


NOTE You should change the keyBytes byte sequence before using it, since this is the encryption password Smiley
You might have to optimize the above like caching the cipher to gain some performance.

Mathias - I Know What [you] Did Last Summer!
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #5 - Posted 2006-04-18 17:07:08 »

You could encrypt your images and load them via a FilterInputStream.

Except that I could easily inject my own class into the classloader and intercept all the data after you've decrypted it for me. Or I could just hook into the OpenGL dlls and extract the image data as you pass it in. Or I could just use print screen.

If it's on the client then it's insecure. You just have to live with that.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline cylab

JGO Ninja


Medals: 43



« Reply #6 - Posted 2006-04-18 17:23:24 »

1  
If it's on the client then it's insecure. You just have to live with that.

Could not argue with that Wink
All you can do is to prevent "normal" users from copying the images. If someone has a little technical knowledge and the will to extract your coprighted data, there is nothing you can do.

Mathias - I Know What [you] Did Last Summer!
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #7 - Posted 2006-04-18 17:25:33 »

1  
If it's on the client then it's insecure. You just have to live with that.

All you can do is to prevent "normal" users from copying the images. If someone has a little technical knowledge and the will to extract your coprighted data, there is nothing you can do.

In which case the easiest way is to just change the file extension.  Grin

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline cylab

JGO Ninja


Medals: 43



« Reply #8 - Posted 2006-04-18 18:16:02 »

Quote
In which case the easiest way is to just change the file extension.  Grin
Naaah... There are some more types of users between DAUs and powerusers (a DAU is a german abbrevation for "Dümmster Anzunehmender User" - "dumbest user in existance" Wink)

Mathias - I Know What [you] Did Last Summer!
Offline Jeff

JGO Coder




Got any cats?


« Reply #9 - Posted 2006-04-18 20:02:01 »

A DLL is a dynamic link library.  Which is tol say a peice of code that can be loaded bythe program at run-time.

Java loads ALL its code at run-time so DLL files are not necessary. In essance, every .class file is a Java DLL.

What this has to do with your image data though I haven't a clue.

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #10 - Posted 2006-04-19 03:28:40 »

1  
If it's on the client then it's insecure. You just have to live with that.

All you can do is to prevent "normal" users from copying the images. If someone has a little technical knowledge and the will to extract your coprighted data, there is nothing you can do.

In which case the easiest way is to just change the file extension.  Grin

Ye, change the extension. ImageIO for example uses the header to determine the format. Use the class extension for irritation or something like "spr" for making it look like a custom format.

弾幕 ☆ @mahonnaiseblog
Offline noblemaster

JGO Ninja


Medals: 20
Projects: 10


Age of Conquest makes your day!


« Reply #11 - Posted 2006-04-19 04:03:15 »

But then somebody could just simply take a screenshot and use the image anyway? Still hard, but not impossible.

Offline Mr_Light

Senior Member




shiny.


« Reply #12 - Posted 2006-04-19 12:12:09 »

anyone looked at System.loadLibrary() yet?

It's harder to read code than to write it. - it's even harder to write readable code.

The gospel of brother Riven: "The guarantee that all bugs are in *your* code is worth gold." Amen brother a-m-e-n.
Offline woogley
« Reply #13 - Posted 2006-04-19 12:20:01 »

kingaschi is right, it doesn't matter how you encrypt it, because it's all just raw image data by the time it hits the screen.

same reason why iTunes (for the few who legally obtain music) can't limit your music to one computer, because, by the time it hits your speakers... it's sound, and VERY recordable from the line out port Tongue

anyway, what I've done before [when I used to care about my image data] is create a file that has the EXTENSION of .dll but isn't really a .dll. I was just using ZipOutputStream to shove all my images to one zip file [but it wasn't .zip, it was just .dll]. So, to a newbie who doesn't know how a normal DLL looks on the inside, this worked fine. But to all of us who happen to know that all zip file data starts with "PK"... it's just a matter of renaming that file to .zip and ta-da.
Offline cylab

JGO Ninja


Medals: 43



« Reply #14 - Posted 2006-04-19 12:43:17 »

Quote
But to all of us who happen to know that all zip file data starts with "PK"... it's just a matter of renaming that file to .zip and ta-da.
That's where encrypting the content helps to some degree. You can't prevent your images from being stolen by criminals, but you can reduce the amount of users capable to do it:

Using unencrypted images with correct suffixes: everyone can steel it
Changing the the suffix: everyone that is courious enough can steel it (Just drag and drop to a capable image viewer)
Using an archive and change the suffix: everyone knowing about archives and hex-editors can steel it
Using encrypted images: the user must at least know about java, processes, classloaders and jad to steal it

I have not listed an encrypted archive, because ZipInputStream generates temporary files afaik.

As pointed ot before, there is always the possibility to steel images directly from screen by just taking a screenshot. This might be a smaller problem, since you can't "bulk-steel", cause one is limited to a single image per screenshot.

There might also be the possibility to steel images with a memory exploration tool.

As a rule of thumb, just protect your data to a degree, where the effort to steel it rises to a degree that enough of your target audience will lose interest to do so. What this means depends on you and your target audience.

The last and probably best option might be just to trust them Wink

Mathias - I Know What [you] Did Last Summer!
Offline ENC

Junior Member





« Reply #15 - Posted 2006-04-19 13:43:29 »

Heys... Thanks alot people!!!  Grin

Your information really help me alot.. i learnt something...  Wink

Thanks Kova, cylab and the rest!!!  Lips Sealed

Cheers!
Offline Ask_Hjorth_Larsen

Junior Member




Java games rock!


« Reply #16 - Posted 2006-04-19 19:03:26 »

1  
But then somebody could just simply take a screenshot and use the image anyway? Still hard, but not impossible.


Actually there are situations where normal screen shots will fail, believe it or not. Some media players will direct stuff through some hardware pipe or something (I presume), and the image information will not be inside the memory which the screenshot copies (this, of course, depends on how 'close' to the screen that memory buffer resides). This is sometimes a pain in the butt when trying to display movies on an external screen. One 'fix' I usually apply is to start TWO instances of media players, of which the first one will use the hardware piping thingy (or whatever it is), and the second will display properly Smiley
Offline Kova

Senior Member





« Reply #17 - Posted 2006-04-20 00:40:19 »

I doubt that.. you have a link to article or some info we can google about?
I think screenshots take data directly from output of graphics card, the data that arrives in monitor. If it's like that it would be impossible to hide image from a screenshot.
Offline ryanm

Senior Member


Projects: 1
Exp: 15 years


Used to be bleb


« Reply #18 - Posted 2006-04-20 08:09:15 »

I've seen it happen: In my final year at university, one of the groups went to the trouble of making a 3D movie for their presentation. They distributed the 3D goggles, the expectation was palpable, and then the projector gave them a blank section of screen where their movie should have been  Undecided
Offline cylab

JGO Ninja


Medals: 43



« Reply #19 - Posted 2006-04-20 08:54:28 »

You can only screenshot image data that is displayed in the normal graphic memory of the video card (at least with the standard screenshot methods). If the media-player or game uses overlays, you will just capture the overlay color. It might be possible to implement a game using overlays to disable screenshot capability by rendering to a background buffer and blitting it to a window or the screen using overlay methods. But don't ask how Wink

Mathias - I Know What [you] Did Last Summer!
Offline harry@dayfamilyweb

Junior Member





« Reply #20 - Posted 2006-04-20 09:14:14 »

did you know jars are just .zip files with .jar at the end but the os treats them differently
if you want to see the contents of a jar rename it .zip
Offline Kova

Senior Member





« Reply #21 - Posted 2006-04-20 10:39:15 »

most arhive tools already know that and will open them if you try it...
Offline Ask_Hjorth_Larsen

Junior Member




Java games rock!


« Reply #22 - Posted 2006-04-20 16:14:37 »

Quote
I doubt that.. you have a link to article or some info we can google about?
I think screenshots take data directly from output of graphics card, the data that arrives in monitor. If it's like that it would be impossible to hide image from a screenshot.

My comments are based on the following observations:

First, I once wanted to take a screen shot from a file played in a media player, but all that was pasted was garbage in that particular area of the screen. Launching another media player (which was cumbersome because some applications prevent other instances of themselves to be started at the same time) solved the problem completely.

Second, one of my friends cannot watch video on the TV screen without launching two media players, presumably for the same reason. The first video player launched will show black only. This was observed for Windows Media Player and Media Player Classic.

Third, well, I have seen the problem multiple times, I don't remember all of them Smiley
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #23 - Posted 2006-04-20 16:29:43 »

Yeah, it's the use of hardware overlays. IIRC these only get used when the graphics card is doing video decoding (so you're not going to have this problem with a game) - it bypasses the actual framebuffer and gets composed right at the last minute.

Incidentally if you want to disable these overlays you can turn the 'graphics acceleration' slider in windows down. The lowest or second lowest does all of that in software so it'll screen capture just fine.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline woogley
« Reply #24 - Posted 2006-04-20 17:38:54 »

you can try this for an even weirder example. open up a movie in a media player [say, winamp], and perform a print screen. paste it into mspaint or whatever, BUT DONT STOP THE MOVIE. the area on the pasted image that came from the media player will continue to update, even though the rest of the image does not [like the clock will never change, for example]
Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #25 - Posted 2006-04-20 17:51:36 »

you can try this for an even weirder example. open up a movie in a media player [say, winamp], and perform a print screen. paste it into mspaint or whatever, BUT DONT STOP THE MOVIE. the area on the pasted image that came from the media player will continue to update, even though the rest of the image does not [like the clock will never change, for example]

sounds like that is a case of using a color mask for the overlay area.  Often a bright purple/pink.  The video card can use that colour to know where on the screen it should show the overlay buffer.  When you paste into paint you get that exact overlay mask colour in the paint image... if you save the bitmap it should show that colour.

Offline woogley
« Reply #26 - Posted 2006-04-20 18:09:35 »

actually, saving the bitmap has the exact same effect as pasting the bitmap into mspaint. even between different photo viewers, it was still playing the movie Wink

the mask seems to be a shade of black [after stopping the movie]

edit: when it comes to windows at least, the color (16,0,16) always shows the movie when played in winamp. even if this color is drawn by a java program .....
Offline Jeff

JGO Coder




Got any cats?


« Reply #27 - Posted 2006-04-20 18:17:36 »

Yeah, it's the use of hardware overlays. IIRC these only get used when the graphics card is doing video decoding (so you're not going to have this problem with a game) - it bypasses the actual framebuffer and gets composed right at the last minute.

The VERY first 3D cards (the early Vodoo cards) did this as well.


Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #28 - Posted 2006-04-20 19:42:15 »

Yeah, it's the use of hardware overlays. IIRC these only get used when the graphics card is doing video decoding (so you're not going to have this problem with a game) - it bypasses the actual framebuffer and gets composed right at the last minute.

The VERY first 3D cards (the early Vodoo cards) did this as well.



Ah yes, those odd pass-though vga cables that were such a pain to twist into the correct shape. I've still got a 12Mb voodoo 2 knocking around here somewhere...

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline Ask_Hjorth_Larsen

Junior Member




Java games rock!


« Reply #29 - Posted 2006-04-20 20:31:06 »

Quote
you can try this for an even weirder example. open up a movie in a media player [say, winamp], and perform a print screen. paste it into mspaint or whatever, BUT DONT STOP THE MOVIE. the area on the pasted image that came from the media player will continue to update, even though the rest of the image does not [like the clock will never change, for example]

When I first experienced that it was like seeing a pink elephant. Luckily there were a couple of other people present to confirm that I was not seeing things Smiley
Pages: [1] 2
  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.

CopyableCougar4 (23 views)
2014-08-22 19:31:30

atombrot (34 views)
2014-08-19 09:29:53

Tekkerue (30 views)
2014-08-16 06:45:27

Tekkerue (28 views)
2014-08-16 06:22:17

Tekkerue (18 views)
2014-08-16 06:20:21

Tekkerue (27 views)
2014-08-16 06:12:11

Rayexar (65 views)
2014-08-11 02:49:23

BurntPizza (41 views)
2014-08-09 21:09:32

BurntPizza (31 views)
2014-08-08 02:01:56

Norakomi (41 views)
2014-08-06 19:49:38
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

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!