VBoxVideoWinDbg.cpp revision 67927207a2d6bb545eb655ef14cdb090b1957120
70d78cc23a9585983d71fec4e7df3dce0de2b713vboxsync * Copyright (C) 2010 Oracle Corporation
70d78cc23a9585983d71fec4e7df3dce0de2b713vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
70d78cc23a9585983d71fec4e7df3dce0de2b713vboxsync * available from http://www.virtualbox.org. This file is free software;
c7814cf6e1240a519cbec0441e033d0e2470ed00vboxsync * you can redistribute it and/or modify it under the terms of the GNU
70d78cc23a9585983d71fec4e7df3dce0de2b713vboxsync * General Public License (GPL) as published by the Free Software
70d78cc23a9585983d71fec4e7df3dce0de2b713vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
70d78cc23a9585983d71fec4e7df3dce0de2b713vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
70d78cc23a9585983d71fec4e7df3dce0de2b713vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
70d78cc23a9585983d71fec4e7df3dce0de2b713vboxsync * DLL entry point.
70d78cc23a9585983d71fec4e7df3dce0de2b713vboxsync/* note: need to name it this way to make dprintf & other macros defined in wdbgexts.h work */
70d78cc23a9585983d71fec4e7df3dce0de2b713vboxsyncVOID WDBGAPI WinDbgExtensionDllInit(PWINDBG_EXTENSION_APIS64 lpExtensionApis, USHORT MajorVersion, USHORT MinorVersion);
70d78cc23a9585983d71fec4e7df3dce0de2b713vboxsyncVOID WDBGAPI WinDbgExtensionDllInit(PWINDBG_EXTENSION_APIS64 lpExtensionApis, USHORT MajorVersion, USHORT MinorVersion)
70d78cc23a9585983d71fec4e7df3dce0de2b713vboxsync dprintf("**** VirtulBox Video Driver debugging extension ****\n"
70d78cc23a9585983d71fec4e7df3dce0de2b713vboxsync " The following commands are supported: \n"
70d78cc23a9585983d71fec4e7df3dce0de2b713vboxsync " !ms - save memory (video data) to clipboard \n"
70d78cc23a9585983d71fec4e7df3dce0de2b713vboxsync " usage: !ms <virtual memory address> <width> <height> [bitsPerPixel (default is 32)] [pitch (default is ((width * bpp + 7) >> 3) + 3) & ~3)]\n");
002ceede8bd0a6978946f0fbf9877b6a07e94db7vboxsync if (!pExpr) { dprintf("address not specified\n"); return; }
002ceede8bd0a6978946f0fbf9877b6a07e94db7vboxsync if (!GetExpressionEx(pExpr, &u64Mem, &pExpr)) { dprintf("error evaluating address\n"); return; }
002ceede8bd0a6978946f0fbf9877b6a07e94db7vboxsync if (!u64Mem) { dprintf("address value can not be NULL\n"); return; }
70d78cc23a9585983d71fec4e7df3dce0de2b713vboxsync if (!pExpr) { dprintf("width not specified\n"); return; }
70d78cc23a9585983d71fec4e7df3dce0de2b713vboxsync if (!GetExpressionEx(pExpr, &u64Width, &pExpr)) { dprintf("error evaluating width\n"); return; }
70d78cc23a9585983d71fec4e7df3dce0de2b713vboxsync if (!u64Width) { dprintf("width value can not be NULL\n"); return; }
70d78cc23a9585983d71fec4e7df3dce0de2b713vboxsync if (!pExpr) { dprintf("height not specified\n"); return; }
70d78cc23a9585983d71fec4e7df3dce0de2b713vboxsync if (!GetExpressionEx(pExpr, &u64Height, &pExpr)) { dprintf("error evaluating height\n"); return; }
70d78cc23a9585983d71fec4e7df3dce0de2b713vboxsync if (!u64Height) { dprintf("height value can not be NULL\n"); return; }
70d78cc23a9585983d71fec4e7df3dce0de2b713vboxsync if (pExpr && GetExpressionEx(pExpr, &u64NumColors, &pExpr))
70d78cc23a9585983d71fec4e7df3dce0de2b713vboxsync if (!u64NumColors) { dprintf("Num Colors value can not be NULL\n"); return; }
70d78cc23a9585983d71fec4e7df3dce0de2b713vboxsync if (pExpr && GetExpressionEx(pExpr, &u64Bpp, &pExpr))
70d78cc23a9585983d71fec4e7df3dce0de2b713vboxsync if (!u64Bpp) { dprintf("bpp value can not be NULL\n"); return; }
70d78cc23a9585983d71fec4e7df3dce0de2b713vboxsync u64DefaultPitch = (((((u64Width * u64Bpp) + 7) >> 3) + 3) & ~3ULL);
4d0d9097df43f55a27ac86bdd587e8c217493e62vboxsync if (pExpr && GetExpressionEx(pExpr, &u64Pitch, &pExpr))
4d0d9097df43f55a27ac86bdd587e8c217493e62vboxsync if (u64Pitch < u64DefaultPitch) { dprintf("pitch value can not be less than (%I)\n", u64DefaultPitch); return; }
4d0d9097df43f55a27ac86bdd587e8c217493e62vboxsync dprintf("processing data for address(0x%p), width(%d), height(%d), bpp(%d), pitch(%d)...\n",
4d0d9097df43f55a27ac86bdd587e8c217493e62vboxsync u64Mem, (UINT)u64Width, (UINT)u64Height, (UINT)u64Bpp, (UINT)u64Pitch);
70d78cc23a9585983d71fec4e7df3dce0de2b713vboxsync dprintf("Failed to read the memory buffer of size(%I)\n", cbSize);
70d78cc23a9585983d71fec4e7df3dce0de2b713vboxsync dprintf("the actual number of bytes read(%I) no equal the requested size(%I)\n", cbRead, cbSize);
70d78cc23a9585983d71fec4e7df3dce0de2b713vboxsync dprintf("reading memory by chunks since custom pitch is specified...\n");
70d78cc23a9585983d71fec4e7df3dce0de2b713vboxsync for (i = 0; i < u64Height; ++i, u64Offset+=u64Pitch, pvcBuf+=u64DefaultPitch)
70d78cc23a9585983d71fec4e7df3dce0de2b713vboxsync uRc = ReadMemory(u64Offset, pvcBuf, u64DefaultPitch, &cbRead);
70d78cc23a9585983d71fec4e7df3dce0de2b713vboxsync dprintf("Failed to read the memory buffer of size(%I), chunk(%I)\n", u64DefaultPitch, i);
0d7011109d3d6a3608cd2e3e2d4f80bf537501b9vboxsync dprintf("the actual number of bytes read(%I) no equal the requested size(%I), chunk(%I)\n", cbRead, u64DefaultPitch, i);
0d7011109d3d6a3608cd2e3e2d4f80bf537501b9vboxsync dprintf("WARNING: unsupported number colors: (%d)\n", u64NumColors);
70d78cc23a9585983d71fec4e7df3dce0de2b713vboxsync ULONG64 cbSize32 = u64DefaultPitch * 4 * u64Height;
009635ee9648f6f4405065001dc9acb6f9af7c83vboxsync dprintf("WARNING: unsupported number colors: (%d)\n", u64NumColors);
70d78cc23a9585983d71fec4e7df3dce0de2b713vboxsync dprintf("succeeded!! You can now do <ctrl>+v in your favourite image editor\n");