RunProgram Pass Parameter

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by LJ.

Being that the baggage is so low on a PureBasic .exe, I'm thinking about creating the program in module form with a seperate .exe for certain sections. What I don't want customers doing is distributing the seperate .exe's from the main program.

While I can't TOTALLY prevent this, especially from the savy hacker, a minimum amount of security will discourage enough from doing this.

What I'd like to do is to pass a password parameter with the RunProgram command. Something like:

RunProgram("chapter1.exe", "64gf9g7")

Now, inside of the chapter1.exe file, I'd like it to be able to say if I don't get the password parameter of 64gf9g7, I'm going to just end the program.

Is this possible?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.

Code: Select all

If ProgramParameter()  "64gf9g7"
  End
EndIf
I hope this helps..
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by LJ.

You bet that helps! Thank you Fred.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Eikeland.

Hi,

Just be carefull when you use strings like this, the first thing a hacker does is read all the static strings in your compiled code.

Eg. compile the code from Fred, and just open the exe in notepad or another tool and you see the "cryptic" 64gf9g7 right away.

Anyway, I early learned my lession after a few small games a wrote in the "old days" was hacked to fast. LOL

Fred, is it anyway you could "encrypt" the string's in a future version of PB? But I guess this of course would slow the program some....

Richard
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

> Just be carefull when you use strings like this, the first thing a hacker does is read
> all the static strings in your compiled code.

True.

> Fred, is it anyway you could "encrypt" the string's in a future version of PB? But I
> guess this of course would slow the program some....

Definitely would slow it and add bloat to it. To encrypt a string in your exe, just
code it like so:

Code: Select all

If ProgramParameter()  "6"+"4"+"g"+"f"+"9"+"g"+"7"
  End
EndIf
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.

Hehe, PureBasic is smart enough to combin them into one string :). Even the Chr(65)+Chr(66)... won't work. That's the joice of optimizations...

You can do something like that tough:

c6 = chr('6')
c4 = chr('4')

and more..

Fred - AlphaSND
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

> Hehe, PureBasic is smart enough to combin them into one string :).

Hmm, you're right! :cry: Older versions of PureBasic didn't, though.

Thus, the following code will NOT been seen with a hex editor in a v3.62 exe:

Code: Select all

a$=Chr('n')+Chr('o')+Chr('t')+Chr(' ')+Chr('s')+Chr('e')+Chr('e')+Chr('n')
MessageRequester("test",a$,0)
Thanks for the updated tip, Fred. BTW, what does the apostrophe thing do,
anyway? I always assumed it was just an alternate symbol for a constant?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by LJ.


Thanks guys. I'm not too much into preventing hacking. After I had a friend who broke an encryption scheme with SoftIce that protected $5,000 worth of software, I said forget it. If Microsoft can't stop it, I certainly can't.

But what I did want to do is discourage the average user. My customer base doesn't really care a whole lot about computers as a whole. They want to use my software as means to their own non-computer based end. I've done some studying of the subject and have concluded that about 98% of my customers don't know what a hex editor even is, let alone to use one. But to not even take a simple step to discourage the breakup and distribution of the seperate .exe's, when I can discourage 98% of my customers from doing simply by passing a program parameter with 3 lines of code would be a little calus on my part.

It's important to keep a healthy perspective and to not let paranoia get the better of you. The rule is that most computer users are not out to hack your software, especially if you deal in the market of non-computer oriented people like I do; however, expert computer users like purchasers of Pure Basic, now they are very dangerous :evil: Just kidding.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by plouf.
Thanks for the updated tip, Fred. BTW, what does the apostrophe thing do,
anyway? I always assumed it was just an alternate symbol for a constant?
it does return the ASCII numbe of the specified letter
so 'A' will return 65 'a' 97 and so on..

Christos
Post Reply