|
没办法 被逼自己研究了下,特此公开,目前只在WIN2003 SP2 下测试,WIN64 应该也可以
- //未公开结构申明
- typedef struct _CM_KEY_BODY
- {
- ULONG Type;
- PVOID KeyControlBlock;
- PVOID NotifyBlock;
- HANDLE ProcessID; // the owner process
- LIST_ENTRY KeyBodyList; // key_nodes using the same kcb
- } CM_KEY_BODY, *PCM_KEY_BODY;
- typedef struct _CM_NAME_CONTROL_BLOCK
- {
- USHORT Compressed;
- USHORT RefCount;
- ULONG ConvKey;
- void* NextHash;
- USHORT NameLength;
- USHORT Name;
- } CM_NAME_CONTROL_BLOCK, *PCM_NAME_CONTROL_BLOCK;
- typedef struct _CM_KEY_CONTROL_BLOCK
- {
- ULONG RefCount;
- ULONG ExtFlags: 8;
- ULONG PrivateAlloc: 1;
- ULONG Delete: 1;
- ULONG DelayedCloseIndex: 12;
- ULONG TotalLevels: 10;
- ULONG ConvKey;
- void* NextHash;
- void* KeyHive;
- ULONG KeyCell;
- void* ParentKcb;
- void* NameBlock;
- //...
- }CM_KEY_CONTROL_BLOCK, *PCM_KEY_CONTROL_BLOCK;
- //RegistryCallback 调用
- case RegNtPreCreateKeyEx:
- {
- PREG_CREATE_KEY_INFORMATION createKey = (PREG_CREATE_KEY_INFORMATION)Argument2;
- GetRegObjectCompletePath(createKey->RootObject, createKey->CompleteName, ®istryPath);
- KdPrint(("[xiaoc] RegNtPreCreateKeyEx %wZ",registryPath));
- enumType = REG_TYPE_CREATE;
- if( RegFilter(enumType, ®istryPath, &g_stCreateReg) )
- {
- ntReg = STATUS_ACCESS_DENIED;
- }
- break;
- }
- BOOLEAN GetRegObjectCompletePath(PVOID pObject,PUNICODE_STRING pKeyName, PUNICODE_STRING pRootPath)
- {
- BOOLEAN bRet = FALSE;
- PCM_KEY_BODY pKeyBody = NULL;
- PCM_KEY_CONTROL_BLOCK pKeyControlBlock = NULL;
- PCM_NAME_CONTROL_BLOCK pNameBlock = NULL;
- ANSI_STRING aniPath;
- char szBuf[MAX_LENGTH] = {0};
- int nLen = 0;
- do
- {
- if( !pObject || !MmIsAddressValid(pObject) )
- {
- RtlCopyUnicodeString(pRootPath, pKeyName);
- RtlAppendUnicodeToString(pRootPath, L"\");
- break;
- }
- pKeyBody = (PCM_KEY_BODY)pObject;
- pKeyControlBlock = (PCM_KEY_CONTROL_BLOCK)pKeyBody->KeyControlBlock;
- while(pKeyControlBlock)
- {
- pNameBlock = (PCM_NAME_CONTROL_BLOCK)pKeyControlBlock->NameBlock;
- if( nLen + pNameBlock->NameLength + 1 >= MAX_LENGTH )
- {
- break;
- }
- RtlMoveMemory(szBuf + pNameBlock->NameLength + 1, szBuf, nLen);
- szBuf[0] = '\\';
- RtlCopyMemory(szBuf + 1, &pNameBlock->Name, pNameBlock->NameLength);
- nLen += pNameBlock->NameLength + 1;
- pKeyControlBlock = (PCM_KEY_CONTROL_BLOCK)pKeyControlBlock->ParentKcb;
- if( !MmIsAddressValid(pKeyControlBlock) )
- {
- break;
- }
- }
- RtlInitAnsiString(&aniPath, szBuf);
- RtlAnsiStringToUnicodeString(pRootPath,&aniPath, FALSE);
- if(pKeyName && pKeyName->Buffer)
- {
- RtlAppendUnicodeToString(pRootPath, pKeyName);
- RtlAppendUnicodeToString(pRootPath, L"\");
- }
- bRet = TRUE;
- } while (FALSE);
- return bRet;
- }
复制代码 |
评分
-
查看全部评分
|