| 94 | } |
| 95 | |
| 96 | NTSTATUS Section::FreeSection() { |
| 97 | // Release resources held for the mapped section |
| 98 | NTSTATUS status; |
| 99 | |
| 100 | PVOID Context = nullptr; |
| 101 | status = RtlRunOnceBeginInitialize(&_sectionSingletonState, 0, &Context); |
| 102 | if (NT_SUCCESS(status)) { |
| 103 | // We have initilized our singleton |
| 104 | |
| 105 | // do we have the context - otherwise there's nothing to delete |
| 106 | if (Context) { |
| 107 | LogInfo("FreeSection ,sectionType=%d", _type); |
| 108 | DllStats* pDllStats = (DllStats*)Context; |
| 109 | |
| 110 | ObMakeTemporaryObject(pDllStats->Section); |
| 111 | |
| 112 | ObDereferenceObjectWithTag(pDllStats->Section, 'k23w'); |
| 113 | pDllStats->Section = nullptr; |
| 114 | |
| 115 | // Free memory |
| 116 | delete pDllStats; |
| 117 | Context = nullptr; |
| 118 | } |
| 119 | |
| 120 | // Reset the singleton back |
| 121 | RtlRunOnceInitialize(&_sectionSingletonState); |
| 122 | } |
| 123 | else if (status == STATUS_UNSUCCESSFUL) { |
| 124 | // GetSection() wasn't called yet |
| 125 | status = STATUS_SUCCESS; |
| 126 | } |
| 127 | else { |
| 128 | // Error |
| 129 | LogError("Error: 0x%x RtlRunOnceBeginInitialize", status); |
| 130 | ASSERT(nullptr); |
| 131 | } |
| 132 | |
| 133 | return status; |
| 134 | } |
| 135 | |
| 136 | NTSTATUS Section::CreateKnownDllSection(DllStats& dllStats) { |
| 137 | // Create a known dll system section of our own |
no test coverage detected