Use custom IFDEF so same project is full version and lite, is it possible?

Previous topic - Next topic

MrTAToad

You can also do :

?IF DEFINED(X) OR DEFINED(Y) AND ... etc

Hark0

Quote from: ampos on 2012-Apr-19
why not use a simple IF/THEM?

Code (glbasic) Select
IF demo=0
   debug "Not demo!"
ELSE
  debug "Demo!"
ENDIF


If you want to hide it a little (so it will not cracked), name DEMO to something else as DFWP at the start of your code:

Code (glbasic) Select
DFWP=SQR(4)-1

Notice that game code is not changed by pirates in iOS. They just patch the iOS routines that check validations. If huge games as Infinity Blade has not been altered to get unlimited money, I think your's will not be...

This idea not are very good for avoid cracking apps... the variable DEMO maybe are stored on any kind of file... the cracker can compare full/lite versions to find this file changed...

Right?
http://litiopixel.blogspot.com
litiopixel.blogspot.com - Desarrollo videojuegos Indie · Pixel-Art · Retroinformática · Electrónica Development Indie Videogames · Pixel-Art · Retrocomputing · Electronic

Hark0

For my game I think release two versions... one full... and other (lite) with many REMs for deactivate full features...
http://litiopixel.blogspot.com
litiopixel.blogspot.com - Desarrollo videojuegos Indie · Pixel-Art · Retroinformática · Electrónica Development Indie Videogames · Pixel-Art · Retrocomputing · Electronic

ampos

Quote from: Hark0 on 2012-Apr-20
Quote from: ampos on 2012-Apr-19
why not use a simple IF/THEM?

Code (glbasic) Select
IF demo=0
   debug "Not demo!"
ELSE
  debug "Demo!"
ENDIF


If you want to hide it a little (so it will not cracked), name DEMO to something else as DFWP at the start of your code:

Code (glbasic) Select
DFWP=SQR(4)-1

Notice that game code is not changed by pirates in iOS. They just patch the iOS routines that check validations. If huge games as Infinity Blade has not been altered to get unlimited money, I think your's will not be...

This idea not are very good for avoid cracking apps... the variable DEMO maybe are stored on any kind of file... the cracker can compare full/lite versions to find this file changed...

Right?

My idea is that if even Infinity Blade has not been cracked, will ours be? I doubt.
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

BdR

Quote from: ampos on 2012-Apr-19
why not use a simple IF/THEM?

Code (glbasic) Select
IF demo=0
   debug "Not demo!"
ELSE
  debug "Demo!"
ENDIF


If you want to hide it a little (so it will not cracked), name DEMO to something else as DFWP at the start of your code:

Code (glbasic) Select
DFWP=SQR(4)-1

Notice that game code is not changed by pirates in iOS. They just patch the iOS routines that check validations. If huge games as Infinity Blade has not been altered to get unlimited money, I think your's will not be...
You're right, it probably won't be cracked because finding the variable in the compiled binary is very hard. Btw, the variable names as you write them in GLB code are not included in the final binary. The compiler will convert them to memory addresses, so it doesn't really matter what you call them. Any potential hacker would have to decompile the binary and go through the compiler generated (=totally unreadable) code looking for some variable that *might*maybe* do something he wants.

However, you are basically using a variable as if it's a constant or a preprocessor define. So why not use a preprocessor define instead, as this is exactly what their purpose is for.

BdR

Quote from: Hark0 on 2012-Apr-20
For my game I think release two versions... one full... and other (lite) with many REMs for deactivate full features...

no, no, please.. do yourself a favor and see the opening post. If you use the preprocessor defines, you can use the same GLB project to maintain both the lite and full versions. At least for me this works perfectly.

Code (glbasic) Select

?DEFINE DEF_MAKE_LITE_VERSION

// .. code

?IFDEF DEF_MAKE_LITE_VERSION
  // display label "full version available"
  MyGameDisplayFullVersion()
?ELSE
  // full version feature
  MyGameOptionsScreen()
?ENDIF

Hark0

Quote from: BdR
You're right, it probably won't be cracked because finding the variable in the compiled binary is very hard. Btw, the variable names as you write them in GLB code are not included in the final binary. The compiler will convert them to memory addresses, so it doesn't really matter what you call them. Any potential hacker would have to decompile the binary and go through the compiler generated (=totally unreadable) code looking for some variable that *might*maybe* do something he wants.

Sorry... but.... How store the variable? Maybe in a file NOT in the "exe"...

If you compile FOR DEBUG... you have yet a Version "A"...

If you compile FOR RELEASE... you have ANOTHER version "B"...

Right?
http://litiopixel.blogspot.com
litiopixel.blogspot.com - Desarrollo videojuegos Indie · Pixel-Art · Retroinformática · Electrónica Development Indie Videogames · Pixel-Art · Retrocomputing · Electronic

Hark0

Quote from: BdR on 2012-Apr-20
Quote from: Hark0 on 2012-Apr-20
For my game I think release two versions... one full... and other (lite) with many REMs for deactivate full features...

no, no, please.. do yourself a favor and see the opening post. If you use the preprocessor defines, you can use the same GLB project to maintain both the lite and full versions. At least for me this works perfectly.

Code (glbasic) Select

?DEFINE DEF_MAKE_LITE_VERSION

// .. code

?IFDEF DEF_MAKE_LITE_VERSION
  // display label "full version available"
  MyGameDisplayFullVersion()
?ELSE
  // full version feature
  MyGameOptionsScreen()
?ENDIF


I have been readed but I no understand HOW the app knows where is his own state.  O_O

Can you explain-me?  :blink:
http://litiopixel.blogspot.com
litiopixel.blogspot.com - Desarrollo videojuegos Indie · Pixel-Art · Retroinformática · Electrónica Development Indie Videogames · Pixel-Art · Retrocomputing · Electronic

kanonet

They fantastic point ist, that ?IF / ?IFDEF is for precompiler, you can use it to automate kicking out some code from your project. If you want something not to be in your demo, just use this and it wount even get compiled! Thats why it cracker wont be able to hack it, cuz they cant hack what isnt in your binary.
And if you want to compile full version, just change the ?DEFINE and precompiler does all the work for you.

Its just awesome, isnt it? =D
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64


Hark0

http://litiopixel.blogspot.com
litiopixel.blogspot.com - Desarrollo videojuegos Indie · Pixel-Art · Retroinformática · Electrónica Development Indie Videogames · Pixel-Art · Retrocomputing · Electronic

BdR

Quote from: Hark0 on 2012-Apr-20
Sorry... but.... How store the variable? Maybe in a file NOT in the "exe"...
The way ampos does it, is that he "stores" the variable value by including a line of code that sets the variable, so for example the full version could works like this:
Code (glbasic) Select

Demo = 0

//..rest of code
IF (Demo = 0)
  // full version, allow user access to all 100 levels
ELSE
  // demo version, allow user access only to first 5 levels
ENDIF

And when you want to create the demo version, you only have to change one line and then you compile again, like this.
Code (glbasic) Select

Demo = 1
//..rest of code unchanged

Btw this is called a "hardcoded" value, because it's a value in the program, not a value read from an external data or settings file.

This way, the binary for the DEMO and FULL versions are almost identical, except for "Demo = 1" or "Demo = 0" line. So in theory, an evil hacker *could* try to find the byte in the binary that sets the 0 or 1, so he can change the DEMO app to FULL version. (although I think this is a lot of work and very difficult, so I doubt any hacker will even try it)

BdR

Quote from: Hark0 on 2012-Apr-20
I have been readed but I no understand HOW the app knows where is his own state.  O_O

Can you explain-me?  :blink:
It's not one app that knows a DEMO and a FULL state.. The DEMO app and FULL app are two separate apps.

You as the programmer decide to create/compile the DEMO or FULL version of the program. You do this by including or not including the DEFINE line before compiling to final executable. And then the compiler will include or exclude certain parts of the code (based on the ?IFDEF ?ELSE ?ENDIF commands) to create either the DEMO app or the FULL app.

So the binary for the DEMO only contains code for the demo version, and the binary for the FULL version only contains code for the full version. So in this case, an evil hacker cannot change the DEMO app to a FULL app.

Slydog

Here's a site that explains the purpose of these preprocessor commands, and their benefits:
(It is 'C++' based, but the concepts mostly apply to GLBasic too, which uses '?' instead of '#' as a prefix)

http://wiki.answers.com/Q/Explain_preprocessor_directives_in_c_plus_plus
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Hark0

Quote from: BdR on 2012-Apr-20
Quote from: Hark0 on 2012-Apr-20
Sorry... but.... How store the variable? Maybe in a file NOT in the "exe"...
The way ampos does it, is that he "stores" the variable value by including a line of code that sets the variable, so for example the full version could works like this:
Code (glbasic) Select

Demo = 0

//..rest of code
IF (Demo = 0)
  // full version, allow user access to all 100 levels
ELSE
  // demo version, allow user access only to first 5 levels
ENDIF

And when you want to create the demo version, you only have to change one line and then you compile again, like this.
Code (glbasic) Select

Demo = 1
//..rest of code unchanged

Btw this is called a "hardcoded" value, because it's a value in the program, not a value read from an external data or settings file.

This way, the binary for the DEMO and FULL versions are almost identical, except for "Demo = 1" or "Demo = 0" line. So in theory, an evil hacker *could* try to find the byte in the binary that sets the 0 or 1, so he can change the DEMO app to FULL version. (although I think this is a lot of work and very difficult, so I doubt any hacker will even try it)

AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH!

YES!!!! NOW YES!!!!

:good: :good:

(It's same my variable Idevice=true/false in my project for test paths.....  ;))
http://litiopixel.blogspot.com
litiopixel.blogspot.com - Desarrollo videojuegos Indie · Pixel-Art · Retroinformática · Electrónica Development Indie Videogames · Pixel-Art · Retrocomputing · Electronic