Exetools  

Go Back   Exetools > General > General Discussion

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 03-24-2005, 16:03
nerst
 
Posts: n/a
Quote:
Originally Posted by MaRKuS-DJM
hi bro's,

i'm searching for a way to hook API's for a simple protected application (won't name protector )

i heard something of an undocumented API with ordinal 1 that should be able to unprotect this memory. anybody knows about this?
or any suggestions?
Here is an example on Delphi from different public sources & articles.

Code:
//------------------------------------------------------------------------------

function ProtectAddress( Address, Flag : DWORD ): Boolean; stdcall;
var
//fa      : DWORD;  // FirstAddress
  fp,np   : DWORD;  // FirstPage / numPages
  VXDCall : Pointer;

begin
  Result  := False;

  try

// fa := Address;
   fp := 1;//Address div 4096;
   np := 1;
// DEC( fa, fa mod 4096 );
// Result := not IsBadWritePtr( Pointer(fa), np*4096 );
   if not Result then
   begin
     // Get undocumented VxDCall procedure
     VXDCall := GetProcAddress_(GetModuleHandle(kernel32), 1);
     if @VXDCall = nil then Exit;
     asm
//     push 020060000h           // PC_WRITEABLE | PC_USER | PC_STATIC
       push Flag
       push 0FFFFFFFFh           // Keep all previous bits
       push DWORD PTR [np]       // dword ptr [mbi+0Ch] # of pages
       push DWORD PTR [fp]       // dword ptr [ped] page #
       push 1000Dh               // _PageModifyPermissions (win32_service_table #)
       call DWORD PTR [VXDCall]  // VxDCall0
     end;
//   Result := not IsBadWritePtr( Pointer(fa), np*4096 );
     Result := True;
   end;

  except
  end;
end;

//------------------------------------------------------------------------------

function SetWriteAccess( Address, Size : DWORD ) : Boolean;
var
  OldProtect : DWORD;

begin
  Result     := False;

  If IsNT then
  begin

    if VirtualProtect( Pointer(Address), Size, PAGE_EXECUTE_READWRITE, OldProtect ) = False then Exit;
    Result := (IsBadWritePtr( Pointer(Address), Size ) = False);

  end else
  begin

    If ProtectAddress( Address, PC_USER OR PC_STATIC OR PC_WRITEABLE ) = False then Exit;
    Result := (IsBadWritePtr( Pointer(Address), Size ) = False);

  end;

end;

//------------------------------------------------------------------------------

function SetReadAccess( Address, Size : DWORD ) : Boolean;
var
  OldProtect : DWORD;

begin
  Result     := False;

  If IsNT then
  begin

    if VirtualProtect( Pointer(Address), Size, PAGE_EXECUTE_READ, OldProtect ) = False then Exit;
    Result := (IsBadWritePtr( Pointer(Address), Size ) );

  end else
  begin

    If ProtectAddress( Address, PC_USER OR PC_STATIC ) = False then Exit;
    Result := (IsBadWritePtr( Pointer(Address), Size ) );

  end;

end;
br, nerst
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
.NET dll hooking Avi_RE General Discussion 10 09-28-2023 07:09
Windows Api Hooking user1 Source Code 12 12-24-2022 09:57
Hooking WMI (.NET Application) aldente General Discussion 12 08-07-2012 01:32
API Hooking thomasantony General Discussion 5 04-22-2005 11:44


All times are GMT +8. The time now is 16:52.


Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX, chessgod101
( Since 1998 )