AGB  ·  Datenschutz  ·  Impressum  







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

DLL Injection von Memory in anderen Prozess

Ein Thema von snapseep · begonnen am 24. Jul 2015 · letzter Beitrag vom 28. Jul 2015
 
snapseep

Registriert seit: 24. Jul 2015
6 Beiträge
 
#1

DLL Injection von Memory in anderen Prozess

  Alt 24. Jul 2015, 13:43
Delphi-Version: XE8
Mit Hilfe von BTMemoryModule (Link) lade ich eine DLL in den Speicher meines Programms.

Delphi-Quellcode:
unit Main;

{ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  * Memory DLL loading code Demo Application                                *
  *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*
  * Copyright (c) 2005-2010 by Martin Offenwanger / coder@dsplayer.de      *
  * http://www.dsplayer.de                                                  *
  *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*
  * Mozilla Public License Version 1.1:                                    *
  *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*
  * The contents of this file are used with permission, subject to the      *
  * Mozilla Public License Version 1.1 (the "License"); you may            *
  * not use this file except in compliance with the License. You may        *
  * obtain a copy of the License at                                        *
  * http://www.mozilla.org/MPL/MPL-1.1.html                                *
  *                                                                        +
  * Software distributed under the License is distributed on an            *
  * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or          *
  * implied. See the License for the specific language governing            *
  * rights and limitations under the License.                              *
  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * }

{
  @author(Martin Offenwanger: coder@dsplayer.de)
  @created(Mar 20, 2005)
  @lastmod(Jul 16, 2010)
  @supported operationg systems(Windows 98 up to Windows 7)
  @tested Delphi compilers(Delphi 7, Delphi 2007 , Delphi 2010)
}


interface

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

type
  TTestCallstdA = procedure(f_Text: PAnsiChar); stdcall;
  TTestCallstdW = procedure(f_Text: PWideChar); stdcall;
  TTestCallcdelA = procedure(f_Text: PAnsiChar); cdecl;
  TTestCallcdelW = procedure(f_Text: PWideChar); cdecl;

  TForm1 = class(TForm)
    BtnMemCall: TButton;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure BtnMemCallClick(Sender: TObject);
  private
    m_TestCallstdA: TTestCallstdA;
    m_TestCallstdW: TTestCallstdW;
    m_TestCallcdelA: TTestCallcdelA;
    m_TestCallcdelW: TTestCallcdelW;
    mp_DllData: Pointer;
    m_DllDataSize: Integer;
    mp_MemoryModule: PBTMemoryModule;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;


implementation

{$R *.dfm}
{$R DemoDLL.RES}

procedure TForm1.FormCreate(Sender: TObject);
var
  ResStream: TResourceStream;
begin
  Position := poScreenCenter;
  ResStream := TResourceStream.Create(HInstance, 'DemoDLL', RT_RCDATA);
  ResStream.Position := 0;
  m_DllDataSize := ResStream.Size;
  mp_DllData := GetMemory(m_DllDataSize);
  ResStream.Read(mp_DllData^, m_DllDataSize);
  ResStream.Free;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  FreeMemory(mp_DllData);
end;

procedure TForm1.BtnMemCallClick(Sender: TObject);
begin
  mp_MemoryModule := BTMemoryLoadLibary(mp_DllData, m_DllDataSize);
  try
    if mp_MemoryModule = nil then
      Abort;
    @m_TestCallstdA := BTMemoryGetProcAddress(mp_MemoryModule, 'TestCallstdA');
    if @m_TestCallstdA = nil then
      Abort;
    @m_TestCallstdW := BTMemoryGetProcAddress(mp_MemoryModule, 'TestCallstdW');
    if @m_TestCallstdW = nil then
      Abort;
    @m_TestCallcdelA := BTMemoryGetProcAddress(mp_MemoryModule, 'TestCallcdelA');
    if @m_TestCallcdelA = nil then
      Abort;
    @m_TestCallcdelW := BTMemoryGetProcAddress(mp_MemoryModule, 'TestCallcdelW');
    if @m_TestCallcdelW = nil then
      Abort;
    m_TestCallstdA('This is a Dll Memory call loaded from resource!');
    m_TestCallstdW('This is a Dll Memory call loaded from resource!');
    m_TestCallcdelA('This is a Dll Memory call loaded from resource!');
    m_TestCallcdelW('This is a Dll Memory call loaded from resource!');
  except
    Showmessage('An error occoured while loading the dll: ' +
      BTMemoryGetLastError);
  end;
  if mp_MemoryModule <> nil then
    BTMemoryFreeLibrary(mp_MemoryModule);
end;

end.
Jedoch möchte ich die DLL nicht in meinen Speicher laden und verwenden, sondern in einen anderen Prozesss (Notepad).


Leider fehlt mir die Erfahrung bzw. das Know-How, wie dies zu bewerkstelligen ist.

Über jegliche Hilfe wäre ich sehr dankbar.

Geändert von snapseep (24. Jul 2015 um 14:07 Uhr)
  Mit Zitat antworten Zitat
 


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 06:26 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