reactos/dll/cpl/desk/dibitmap.c
Hermès Bélusca-Maïto e1ef078741 Create this branch to work on loading of different Kernel-Debugger DLL providers, and see whether it is possible to move KDBG from ntoskrnl to a new DLL called, say, KDROSDBG.DLL.
The idea then would be to have the following behaviour (when specifying the following options in the kernel command line):

/DEBUGPORT=COMi --> load KDCOM.DLL and use COMi port (i == 1,2,3,4) if possible.
/DEBUGPORT=FOO  --> load KDFOO.DLL (useful for KDUSB.DLL, KD1394.DLL, KDBAZIS.DLL for VirtualKD, etc...)
/DEBUGPORT=ROSDBG:[COMi|SCREEN|FILE|GDB|...] --> load KDROSDBG.DLL which contains the ROS kernel debugger, and use COMi or SCREEN or... as output port.

svn path=/branches/kd++/; revision=58883
2013-04-28 13:26:45 +00:00

99 lines
2.5 KiB
C

/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Display Control Panel
* FILE: dll/cpl/desk/dibitmap.c
* PURPOSE: DIB loading
*
* PROGRAMMERS: Trevor McCort (lycan359@gmail.com)
*/
#include "desk.h"
PDIBITMAP
DibLoadImage(LPTSTR lpFilename)
{
BOOL bSuccess;
DWORD dwFileSize, dwHighSize, dwBytesRead;
HANDLE hFile;
PDIBITMAP lpBitmap;
hFile = CreateFile(lpFilename,
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_FLAG_SEQUENTIAL_SCAN,
NULL);
if (hFile == INVALID_HANDLE_VALUE)
return NULL;
dwFileSize = GetFileSize(hFile, &dwHighSize);
if (dwHighSize)
{
CloseHandle(hFile);
return NULL;
}
lpBitmap = HeapAlloc(GetProcessHeap(), 0, sizeof(DIBITMAP));
if (lpBitmap == NULL)
{
CloseHandle(hFile);
return NULL;
}
lpBitmap->header = HeapAlloc(GetProcessHeap(), 0, dwFileSize);
if (lpBitmap->header == NULL)
{
HeapFree(GetProcessHeap(), 0, lpBitmap);
CloseHandle(hFile);
return NULL;
}
bSuccess = ReadFile(hFile, lpBitmap->header, dwFileSize, &dwBytesRead, NULL);
CloseHandle(hFile);
if (!bSuccess ||
(dwBytesRead != dwFileSize) ||
(lpBitmap->header->bfType != * (WORD *) "BM") ||
(lpBitmap->header->bfSize != dwFileSize))
{
HeapFree(GetProcessHeap(), 0, lpBitmap->header);
HeapFree(GetProcessHeap(), 0, lpBitmap);
return NULL;
}
lpBitmap->info = (BITMAPINFO *)(lpBitmap->header + 1);
lpBitmap->bits = (BYTE *)lpBitmap->header + lpBitmap->header->bfOffBits;
/* Get the DIB width and height */
if (lpBitmap->info->bmiHeader.biSize == sizeof(BITMAPCOREHEADER))
{
lpBitmap->width = ((BITMAPCOREHEADER *)lpBitmap->info)->bcWidth;
lpBitmap->height = ((BITMAPCOREHEADER *)lpBitmap->info)->bcHeight;
}
else
{
lpBitmap->width = lpBitmap->info->bmiHeader.biWidth;
lpBitmap->height = abs(lpBitmap->info->bmiHeader.biHeight);
}
return lpBitmap;
}
VOID
DibFreeImage(PDIBITMAP lpBitmap)
{
if (lpBitmap == NULL)
return;
/* Free the header */
if (lpBitmap->header != NULL)
HeapFree(GetProcessHeap(), 0, lpBitmap->header);
/* Free the bitmap structure */
if (lpBitmap != NULL)
HeapFree(GetProcessHeap(), 0, lpBitmap);
}