'델파이DLL'에 해당되는 글 2건

  1. 2020.04.12 :: [DelPhi] 자신의 개인 DLL 제작한 후 사용해보기 소스
  2. 2020.04.11 :: [DelPhi] DLL 인젝터 소스
DelPhi 2020. 4. 12. 14:00

{ 여기서 부터 dll 작성부분이다 }

{ 여기서 두함수가 DLL 함수가 된다 }

library Firstdll;

uses

Windows;

 

function Triple( N : Integer) : Integer; stdcall;

begin

MessageBox(0,'Triple function called',

'First Dll',mb_Ok);

Result := N * 3;

end;

function Double( N : Integer) : Integer; stdcall;

begin

MessageBox(0,'Double function called',

'First Dll',mb_Ok);

Result := N * 2;

end;

exports

Triple , Double;

begin

end.

{ 여기까지가 Dll 작성 루틴이다 }

{ 여기서 부터는 DLL 에 있는 함수를 호출하는것을 보여주는 예이다.}

unit dllcall;

interface

uses

Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

StdCtrls, Spin;

type

TForm1 = class(TForm)

Button1: TButton;

Button2: TButton;

SpinEdit1: TSpinEdit;

SpinEdit2: TSpinEdit;

procedure Button1Click(Sender: TObject);

procedure Button2Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

{ DLL 함수를 선언한다 }

function Double( N : Integer) : Integer;

stdcall; external 'FirstDll.dll';

function Triple( N : Integer) : Integer;

stdcall; external 'FirstDll.dll';

implementation

{$R *.DFM}

{DLL 함수의 호출}

procedure TForm1.Button1Click(Sender: TObject);

begin

SpinEdit1.Value := Double(SpinEdit1.Value);

end;

procedure TForm1.Button2Click(Sender: TObject);

begin

SpinEdit2.Value := Triple(SpinEdit2.Value);

end;

end.

----- Dfm 파일 -----

object Form1: TForm1

Left = 200

Top = 108

Width = 328

Height = 156

Caption = 'Form1'

Font.Charset = DEFAULT_CHARSET

Font.Color = clWindowText

Font.Height = -11

Font.Name = 'MS Sans Serif'

Font.Style = []

PixelsPerInch = 96

TextHeight = 13

object Button1: TButton

Left = 24

Top = 24

Width = 75

Height = 25

Caption = 'Double'

TabOrder = 0

OnClick = Button1Click

end

object Button2: TButton

Left = 24

Top = 80

Width = 75

Height = 25

Caption = 'Triple'

TabOrder = 1

OnClick = Button2Click

end

object SpinEdit1: TSpinEdit

Left = 144

Top = 24

Width = 121

Height = 22

MaxValue = 0

MinValue = 0

TabOrder = 2

Value = 0

end

object SpinEdit2: TSpinEdit

Left = 144

Top = 80

Width = 121

Height = 22

MaxValue = 0

MinValue = 0

TabOrder = 3

Value = 0

end;

end;

posted by 핵커 커뮤니티
:
DelPhi 2020. 4. 11. 13:54

uses Windows;var BytesWritten: cardinal; PID, Process, Thread, ThreadId, hKernel: dword;pLoadLibrary, Paramaters: pointer; DLL: AnsiString; begin DLL := 'C:\test.dll'; // Must be full path name. PID := 3160; Process := OpenProcess(PROCESS_ALL_ACCESS, False, PID);Paramaters := VirtualAllocEx(Process, nil, Length(DLL), MEM_COMMIT,PAGE_EXECUTE_READWRITE); WriteProcessMemory(Process, Paramaters, PAnsiChar(DLL),Length(DLL), BytesWritten); hKernel := GetModuleHandle('KERNEL32.DLL'); pLoadLibrary := GetProcAddress(hKernel, 'LoadLibraryA'); Thread := CreateRemoteThread(Process, nil, 0,pLoadLibrary, Paramaters, 0, ThreadId); WaitForSingleObject(Thread, INFINITE);VirtualFreeEx(Process, Paramaters, 0, MEM_RELEASE); CloseHandle(Thread);CloseHandle(Process);end.

My DLL code is simple like this:

uses SysUtils, Classes, Windows;{$R *.res}procedure EntryPoint(Reason: dword); stdcall;begin if Reason = DLL_PROCESS_ATTACH then begin MessageBox(0, 'DLL Injected', 'DLL Injected', 0); end;end;begin DLLProc:= @EntryPoint; EntryPoint(DLL_PROCESS_ATTACH);end.>

 

@ALL 중요포인트! < OK !​ 

posted by 핵커 커뮤니티
: