By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,932 Members | 1,486 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,932 IT Pros & Developers. It's quick & easy.

Loading an image with no palette...

P: n/a
I've been ripping my hair our trying to get this to work for a week and I can't seem to get it. I'm trying to display a 4BppIndexed Bitmap from within the ntoskrnl.exe file that contains no palette. This bitmap is the one everyone likes to change to customize their boot screen. My goal is not to edit the kernel, but simply to display the bitmap content in much the same way a resource editor does.

My problem is that no matter what I do, the image always comes out completely black. Here's the code I'm using below, I hope SOMEONE can help me...

Thank you,
Jean-Sebastien Carle

-----------------------------------------------------------

// Get the module handle.
IntPtr hModule = Win32API.Kernel32.LoadLibrary(@"C:\Windows\System3 2\ntoskrnl.exe");

// Get the bitmap handle.
IntPtr hBMP = Win32API.User32.LoadImage(hModule, 1, Win32API.User32.IMAGE_BITMAP, 0, 0, Win32API.User32.LR_CREATEDIBSECTION);

// Release the module handle.
Win32API.Kernel32.FreeLibrary(hModule);

// Create default 16 color palette.
Win32API.GDI32.LOGPALETTE logPal;
logPal.palVersion = 0x300;
logPal.palNumEntries = 16;
logPal.palPalEntry = new byte[64];
logPal.palPalEntry[0] = 0;
logPal.palPalEntry[1] = 0;
logPal.palPalEntry[2] = 0;
logPal.palPalEntry[3] = 0;
logPal.palPalEntry[4] = 0;
logPal.palPalEntry[5] = 0;
logPal.palPalEntry[6] = 0;
logPal.palPalEntry[7] = 0;
logPal.palPalEntry[8] = 32;
logPal.palPalEntry[9] = 26;
logPal.palPalEntry[10] = 21;
logPal.palPalEntry[11] = 0;
logPal.palPalEntry[12] = 45;
logPal.palPalEntry[13] = 62;
logPal.palPalEntry[14] = 210;
logPal.palPalEntry[15] = 0;
logPal.palPalEntry[16] = 83;
logPal.palPalEntry[17] = 101;
logPal.palPalEntry[18] = 1;
logPal.palPalEntry[19] = 0;
logPal.palPalEntry[20] = 178;
logPal.palPalEntry[21] = 53;
logPal.palPalEntry[22] = 5;
logPal.palPalEntry[23] = 0;
logPal.palPalEntry[24] = 70;
logPal.palPalEntry[25] = 70;
logPal.palPalEntry[26] = 70;
logPal.palPalEntry[27] = 0;
logPal.palPalEntry[28] = 137;
logPal.palPalEntry[29] = 146;
logPal.palPalEntry[30] = 0;
logPal.palPalEntry[31] = 0;
logPal.palPalEntry[32] = 74;
logPal.palPalEntry[33] = 127;
logPal.palPalEntry[34] = 252;
logPal.palPalEntry[35] = 0;
logPal.palPalEntry[36] = 247;
logPal.palPalEntry[37] = 107;
logPal.palPalEntry[38] = 32;
logPal.palPalEntry[39] = 0;
logPal.palPalEntry[40] = 141;
logPal.palPalEntry[41] = 166;
logPal.palPalEntry[42] = 255;
logPal.palPalEntry[43] = 0;
logPal.palPalEntry[44] = 142;
logPal.palPalEntry[45] = 220;
logPal.palPalEntry[46] = 4;
logPal.palPalEntry[47] = 0;
logPal.palPalEntry[48] = 243;
logPal.palPalEntry[49] = 188;
logPal.palPalEntry[50] = 27;
logPal.palPalEntry[51] = 0;
logPal.palPalEntry[52] = 188;
logPal.palPalEntry[53] = 188;
logPal.palPalEntry[54] = 188;
logPal.palPalEntry[55] = 0;
logPal.palPalEntry[56] = 255;
logPal.palPalEntry[57] = 255;
logPal.palPalEntry[58] = 255;
logPal.palPalEntry[59] = 0;
logPal.palPalEntry[60] = 255;
logPal.palPalEntry[61] = 255;
logPal.palPalEntry[62] = 255;
logPal.palPalEntry[63] = 0;

// Assign logical palette.
IntPtr hPalette = Win32API.GDI32.CreatePalette(ref logPal);

// Create bitmap with specified palette.
Bitmap bmp1 = new Bitmap(Image.FromHbitmap(hBMP, hPalette), Image.FromHbitmap(hBMP).Width, Image.FromHbitmap(hBMP).Height);

Nov 16 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.