관리 메뉴

kisoo

CmRegisterCallback routine 본문

01.About Programming /2.Kernel Lab

CmRegisterCallback routine

JamesK78 2012. 2. 15. 11:44
기존 WINDOW 32비트 플랫폼에서의 regmon은 KeServiceDescriptorTable에 등록되어있는
NativeAPI 중 레지스트리 관련 API들을 Hooking하는 드라이버를 제작하여
regmon 을 구현 하였다. 

하지만 64비트 플랫폼에서는 더이상 커널 후킹이 불가능(Kernel Patch Protection때문)하고
기존의 KeServiceDescriptorTable과 같이 후킹하기 편한 형태로 SystemCall을 구현하고 있지 않기 때문에
더이상 기존의 방식을 사용할수가 없게 되었다. 

regmon for x64 버전을 살펴보았더니 MS에서 이미 이런 문제를 위해 XP이상 부터 동작 가능한 
Registry Callback 기능을 추가하였다. 

참고 URL : 
http://www.codeproject.com/Articles/17263/Moving-to-Windows-Vista-x64 


NTSTATUS 
  RegistryCallback(
    IN PVOID  CallbackContext,
    IN PVOID  Argument1,
    IN PVOID  Argument2 
    );

위와 같은 함수형태를 가지고 있고 레지스트리 API 가 호출되기전에  callback을 받을수도있고
호출된후에 callback을 받을수도 있도록 되어있다. 

NTSTATUS
  CmRegisterCallback(
    IN PEX_CALLBACK_FUNCTION
  Function,
    IN PVOID  
Context,
    OUT PLARGE_INTEGER  
Cookie 
    );
 
 
Callback 함수는 위와 같은 프로토타입을 가지고 있고 적절한 STATUS를 리턴할수있도록

되어 있어 레지스트리 억세스 컨트롤 기능도 그대로 구현할 수 있다. 
 


This topic has not yet been rated Rate this topic

The CmRegisterCallback routine is obsolete for Windows Vista and later operating system versions. Use CmRegisterCallbackEx instead.

The CmRegisterCallback routine registers a RegistryCallback routine.

Syntax

NTSTATUS CmRegisterCallback(
  __in      PEX_CALLBACK_FUNCTION Function,
  __in_opt  PVOID Context,
  __out     PLARGE_INTEGER Cookie
);

Parameters

Function [in]

A pointer to the RegistryCallback routine to register.

Context [in, optional]

A driver-defined value that the configuration manager will pass as the CallbackContext parameter to the RegistryCallback routine

Cookie [out]

A pointer to a LARGE_INTEGER variable that receives the value that identifies the callback routine. When you unregister the callback routine, pass this value as the Cookie parameter to CmUnRegisterCallback.

Return value

CmRegisterCallback returns STATUS_SUCCESS if the operation succeeds or the appropriate NTSTATUS error code if it fails.

Remarks

The CmRegisterCallback routine is available on Windows XP and later operating system versions. For Windows Vista and later operating system versions, you should use CmRegisterCallbackEx instead.

A driver calls CmRegisterCallback to register a RegistryCallback routine, which is called every time a thread performs an operation on the registry.

Call CmUnRegisterCallback to unregister a callback routine that CmRegisterCallback registered.

For more information about CmRegisterCallback and filtering registry operations, see Filtering Registry Calls.

Requirements

Version

Available in Windows XP and later versions of Windows.

Header

Wdm.h (include Wdm.h, Ntddk.h, or Ntifs.h)

Library

Contained in Ntoskrnl.lib.

IRQL

<=APC_LEVEL

See also

RegistryCallback
CmRegisterCallbackEx
CmUnRegisterCallback

 
http://msdn.microsoft.com/en-us/library/windows/hardware/ff541918(v=vs.85).aspx  

Comments