RE: [DUG]:changing compile conditions at runtime...

2002-12-05 Thread Conor Boyd
Hi Chris,

My initial thought is that this is something that needs embedded into the
functionality of your program rather than a compile time issue.  Security is
really something that should be addressed as a constituent part of your
design from the start...

However, one relatively quick workaround if you don't want to revisit your
design would be to do the following:

Compile the two versions of your application (with the different compile
conditions) into 2 separate executables.  These executables should not run
unless a particular 'code' (known only to you as a developer) is passed as a
command line parameter.

Create a 'launcher' executable, which is responsible for asking the user for
the passcode.  Your launcher should use this passcode to determine the
correct code to pass on the command line that it then uses to launch one of
your two existing executables via CreateProcess or ShellExecute.

You can make your security check (i.e. the code you pass on the command
line) as complicated as you like, I suppose; ultimately, it depends on how
determined your users are likely to be in terms of trying to get around your
restrictions.

Hope this makes sense.  Any questions, drop me a line.

Cheers,

Conor

-Original Message-
From: Chris Veale [mailto:[EMAIL PROTECTED]]

I want to implement something like a passcode that when entered allows the
user to do something different than a user without that passcode.  I have
all the functionality already in the code with compile conditions but from
all the help Ive looked through, I cant change this on the fly - it takes a
full recompile.

Is there any way of allowing this change at runtime using compile conditions
or am I going to have to rebuild the functionality with if statements?
---
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of unsubscribe delphi
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/



RE: [DUG]:changing compile conditions at runtime...

2002-12-05 Thread Conor Boyd
Actually, you could look at doing something with Delphi packages, although I
haven't tried anything like that myself, so I don't know how feasible it
would be.

Create two runtime packages with your different compiled functionality.

Your simple launcher exe might then be able to choose which package to load
based on the passcode.

Like I said, no idea how feasible or easy to implement, that would be, but
if it was, it would mean that you then still only have one executable.

HTH,

Conor

-Original Message-
From: Conor Boyd [mailto:[EMAIL PROTECTED]]

[snip]

Compile the two versions of your application (with the different compile
conditions) into 2 separate executables.  These executables should not run
unless a particular 'code' (known only to you as a developer) is passed as a
command line parameter.

Create a 'launcher' executable, which is responsible for asking the user for
the passcode.  Your launcher should use this passcode to determine the
correct code to pass on the command line that it then uses to launch one of
your two existing executables via CreateProcess or ShellExecute.

[snip]
---
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of unsubscribe delphi
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/



Re: [DUG]:changing compile conditions at runtime...

2002-12-05 Thread Corey Murtagh
- Original Message -
From: Chris Veale [EMAIL PROTECTED]
Sent: Friday, December 06, 2002 11:33 AM
Subject: [DUG]:changing compile conditions at runtime...


 Hi

 I want to implement something like a passcode that when entered allows the
 user to do something different than a user without that passcode.  I have
 all the functionality already in the code with compile conditions but from
 all the help Ive looked through, I cant change this on the fly - it takes
a
 full recompile.

 Is there any way of allowing this change at runtime using compile
conditions
 or am I going to have to rebuild the functionality with if statements?

The compile-time conditions alter the code that is produced, so any
condition that isn't met effectively comments out the code it encloses.  If
you want to offer variable functionality dependant on a code, user level,
etc. then you'll have to write the logic for it into your code.

How to go about it depends on a variety of things, including how much
difference there is between one level and another.  If you have only two
states that differ only in a few lines of code, then a conditional statement
is probably sufficient.  For a more complex difference (additions to the
interface, completely new functionality, etc), and if you use a reasonably
OO design, you could derive a higher-functionality object from the standard
interface, add whatever you need, then instanciate the one that fits the
current user level.

Remember KISS though.  If you don't need to change much, do it the simplest
way you can - which usually means conditionals in your code.

Final thought: if you want the REALLY complex way, how about implementing
the enhanced functionality in a BPL, and only distribute that to people who
need it.  Same as deriving from a common object, but with added security in
that people who don't have the BPL can't get access to the extra functions,
no matter how they try to hack the program.

--
Corey Murtagh
The Electric Monk
Quidquid latine dictum sit, altum viditur.

---
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of unsubscribe delphi
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/