AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Win32/Win64 API (native code) Delphi madCodeHook: UninjectLibrary verursacht Neustart
Thema durchsuchen
Ansicht
Themen-Optionen

madCodeHook: UninjectLibrary verursacht Neustart

Ein Thema von diabox · begonnen am 11. Nov 2006 · letzter Beitrag vom 11. Nov 2006
Antwort Antwort
Benutzerbild von diabox
diabox

Registriert seit: 13. Sep 2006
61 Beiträge
 
Delphi 2010 Professional
 
#1

madCodeHook: UninjectLibrary verursacht Neustart

  Alt 11. Nov 2006, 16:50
moin allerseits!

Ich verwende die madCodeHook Unit (madshi) für ein kleines Projekt, das "Shell_NotifyIcon" systemweit hooken soll. Prozessweit klappt alles reibungslos. Das Hooken funktioniert zwar auch systemweit, aber sobald ich UninjectLibrary aufrufe, wird mein PC ohne Vorwarnung neugestartet, d.h. Bildschirm wird schwarz und zack isser wieder am booten.

DLL:
Delphi-Quellcode:
library DBXHookDLL;

uses Windows,SysUtils, Classes, ShellApi, madRemote, madCodeHook, madStrings, Dialogs;

var Shell_NotifyIconNext : function (dwMessage: DWord; lpdata: PNOTIFYICONDATA): Boolean; stdcall;

const
 {$EXTERNALSYM NIM_SETFOCUS} 
  NIM_SETFOCUS = $00000003;
  {$EXTERNALSYM NIM_SETVERSION}
  NIM_SETVERSION = $00000004;

function Shell_NotifyIconCallback(dwMessage: DWord; lpdata: PNOTIFYICONDATA): Boolean; stdcall;
var
MyLog: TStringList;
begin
try
MyLog:=TStringList.Create();
if dwMessage = NIM_ADD then MyLog.Add('NIM_ADD');
if dwMessage = NIM_DELETE then MyLog.Add('NIM_DELETE');
if dwMessage = NIM_MODIFY then MyLog.Add('NIM_MODIFY');
if dwMessage = NIM_SETFOCUS then MyLog.Add('NIM_SETFOCUS');
if dwMessage = NIM_SETVERSION then MyLog.Add('NIM_SETVERSION');
MyLog.SaveToFile('C:\DBXHookDLLLog.txt'); //Die Datei wird erstellt und es steht
//je nach Aktion dann auch NIM_ADD usw. drin
MyLog.Destroy();
except on E: Exception do begin end; //Was auch immer für Exceptions
//auftreten - ich will keine sehen :-) (Habs auch ohne getestet:
//bringt mich nicht weiter...)
end;

result := Shell_NotifyIconNext(dwMessage,lpdata);
end;

begin
  HookAPI('shell32.dll', 'Shell_NotifyIcon', @Shell_NotifyIconCallback, @Shell_NotifyIconNext);
end.
MainAPP:
Delphi-Quellcode:
unit uMain;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, madCodeHook;

type
  TForm1 = class(TForm)
    Button3: TButton;
    procedure Button3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}


procedure TForm1.Button3Click(Sender: TObject);
begin
  InjectLibrary(ALL_SESSIONS or SYSTEM_PROCESSES, 'DBXHookDll.dll');
  MessageBox(0, 'Active...', 'Hook is active...', MB_ICONINFORMATION);
  UninjectLibrary(ALL_SESSIONS or SYSTEM_PROCESSES, 'DBXHookDll.dll'); //shutdown
end;

end.
Was mach ich falsch?
Ist mein zweiter Versuch mit Code Hooking, also seid nachsichtig mit mir

Danke im voraus
Wer zweifelt, detoniert nicht!'
Dieter Nuhr
  Mit Zitat antworten Zitat
jmd anders

Registriert seit: 13. Mai 2004
84 Beiträge
 
#2

Re: madCodeHook: UninjectLibrary verursacht Neustart

  Alt 11. Nov 2006, 17:27
also soweit ich weiß, sollte man grundsätzlich kein vcl inner hook dll verwenden, des weiteren glaube ich fragst du am besten mal bei madshi im forum nach, der antwortet eigentlich relativ schnell immer.
  Mit Zitat antworten Zitat
Benutzerbild von diabox
diabox

Registriert seit: 13. Sep 2006
61 Beiträge
 
Delphi 2010 Professional
 
#3

Re: madCodeHook: UninjectLibrary verursacht Neustart

  Alt 11. Nov 2006, 17:36
Oh, hab das Forum ganz übersehen ^^ Vielleicht werd ich da fündig. Danke
Wer zweifelt, detoniert nicht!'
Dieter Nuhr
  Mit Zitat antworten Zitat
Antwort Antwort


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 15:09 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