unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm3 =
class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form3: TForm3;
implementation
uses perlregex;
{$R *.dfm}
function verarbeitung(code:
array of string;pos:
array of integer):
string;
var
i:integer;
begin
for i := low(code)
to high(code)
do
result := result + code[i] + '
|' + '
,';
end;
function regl(subj, expr:
string):
string;
var
code:
array of string;
pos:
array of integer;
h:integer;
begin
with TPerlRegEx.Create(
nil)
do
begin
try
RegEx := expr;
Subject := subj;
//A fehlerquelle meinermeinung nach
if Match
then
begin
repeat
setlength(code,SubExpressionCount);
code[High(code)] := SubExpressions[High(code)];
until MatchAgain;
result := verarbeitung(code,pos);
end;
//B Ende
finally
free;
end;
end;
end;
procedure TForm3.Button1Click(Sender: TObject);
begin
edit1.Text:=regl(edit2.Text,'
<*>');
end;
procedure PatchINT3;
var
NOP : Byte;
NTDLL: THandle;
BytesWritten: DWORD;
Address: Pointer;
begin
if Win32Platform <> VER_PLATFORM_WIN32_NT
then Exit;
NTDLL := GetModuleHandle('
NTDLL.DLL');
if NTDLL = 0
then Exit;
Address := GetProcAddress(NTDLL, '
DbgBreakPoint');
if Address =
nil then Exit;
try
if Char(Address^) <> #$
CC then Exit;
NOP := $90;
if WriteProcessMemory(GetCurrentProcess, Address, @NOP, 1, BytesWritten)
and
(BytesWritten = 1)
then
FlushInstructionCache(GetCurrentProcess, Address, 1);
except
//Do not panic if you see an EAccessViolation here, it is perfectly harmless!
on EAccessViolation
do ;
else raise;
end;
end;
initialization
// nur wenn ein Debugger vorhanden, den Patch ausführen
if DebugHook<>0
then
PatchINT3;
end.