2011-11-21 3 views
6

this post을 읽은 후 숨겨진 레지스트리 키/값을 읽고 쓸 필요가있는 작은 응용 프로그램을 작성하려고했습니다.
Registry Manipulation using NT Native APIsCreating "Hidden" Registry Values 링크를 확인했습니다.
첫 번째 작업은 나에게 뭔가를 주었지만 C++로 작성되었으며 두 번째는 Delphi 프로젝트로 잘 작성되었습니다.
먼저 변환 할 수 없으며 두 번째 변환을 시도 할 수 있지만 키/값을 읽는 코드를 찾아야합니다. 이런 이유로 나는 "준비가되어있는"것이 있고 C#으로 테스트되었는지 알고 싶습니다.
Proces Hacker v1.11 소스 코드를 다운로드하여 아래에 표시된 것처럼 델파이 예제를 부분적으로 변환하는 데 사용했지만 숨겨진 레지스트리 키는 액세스 할 수 있지만 델파이에서는 그렇지 않습니다. 값을 쓰는 API는 없습니다. 숨겨진 레지스트리 키/값

static void Main(string[] args) 
{ 
    string KeyNameBuffer = @"\Registry\User\S-1-5-21-3979903645-2167650815-2353538381-1001\SOFTWARE"; 
    string NewKeyNameBuffer = "Systems Internals"; 
    string HiddenKeyNameBuffer = "Can't touch me\0"; 
    string HiddenValueNameBuffer = "Hidden Value"; 

    // Apro la chiave di registro 
    IntPtr SoftwareKeyHandle = CreateKey(KeyNameBuffer, IntPtr.Zero); 
    if (SoftwareKeyHandle != IntPtr.Zero) 
    { 
     IntPtr SysKeyHandle = CreateKey(NewKeyNameBuffer, SoftwareKeyHandle); 
     if (SysKeyHandle != IntPtr.Zero) 
     {   
      // This key shouldn't be accessible, but it is    
      IntPtr HiddenKeyHandle = CreateKey(HiddenKeyNameBuffer, SysKeyHandle); 
      if (HiddenKeyHandle != IntPtr.Zero) 
      { 
       // I don't have APIs to write values 
      } 
     } 
    } 
} 

static IntPtr CreateKey(string keyName, IntPtr rootKey) 
{ 
    IntPtr res; 
    KeyCreationDisposition disp; 
    ObjectAttributes attributes = new ObjectAttributes(keyName, 
     ObjectFlags.CaseInsensitive, 
     new NativeHandle(rootKey)); 
    NtStatus st = Win32.NtCreateKey(out res, KeyAccess.All, 
     ref attributes, 0, 
     IntPtr.Zero, RegOptions.NonVolatile, out disp); 
    return st == NtStatus.Success ? res : IntPtr.Zero; 
} 

마지막 : 예에서 내 사용자의 레지스트리 키를 사용 있도록, 관리자로 응용 프로그램을 실행하지 않는 경우에 비스타에서, 당신은 \Registry\Machine 일부를 쓸 수 없습니다. 컴퓨터 당 값을 저장해야한다면 레지스트리의 해당 부분을 쓰는 방법이 있습니까?

답변

1

당신이 그것을 HKLM에서 원하고 권한이 당신을 허용하지 않는다면, 당신이 사용하고있는 API 레이어, Nt *의 Reg * 기능에 상관 없습니다 - 그것은 당신이 접근 거부 오류.

관련 문제