[BOOTVID][HAL][NTOS:INBV][NDK] *DisplayString(): Use a more suitable string pointer parameter type

Use `PCSTR` for the type of the (Hal,Inbv,Vid)DisplayString() routines'
`String` parameter, instead of `PCHAR` or `PUCHAR`, since it points to a
NUL-terminated string. (The buffer isn't a counted string.)

And improve SAL annotations along the way.
This commit is contained in:
Hermès Bélusca-Maïto
2026-01-02 18:10:54 +01:00
parent 3b33b1025e
commit 5674e5d32b
10 changed files with 57 additions and 50 deletions

View File

@@ -72,7 +72,7 @@ VidSetScrollRegion(
VOID
NTAPI
VidDisplayStringXY(
_In_z_ PUCHAR String,
_In_ PCSTR String,
_In_ ULONG Left,
_In_ ULONG Top,
_In_ BOOLEAN Transparent)
@@ -96,7 +96,7 @@ VidDisplayStringXY(
VOID
NTAPI
VidDisplayString(
_In_z_ PUCHAR String)
_In_ PCSTR String)
{
/* Start looping the string */
for (; *String; ++String)

View File

@@ -7,8 +7,6 @@
*/
#include <hal.h>
#define NDEBUG
#include <debug.h>
#include <ndk/inbvfuncs.h>
/* PUBLIC FUNCTIONS ***********************************************************/
@@ -18,7 +16,8 @@
*/
VOID
NTAPI
HalAcquireDisplayOwnership(IN PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters)
HalAcquireDisplayOwnership(
_In_ PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters)
{
/* Stub since Windows XP implemented Inbv */
return;
@@ -29,7 +28,8 @@ HalAcquireDisplayOwnership(IN PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParamete
*/
VOID
NTAPI
HalDisplayString(IN PCH String)
HalDisplayString(
_In_ PCSTR String)
{
/* Call the Inbv driver */
InbvDisplayString(String);
@@ -40,10 +40,11 @@ HalDisplayString(IN PCH String)
*/
VOID
NTAPI
HalQueryDisplayParameters(OUT PULONG DispSizeX,
OUT PULONG DispSizeY,
OUT PULONG CursorPosX,
OUT PULONG CursorPosY)
HalQueryDisplayParameters(
_Out_ PULONG DispSizeX,
_Out_ PULONG DispSizeY,
_Out_ PULONG CursorPosX,
_Out_ PULONG CursorPosY)
{
/* Stub since Windows XP implemented Inbv */
return;
@@ -54,8 +55,9 @@ HalQueryDisplayParameters(OUT PULONG DispSizeX,
*/
VOID
NTAPI
HalSetDisplayParameters(IN ULONG CursorPosX,
IN ULONG CursorPosY)
HalSetDisplayParameters(
_In_ ULONG CursorPosX,
_In_ ULONG CursorPosY)
{
/* Stub since Windows XP implemented Inbv */
return;

View File

@@ -7,8 +7,6 @@
*/
#include <hal.h>
#define NDEBUG
#include <debug.h>
#include <ndk/inbvfuncs.h>
/* PUBLIC FUNCTIONS **********************************************************/
@@ -18,7 +16,8 @@
*/
VOID
NTAPI
HalAcquireDisplayOwnership(IN PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters)
HalAcquireDisplayOwnership(
_In_ PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters)
{
/* Stub since Windows XP implemented Inbv */
return;
@@ -29,7 +28,8 @@ HalAcquireDisplayOwnership(IN PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParamete
*/
VOID
NTAPI
HalDisplayString(IN PCH String)
HalDisplayString(
_In_ PCSTR String)
{
/* Call the Inbv driver */
InbvDisplayString(String);
@@ -40,10 +40,11 @@ HalDisplayString(IN PCH String)
*/
VOID
NTAPI
HalQueryDisplayParameters(OUT PULONG DispSizeX,
OUT PULONG DispSizeY,
OUT PULONG CursorPosX,
OUT PULONG CursorPosY)
HalQueryDisplayParameters(
_Out_ PULONG DispSizeX,
_Out_ PULONG DispSizeY,
_Out_ PULONG CursorPosX,
_Out_ PULONG CursorPosY)
{
/* Stub since Windows XP implemented Inbv */
return;
@@ -54,8 +55,9 @@ HalQueryDisplayParameters(OUT PULONG DispSizeX,
*/
VOID
NTAPI
HalSetDisplayParameters(IN ULONG CursorPosX,
IN ULONG CursorPosY)
HalSetDisplayParameters(
_In_ ULONG CursorPosX,
_In_ ULONG CursorPosY)
{
/* Stub since Windows XP implemented Inbv */
return;

View File

@@ -1804,7 +1804,7 @@ Phase1InitializationDiscard(IN PVOID Context)
if (NT_SUCCESS(Status))
{
/* Display it */
InbvDisplayString((PCHAR)MsgEntry->Text);
InbvDisplayString((PCSTR)MsgEntry->Text);
}
}
}
@@ -1824,7 +1824,7 @@ Phase1InitializationDiscard(IN PVOID Context)
if (NT_SUCCESS(Status))
{
/* Display it */
InbvDisplayString((PCHAR)MsgEntry->Text);
InbvDisplayString((PCSTR)MsgEntry->Text);
}
/* Setup boot logging */

View File

@@ -452,7 +452,7 @@ static
VOID
NTAPI
DisplayFilter(
_Inout_ PCHAR* String)
_Inout_ PCSTR* String)
{
/* Windows hack to skip first dots displayed by AUTOCHK */
static BOOLEAN DotHack = TRUE;

View File

@@ -333,26 +333,29 @@ InbvGetDisplayState(VOID)
BOOLEAN
NTAPI
InbvDisplayString(
_In_ PCHAR String)
_In_ PCSTR String)
{
/* Make sure we own the display */
if (InbvDisplayState == INBV_DISPLAY_STATE_OWNED)
{
/* If we're not allowed, return success anyway */
if (!InbvDisplayDebugStrings) return TRUE;
if (!InbvDisplayDebugStrings)
return TRUE;
/* Check if a filter is installed */
if (InbvDisplayFilter) InbvDisplayFilter(&String);
if (InbvDisplayFilter)
InbvDisplayFilter(&String);
/* Acquire the lock */
InbvAcquireLock();
/* Make sure we're installed and display the string */
if (InbvBootDriverInstalled) VidDisplayString((PUCHAR)String);
if (InbvBootDriverInstalled)
VidDisplayString(String);
/* Print the string on the EMS port */
HeadlessDispatch(HeadlessCmdPutString,
String,
(PVOID)String,
strlen(String) + sizeof(ANSI_NULL),
NULL,
NULL);

View File

@@ -59,7 +59,7 @@ NTHALAPI
VOID
NTAPI
HalDisplayString(
_In_ PCHAR String
_In_ PCSTR String
);
//

View File

@@ -75,7 +75,7 @@ InbvIsBootDriverInstalled(
BOOLEAN
NTAPI
InbvDisplayString(
_In_ PCHAR String
_In_ PCSTR String
);
BOOLEAN

View File

@@ -48,7 +48,7 @@ BOOLEAN
typedef
VOID
(NTAPI *INBV_DISPLAY_STRING_FILTER)(
_Inout_ PCHAR* String
_Inout_ PCSTR* String
);
#endif

View File

@@ -22,15 +22,19 @@ NTAPI
VidResetDisplay(
_In_ BOOLEAN SetMode);
ULONG
VOID
NTAPI
VidSetTextColor(
_In_ ULONG Color);
VidCleanUp(VOID);
VOID
NTAPI
VidDisplayString(
_In_ PCSTR String);
VOID
NTAPI
VidDisplayStringXY(
_In_z_ PUCHAR String,
_In_ PCSTR String,
_In_ ULONG Left,
_In_ ULONG Top,
_In_ BOOLEAN Transparent);
@@ -43,9 +47,17 @@ VidSetScrollRegion(
_In_ ULONG Right,
_In_ ULONG Bottom);
ULONG
NTAPI
VidSetTextColor(
_In_ ULONG Color);
VOID
NTAPI
VidCleanUp(VOID);
VidBitBlt(
_In_ PUCHAR Buffer,
_In_ ULONG Left,
_In_ ULONG Top);
VOID
NTAPI
@@ -57,18 +69,6 @@ VidBufferToScreenBlt(
_In_ ULONG Height,
_In_ ULONG Delta);
VOID
NTAPI
VidDisplayString(
_In_z_ PUCHAR String);
VOID
NTAPI
VidBitBlt(
_In_ PUCHAR Buffer,
_In_ ULONG Left,
_In_ ULONG Top);
VOID
NTAPI
VidScreenToBufferBlt(