How to put commands at the beging of a allready existing exe

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
Evan
Coder
Posts: 21
Joined: Wed Dec 27, 2006 6:03 pm
Location: Weatherford TX

How to put commands at the beging of a allready existing exe

Post by Evan » Wed Dec 27, 2006 6:11 pm

How do you put commands at the beging of a allready existing exe file with qbasic?
Evan Hurd

moneo
Veteran
Posts: 451
Joined: Tue Jun 28, 2005 7:00 pm
Location: Mexico City, Mexico

Re: How to put commands at the beging of a allready existing

Post by moneo » Thu Dec 28, 2006 2:30 pm

Evan wrote:How do you put commands at the beging of a allready existing exe file with qbasic?
First of all, you can't modify an existing exe file unless you know assembler well and know how to use Debug.

What are you trying to do?

*****

Evan
Coder
Posts: 21
Joined: Wed Dec 27, 2006 6:03 pm
Location: Weatherford TX

Re: How to put commands at the beging of a allready existing

Post by Evan » Thu Dec 28, 2006 7:47 pm

I am trying to attach a password field or something to keep people off of the program with out some sort of verification to the beginning of a program. I do not have any pacific program to do attach it to but I but I am asking for educational purposes.

Evan

Thanks
Evan Hurd

moneo
Veteran
Posts: 451
Joined: Tue Jun 28, 2005 7:00 pm
Location: Mexico City, Mexico

Re: How to put commands at the beging of a allready existing

Post by moneo » Fri Dec 29, 2006 6:42 pm

Evan wrote:I am trying to attach a password field or something to keep people off of the program with out some sort of verification to the beginning of a program. I do not have any pacific program to do attach it to but I but I am asking for educational purposes.

Evan

Thanks
There is a way to attach data to the end of an exe file. However, for storing a password, this would not be a very secure solution.

Why don't you just encrypt the password and write it to a file? Then when the user enters the password, you read the encrypted password from the file, decrypt it, and compare to the user password.

Here's the code for an encryption or decryption function. It won't get passed the CIA, but it's pretty secure otherwise.

Code: Select all

FUNCTION Crypt$ (Password$, X$)
rem X$ is the text to be encrypted or decrypted.
DIM i AS INTEGER
DIM Pass AS INTEGER
DIM X AS INTEGER
DO
  FOR X = 1 TO LEN(Password$)
    i = i + 1: IF i > LEN(X$) THEN EXIT DO
    Pass = ASC(MID$(Password$, X, 1))
    MID$(X$, i, 1) = CHR$(ASC(MID$(X$, i, 1)) XOR Pass)
  NEXT X
LOOP
Crypt$ = X$
END FUNCTION
Good luck and regards..... Moneo

Evan
Coder
Posts: 21
Joined: Wed Dec 27, 2006 6:03 pm
Location: Weatherford TX

Post by Evan » Fri Dec 29, 2006 9:57 pm

Thanks
Evan Hurd

Post Reply