AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

bestimmte Tasten Sperren.

Ein Thema von Noobinator · begonnen am 9. Mai 2006 · letzter Beitrag vom 17. Mai 2006
Antwort Antwort
Seite 4 von 6   « Erste     234 56      
Noobinator

Registriert seit: 9. Mai 2006
147 Beiträge
 
Delphi 7 Personal
 
#31

Re: bestimmte Tasten Sperren.

  Alt 15. Mai 2006, 15:46
könntest du mir vllt noch einen Hook für ALT+TAB und STRG+ALT+ENTF schreiben?
oder am besten alles in einem.
habe versucht deinen abzuändern, aber bekomme das irgendwie nicht hin
  Mit Zitat antworten Zitat
Benutzerbild von mirage228
mirage228

Registriert seit: 23. Mär 2003
Ort: Münster
3.750 Beiträge
 
Delphi 2010 Professional
 
#32

Re: bestimmte Tasten Sperren.

  Alt 15. Mai 2006, 15:50
Hi,

Ich glaube, dass sich zumindest Strg+Alt+Entf von Windows her nicht hooken lässt.

mfG
mirage228
David F.

May the source be with you, stranger.
PHP Inspection Unit (Delphi-Unit zum Analysieren von PHP Code)
  Mit Zitat antworten Zitat
DevilsCamp
(Gast)

n/a Beiträge
 
#33

Re: bestimmte Tasten Sperren.

  Alt 15. Mai 2006, 15:55
Der Affengriff scheint zu gehen.

Jedenfalls habe ich irgendwo einen Code dafür gesehen. Da ich den Link dazu aber zu Hause habe, kann ich ihn frühestens heute Abend posten.
  Mit Zitat antworten Zitat
Noobinator

Registriert seit: 9. Mai 2006
147 Beiträge
 
Delphi 7 Personal
 
#34

Re: bestimmte Tasten Sperren.

  Alt 15. Mai 2006, 15:57
Zitat von DevilsCamp:
Der Affengriff scheint zu gehen.

Jedenfalls habe ich irgendwo einen Code dafür gesehen. Da ich den Link dazu aber zu Hause habe, kann ich ihn frühestens heute Abend posten.
würde auch gehen, habe bis mittwoch zeit, also braucht ihr euch keinen Stress machen^^.

Danke schonmal für die Hilfe
  Mit Zitat antworten Zitat
nat

Registriert seit: 10. Nov 2005
216 Beiträge
 
RAD-Studio 2009 Pro
 
#35

Re: bestimmte Tasten Sperren.

  Alt 15. Mai 2006, 18:07
ich glaube strg+alt+entf (und auch alt+tab) kann man nicht so einfach sperren.
vll hilft es dir aber ja, wenn du dein programm aus der liste im taskmanager
entfernst. mit folgendem code kannste das bewerkstelligen (habe ich nicht selber
geschrieben, sondern ma irgendwo gefunden - funzt aber).
is wieder ne dll.


Delphi-Quellcode:
library HideProcessNT;

uses
  Windows,tlhelp32,ImageHlp,SysUtils;

var
  hmap: THandle;
  hFirstMapHandle:THandle;

type
  SYSTEM_INFORMATION_CLASS = (SystemBasicInformation, SystemProcessorInformation, SystemPerformanceInformation,
    SystemTimeOfDayInformation, SystemNotImplemented1, SystemProcessesAndThreadsInformation, SystemCallCounts,
    SystemConfigurationInformation, SystemProcessorTimes, SystemGlobalFlag, SystemNotImplemented2, SystemModuleInformation,
    SystemLockInformation, SystemNotImplemented3, SystemNotImplemented4, SystemNotImplemented5,
    SystemHandleInformation, SystemObjectInformation, SystemPagefileInformation,
    SystemInstructionEmulationCounts, SystemInvalidInfoClass1, SystemCacheInformation,
    SystemPoolTagInformation, SystemProcessorStatistics, SystemDpcInformation,
    SystemNotImplemented6, SystemLoadImage, SystemUnloadImage, SystemTimeAdjustment,
    SystemNotImplemented7, SystemNotImplemented8, SystemNotImplemented9,
    SystemCrashDumpInformation, SystemExceptionInformation, SystemCrashDumpStateInformation,
    SystemKernelDebuggerInformation, SystemContextSwitchInformation, SystemRegistryQuotaInformation,
    SystemLoadAndCallImage, SystemPrioritySeparation, SystemNotImplemented10, SystemNotImplemented11,
    SystemInvalidInfoClass2, SystemInvalidInfoClass3, SystemTimeZoneInformation,
    SystemLookasideInformation, SystemSetTimeSlipEvent, SystemCreateSession, SystemDeleteSession, SystemInvalidInfoClass4,
    SystemRangeStartInformation, SystemVerifierInformation, SystemAddVerifier, SystemSessionProcessesInformation
  );
  PFARPROC = ^FARPROC;
  _IMAGE_IMPORT_DESCRIPTOR = packed record
    case Integer of
      0:(Characteristics: DWORD);
      1:(OriginalFirstThunk: DWORD; TimeDateStamp: DWORD; ForwarderChain: DWORD; Name: DWORD; FirstThunk: DWORD);
  end;
  IMAGE_IMPORT_DESCRIPTOR = _IMAGE_IMPORT_DESCRIPTOR;
  PIMAGE_IMPORT_DESCRIPTOR = ^IMAGE_IMPORT_DESCRIPTOR;

procedure RedirectIAT(pszCallerModName: Pchar; pfnCurrent: FarProc; pfnNew: FARPROC; hmodCaller: hModule);
var
  ulSize: ULONG;
  pImportDesc: PIMAGE_IMPORT_DESCRIPTOR;
  pszModName: PChar;
  pThunk: PDWORD;
  ppfn:PFARPROC;
  ffound: LongBool;
  written: DWORD;
begin
  pImportDesc:= ImageDirectoryEntryToData(Pointer(hmodCaller), TRUE,IMAGE_DIRECTORY_ENTRY_IMPORT, ulSize);
  if pImportDesc = nil then exit;
  while pImportDesc.Name<>0 do
  begin
    pszModName := PChar(hmodCaller + pImportDesc.Name);
    if (lstrcmpiA(pszModName, pszCallerModName) = 0) then break;
    Inc(pImportDesc);
  end;
  if (pImportDesc.Name = 0) then exit;
  pThunk := PDWORD(hmodCaller + pImportDesc.FirstThunk);
  while pThunk^<>0 do
  begin
    ppfn := PFARPROC(pThunk);
    fFound := (ppfn^ = pfnCurrent);
    if (fFound) then
    begin
      VirtualProtectEx(GetCurrentProcess,ppfn,4,PAGE_EXECUTE_READWRITE,written);
      WriteProcessMemory(GetCurrentProcess, ppfn, @pfnNew, sizeof(pfnNew), Written);
      exit;
    end;
    Inc(pThunk);
  end;
end;

var
  addr_NtQuerySystemInformation: Pointer;
  mypid: DWORD;
  fname: PCHAR;
  mapaddr: PDWORD;
  hideOnlyTaskMan: PBOOL;

function myNtQuerySystemInfo(SystemInformationClass: SYSTEM_INFORMATION_CLASS; SystemInformation: Pointer;
  SystemInformationLength:ULONG; ReturnLength:PULONG):LongInt; stdcall;
label lop, nextpid, exit, fillzero;
asm
  push ReturnLength
  push SystemInformationLength
  push SystemInformation
  push dword ptr SystemInformationClass
  call dword ptr [addr_NtQuerySystemInformation]
  or eax,eax
  jl exit
  cmp SystemInformationClass, SystemProcessesAndThreadsInformation
  jne exit
lop:
  mov esi, SystemInformation
nextpid:
  mov ebx, esi
  cmp dword ptr [esi],0
  je exit
  add esi, [esi]
  mov ecx, [esi+44h]
  cmp ecx, mypid
  jne nextpid
  mov edx, [esi]
  test edx, edx
  je fillzero
  add [ebx], edx
  jmp lop
fillzero:
  and [ebx], edx
  jmp lop
exit:
  mov Result, eax
end;

procedure FuncIncept;
var
  hSnapShot: THandle;
  me32: MODULEENTRY32;
begin
  addr_NtQuerySystemInformation := GetProcAddress(getModuleHandle('ntdll.dll'),'NtQuerySystemInformation');
  hSnapShot := CreateToolHelp32SnapShot(TH32CS_SNAPMODULE,GetCurrentProcessId);
  if hSnapshot = INVALID_HANDLE_VALUE then exit;
  try
    ZeroMemory(@me32,sizeof(MODULEENTRY32));
    me32.dwSize:=sizeof(MODULEENTRY32);
    Module32First(hSnapShot,me32);
    repeat
      RedirectIAT('ntdll.dll',addr_NtQuerySystemInformation,@MyNtQuerySystemInfo,me32.hModule);
    until not Module32Next(hSnapShot,me32);
  finally
    CloseHandle(hSnapShot);
  end;
end;

procedure FreeFunc;
var
  hSnapShot: THandle;
  me32: MODULEENTRY32;
begin
  addr_NtQuerySystemInformation:=GetProcAddress(getModuleHandle('ntdll.dll'),'NtQuerySystemInformation');
  hSnapShot:=CreateToolHelp32SnapShot(TH32CS_SNAPMODULE,GetCurrentProcessId);
  if hSnapshot=INVALID_HANDLE_VALUE then exit;
  try
    ZeroMemory(@me32,sizeof(MODULEENTRY32));
    me32.dwSize:=sizeof(MODULEENTRY32);
    Module32First(hSnapShot,me32);
    repeat
      RedirectIAT('ntdll.dll',@MyNtQuerySystemInfo,addr_NtQuerySystemInformation,me32.hModule);
    until not Module32Next(hSnapShot,me32);
  finally
    CloseHandle(hSnapShot);
  end;
end;


var
  HookHandle: THandle;

function CbtProc(code: integer; wparam: integer; lparam: integer):Integer; stdcall;
begin
  Result:=0;
end;

procedure AttachHook; stdcall;
begin
  HookHandle := SetWindowsHookEx(WH_CBT, @CbtProc, HInstance, 0);
end;

procedure LibraryProc(Reason: Integer);
begin
  if Reason = DLL_PROCESS_DETACH then
    if mypid > 0 then
      FreeFunc()
    else
      CloseHandle(hFirstMapHandle);
end;

function HideNtProcess(pid:DWORD):BOOL; stdcall;
var
  addrMap: PDWORD;
  ptr2: PBOOL;
  OnlyBlindTaskmgr: BOOL;
begin
  mypid:=0;
  result:=false;
  OnlyBlindTaskmgr:=False;
  hFirstMapHandle:=CreateFileMapping($FFFFFFFF,nil,PAGE_READWRITE,0,8,'NtHideFileMapping');
  if hFirstMapHandle=0 then exit;
  addrMap:=MapViewOfFile(hFirstMapHandle,FILE_MAP_WRITE,0,0,8);
  if addrMap=nil then
  begin
    CloseHandle(hFirstMapHandle);
    exit;
  end;
  addrMap^:=pid;
  ptr2:=PBOOL(DWORD(addrMap)+4);
  ptr2^:=OnlyBlindTaskmgr;
  UnmapViewOfFile(addrMap);
  AttachHook;
  result:=true;
end;

exports
  HideNtProcess;

begin
  hmap:=OpenFileMapping(FILE_MAP_READ,false,'NtHideFileMapping');
  if hmap=0 then exit;
  try
    mapaddr:=MapViewOfFile(hmap,FILE_MAP_READ,0,0,0);
    if mapaddr=nil then exit;
    mypid:=mapaddr^;
    hideOnlyTaskMan:=PBOOL(DWORD(mapaddr)+4);
    if hideOnlyTaskMan^ then
    begin
      fname:=allocMem(MAX_PATH+1);
      GetModuleFileName(GetModuleHandle(nil),fname,MAX_PATH+1);
      if not (ExtractFileName(fname)='taskmgr.exe') then exit;
    end;
    FuncIncept;
  finally
    UnmapViewOfFile(mapaddr);
    CloseHandle(Hmap);
    DLLProc:=@LibraryProc;
  end;
end.

so bindeste das ein
function HideNtProcess(pid:DWORD):BOOL; stdcall; external 'HideProcessNT.dll'; und aufrufen kannste das dann so
HideNtProcess(GetCurrentProcessId);
  Mit Zitat antworten Zitat
Noobinator

Registriert seit: 9. Mai 2006
147 Beiträge
 
Delphi 7 Personal
 
#36

Re: bestimmte Tasten Sperren.

  Alt 15. Mai 2006, 20:18
danke für die Arbeit, aber das nützt mir nichts.. ich will nur verhindern, das man das Programm beiseiteschiebt. Sobald ich dann allerdings STRG+AL+ENTF drücke, minimiert das Fenster ja schon automatisch, und man hat es umgangen.

@DevilsCamp
schau mal bitte ob du deins wiederfindest.
  Mit Zitat antworten Zitat
DevilsCamp
(Gast)

n/a Beiträge
 
#37

Re: bestimmte Tasten Sperren.

  Alt 15. Mai 2006, 20:25
Dieser Code stammt von Enrico's Delphi Pages

Bei den Tips unter System

Delphi-Quellcode:
var
  Affengriff: Longbool;


//Taskmanager Aufruf verbieten
procedure TForm1.Button1Click(Sender: TObject);
begin
  SystemParametersInfo(97,Word(True),@Affengriff,0);
end;



//Taskmanager wieder erlauben
procedure TForm1.Button2Click(Sender: TObject);
begin
  SystemParametersInfo(97,Word(False),@Affengriff,0); //entsperrt
end;

Ich habe es nicht getestet, also keine Garantie, dass es funktioniert.
  Mit Zitat antworten Zitat
nat

Registriert seit: 10. Nov 2005
216 Beiträge
 
RAD-Studio 2009 Pro
 
#38

Re: bestimmte Tasten Sperren.

  Alt 15. Mai 2006, 20:45
ich glaub der o.g. code is nur für win9x/me.
unter nt/2k/xp geht der nich.
  Mit Zitat antworten Zitat
Noobinator

Registriert seit: 9. Mai 2006
147 Beiträge
 
Delphi 7 Personal
 
#39

Re: bestimmte Tasten Sperren.

  Alt 16. Mai 2006, 14:19
ok eine Frage noch.. den Rest habe ich einfach alles so gelöst:
form1.formstyle:=tstayontop damit schiebt sich das Programm vor alle anderen, und ALT+TAB ist nutzlos^^
auch das Startmenu ist dann dank vollbild ganze einfach weg^^
einfach herrlich diese Eigenschafft

Danke für die Ganze geduld und hilfe
  Mit Zitat antworten Zitat
nat

Registriert seit: 10. Nov 2005
216 Beiträge
 
RAD-Studio 2009 Pro
 
#40

Re: bestimmte Tasten Sperren.

  Alt 16. Mai 2006, 14:58
Zitat von Noobinator:
ok eine Frage noch..
und wo is die frage??
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 4 von 6   « Erste     234 56      


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 09:02 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz