Skip to content

Instantly share code, notes, and snippets.

@eahydra
Created May 19, 2015 02:03
Show Gist options
  • Save eahydra/545ac29ddacb95699af6 to your computer and use it in GitHub Desktop.
Save eahydra/545ac29ddacb95699af6 to your computer and use it in GitHub Desktop.
use Inbv API display string in Kernel Mode. Under Windows7 x64
/*++
Copyright (c) Microsoft Corporation. All rights reserved.
You may only use this code if you agree to the terms of the Windows Research Kernel Source Code License agreement (see License.txt).
If you do not agree to the terms, do not use the code.
Module Name:
inbv.h
Abstract:
This module contains the public header information (function prototypes,
data and type declarations) for the Initialization Boot Video component.
--*/
#ifndef _INBV_
#define _INBV_
typedef enum _INBV_DISPLAY_STATE
{
INBV_DISPLAY_STATE_OWNED, // we own the display
INBV_DISPLAY_STATE_DISABLED, // we own but should not use
INBV_DISPLAY_STATE_LOST // we lost ownership
} INBV_DISPLAY_STATE;
typedef
BOOLEAN
(*INBV_RESET_DISPLAY_PARAMETERS)(
ULONG Cols,
ULONG Rows
);
typedef
VOID
(*INBV_DISPLAY_STRING_FILTER)(
PUCHAR *Str
);
NTKERNELAPI
VOID
InbvNotifyDisplayOwnershipLost(
INBV_RESET_DISPLAY_PARAMETERS ResetDisplayParameters
);
NTKERNELAPI
VOID
InbvInstallDisplayStringFilter(
INBV_DISPLAY_STRING_FILTER DisplayStringFilter
);
NTKERNELAPI
VOID
InbvAcquireDisplayOwnership(
VOID
);
BOOLEAN
InbvDriverInitialize(
IN PVOID LoaderBlock,
IN ULONG Count
);
NTKERNELAPI
BOOLEAN
InbvResetDisplay(
);
VOID
InbvBitBlt(
PUCHAR Buffer,
ULONG x,
ULONG y
);
NTKERNELAPI
VOID
InbvSolidColorFill(
ULONG x1,
ULONG y1,
ULONG x2,
ULONG y2,
ULONG color
);
NTKERNELAPI
BOOLEAN
InbvDisplayString(
PUCHAR Str
);
VOID
InbvUpdateProgressBar(
ULONG Percentage
);
VOID
InbvSetProgressBarSubset(
ULONG Floor,
ULONG Ceiling
);
VOID
InbvSetBootDriverBehavior(
PVOID LoaderBlock
);
VOID
InbvIndicateProgress(
VOID
);
VOID
InbvSetProgressBarCoordinates(
ULONG x,
ULONG y
);
NTKERNELAPI
VOID
InbvEnableBootDriver(
BOOLEAN bEnable
);
NTKERNELAPI
BOOLEAN
InbvEnableDisplayString(
BOOLEAN bEnable
);
NTKERNELAPI
BOOLEAN
InbvIsBootDriverInstalled(
VOID
);
PUCHAR
InbvGetResourceAddress(
IN ULONG ResourceNumber
);
VOID
InbvBufferToScreenBlt(
PUCHAR Buffer,
ULONG x,
ULONG y,
ULONG width,
ULONG height,
ULONG lDelta
);
VOID
InbvScreenToBufferBlt(
PUCHAR Buffer,
ULONG x,
ULONG y,
ULONG width,
ULONG height,
ULONG lDelta
);
BOOLEAN
InbvTestLock(
VOID
);
VOID
InbvAcquireLock(
VOID
);
VOID
InbvReleaseLock(
VOID
);
NTKERNELAPI
BOOLEAN
InbvCheckDisplayOwnership(
VOID
);
NTKERNELAPI
VOID
InbvSetScrollRegion(
ULONG x1,
ULONG y1,
ULONG x2,
ULONG y2
);
NTKERNELAPI
ULONG
InbvSetTextColor(
ULONG Color
);
#endif
#include <wdm.h>
#include "inbv.h"
#define DELAY_ONE_MICROSECOND (-10)
#define DELAY_ONE_MILLISECOND (DELAY_ONE_MICROSECOND*1000)
#define VGA_COLOR_BLACK 0
#define VGA_COLOR_RED 1
#define VGA_COLOR_GREEN 2
#define VGA_COLOR_GR 3
#define VGA_COLOR_BULE 4
#define VGA_COLOR_DARK_MEGAENTA 5
#define VGA_COLOR_TURQUOISE 6
#define VGA_COLOR_GRAY 7
#define VGA_COLOR_BRIGHT_GRAY 8
#define VGA_COLOR_BRIGHT_RED 9
#define VGA_COLOR_BRIGHT_GREEN 10
#define VGA_COLOR_BRIGHT_YELLOW 11
#define VGA_COLOR_BRIGHT_BULE 12
#define VGA_COLOR_BRIGHT_PURPLE 13
#define VGA_COLOR_BRIGHT_TURQUOISE 14
#define VGA_COLOR_WHITE 15
void DriverUnload(PDRIVER_OBJECT DriverObject) {
UNREFERENCED_PARAMETER(DriverObject);
}
NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject) {
int count;
InbvAcquireDisplayOwnership();
InbvResetDisplay();
InbvSetTextColor(VGA_COLOR_BRIGHT_RED);
InbvInstallDisplayStringFilter(NULL);
InbvEnableDisplayString(TRUE);
for (count = 0; count < 100; count++) {
if (!InbvDisplayString((UCHAR*)"Test...\n")) {
break;
}
}
DriverObject->DriverUnload = DriverUnload;
return STATUS_SUCCESS;
}
@elDimasX
Copy link

Thanks man!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment