Changeset 18171 in vbox for trunk/src/VBox/Additions/WINNT
- Timestamp:
- Mar 24, 2009 11:12:35 AM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 44882
- Location:
- trunk/src/VBox/Additions/WINNT/VBoxGuest
- Files:
-
- 3 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxGuest/Helper.cpp
r18170 r18171 26 26 #include <VBox/log.h> 27 27 #include <VBox/VBoxGuestLib.h> 28 29 #ifdef VBOX_WITH_GUEST_BUGCHECK_DETECTION30 # ifndef TARGET_NT431 # include <aux_klib.h>32 # endif33 #endif34 28 35 29 #ifdef ALLOC_PRAGMA … … 254 248 } 255 249 256 #ifdef VBOX_WITH_GUEST_BUGCHECK_DETECTION257 /**258 * Called when a bug check occurs.259 *260 * @param pvBuffer Pointer to our device extension, just in case it261 * comes in handy some day.262 * @param cbBuffer The size of our device extension.263 */264 static VOID hlpVBoxGuestBugCheckCallback(PVOID pvBuffer, ULONG cbBuffer)265 {266 /*PVBOXGUESTDEVEXT pDevExt = (PVBOXGUESTDEVEXT)pvBuffer;*/267 268 LogRelBackdoor(("Windows bug check (bluescreen) detected!\n"));269 270 # ifndef TARGET_NT4271 /*272 * Try get details.273 */274 KBUGCHECK_DATA bugCheckData;275 bugCheckData.BugCheckDataSize = sizeof(KBUGCHECK_DATA);276 NTSTATUS rc = AuxKlibGetBugCheckData(&bugCheckData);277 if (NT_SUCCESS(rc))278 {279 LogRelBackdoor(("Bug check code: 0x%08x\n", bugCheckData.BugCheckCode));280 LogRelBackdoor(("Bug check parameters: 1=0x%p 2=0x%p 3=0x%p 4=0x%p\n",281 bugCheckData.Parameter1,282 bugCheckData.Parameter2,283 bugCheckData.Parameter3,284 bugCheckData.Parameter4));285 LogRelBackdoor(("For details run \"!analyze -show %x %p %p %p %p\" in WinDbg.\n",286 bugCheckData.BugCheckCode,287 bugCheckData.Parameter1,288 bugCheckData.Parameter2,289 bugCheckData.Parameter3,290 bugCheckData.Parameter4));291 }292 else293 LogRelBackdoor(("Unable to retrieve bugcheck details! Error: %#x\n", rc));294 # else /* NT4 */295 LogRelBackdoor(("No additional information for Windows NT 4.0 bugcheck available.\n"));296 # endif /* NT4 */297 298 /*299 * Notify the host that we've panicked.300 */301 /** @todo Notify the host somehow over DevVMM. */302 303 NOREF(pvBuffer); NOREF(cbBuffer);304 }305 306 NTSTATUS hlpRegisterBugCheckCallback(PVBOXGUESTDEVEXT pDevExt)307 {308 NTSTATUS rc = STATUS_SUCCESS;309 pDevExt->bBugcheckCallbackRegistered = FALSE;310 311 # ifndef TARGET_NT4312 /*313 * This is required for calling AuxKlibGetBugCheckData() in hlpVBoxGuestBugCheckCallback().314 */315 rc = AuxKlibInitialize();316 if (NT_ERROR(rc))317 {318 dprintf(("VBoxGuest::hlpRegisterBugCheckCallback: Unabled to initialize AuxKlib! rc=%#x\n", rc));319 return STATUS_DRIVER_UNABLE_TO_LOAD;320 }321 # endif322 323 /*324 * Setup bugcheck callback routine.325 */326 pDevExt->bBugcheckCallbackRegistered = FALSE;327 KeInitializeCallbackRecord(&pDevExt->bugcheckRecord);328 if (KeRegisterBugCheckCallback(&pDevExt->bugcheckRecord,329 &hlpVBoxGuestBugCheckCallback,330 pDevExt,331 sizeof(*pDevExt),332 (PUCHAR)"VBoxGuest"))333 {334 pDevExt->bBugcheckCallbackRegistered = TRUE;335 dprintf(("VBoxGuest::hlpRegisterBugCheckCallback: Bugcheck callback registered.\n"));336 }337 else338 LogRelBackdoor(("Could not register bugcheck callback routine!\n"));339 340 return rc;341 }342 343 void hlpDeregisterBugCheckCallback(PVBOXGUESTDEVEXT pDevExt)344 {345 if (pDevExt->bBugcheckCallbackRegistered)346 {347 if (!KeDeregisterBugCheckCallback(&pDevExt->bugcheckRecord))348 dprintf(("VBoxGuest::VBoxGuestUnload: Unregistering bugcheck callback routine failed!\n"));349 pDevExt->bBugcheckCallbackRegistered = FALSE;350 }351 }352 #endif -
trunk/src/VBox/Additions/WINNT/VBoxGuest/Helper.h
r18170 r18171 60 60 * 61 61 * @param pDevExt VMMDev device extension 62 * @return NT status code63 62 */ 64 NTSTATUShlpRegisterBugCheckCallback (PVBOXGUESTDEVEXT pDevExt);63 void hlpRegisterBugCheckCallback (PVBOXGUESTDEVEXT pDevExt); 65 64 66 65 /** -
trunk/src/VBox/Additions/WINNT/VBoxGuest/HelperBugCheck.cpp
r18170 r18171 19 19 */ 20 20 21 //#define LOG_ENABLED 22 21 #ifdef VBOX_WITH_GUEST_BUGCHECK_DETECTION 22 /******************************************************************************* 23 * Header Files * 24 *******************************************************************************/ 23 25 #include "VBoxGuest_Internal.h" 24 26 #include "Helper.h" … … 27 29 #include <VBox/VBoxGuestLib.h> 28 30 29 #ifdef VBOX_WITH_GUEST_BUGCHECK_DETECTION 30 # ifndef TARGET_NT4 31 # include <aux_klib.h> 32 # endif 31 #ifndef TARGET_NT4 32 # include <aux_klib.h> 33 33 #endif 34 34 35 #ifdef ALLOC_PRAGMA36 #pragma alloc_text (PAGE, VBoxScanPCIResourceList)37 #endif38 35 39 /* CM_RESOURCE_MEMORY_* flags which were used on XP or earlier. */40 #define VBOX_CM_PRE_VISTA_MASK (0x3f)41 42 /**43 * Helper to scan the PCI resource list and remember stuff.44 *45 * @param pResList Resource list46 * @param pDevExt Device extension47 */48 NTSTATUS VBoxScanPCIResourceList(PCM_RESOURCE_LIST pResList, PVBOXGUESTDEVEXT pDevExt)49 {50 NTSTATUS rc = STATUS_SUCCESS;51 PCM_PARTIAL_RESOURCE_DESCRIPTOR partialData;52 53 // enumerate the resource list54 dprintf(("found %d resources\n", pResList->List->PartialResourceList.Count));55 ULONG rangeCount = 0;56 ULONG cMMIORange = 0;57 PBASE_ADDRESS baseAddress = pDevExt->baseAddress;58 for (ULONG i = 0; i < pResList->List->PartialResourceList.Count; i++)59 {60 partialData = &pResList->List->PartialResourceList.PartialDescriptors[i];61 switch (partialData->Type)62 {63 case CmResourceTypePort:64 {65 // overflow protection66 if (rangeCount < PCI_TYPE0_ADDRESSES)67 {68 dprintf(("I/O range: Base = %08x : %08x Length = %08x \n",69 partialData->u.Port.Start.HighPart,70 partialData->u.Port.Start.LowPart,71 partialData->u.Port.Length));72 //@todo not so gut73 dprintf(("I got all I want, my dear port, oh!\n"));74 pDevExt->startPortAddress = (ULONG)partialData->u.Port.Start.LowPart;75 // save resource information76 baseAddress->RangeStart = partialData->u.Port.Start;77 baseAddress->RangeLength = partialData->u.Port.Length;78 baseAddress->RangeInMemory = FALSE;79 baseAddress->ResourceMapped = FALSE;80 // next item81 rangeCount++; baseAddress++;82 }83 break;84 }85 86 case CmResourceTypeInterrupt:87 {88 dprintf(("Interrupt: Level = %x Vector = %x Mode = %x \n",89 partialData->u.Interrupt.Level,90 partialData->u.Interrupt.Vector,91 partialData->Flags));92 // save information93 pDevExt->interruptLevel = partialData->u.Interrupt.Level;94 pDevExt->interruptVector = partialData->u.Interrupt.Vector;95 pDevExt->interruptAffinity = partialData->u.Interrupt.Affinity;96 // check interrupt mode97 if (partialData->Flags & CM_RESOURCE_INTERRUPT_LATCHED)98 {99 pDevExt->interruptMode = Latched;100 }101 else102 {103 pDevExt->interruptMode = LevelSensitive;104 }105 break;106 }107 108 case CmResourceTypeMemory:109 {110 // overflow protection111 if (rangeCount < PCI_TYPE0_ADDRESSES)112 {113 dprintf(("Memory range: Base = %08x : %08x Length = %08x \n",114 partialData->u.Memory.Start.HighPart,115 partialData->u.Memory.Start.LowPart,116 partialData->u.Memory.Length));117 // we only care about read/write memory118 /** @todo reconsider memory type */119 if ( cMMIORange == 0 /* only care about the first mmio range (!!!) */120 && (partialData->Flags & VBOX_CM_PRE_VISTA_MASK) == CM_RESOURCE_MEMORY_READ_WRITE)121 {122 pDevExt->memoryAddress = partialData->u.Memory.Start;123 pDevExt->memoryLength = (ULONG)partialData->u.Memory.Length;124 // save resource information125 baseAddress->RangeStart = partialData->u.Memory.Start;126 baseAddress->RangeLength = partialData->u.Memory.Length;127 baseAddress->RangeInMemory = TRUE;128 baseAddress->ResourceMapped = FALSE;129 // next item130 rangeCount++; baseAddress++;cMMIORange++;131 } else132 {133 dprintf(("Ignoring memory: flags = %08x \n", partialData->Flags));134 }135 }136 break;137 }138 139 case CmResourceTypeDma:140 {141 dprintf(("DMA resource found. Hmm...\n"));142 break;143 }144 145 default:146 {147 dprintf(("Unexpected resource found %d. Hmm...\n", partialData->Type));148 break;149 }150 }151 }152 // memorize the number of resources found153 pDevExt->addressCount = rangeCount;154 155 return rc;156 }157 158 159 NTSTATUS hlpVBoxMapVMMDevMemory (PVBOXGUESTDEVEXT pDevExt)160 {161 NTSTATUS rc = STATUS_SUCCESS;162 163 if (pDevExt->memoryLength != 0)164 {165 pDevExt->pVMMDevMemory = (VMMDevMemory *)MmMapIoSpace (pDevExt->memoryAddress, pDevExt->memoryLength, MmNonCached);166 dprintf(("VBoxGuest::VBoxGuestPnp: VMMDevMemory: ptr = 0x%x\n", pDevExt->pVMMDevMemory));167 if (pDevExt->pVMMDevMemory)168 {169 dprintf(("VBoxGuest::VBoxGuestPnp: VMMDevMemory: version = 0x%x, size = %d\n", pDevExt->pVMMDevMemory->u32Version, pDevExt->pVMMDevMemory->u32Size));170 171 /* Check version of the structure */172 if (pDevExt->pVMMDevMemory->u32Version != VMMDEV_MEMORY_VERSION)173 {174 /* Not our version, refuse operation and unmap the memory */175 hlpVBoxUnmapVMMDevMemory (pDevExt);176 177 rc = STATUS_UNSUCCESSFUL;178 }179 }180 else181 {182 rc = STATUS_UNSUCCESSFUL;183 }184 }185 186 return rc;187 }188 189 void hlpVBoxUnmapVMMDevMemory (PVBOXGUESTDEVEXT pDevExt)190 {191 if (pDevExt->pVMMDevMemory)192 {193 MmUnmapIoSpace (pDevExt->pVMMDevMemory, pDevExt->memoryLength);194 pDevExt->pVMMDevMemory = NULL;195 }196 197 pDevExt->memoryAddress.QuadPart = 0;198 pDevExt->memoryLength = 0;199 }200 201 NTSTATUS hlpVBoxReportGuestInfo (PVBOXGUESTDEVEXT pDevExt)202 {203 VMMDevReportGuestInfo *req = NULL;204 205 int rc = VbglGRAlloc ((VMMDevRequestHeader **)&req, sizeof (VMMDevReportGuestInfo), VMMDevReq_ReportGuestInfo);206 207 dprintf(("hlpVBoxReportGuestInfo: VbglGRAlloc rc = %d\n", rc));208 209 if (RT_SUCCESS(rc))210 {211 req->guestInfo.additionsVersion = VMMDEV_VERSION;212 213 /* we've already determined the Windows product before */214 switch (winVersion)215 {216 case WINNT4:217 req->guestInfo.osType = VBOXOSTYPE_WinNT4;218 break;219 case WIN2K:220 req->guestInfo.osType = VBOXOSTYPE_Win2k;221 break;222 case WINXP:223 req->guestInfo.osType = VBOXOSTYPE_WinXP;224 break;225 case WIN2K3:226 req->guestInfo.osType = VBOXOSTYPE_Win2k3;227 break;228 case WINVISTA:229 req->guestInfo.osType = VBOXOSTYPE_WinVista;230 break;231 default:232 /* we don't know, therefore NT family */233 req->guestInfo.osType = VBOXOSTYPE_WinNT;234 break;235 }236 237 /** @todo registry lookup for additional information */238 239 240 rc = VbglGRPerform (&req->header);241 242 if (RT_FAILURE(rc) || RT_FAILURE(req->header.rc))243 {244 dprintf(("VBoxGuest::hlpVBoxReportGuestInfo: error reporting guest info to VMMDev."245 "rc = %d, VMMDev rc = %Rrc\n", rc, req->header.rc));246 }247 248 rc = RT_SUCCESS(rc) ? req->header.rc : rc;249 250 VbglGRFree (&req->header);251 }252 253 return RT_FAILURE(rc) ? STATUS_UNSUCCESSFUL : STATUS_SUCCESS;254 }255 256 #ifdef VBOX_WITH_GUEST_BUGCHECK_DETECTION257 36 /** 258 37 * Called when a bug check occurs. … … 304 83 } 305 84 306 NTSTATUShlpRegisterBugCheckCallback(PVBOXGUESTDEVEXT pDevExt)85 void hlpRegisterBugCheckCallback(PVBOXGUESTDEVEXT pDevExt) 307 86 { 308 NTSTATUS rc = STATUS_SUCCESS;309 87 pDevExt->bBugcheckCallbackRegistered = FALSE; 310 88 … … 313 91 * This is required for calling AuxKlibGetBugCheckData() in hlpVBoxGuestBugCheckCallback(). 314 92 */ 315 rc = AuxKlibInitialize();93 NTSTATUS rc = AuxKlibInitialize(); 316 94 if (NT_ERROR(rc)) 317 95 { 318 dprintf(("VBoxGuest::hlpRegisterBugCheckCallback: Unabled to initialize AuxKlib! rc=%#x\n", rc));319 return STATUS_DRIVER_UNABLE_TO_LOAD;96 LogRelBackdoor(("VBoxGuest: Failed to initialize AuxKlib! rc=%#x\n", rc)); 97 return; 320 98 } 321 99 # endif … … 336 114 } 337 115 else 338 LogRelBackdoor(("Could not register bugcheck callback routine!\n")); 339 340 return rc; 116 LogRelBackdoor(("VBoxGuest: Could not register bugcheck callback routine!\n")); 341 117 } 342 118 … … 350 126 } 351 127 } 352 #endif 128 129 #endif /* VBOX_WITH_GUEST_BUGCHECK_DETECTION */ 130 -
trunk/src/VBox/Additions/WINNT/VBoxGuest/Makefile.kmk
r18170 r18171 44 44 VBoxGuestPnP.cpp \ 45 45 Helper.cpp \ 46 HelperBugCheck.cpp \ 46 47 VBoxGuest.rc 47 48 VBoxGuest_LIBS = \ … … 52 53 53 54 ifdef VBOX_WITH_GUEST_BUGCHECK_DETECTION 54 VBoxGuest_SDKS = WINDDKWLH 55 VBoxGuest_LIBS = \ 55 VBoxGuest_LIBS += \ 56 56 $(PATH_SDK_WINDDKWLH_LIB)/ksecdd.lib \ 57 57 $(PATH_SDK_WINDDKWLH_LIB)/BufferOverflowK.lib \ 58 58 $(PATH_SDK_WINDDKWLH_LIB)/aux_klib.lib 59 VBoxGuest_HelperBugCheck.cpp_SDKS = WINDDKWLH 59 60 endif 60 61 … … 70 71 VBoxGuest.cpp \ 71 72 Helper.cpp \ 73 HelperBugCheck.cpp \ 72 74 NTLegacy.cpp \ 73 75 VBoxGuest.rc
Note:
See TracChangeset
for help on using the changeset viewer.