ReactOS 0.4.16-dev-1012-g3fe4b41
utils.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS API Tests
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: Utility functions
5 * COPYRIGHT: Copyright 2025 Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
6 */
7
8#include "precomp.h"
9
11{
12 if (!us) return "(null)";
13 return wine_dbgstr_wn(us->Buffer, us->Length / sizeof(WCHAR));
14}
15
24{
26 UNICODE_STRING MountMgrDevice;
29 HANDLE MountMgrHandle = NULL;
30
33 &MountMgrDevice,
35 NULL,
36 NULL);
37 Status = NtOpenFile(&MountMgrHandle,
43 if (!NT_SUCCESS(Status))
44 {
45 winetest_print("NtOpenFile(%s) failed, Status 0x%08lx\n",
46 wine_dbgstr_us(&MountMgrDevice), Status);
47 }
48
49 return MountMgrHandle;
50}
51
52VOID
56{
57#define LINE_SIZE (75 + 2)
58 ULONG i;
59 PBYTE Ptr1, Ptr2;
60 CHAR LineBuffer[LINE_SIZE];
61 PCHAR Line;
62 ULONG LineSize;
63
64 Ptr1 = Ptr2 = Buffer;
65 while ((ULONG_PTR)Buffer + Length - (ULONG_PTR)Ptr1 > 0)
66 {
67 Ptr1 = Ptr2;
68 Line = LineBuffer;
69
70 /* Print the address */
71 Line += _snprintf(Line, LINE_SIZE + LineBuffer - Line, "%08Ix ", (ULONG_PTR)Ptr1);
72
73 /* Print up to 16 bytes... */
74
75 /* ... in hexadecimal form first... */
76 i = 0;
77 while (i++ <= 0x0F && ((ULONG_PTR)Buffer + Length - (ULONG_PTR)Ptr1 > 0))
78 {
79 Line += _snprintf(Line, LINE_SIZE + LineBuffer - Line, " %02x", *Ptr1);
80 ++Ptr1;
81 }
82
83 /* ... align with spaces if needed... */
84 RtlFillMemory(Line, (0x0F + 2 - i) * 3 + 2, ' ');
85 Line += (0x0F + 2 - i) * 3 + 2;
86
87 /* ... then in character form. */
88 i = 0;
89 while (i++ <= 0x0F && ((ULONG_PTR)Buffer + Length - (ULONG_PTR)Ptr2 > 0))
90 {
91 *Line++ = ((*Ptr2 >= 0x20 && *Ptr2 <= 0x7E) || (*Ptr2 >= 0x80 && *Ptr2 < 0xFF) ? *Ptr2 : '.');
92 ++Ptr2;
93 }
94
95 /* Newline */
96 *Line++ = '\r';
97 *Line++ = '\n';
98
99 /* Finally display the line */
100 LineSize = Line - LineBuffer;
101 printf("%.*s", (int)LineSize, LineBuffer);
102 }
103}
LONG NTSTATUS
Definition: precomp.h:26
Definition: bufpool.h:45
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define FILE_SHARE_READ
Definition: compat.h:136
#define printf
Definition: freeldr.h:97
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
Status
Definition: gdiplustypes.h:25
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:599
#define MOUNTMGR_DEVICE_NAME
Definition: imports.h:74
VOID DumpBuffer(_In_ PVOID Buffer, _In_ ULONG Length)
Definition: utils.c:53
HANDLE GetMountMgrHandle(_In_ ACCESS_MASK DesiredAccess)
Retrieves a handle to the MountMgr controlling device. The handle should be closed with NtClose() onc...
Definition: utils.c:22
#define LINE_SIZE
LPCSTR wine_dbgstr_us(const UNICODE_STRING *us)
Definition: utils.c:10
static const BYTE us[]
Definition: encode.c:689
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define _In_
Definition: no_sal2.h:158
NTSYSAPI NTSTATUS NTAPI NtOpenFile(OUT PHANDLE phFile, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG ShareMode, IN ULONG OpenMode)
Definition: file.c:3953
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define SYNCHRONIZE
Definition: nt_native.h:61
ULONG ACCESS_MASK
Definition: nt_native.h:40
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
BYTE * PBYTE
Definition: pedump.c:66
#define wine_dbgstr_wn
Definition: testlist.c:2
void __winetest_cdecl winetest_print(const char *msg,...)
Definition: ncftp.h:79
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
char * PCHAR
Definition: typedefs.h:51
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2658
const char * LPCSTR
Definition: xmlstorage.h:183
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _snprintf
Definition: xmlstorage.h:200
char CHAR
Definition: xmlstorage.h:175