Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[EO 3] [DX8] Graphics protection


Qazek
 Share

Recommended Posts

I found this on my cd ;_;

```

Option Explicit

'the following are for compression/decompression
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long)
Private Declare Function compress Lib "zlib.dll" (dest As Any, destLen As Any, src As Any, ByVal srcLen As Long) As Long
Private Declare Function compress2 Lib "zlib.dll" (dest As Any, destLen As Any, src As Any, ByVal srcLen As Long, ByVal level As Long) As Long
Private Declare Function uncompress Lib "zlib.dll" (dest As Any, destLen As Any, src As Any, ByVal srcLen As Long) As Long

'the following are for compression/decompression
Dim lngCompressedSize As Long
Dim lngDecompressedSize As Long

Public Enum CZErrors 'for compression/decompression
    Z_OK = 0
    Z_STREAM_END = 1
    Z_NEED_DICT = 2
    Z_ERRNO = -1
    Z_STREAM_ERROR = -2
    Z_DATA_ERROR = -3
    Z_MEM_ERROR = -4
    Z_BUF_ERROR = -5
    Z_VERSION_ERROR = -6
End Enum

Public Enum CompressionLevels 'for compression/decompression
    Z_NO_COMPRESSION = 0
    Z_BEST_SPEED = 1
    'note that levels 2-8 exist, too
    Z_BEST_COMPRESSION = 9
    Z_DEFAULT_COMPRESSION = -1
End Enum

Public Property Get ValueCompressedSize() As Long
    'size of an object after compression
    ValueCompressedSize = lngCompressedSize
End Property

Private Property Let ValueCompressedSize(ByVal New_ValueCompressedSize As Long)
    lngCompressedSize = New_ValueCompressedSize
End Property

Public Property Get ValueDecompressedSize() As Long
    'size of an object after decompression
    ValueDecompressedSize = lngDecompressedSize
End Property

Private Property Let ValueDecompressedSize(ByVal New_ValueDecompressedSize As Long)
    lngDecompressedSize = New_ValueDecompressedSize
End Property

Public Function CompressByteArray(TheData() As Byte, CompressionLevel As Integer) As Long
'compress a byte array
Dim lngResult As Long
Dim lngBufferSize As Long
Dim arrByteArray() As Byte

    lngDecompressedSize = UBound(TheData) + 1

    'Allocate memory for byte array
    lngBufferSize = UBound(TheData) + 1
    lngBufferSize = lngBufferSize + (lngBufferSize * 0.01) + 12
    ReDim arrByteArray(lngBufferSize)

    'Compress byte array (data)
    lngResult = compress2(arrByteArray(0), lngBufferSize, TheData(0), UBound(TheData) + 1, CompressionLevel)

    'Truncate to compressed size
    ReDim Preserve TheData(lngBufferSize - 1)
    CopyMemory TheData(0), arrByteArray(0), lngBufferSize

    'Set property
    lngCompressedSize = UBound(TheData) + 1

    'return error code (if any)
    CompressByteArray = lngResult

End Function

Public Function CompressString(Text As String, CompressionLevel As Integer) As Long
'compress a string
Dim lngOrgSize As Long
Dim lngReturnValue As Long
Dim lngCmpSize As Long
Dim strTBuff As String

    ValueDecompressedSize = Len(Text)

    'Allocate string space for the buffers
    lngOrgSize = Len(Text)
    strTBuff = String(lngOrgSize + (lngOrgSize * 0.01) + 12, 0)
    lngCmpSize = Len(strTBuff)

    'Compress string (temporary string buffer) data
    lngReturnValue = compress2(ByVal strTBuff, lngCmpSize, ByVal Text, Len(Text), CompressionLevel)

    'Crop the string and set it to the actual string.
    Text = Left$(strTBuff, lngCmpSize)

    'Set compressed size of string.
    ValueCompressedSize = lngCmpSize

    'Cleanup
    strTBuff = ""

    'return error code (if any)
    CompressString = lngReturnValue

End Function

Public Function DecompressByteArray(TheData() As Byte, OriginalSize As Long) As Long
'decompress a byte array
Dim lngResult As Long
Dim lngBufferSize As Long
Dim arrByteArray() As Byte

    lngDecompressedSize = OriginalSize
    lngCompressedSize = UBound(TheData) + 1

    'Allocate memory for byte array
    lngBufferSize = OriginalSize
    lngBufferSize = lngBufferSize + (lngBufferSize * 0.01) + 12
    ReDim arrByteArray(lngBufferSize)

    'Decompress data
    lngResult = uncompress(arrByteArray(0), lngBufferSize, TheData(0), UBound(TheData) + 1)

    'Truncate buffer to compressed size
    ReDim Preserve TheData(lngBufferSize - 1)
    CopyMemory TheData(0), arrByteArray(0), lngBufferSize

    'return error code (if any)
    DecompressByteArray = lngResult

End Function

Public Function DecompressString(Text As String, OriginalSize As Long) As Long
'decompress a string
Dim lngResult As Long
Dim lngCmpSize As Long
Dim strTBuff As String

    'Allocate string space
    strTBuff = String(ValueDecompressedSize + (ValueDecompressedSize * 0.01) + 12, 0)
    lngCmpSize = Len(strTBuff)

    ValueDecompressedSize = OriginalSize

    'Decompress
    lngResult = uncompress(ByVal strTBuff, lngCmpSize, ByVal Text, Len(Text))

    'Make string the size of the uncompressed string
    Text = Left$(strTBuff, lngCmpSize)

    ValueCompressedSize = lngCmpSize

    'return error code (if any)
    DecompressString = lngResult

End Function
Public Function CompressFile(FilePathIn As String, FilePathOut As String, CompressionLevel As Integer) As Long
'compress a file
Dim intNextFreeFile As Integer
Dim TheBytes() As Byte
Dim lngResult As Long
Dim lngFileLen As Long

    ' Along the way, we are gonna make it look professional and infom the user
    ' Of the programs actions
    lngFileLen = FileLen(FilePathIn)

    'allocate byte array
    ReDim TheBytes(lngFileLen - 1)

    'read byte array from file
    Close #10
    intNextFreeFile = FreeFile '10 'FreeFile
    Open FilePathIn For Binary Access Read As #intNextFreeFile
        Get #intNextFreeFile, , TheBytes()
    Close #intNextFreeFile

    'compress byte array
    lngResult = CompressByteArray(TheBytes(), CompressionLevel)

    'kill any file in place
    On Error Resume Next
    Kill FilePathOut
    On Error GoTo 0

    'Write it out
    intNextFreeFile = FreeFile
    Open FilePathOut For Binary Access Write As #intNextFreeFile
        Put #intNextFreeFile, , lngFileLen 'must store the length of the original file
        Put #intNextFreeFile, , TheBytes()
    Close #intNextFreeFile

    Erase TheBytes
    CompressFile = lngResult
End Function

Public Function DecompressFile(FilePathIn As String, FilePathOut As String) As Long
'decompress a file
Dim intNextFreeFile As Integer
Dim TheBytes() As Byte
Dim lngResult As Long
Dim lngFileLen As Long

    'allocate byte array
    ReDim TheBytes(FileLen(FilePathIn) - 1)

    'read byte array from file
    intNextFreeFile = FreeFile
    Open FilePathIn For Binary Access Read As #intNextFreeFile
        Get #intNextFreeFile, , lngFileLen 'the original (uncompressed) file's length
        Get #intNextFreeFile, , TheBytes()
    Close #intNextFreeFile

    'decompress
    lngResult = DecompressByteArray(TheBytes(), lngFileLen)

    'kill any file already there
    On Error Resume Next
    Kill FilePathOut
    On Error GoTo 0

    'Write it out
    intNextFreeFile = FreeFile
    Open FilePathOut For Binary Access Write As #intNextFreeFile
        Put #intNextFreeFile, , TheBytes()
    Close #intNextFreeFile

    Erase TheBytes
    DecompressFile = lngResult

End Function
```

And it works perfectly, but if anyone knows that algoritm, then he could easily decompress files.
Link to comment
Share on other sites

I don't think that saying copyright your graphics solves anything. Everything done is copyrighted.

If you want artists to work for you, you're going to have some sort of prevention method from easily stealing the art.

Just as your composers would like you to protect their music and your programmers wouldn't like you handing out the source code with every client.

Not everyone wants to have an open source game, and if you have to work on a game, you'd at least want the option.
Link to comment
Share on other sites

The problem is the ease of accessing full sprite sheets that can be easily put into an open source engine.

It's the same thing as someone having access to your programmer's coding and easily taking original systems like your guild system straight into their engine.
Link to comment
Share on other sites

Yeah, I understand that, but as I said, I don't think you can protect against print screen, and that's and easy steal, I understand why this question is being asked, but I'm not sure you can fix it. Though, I think I remember seeing in some program once that when you used print screen, it just gave you a black or gray image over the area. I guess you could try that, maybe code something into the source for if Prnt Scrn is pressed and try to encode your images, but I'm pretty sure that's all you can do.
Link to comment
Share on other sites

umm yes you can control the print screen.. that is simply the clipboard. and if you clear the clipboard in a timer or loop while the programs open it will not work. and to be honest suing cost money, so unless you have money to put out first, you will have an uphill battle. you could also put the graphics inside a Resource file in vb6 and call it from there if you really wanted to protect it.
Link to comment
Share on other sites

> umm yes you can control the print screen.. that is simply the clipboard. and if you clear the clipboard in a timer or loop while the programs open it will not work. and to be honest suing cost money, so unless you have money to put out first, you will have an uphill battle. you could also put the graphics inside a Resource file in vb6 and call it from there if you really wanted to protect it.

Instead of a loop just check for when the **PrtScr** key is pressed and then clear the clipboard. Resource files are a bad idea. First of all, resource files are compiled within the **.EXE** and if a resource file is massive you're just going to bloat the **.EXE**. Second of all, the resources within the resource file can be extracted.

I would just grab an encryption algorithm, load a graphic file into a byte array, encrypt the byte array and then dump the byte array in a binary file. So load **test.PNG** into byte array, encrypt byte array and then dump byte array into **test.DAT**. After you've done that for all graphic files you can then delete all the graphic files and you'll be left with **.DAT** files.

Then at runtime or whatever just load the **.DAT** files, decrypt them and then you could use the **CreateTextureFromFileInMemoryEx** function to allow DirectX 8 to use them. I imagine that it would be possible to extract the decrypted files from memory but that is going to be hard and this method will thwart most people.
Link to comment
Share on other sites

> Yeah, I understand that, but as I said, I don't think you can protect against print screen, and that's and easy steal, I understand why this question is being asked, but I'm not sure you can fix it. Though, I think I remember seeing in some program once that when you used print screen, it just gave you a black or gray image over the area. I guess you could try that, maybe code something into the source for if Prnt Scrn is pressed and try to encode your images, but I'm pretty sure that's all you can do.

It's a lot easier to sue someone who steals graphics and music that are encrypted.
Link to comment
Share on other sites

> First of all, resource files are compiled within the **.EXE**

Actually they aren't. VB6 .res files can stand independent of the .exe

> i have a custom encryption engine for dx8 in fact the only one that does not lose transparentcy from .pngs.

What do you mean not lose transparency? I've created and encrypter for Both Nin and another game and they don't lose transparency.
Link to comment
Share on other sites

> You guys are no better than companies like EA that put users through hell in order to protect their assets. I mean, blocking print screen! Are you kidding me???
>
>  
>
> I despise you.
>
>  
>
> inb4warning

Hey, we're just giving him suggestions, I couldn't care less if someone uses graphics, means they were good ones, I'd rather be asked but seeing how much stuff I "buy", I'm not one to hold an opinion, I'm just telling him how he can set this up, and making Prnt Scrn clear the clip board is just cruel. If you can make it so that the client is blocked out when it is pressed then that would be best.
Link to comment
Share on other sites

> Hey, we're just giving him suggestions, I couldn't care less if someone uses graphics, means they were good ones, I'd rather be asked but seeing how much stuff I "buy", I'm not one to hold an opinion, I'm just telling him how he can set this up, and making Prnt Scrn clear the clip board is just cruel. If you can make it so that the client is blocked out when it is pressed then that would be best.

Why go to such great lengths to protect the graphics? I mean, isn't it a sign of success to have others use your work, even if they do not have the rightful permission to do so? I don't believe having your graphics stolen would in any way, shape, or form damage the success of your title; I mean, could someone who cannot create graphical work of their own really compete with what your original product has to offer?

Any attempt to secure digital work is futile. Software has already sustained enough damage from DRM employed by large corporations, and it truly saddens me that the indie community seems to be set on employing the same destructive tactics wherever possible. This is the stuff that makes people hate companies like Electronic Arts. Unfortunately, unlike large corporations, independent developers do not have the vast resources to hide the scars caused by these sort of things. 

OP, do not waste your time on this. Accept that people may want to use your work, and shun those who do use your work without your permission; however, don't make others suffer. Don't allow the majority to suffer due to the actions of a few bad apples.
Link to comment
Share on other sites

Blocking print screen is not good xD

But look at the code, here is Compressing file:

```

Public Function CompressFile(FilePathIn As String, FilePathOut As String, CompressionLevel As Integer) As Long
'compress a file
Dim intNextFreeFile As Integer
Dim TheBytes() As Byte
Dim lngResult As Long
Dim lngFileLen As Long

    ' Along the way, we are gonna make it look professional and infom the user
    ' Of the programs actions
    lngFileLen = FileLen(FilePathIn)

    'allocate byte array
    ReDim TheBytes(lngFileLen - 1)

    'read byte array from file
    Close #10
    intNextFreeFile = FreeFile '10 'FreeFile
    Open FilePathIn For Binary Access Read As #intNextFreeFile
        Get #intNextFreeFile, , TheBytes()
    Close #intNextFreeFile

    'compress byte array
    lngResult = CompressByteArray(TheBytes(), CompressionLevel)

    'kill any file in place
    On Error Resume Next
    Kill FilePathOut
    On Error GoTo 0

    'Write it out
    intNextFreeFile = FreeFile
    Open FilePathOut For Binary Access Write As #intNextFreeFile
        Put #intNextFreeFile, , lngFileLen 'must store the length of the original file
        Put #intNextFreeFile, , TheBytes()
    Close #intNextFreeFile

    Erase TheBytes
    CompressFile = lngResult
End Function
```
And it works with EO and DX8 (tested), but only what I want is to change anything in this function to make my files more difficult to decompress using DecompressFile function. I never worked on a files like that so it's new experience for me ^^
Link to comment
Share on other sites

Just because it's possible to steal art, doesn't mean you make it easy.

Most of the people who would steal your art, couldn't make a game even if they wanted to.

You make it hard as an assurance to your artists that their work will not be released into the public domain the moment you release the game.

Imagine you're a programmer and the moment you release the first alpha of your brand new game, some guy takes your source code and makes another game project stemming from your code.
Link to comment
Share on other sites

> Just because it's possible to steal art, doesn't mean you make it easy.
>
> Most of the people who would steal your art, couldn't make a game even if they wanted to.
>
> You make it hard as an assurance to your artists that their work will not be released into the public domain the moment you release the game.
>
> Imagine you're a programmer and the moment you release the first alpha of your brand new game, some guy takes your source code and makes another game project stemming from your code.

And by making it difficult, which has clearly been proven to be futile by the attempts of many large AAA developers, you usually hinder the user's experience. I believe that you defeated your own argument in your second sentence; as I've stated before, any person that must resort to stealing art either wants something to use as a placeholder or is all-round incompetent and not a threat to your production.

The same goes with programming; the most we can ever do is obfuscate the code if it's an interpreted language; if it's a compiled language, we can only hope that the person doesn't take the time to study the machine code in order to make a replication.

Any artist that needs assurance that their work will not be released into the public domain needs to learn about licensing, and any artist that needs assurance that their work will not be leaked or used illegally needs a mental institution.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...