00001 /*++ 00002 00003 Copyright (c) 1991 Microsoft Corporation 00004 00005 Module Name: 00006 00007 cmdelete.c 00008 00009 Abstract: 00010 00011 This module contains the delete object method (used to delete key 00012 control blocks when last handle to a key is closed, and to delete 00013 keys marked for deletetion when last reference to them goes away.) 00014 00015 Author: 00016 00017 Bryan M. Willman (bryanwi) 13-Nov-91 00018 00019 Revision History: 00020 00021 --*/ 00022 00023 #include "cmp.h" 00024 00025 #ifdef ALLOC_PRAGMA 00026 #pragma alloc_text(PAGE,CmpDeleteKeyObject) 00027 #endif 00028 00029 00030 VOID 00031 CmpDeleteKeyObject( 00032 IN PVOID Object 00033 ) 00034 /*++ 00035 00036 Routine Description: 00037 00038 This routine interfaces to the NT Object Manager. It is invoked when 00039 the last reference to a particular Key object (or Key Root object) 00040 is destroyed. 00041 00042 If the Key object going away holds the last reference to 00043 the extension it is associated with, that extension is destroyed. 00044 00045 Arguments: 00046 00047 Object - supplies a pointer to a KeyRoot or Key, thus -> KEY_BODY. 00048 00049 Return Value: 00050 00051 NONE. 00052 00053 --*/ 00054 { 00055 PCM_KEY_CONTROL_BLOCK KeyControlBlock; 00056 PCM_KEY_BODY KeyBody; 00057 00058 PAGED_CODE(); 00059 00060 CMLOG(CML_MAJOR, CMS_NTAPI) { 00061 KdPrint(("CmpDeleteKeyObject: Object = %08lx\n", Object)); 00062 } 00063 00064 CmpLockRegistry(); 00065 00066 KeyBody = (PCM_KEY_BODY)Object; 00067 00068 if (KeyBody->Type==KEY_BODY_TYPE) { 00069 KeyControlBlock = KeyBody->KeyControlBlock; 00070 00071 // 00072 // the keybody should be initialized; when kcb is null, something went wrong 00073 // between the creation and the dereferenciation of the object 00074 // 00075 if( KeyControlBlock != NULL ) { 00076 00077 // 00078 // Clean up any outstanding notifies attached to the KeyBody 00079 // 00080 CmpFlushNotify(KeyBody); 00081 00082 // 00083 // Remove our reference to the KeyControlBlock, clean it up, perform any 00084 // pend-till-final-close operations. 00085 // 00086 // NOTE: Delete notification is seen at the parent of the deleted key, 00087 // not the deleted key itself. If any notify was outstanding on 00088 // this key, it was cleared away above us. Only parent/ancestor 00089 // keys will see the report. 00090 // 00091 // 00092 // The dereference will free the KeyControlBlock. If the key was deleted, it 00093 // has already been removed from the hash table, and relevent notifications 00094 // posted then as well. All we are doing is freeing the tombstone. 00095 // 00096 // If it was not deleted, we're both cutting the kcb out of 00097 // the kcb list/tree, AND freeing its storage. 00098 // 00099 00100 DELIST_KEYBODY_FROM_KEYBODY_LIST(KeyBody); 00101 CmpDereferenceKeyControlBlock(KeyControlBlock); 00102 } 00103 } else { 00104 // 00105 // This must be a predefined handle 00106 // some sanity asserts 00107 // 00108 KeyControlBlock = KeyBody->KeyControlBlock; 00109 00110 ASSERT( KeyBody->Type®_PREDEF_HANDLE_MASK); 00111 ASSERT( KeyControlBlock->Flags&KEY_PREDEF_HANDLE ); 00112 00113 if( KeyControlBlock != NULL ) { 00114 CmpDereferenceKeyControlBlock(KeyControlBlock); 00115 } 00116 00117 } 00118 CmpUnlockRegistry(); 00119 return; 00120 } 00121