Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Password Protection difficulties.

Author
Message
Nilrem
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 25th Apr 2003 21:12
Well sort of anyways.
I'm trying to make a program (just a normal full screen non-windowed window) that when you press any key it asks you for the password.

So far I have successfully done it using spacebar, but couldn't do it with the wait any key



Also I wondered if it is possible to prevent alt-tabbing and using alt 4 or ctrl+alt+del to end the program, basically I'm trying to make a screen saver, well a program with screen saver functions, you know when you use a screen saver you can make it to need a password to get back onto your desktop etc.
The One Ring
23
Years of Service
User Offline
Joined: 15th Sep 2002
Location: United States
Posted: 25th Apr 2003 21:14
maybe...



Good, bad... I'm the guy with the gun. - Ash in Army Of Darkness(1993).
http://www.geocities.com/the_one_ring
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 25th Apr 2003 21:26


Tsu'va Oni Ni Jyuuko Fiori Sei Tau!
One block follows the suit ... the whole suit of blocks is the path ... what have you found?
Nilrem
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 27th Apr 2003 20:49
Well (Forgot to ask) how does a screensaver (with password protection on) work? You know any key or movement will not close it unless the password is entered (I can do the password part easy)

Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 27th Apr 2003 20:55
basically my code... just returns a one if the key is pressed and 0 if its not.

all you do with that is then



if you already have the password code its pretty simple

Tsu'va Oni Ni Jyuuko Fiori Sei Tau!
One block follows the suit ... the whole suit of blocks is the path ... what have you found?
Nilrem
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 27th Apr 2003 21:23
Hehe I've already done all of that, bit more code, and not as clean, what I mean is (I think this is how a password protected screensaver works) when you hit a key or move the mouse, it disables the alt key, the esc key, and whatever else can change to your desktop, even if you got the password wrong.

Well this is my idea, any idea on how to disable a key? Or is that not how a password protection enabled screensaver work? (I've googled it but can't find any relevant information just some VB crap).

Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 27th Apr 2003 21:58
oh oki
well try DISABLE SYSTEM KEYS that disables the ability to use CTRL-ALT-DEL and such

but i'd be careful with it

Tsu'va Oni Ni Jyuuko Fiori Sei Tau!
One block follows the suit ... the whole suit of blocks is the path ... what have you found?
Nilrem
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 27th Apr 2003 22:59
Said it couldn't understand the command (It didn't come up in blue like a command anyways, tried putting ENABLE SYSTEM KEYS to see if that did, but it didn't).

Help?

Nilrem
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 27th Apr 2003 23:00
Also how come the forums don't have a search button? Or am I just humiliating myself greatly?

Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 28th Apr 2003 00:15
no search... however someone has an offsite search for them (can't remember who thou)

oki my bad the actual commands are ->
disable systemkeys & enable systemkeys



Tsu'va Oni Ni Jyuuko Fiori Sei Tau!
One block follows the suit ... the whole suit of blocks is the path ... what have you found?
The One Ring
23
Years of Service
User Offline
Joined: 15th Sep 2002
Location: United States
Posted: 28th Apr 2003 01:09
however, I believe those commands only work for Win9X systems. Win2K and XP (if I remember correctly) ignore it. Why? Cause I'm betting its using the old enable screensaver trick...

The only real good way to disable any keys, mouse, or most other access is to write a system-wide hook in C++...

Good, bad... I'm the guy with the gun. - Ash in Army Of Darkness(1993).
http://www.geocities.com/the_one_ring
Nilrem
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 28th Apr 2003 02:13
How would one go about that? Is it possible in DBP? I used to program in C++ but what you stated sounds very complicated.

Is there no way? (In scripting for a game you could do the following):


I hear and I forget. I see and I remember. I do and I understand.
simonuk74
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location:
Posted: 28th Apr 2003 02:42
to diable certain keys, cant you put the scancodes for those into an array, then when a key is pressed, it searches the array, an if it finds the scancode for the key pressed, it wont do anything, or if it doesn`t find it in the `ignore list`, then it will let the key be used as usual.

or does the system ( for example, ESC ) use the keypress as a system key, before the code gets a look in ?

Nilrem
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 28th Apr 2003 03:26
How do you disable a specific key then?

I hear and I forget. I see and I remember. I do and I understand.
MrTAToad
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 28th Apr 2003 10:42
If its a normal key, then you just ignore it. If your thinking of CTRL+ALT+DEL or the Windows keys, then you shouldn't.

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
Nilrem
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 28th Apr 2003 12:27
Quote: "If your thinking of CTRL+ALT+DEL or the Windows keys, then you shouldn't."


That's exactly what I want to do, ignore/disable the use (whilst my program is running) of the system keys, CTRL+ALT+DEL etc;
but DISABLE SYSTEMKEYS did not work for me (I'm on XP pro).

I really need to disable them. Otherwise you could close the program or even alt+tab out of it without entering the password.

I hear and I forget. I see and I remember. I do and I understand.
The One Ring
23
Years of Service
User Offline
Joined: 15th Sep 2002
Location: United States
Posted: 28th Apr 2003 19:29
Not gonna happen in XP Pro, dude. If I'm not mistaken, XP Pro will show that Task Manager box (brought up by Ctrl-Alt-Delete) over any app.

Good, bad... I'm the guy with the gun. - Ash in Army Of Darkness(1993).
http://www.geocities.com/the_one_ring
Nilrem
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 28th Apr 2003 20:01
No matter what? Then how come that doesn't happen if you have a screensaver with password protection enabled on xp?

Even with a system wide hook?
If possible using a system wide hook, does rich or lee, or anyone for that matter of fact know if a system wide (keyboard) hook would do the trick? If so would it be writeable in DBP, if not C or C++ and if so how would you incorporate a different language into DBP? (compiler issues)?

I hear and I forget. I see and I remember. I do and I understand.
Nilrem
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 28th Apr 2003 21:07
Because that will just pause the program until a key is pressed?
Chronic what I want to do is prevent ctrl + alt + del
If I am correct if I did a system wide hook in C++ it'd have to be low level, but I don't know how to incorporate/implement another language, well a piece of C++ into DBP.


Or if what I want to do can already be done in DBP?

I hear and I forget. I see and I remember. I do and I understand.
The One Ring
23
Years of Service
User Offline
Joined: 15th Sep 2002
Location: United States
Posted: 28th Apr 2003 22:12
A system-wide hook can't be done directly in DBP. What you do is write it in C++ in a DLL. Create a hook installation function in the dll which is called from your DBP program. This installation function installs the keyboard hook 'KeyboardProc' (a callback function) using the SetWindowsHookEx WinAPI function. Take a look in the MSDN (http://msdn.microsoft.com) for that function for more info.

Good, bad... I'm the guy with the gun. - Ash in Army Of Darkness(1993).
http://www.geocities.com/the_one_ring
KamaKase
23
Years of Service
User Offline
Joined: 29th Oct 2002
Location:
Posted: 28th Apr 2003 22:24
if controlkey=1 or altkey=1 then load program "screensaver.exe"

Basically re-incarnate if you press the button.
EdzUp
23
Years of Service
User Offline
Joined: 8th Sep 2002
Location: UK
Posted: 28th Apr 2003 23:47
Unfortunately without a dll you are not going to stop windows popping up its little Task box, the main reason is Windows gets keys first then pools them to your programs if it doesnt match its criteria.

There was a dll floating around the Net that did this but I cant remember where it was tho or what it was called

-EdzUp
The One Ring
23
Years of Service
User Offline
Joined: 15th Sep 2002
Location: United States
Posted: 29th Apr 2003 00:22
I threw together some code that installs a system-wide hook, and some DBP code that uses it. The hook, however, fails to work. I'll put it here so you can play with it. I think it fails because if I remember correctly, DirectX uses a system-wide keyboard hook for DirectInput.

Here is the C++ DLL code:



And here is the DBP code that uses it...



If you get this to work properly, let me know. When the DBP code is executed, you get a HookID returned properly. But the actuall hook does not work...

Good luck... Wish I had more time to play with this...

Good, bad... I'm the guy with the gun. - Ash in Army Of Darkness(1993).
http://www.geocities.com/the_one_ring
Nilrem
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 29th Apr 2003 01:45
Me get two warnings when compiling the dll wondered if they were significant? (Maybe that's why it didn't work properly)

I've included it in the source button below.

I hear and I forget. I see and I remember. I do and I understand.
Nilrem
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 29th Apr 2003 01:52
Sorry, I meant to say when compiling the cpp file, when actually building the dll file I recieve no warnings, nor no errors.

I hear and I forget. I see and I remember. I do and I understand.
Nilrem
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 29th Apr 2003 01:56
When trying to run the hookinstaller (dbp) upon execution of the program it says Runtime Error 9704 - Could not call DLL function at line 79
Which is:


I hear and I forget. I see and I remember. I do and I understand.
The One Ring
23
Years of Service
User Offline
Joined: 15th Sep 2002
Location: United States
Posted: 29th Apr 2003 07:39
I compiled in Borland C++ Builder 6. If you are using VC++, the name may be decorated differently... but I don't rememeber how... MrTAToad, you use VC++, right?

Good, bad... I'm the guy with the gun. - Ash in Army Of Darkness(1993).
http://www.geocities.com/the_one_ring
Nilrem
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 29th Apr 2003 10:43
It isn't when I compile the source file or build the dll, but when I actually execute my project (e.g. desktop_protector.exe) that's when I get that error.

I hear and I forget. I see and I remember. I do and I understand.
Terabyte
23
Years of Service
User Offline
Joined: 28th Dec 2002
Location: UK
Posted: 29th Apr 2003 11:05
are you sure that the program isnt already running in the background. That happened to me and that was all that was wrong

I have a word of advice...
..don't piss on an electric fence!
MrTAToad
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 29th Apr 2003 12:48
Yes, I use VC V6 (and to a much less extend - mainly because I dont like the layout - VC .NET)

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
Rob K
Retired Moderator
23
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 29th Apr 2003 19:02
"The only real good way to disable any keys, mouse, or most other access is to write a system-wide hook in C++..."

Not necessarily. An alternative is to write a program which keeps calling the Window API function which brings the window to the front of the screen (ie. once per loop or so), that way the only possible ability that they will have is to Log-out, as they will never be able to switch to any other open app.

Current Project: Retro Compo. Entry.
darkdomy
23
Years of Service
User Offline
Joined: 6th Apr 2003
Location: Italy
Posted: 29th Apr 2003 22:13
hello and the DLL? I do not know to program in in c c++ or visual etc I want to unload the DLL. hello thanks

Rob K
Retired Moderator
23
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 29th Apr 2003 23:44
You don't need a DLL. You can do it using the CALL DLL function.

Current Project: Retro Compo. Entry.
Nilrem
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 30th Apr 2003 01:14
Quote: "An alternative is to write a program which keeps calling the Window API function which brings the window to the front of the screen (ie. once per loop or so), that way the only possible ability that they will have is to Log-out, as they will never be able to switch to any other open app."


How would I go about that? Just until I can get the system wide hook to work.

I hear and I forget. I see and I remember. I do and I understand.
Nilrem
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 30th Apr 2003 01:16
and nope it isn't running, I'm still getting the error in DBP.

Error resulting from:


I hear and I forget. I see and I remember. I do and I understand.
Nilrem
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 30th Apr 2003 01:17
Could you possibly upload your .dba and .dll file please? bit of a painstake I know, I apologise.

I hear and I forget. I see and I remember. I do and I understand.
Rob K
Retired Moderator
23
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 30th Apr 2003 01:29
Hmm, I haven't got time this evening, but this info from another site should be useful:

"Making a window the foreground window requires more than just calling the SetForegroundWindow API. You must first determine the foreground thread and attach it to your window, using AttachThreadInput, then call SetForegroundWindow. That way they can share input states.

First I call GetForegroundWindow to get the handle of the current foreground window. Then a few calls to GetWindowThreadProcessId retrieve the threads associated with the current foreground window and the window I want to bring to the foreground. If these threads are the same a simple call to SetForegroundWindow is all that is necessary. Otherwise, the foreground thread is attached to the window that I am bringing to the front and detached from what was the current foreground window. The AttachThreadInput API handles this.

Once this is accomplished, the state of the window is determined. If IsIconic says that the window is minimized, I restore it by issuing ShowWindow with the SW_RESTORE flag. Otherwise ShowWindow is called with the SW_SHOW flag."

Use another language to get the values of the constant. I'll try with a DBA, but maybe a DLL is necessary. I have done this before, so I'll try and dig it out later.

Current Project: Retro Compo. Entry.
Nilrem
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 30th Apr 2003 01:43
Thankyou Rob K, thanks to everyone for their input on this matter.

I hear and I forget. I see and I remember. I do and I understand.
Nilrem
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 30th Apr 2003 22:41
The One Ring : I have removed (in the .dba file) the underscores from hookinstall and removehook, and the program now runs, but it says the window 'title' could not be found then on a black screen says hookid = 0 and to press spacebar to quit(or something along those lines) :-s so is it something in the dll code?

I hear and I forget. I see and I remember. I do and I understand.
The One Ring
23
Years of Service
User Offline
Joined: 15th Sep 2002
Location: United States
Posted: 30th Apr 2003 23:00
The second parameter in the call to the dll is the title of your darkbasic window. Here is the modified stuff...





Good, bad... I'm the guy with the gun. - Ash in Army Of Darkness(1993).
http://www.geocities.com/the_one_ring
Nilrem
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 1st May 2003 10:21
I now get the error "Runtime error 9704 - Could not call DLL function at line 81" (Line 81 is HookID = call dll(1, "_InstallHook"))

So I removed the _'s so it became InstallHook in the .dba file, and then it loads up cannot get the procedure (or something like that) then it says hookid = 0 press spacebar to continue.

Do they work for you? (I take it you need the _'s in for the program to properly work)?

I hear and I forget. I see and I remember. I do and I understand.
Nilrem
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 1st May 2003 22:45
TOR?

I hear and I forget. I see and I remember. I do and I understand.
Nilrem
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 4th May 2003 15:04
I apologise for this, but;
*BUMP*

I hear and I forget. I see and I remember. I do and I understand.
Pal
23
Years of Service
User Offline
Joined: 13th Apr 2003
Location:
Posted: 4th May 2003 20:42
the best thing is



I am da man! Beware of my LAZER EYES!
APEXnow
Retired Moderator
23
Years of Service
User Offline
Joined: 15th Apr 2003
Location: On a park bench
Posted: 4th May 2003 20:45
I think that's already been mentioned earlier, and plus the Password code wouldn't run until any key has been pressed. Defeats the object.

"Man who looses key to woman's appartment...... He get no nookie" - A wise chinese man.
Nilrem
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 5th May 2003 01:31
APEXnow:
Yes it has.

Dark_Basic_Pro_Master:
Thanks for the suggestion, but it has already been mentioned, you see DBPM what is needed is a system wide hook, because DISABLE SYSTEM KEYS does not work properly on (to all of my knowledge anyways) WIN2K and WINXP (Home and Pro), plus suspend for key wouldn't cover System Keys (ctrl+alt+del)

I hear and I forget. I see and I remember. I do and I understand.

Login to post a reply

Server time is: 2026-07-11 12:02:13
Your offset time is: 2026-07-11 12:02:13