Changeset 38903 in vbox for trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/dbg
- Timestamp:
- Sep 29, 2011 4:20:22 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 74235
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/dbg/VBoxVideoWinDbg.cpp
r36867 r38903 106 106 PCSTR pExpr = args; 107 107 108 /* address */ 108 109 if (!pExpr) { dprintf("address not specified\n"); return; } 109 110 if (!GetExpressionEx(pExpr, &u64Mem, &pExpr)) { dprintf("error evaluating address\n"); return; } 110 111 if (!u64Mem) { dprintf("address value can not be NULL\n"); return; } 111 112 113 /* width */ 112 114 if (!pExpr) { dprintf("width not specified\n"); return; } 113 115 if (!GetExpressionEx(pExpr, &u64Width, &pExpr)) { dprintf("error evaluating width\n"); return; } 114 116 if (!u64Width) { dprintf("width value can not be NULL\n"); return; } 115 117 118 /* height */ 116 119 if (!pExpr) { dprintf("height not specified\n"); return; } 117 120 if (!GetExpressionEx(pExpr, &u64Height, &pExpr)) { dprintf("error evaluating height\n"); return; } 118 121 if (!u64Height) { dprintf("height value can not be NULL\n"); return; } 119 122 123 #if 0 120 124 if (pExpr && GetExpressionEx(pExpr, &u64NumColors, &pExpr)) 121 125 { 122 126 if (!u64NumColors) { dprintf("Num Colors value can not be NULL\n"); return; } 123 127 } 124 128 #endif 129 130 /* bpp */ 125 131 if (pExpr && GetExpressionEx(pExpr, &u64Bpp, &pExpr)) 126 132 { … … 128 134 } 129 135 136 /* pitch */ 130 137 u64DefaultPitch = (((((u64Width * u64Bpp) + 7) >> 3) + 3) & ~3ULL); 131 138 if (pExpr && GetExpressionEx(pExpr, &u64Pitch, &pExpr)) 132 139 { 133 if (u64Pitch < u64DefaultPitch) { dprintf("pitch value can not be less than (% I)\n",u64DefaultPitch); return; }140 if (u64Pitch < u64DefaultPitch) { dprintf("pitch value can not be less than (%d)\n", (UINT)u64DefaultPitch); return; } 134 141 } 135 142 else … … 143 150 ULONG64 cbSize = u64DefaultPitch * u64Height; 144 151 PVOID pvBuf = malloc(cbSize); 145 if (pvBuf) 146 { 147 ULONG uRc = 0; 148 if(u64DefaultPitch == u64Pitch) 152 if (!pvBuf) 153 { 154 dprintf("failed to allocate memory buffer of size(%d)\n", (UINT)cbSize); 155 return; 156 } 157 ULONG uRc = 0; 158 #if 0 159 if(u64DefaultPitch == u64Pitch) 160 #else 161 if(0) 162 #endif 163 { 164 ULONG cbRead = 0; 165 dprintf("reading the entire memory buffer...\n"); 166 uRc = ReadMemory(u64Mem, pvBuf, cbSize, &cbRead); 167 if (!uRc) 168 { 169 dprintf("Failed to read the memory buffer of size(%d)\n", (UINT)cbSize); 170 } 171 else if (cbRead != cbSize) 172 { 173 dprintf("the actual number of bytes read(%d) no equal the requested size(%d)\n", (UINT)cbRead, (UINT)cbSize); 174 uRc = 0; 175 } 176 177 } 178 else 179 { 180 ULONG64 u64Offset = u64Mem; 181 char* pvcBuf = (char*)pvBuf; 182 ULONG64 i; 183 dprintf("reading memory by chunks since custom pitch is specified...\n"); 184 for (i = 0; i < u64Height; ++i, u64Offset+=u64Pitch, pvcBuf+=u64DefaultPitch) 149 185 { 150 186 ULONG cbRead = 0; 151 dprintf("reading the entire memory buffer...\n"); 152 uRc = ReadMemory(u64Mem, pvBuf, cbSize, &cbRead); 187 uRc = ReadMemory(u64Offset, pvcBuf, u64DefaultPitch, &cbRead); 153 188 if (!uRc) 154 189 { 155 dprintf("Failed to read the memory buffer of size(%I)\n", cbSize); 156 } 157 else if (cbRead != cbSize) 158 { 159 dprintf("the actual number of bytes read(%I) no equal the requested size(%I)\n", cbRead, cbSize); 160 uRc = 0; 161 } 162 163 } 164 else 165 { 166 ULONG64 u64Offset = u64Mem; 167 char* pvcBuf = (char*)pvBuf; 168 ULONG64 i; 169 dprintf("reading memory by chunks since custom pitch is specified...\n"); 170 for (i = 0; i < u64Height; ++i, u64Offset+=u64Pitch, pvcBuf+=u64DefaultPitch) 171 { 172 ULONG cbRead = 0; 173 uRc = ReadMemory(u64Offset, pvcBuf, u64DefaultPitch, &cbRead); 174 if (!uRc) 190 dprintf("WARNING!!! Failed to read the memory buffer of size(%d), chunk(%d)\n", (UINT)u64DefaultPitch, (UINT)i); 191 dprintf("ignoring this one and the all the rest, using height(%d)\n", (UINT)i); 192 u64Height = i; 193 uRc = 1; 194 break; 195 } 196 else if (cbRead != u64DefaultPitch) 197 { 198 dprintf("WARNING!!! the actual number of bytes read(%d) not equal the requested size(%d), chunk(%d)\n", (UINT)cbRead, (UINT)u64DefaultPitch, (UINT)i); 199 dprintf("ignoring this one and the all the rest, using height(%d)\n", (UINT)i); 200 u64Height = i; 201 break; 202 } 203 } 204 } 205 206 if (!uRc) 207 { 208 dprintf("read memory failed\n"); 209 free(pvBuf); 210 return; 211 } 212 213 if (!u64Height) 214 { 215 dprintf("no data to be processed since height it 0\n"); 216 free(pvBuf); 217 return; 218 } 219 220 switch (u64Bpp) 221 { 222 case 32: 223 case 24: 224 case 16: 225 #if 0 226 if (u64NumColors != 3) 227 { 228 dprintf("WARNING: unsupported number colors: (%d)\n", (UINT)u64NumColors); 229 } 230 #else 231 u64NumColors = 3; 232 #endif 233 break; 234 case 8: 235 { 236 #if 1 237 u64NumColors = 1; 238 #endif 239 240 if (u64NumColors == 1) 175 241 { 176 dprintf("Failed to read the memory buffer of size(%I), chunk(%I)\n", u64DefaultPitch, i); 177 break; 178 } 179 else if (cbRead != u64DefaultPitch) 180 { 181 dprintf("the actual number of bytes read(%I) no equal the requested size(%I), chunk(%I)\n", cbRead, u64DefaultPitch, i); 182 uRc = 0; 183 break; 184 } 185 } 186 } 187 188 if (uRc) 189 { 190 switch (u64Bpp) 191 { 192 case 32: 193 case 24: 194 case 16: 195 if (u64NumColors != 3) 242 ULONG64 cbSize32 = u64DefaultPitch * 4 * u64Height; 243 PVOID pvBuf32 = malloc(cbSize32); 244 if (!pvBuf32) 196 245 { 197 dprintf("WARNING: unsupported number colors: (%d)\n", u64NumColors); 246 dprintf("ERROR: failed to allocate memory buffer of size(%d)", cbSize32); 247 free(pvBuf); 248 return; 198 249 } 199 break; 200 case 8: 250 byte* pByteBuf32 = (byte*)pvBuf32; 251 byte* pByteBuf = (byte*)pvBuf; 252 memset(pvBuf32, 0, cbSize32); 253 for (UINT i = 0; i < u64Height; ++i) 201 254 { 202 if (u64NumColors == 1)255 for (UINT j = 0; j < u64Width; ++j) 203 256 { 204 ULONG64 cbSize32 = u64DefaultPitch * 4 * u64Height; 205 PVOID pvBuf32 = malloc(cbSize32); 206 if (pvBuf32) 207 { 208 byte* pByteBuf32 = (byte*)pvBuf32; 209 byte* pByteBuf = (byte*)pvBuf; 210 memset(pvBuf32, 0, cbSize32); 211 for (UINT i = 0; i < u64Height; ++i) 212 { 213 for (UINT j = 0; j < u64Width; ++j) 214 { 215 pByteBuf32[0] = pByteBuf[0]; 216 pByteBuf32[1] = pByteBuf[0]; 217 pByteBuf32[2] = pByteBuf[0]; 218 pByteBuf32 += 4; 219 pByteBuf += 1; 220 } 221 } 222 free(pvBuf); 223 pvBuf = pvBuf32; 224 u64DefaultPitch *= 4; 225 u64Bpp *= 4; 226 } 227 } 228 else 229 { 230 dprintf("WARNING: unsupported number colors: (%d)\n", u64NumColors); 257 pByteBuf32[0] = pByteBuf[0]; 258 pByteBuf32[1] = pByteBuf[0]; 259 pByteBuf32[2] = pByteBuf[0]; 260 pByteBuf32 += 4; 261 pByteBuf += 1; 231 262 } 232 263 } 233 break; 234 } 235 BITMAP Bmp = {0}; 236 HBITMAP hBmp; 237 dprintf("read memory succeeded..\n"); 238 Bmp.bmType = 0; 239 Bmp.bmWidth = (LONG)u64Width; 240 Bmp.bmHeight = (LONG)u64Height; 241 Bmp.bmWidthBytes = (LONG)u64DefaultPitch; 242 Bmp.bmPlanes = 1; 243 Bmp.bmBitsPixel = (WORD)u64Bpp; 244 Bmp.bmBits = (LPVOID)pvBuf; 245 hBmp = CreateBitmapIndirect(&Bmp); 246 if (hBmp) 247 { 248 if (OpenClipboard(GetDesktopWindow())) 264 free(pvBuf); 265 pvBuf = pvBuf32; 266 u64DefaultPitch *= 4; 267 u64Bpp *= 4; 268 } 269 else 249 270 { 250 if (EmptyClipboard()) 251 { 252 if (SetClipboardData(CF_BITMAP, hBmp)) 253 { 254 dprintf("succeeded!! You can now do <ctrl>+v in your favourite image editor\n"); 255 } 256 else 257 { 258 DWORD winEr = GetLastError(); 259 dprintf("SetClipboardData failed, err(%I)\n", winEr); 260 } 261 } 262 else 263 { 264 DWORD winEr = GetLastError(); 265 dprintf("EmptyClipboard failed, err(%I)\n", winEr); 266 } 267 268 CloseClipboard(); 271 dprintf("WARNING: unsupported number colors: (%d)\n", (UINT)u64NumColors); 272 } 273 } 274 break; 275 } 276 BITMAP Bmp = {0}; 277 HBITMAP hBmp; 278 dprintf("read memory succeeded..\n"); 279 Bmp.bmType = 0; 280 Bmp.bmWidth = (LONG)u64Width; 281 Bmp.bmHeight = (LONG)u64Height; 282 Bmp.bmWidthBytes = (LONG)u64DefaultPitch; 283 Bmp.bmPlanes = 1; 284 Bmp.bmBitsPixel = (WORD)u64Bpp; 285 Bmp.bmBits = (LPVOID)pvBuf; 286 hBmp = CreateBitmapIndirect(&Bmp); 287 if (hBmp) 288 { 289 if (OpenClipboard(GetDesktopWindow())) 290 { 291 if (EmptyClipboard()) 292 { 293 if (SetClipboardData(CF_BITMAP, hBmp)) 294 { 295 dprintf("succeeded!! You can now do <ctrl>+v in your favourite image editor\n"); 269 296 } 270 297 else 271 298 { 272 299 DWORD winEr = GetLastError(); 273 dprintf(" OpenClipboard failed, err(%I)\n", winEr);300 dprintf("SetClipboardData failed, err(%d)\n", winEr); 274 301 } 275 276 DeleteObject(hBmp);277 302 } 278 303 else 279 304 { 280 305 DWORD winEr = GetLastError(); 281 dprintf("CreateBitmapIndirect failed, err(%I)\n", winEr); 282 } 306 dprintf("EmptyClipboard failed, err(%d)\n", winEr); 307 } 308 309 CloseClipboard(); 283 310 } 284 311 else 285 312 { 286 dprintf("read memory failed\n"); 287 } 288 free(pvBuf); 313 DWORD winEr = GetLastError(); 314 dprintf("OpenClipboard failed, err(%d)\n", winEr); 315 } 316 317 DeleteObject(hBmp); 289 318 } 290 319 else 291 320 { 292 dprintf("failed to allocate memory buffer of size(%I)\n", cbSize); 293 } 294 } 321 DWORD winEr = GetLastError(); 322 dprintf("CreateBitmapIndirect failed, err(%d)\n", winEr); 323 } 324 }
Note:
See TracChangeset
for help on using the changeset viewer.