Autor Beitrag
maxk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: Do 16.10.03 20:05 
Hi,
mit folgendem Code gibt's Probleme:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
var LibHnd:integer;
    FuncCall:function (fBlock: boolean):boolean;
begin
 LibHnd:=LoadLibrary('user32.dll');
 if LibHnd=0 then exit;
 FuncCall:=GetProcAddress(LibHnd,'BlockInput');
 if @FuncCall<>nil then begin
  if FuncCall(True) then Caption:='True' else Caption:='False';
 end;
 FreeLibrary(LibHnd);
end;

Der Code sperrt die Eingabegeräte durch Aufruf der entsprechenden Funktion in der USER32.DLL. Leider erscheint eine Fehlermeldung "Externe Exception C000001D", nachdem die Geräte gesperrt wurden.

Bindet man BlockInput statisch ein:
ausblenden Delphi-Quelltext
1:
function BlockInput(fBlock:boolean):boolean;stdcallexternal 'user32.dll';					
Funktioniert alles, wie es soll.

Was mache ich falsch?

maxk

PS: Zum Aufheben der Sperrung Adlergriff benutzen.

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.
worm
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 135


D6 Prof
BeitragVerfasst: Do 16.10.03 21:44 
@FuncCall:=GetProcAddress(LibHnd,'BlockInput');Du hast da bloß ein @ vergessen.
Und hinter die Deklaration der Variable FuncCall muss noch ein stdcall; !

_________________
In the beginning, the universe was created. This has made a lot of people very angry, and is generally considered to have been a bad move.
toms
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1099
Erhaltene Danke: 2



BeitragVerfasst: Do 16.10.03 22:34 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
function FunctionDetect (LibName, FuncName: Stringvar LibPointer:
Pointer): boolean;
var LibHandle: THandle;
begin
 Result := false;
 LibPointer := NIL;
  if LoadLibrary(PChar(LibName)) = 0 then Exit;
  LibHandle := GetModuleHandle(PChar(LibName));
  if LibHandle <> 0 then
  begin
   LibPointer := GetProcAddress(LibHandle, PChar(FuncName));
   if LibPointer <> NIL then Result := True;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var xBlockInput : function (Block: BOOL): BOOL; stdcall;
begin
 if FunctionDetect ('USER32.DLL''BlockInput', @xBlockInput) then
 begin
  xBlockInput (True);  // Disable Keyboard & mouse
   Sleep(5000);       // Wait for for 10 Secounds
  xBlockInput (False); // Enable  Keyboard & mouse
 end;
end;
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Fr 17.10.03 14:30 
was ich mich frage: wie machst du das dynamisch ? die user32.dll ist doch sowieso imer in windows vorhanden !

_________________
In the beginning was the word.
And the word was content-type: text/plain.
maxk Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: Fr 17.10.03 19:58 
Erstmal Danke für eine Hilfe :D
matze hat folgendes geschrieben:
was ich mich frage: wie machst du das dynamisch ? die user32.dll ist doch sowieso imer in windows vorhanden !
Vorsicht: Das soll ein Prog für meine Schule werden. Da muss jeder Fehler (ob wahrscheinlich oder nicht) abgefangen werden.

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Fr 17.10.03 20:04 
Wenn die user32.dll nicht geladen ist, dann íst nichts zum abfangen da. Denn dann dürfte sich Windows schon sehr viel früher beschwert haben.
maxk Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: Fr 17.10.03 20:25 
Vielleicht kommt mal jemand auf die Idee ein Patch der user32.dll zu installieren (Sicherheitspatch, etc.), in der es (Gott bewahre) diese Funktionen nicht mehr gibt. Ich möchte nicht wissen, wie oft BlockInput missbraucht wird :twisted:

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Sa 18.10.03 10:15 
hmmm... also wenn sich jemand die mühe macht die user32.dll zu patchen, dass es den blockinput nichtmehr gibt und windows noch suaber läuft, dann glaube ich hat der auch keine nennenswerten probleme damit dein proggi abzuschalten !

_________________
In the beginning was the word.
And the word was content-type: text/plain.
maxk Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: Sa 18.10.03 20:58 
Hmm,
ich habe den Code geändert:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
var LibHnd:Cardinal;
    FuncCall:function (fBlock:boolean):boolean;
begin
 LibHnd:=LoadLibrary('user32.dll');
 if LibHnd=0 then exit;
 @FuncCall:=GetProcAddress(LibHnd,'BlockInput');
 if @FuncCall<>nil then begin
  FuncCall(True);
 end;
 FreeLibrary(LibHnd);
end;

Jetzt bekomme ich eine Zugriffsverletzung (Zugriffsverletzung bei Adresse 008C32B7. Schreiben von Adresse A8008C5C). Nachdem die Eingabegeräte nicht mehr funktionieren.
:hilfe:

@matze: Wenn z.B. ein Lehrer ein Patch installiert, ohne zu wissen, was sich ändert und das mein Prog evtl. nicht mehr läuft...

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.
maxk Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: Sa 18.10.03 21:00 
Ich Vollidot (wehe jemand zitiert das) habe das stdcall; vergessen. Jetzt funktioniert es. Danke auch allen. :D

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: So 19.10.03 11:00 
das ist schön
kannst du mal ein bisscen beschrieben, wie dein proggi funktioniert und was es macht ?

_________________
In the beginning was the word.
And the word was content-type: text/plain.
maxk Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: Mo 20.10.03 18:25 
Mein Prog besteht aus einem Client und einem Server. Der Client, der auch für das BlockInput zuständig ist, verbindet sich mit dem Server. Besteht eine Verbindung, ist der Client nicht mehr beendbar. Dann ist folgendes möglich:
    1. Die Clients können untereinander Chatten (abschaltbar)
    2. Die Clients können vom Server aus gesperrt werden (BlockInput)
    3. Der Server kann alle Clients gleichzeitig herunterfahren, neustarten, etc.
    4. Die Clients stellen automatisch ihre Uhr nachdem Server
    5. TODO: Die Clients können ein Monitorstreaming vom Server empfangen

Das alles soll es dem Lehrer oder Vortragendem ermöglichen, den Schüler etwas am PC zu erklären, ohne dass sie zum Beispiel währendessen daran raumspielen (BlockInput machts möglich). Außerdem kann der Lehrer nach dem Unterricht alle Rechner aufeinmal ausschalten, was unheimlich Zeit sparen kann. Natürlich gibt es solche Programme schon, aber so muss sich unsere Schule wenigstens nicht mit Lizenzen ärgern.

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Mo 20.10.03 19:51 
ich entwickle an unserer schule sowas ähnliches. nur mit ner datenbank im hintergrund un nem Linux Server, der lehrer kann fast alles am schülerrechner machen und der schüler kann sich mit seinem namen und nem eigenen passwort anmelden.

wie hast dus gemacht, dass der client unbeendbar ist ? einfach nur mit canclose := false oder wie ?

_________________
In the beginning was the word.
And the word was content-type: text/plain.
maxk Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: Mo 20.10.03 20:27 
CanClose:=False;
Und die Message zum herunterfahren abfangen damit es keine Probleme gibt. Da wir noch 98 verwenden ist das sicher genug. An meiner anderen Schule ( :mrgreen: ) habe ich es mit einem zweiten Prozess geregelt. Wenn FindWindow('MyProg','')=0 then WinExec('MyProg.exe',SW_HIDE) - oder so ähnlich. Auch sehr beliebt: Services

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Di 21.10.03 15:06 
danke für die anregungen !!

wenn du willst können wir uns mal im ICQ über diese Thema weiter unterhalten

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Mi 22.10.03 09:51 
www.realvnc.com - ein OpenSource Remote-Control Tool mit ähnlichen Features wie von dir beschrieben...

Das schreib ich gerade um / erweitere es ein bisschen, um hier in dem Institut in dem ich grad Zivi mach die Kursteilnehmer etwas mehr unter Kontrolle halten zu können! :)

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Mi 22.10.03 16:31 
es wäre viellicht cool, wenn alle leuz die so ein ähnlices projekt planen, sich mal in ICQ oder so averabreden könnten um ideenen und sicherheitsrelevante sachen auszutauschen !

_________________
In the beginning was the word.
And the word was content-type: text/plain.