كل الـ Samples الخاصة بـ KMD لـ mickeylan
#1
السلام عليكم و رحمة الله و بركاته
- ProcessMon , ssdt , FileWorks ..... ect
PHP كود :
Welcome to Kmdkit4d

 
as you see,Kmdkit4d is a driver development kit for Delphi users,you can build driver with object pascal,no more C or C++,if you are not familiar with C language,write code for driver mayy be difficult,but,now,no more,we offerd an alternative choice for Delphi users,that's kmdkit4d.
 to download kmdkit4d,you may check your version for Delphi,since some type definition changed,there are two different version,one for Delphi 7 and one for Delphi2010.

 BTW,Kmdkit4d is not a complete development kit,upgrade will be realeased to enhance its function.
 THX for supporting Kmdkit4d,the Kernel Mode Driver Kit 4 Delphi.
 any questions are welcomed, you can post it here,we will do what we can to help

Update Log:
  2010.02.05 -- Added DirectIO routine for the demonstration how to use Direct I/O when the user application communication with driver, and the client using WriteFile and ReadFile send and receive data to/from driver; 
  Added a simple example -- ProcessMon for demonstration usage of Shared Event object and client application interact with the driver; 
  KmdKit4D can use the try ... except and try...finally to handle exception; 
  Updated rmcoff2 to 2.0.0.89. 
التحميل :
كود :
hxxp://www.4shared.com/file/A7uLnkmD/samplesBy_mickeylan.html
كود :
hxxp://www.mediafire.com/?c52o7x1xx7y96j4
بالتوفيق,,
I'M Fly Like A G6

الرد
#2
- وحدة ntddk Smile
كود :
// // all DDDK drivers should include this unit // this unit exports all currently supported kernel function, structures and constants //
- مثال NtOpenProcess[SSDT Hook]i
PHP كود :
{
  
NtOpenProcess(SSDT Hook) By Anskya
  Email
: Anskya(at)G M A I L.com
}
unit Driver;

interface

uses
  ntddk
;  // ---->DDDK.pas

function _DriverEntry(DriverObject: PDriverObject; RegistryPath: PUnicodeString): NTSTATUS; stdcall;

implementation

type
  TZwOpenProcess 
= function(ProcessHandle:PHandle; DesiredAccess:TAccessMask; ObjectAttributes:PObjectAttributes; ClientId:PClientId): NTSTATUS; stdcall;

var
  
HookActive: Boolean;
  
ZwOpenProcessNextHook: TZwOpenProcess;

function 
GetImportFunAddr(lpImportAddr: Pointer): Pointer; stdcall;
begin
  Result 
:= PPointer(PPointer(Cardinal(lpImportAddr) + 2)^)^;
end;

function 
SystemServiceName(AFunc: Pointer): PLONG; stdcall;
var
  
lpKeServiceDescriptorTable: PServiceDescriptorEntry;
begin
  lpKeServiceDescriptorTable 
:= PPointer(@KeServiceDescriptorTable)^;
  
Result := PLONG(Cardinal(lpKeServiceDescriptorTable^.ServiceTableBase) + (SizeOf(ULONG) * PULONG(ULONG(AFunc) + 1)^));
end;

function 
SystemServiceOrd(iOrd: ULONG): PLONG; stdcall;
var
  
lpKeServiceDescriptorTable: PServiceDescriptorEntry;
begin
  lpKeServiceDescriptorTable 
:= PPointer(@KeServiceDescriptorTable)^;
  
Result := PLONG(PLONG(Cardinal(lpKeServiceDescriptorTable^.ServiceTableBase) + (SizeOf(ULONG) * iOrd)));
end;

function 
ZwOpenProcessHookProc(ProcessHandle:PHandle; DesiredAccess:TAccessMask; ObjectAttributes:PObjectAttributes; ClientId:PClientId): NTSTATUS; stdcall;
begin
  DbgPrint
('ZwOpenProcess HookProc: NewZwOpenProcess(ProcessHandle:0x%.8X,DesiredAccess:0x%.8X,ObjectAttributes:0x%.8X,ClientId:0x%.8X)',
         
ProcessHandle, DesiredAccess, ObjectAttributes, ClientId);

  
Result := ZwOpenProcessNextHook(ProcessHandle, DesiredAccess, ObjectAttributes, ClientId);
  
DbgPrint('ZwOpenProcess HookProc: NewZwOpenProcess(-):0x%.8X', Result);
end;

procedure DriverUnload(DriverObject:PDriverObject); stdcall;
begin
  
if (HookActive) then
  begin
    asm
      cli                                               
//disable WP bit
      
push  eax
      mov   eax
, cr0                                    //move CR0 register into EAX
      
and   eax, not 000010000h                         //disable WP bit
      
mov   cr0, eax                                    //write register back
      
pop   eax
    end
;

    
ZwOpenProcessNextHook := TZwOpenProcess(xInterlockedExchange(SystemServiceName(GetImportFunAddr(@ZwOpenProcess)), LONG(@ZwOpenProcessNextHook)));

    
asm
      push  eax                                           
//enable WP bit
      
mov   eax, cr0                                      //move CR0 register into EAX
      
or    eax, 000010000h                               //enable WP bit
      
mov   cr0, eax                                      //write register back
      
pop   eax
      sti
    end
;

    
DbgPrint('ZwOpenProcess New Address: 0x%.8X', SystemServiceName(GetImportFunAddr(@ZwOpenProcess))^);
    
DbgPrint('ZwOpenProcess Old Address: 0x%.8X', DWORD(@ZwOpenProcessNextHook));

    
HookActive := False;
  
end;
  
DbgPrint('DriverUnload(-)');
end;

function 
_DriverEntry(DriverObject:PDriverObject;RegistryPath:PUnicodeString): NTSTATUS; stdcall;
begin
  DriverObject
^.DriverUnload := @DriverUnload;
  
Result := STATUS_SUCCESS;
  
DbgPrint('DriverEntry(-):0x%.8X', Result);

  
HookActive := False;

  
DbgPrint('ZwOpenProcess Import Address: 0x%.8X', GetImportFunAddr(@ZwOpenProcess));
  
DbgPrint('KeServiceDescriptorTable() Address 1: 0x%.8X', @KeServiceDescriptorTable);
  
DbgPrint('KeServiceDescriptorTable() Address 2: 0x%.8X', PPointer(@KeServiceDescriptorTable)^);

  
DbgPrint('ZwOpenProcess Ord Address: 0x%.8X', SystemServiceOrd($7A)^);    //  XP Ord!
  
DbgPrint('ZwOpenProcess Name Address: 0x%.8X', SystemServiceName(GetImportFunAddr(@ZwOpenProcess))^);
  
DbgPrint('ZwOpenProcess HookProc Address: 0x%.8X', @ZwOpenProcessHookProc);

  if (
Not HookActive) then
  begin
    
//  SSDT Hook
    
asm                                             //disable WP bit
      
cli
      push  eax
      mov   eax
, cr0                                   //move CR0 register into EAX
      
and   eax, not 000010000h                        //disable WP bit
      
mov   cr0, eax                                   //write register back
      
pop   eax
    end
;

    
//lpNew^ := LONG(lpOld);
    
ZwOpenProcessNextHook := TZwOpenProcess(xInterlockedExchange(SystemServiceName(GetImportFunAddr(@ZwOpenProcess)), LONG(@ZwOpenProcessHookProc)));

    
asm
      push  eax                                       
//enable WP bit
      
mov   eax, cr0                                  //move CR0 register into EAX
      
or    eax, 000010000h                           //enable WP bit
      
mov   cr0, eax                                  //write register back
      
pop   eax
      sti
    end
;

    
DbgPrint('ZwOpenProcess New Address: 0x%.8X', SystemServiceName(GetImportFunAddr(@ZwOpenProcess))^);
    
DbgPrint('ZwOpenProcess Old Address: 0x%.8X', DWORD(@ZwOpenProcessNextHook));

    
HookActive := True;
  
end else
  
begin
    DbgPrint
('ZwOpenProcess Hooked!!! By Anskya');
  
end;

end;

end. 


الملفات المرفقة
.rar   ntddk.rar (الحجم : 9.75 ك ب / التحميلات : 57)
I'M Fly Like A G6

الرد


التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم