mirror of
https://github.com/reactos/reactos.git
synced 2025-02-28 19:32:59 +00:00
[MOUNTMGR_APITEST] Add utils.c for some utility functions (#6990)
And update the precompiled header.
This commit is contained in:
parent
357505e752
commit
2da5db933c
3 changed files with 75 additions and 10 deletions
|
@ -1,6 +1,7 @@
|
||||||
|
|
||||||
list(APPEND SOURCE
|
list(APPEND SOURCE
|
||||||
QueryPoints.c)
|
QueryPoints.c
|
||||||
|
utils.c)
|
||||||
|
|
||||||
list(APPEND PCH_SKIP_SOURCE
|
list(APPEND PCH_SKIP_SOURCE
|
||||||
testlist.c)
|
testlist.c)
|
||||||
|
@ -9,9 +10,8 @@ add_executable(mountmgr_apitest
|
||||||
${SOURCE}
|
${SOURCE}
|
||||||
${PCH_SKIP_SOURCE})
|
${PCH_SKIP_SOURCE})
|
||||||
|
|
||||||
|
add_pch(mountmgr_apitest precomp.h "${PCH_SKIP_SOURCE}")
|
||||||
target_link_libraries(mountmgr_apitest wine ${PSEH_LIB})
|
target_link_libraries(mountmgr_apitest wine ${PSEH_LIB})
|
||||||
set_module_type(mountmgr_apitest win32cui)
|
set_module_type(mountmgr_apitest win32cui)
|
||||||
add_importlibs(mountmgr_apitest msvcrt kernel32 ntdll)
|
add_importlibs(mountmgr_apitest msvcrt kernel32 ntdll)
|
||||||
# TODO: Enable this when we get more than one source file to justify its use
|
|
||||||
#add_pch(mountmgr_apitest precomp.h "${PCH_SKIP_SOURCE}")
|
|
||||||
add_rostests_file(TARGET mountmgr_apitest)
|
add_rostests_file(TARGET mountmgr_apitest)
|
||||||
|
|
|
@ -1,12 +1,28 @@
|
||||||
#ifndef _MOUNTMGR_APITEST_PRECOMP_H_
|
/*
|
||||||
#define _MOUNTMGR_APITEST_PRECOMP_H_
|
* PROJECT: ReactOS API Tests
|
||||||
|
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
|
||||||
|
* PURPOSE: Precompiled header
|
||||||
|
* COPYRIGHT: Copyright 2019 Pierre Schweitzer <pierre@reactos.org>
|
||||||
|
* Copyright 2025 Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
#define WIN32_NO_STATUS
|
#define WIN32_NO_STATUS
|
||||||
|
|
||||||
#include <apitest.h>
|
#include <apitest.h>
|
||||||
#include <strsafe.h>
|
|
||||||
#include <ntstatus.h>
|
#define NTOS_MODE_USER
|
||||||
#include <mountmgr.h>
|
#include <ndk/iofuncs.h>
|
||||||
#include <ndk/rtlfuncs.h>
|
#include <ndk/rtlfuncs.h>
|
||||||
|
|
||||||
#endif /* _MOUNTMGR_APITEST_PRECOMP_H_ */
|
#include <mountmgr.h>
|
||||||
|
#include <strsafe.h>
|
||||||
|
|
||||||
|
/* utils.c */
|
||||||
|
|
||||||
|
LPCSTR wine_dbgstr_us(const UNICODE_STRING *us);
|
||||||
|
|
||||||
|
HANDLE
|
||||||
|
GetMountMgrHandle(VOID);
|
||||||
|
|
||||||
|
/* EOF */
|
||||||
|
|
49
modules/rostests/apitests/mountmgr/utils.c
Normal file
49
modules/rostests/apitests/mountmgr/utils.c
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
/*
|
||||||
|
* PROJECT: ReactOS API Tests
|
||||||
|
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
|
||||||
|
* PURPOSE: Utility functions
|
||||||
|
* COPYRIGHT: Copyright 2025 Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "precomp.h"
|
||||||
|
|
||||||
|
LPCSTR wine_dbgstr_us(const UNICODE_STRING *us)
|
||||||
|
{
|
||||||
|
if (!us) return "(null)";
|
||||||
|
return wine_dbgstr_wn(us->Buffer, us->Length / sizeof(WCHAR));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief
|
||||||
|
* Retrieves a handle to the MountMgr controlling device.
|
||||||
|
* The handle should be closed with NtClose() once it is no longer in use.
|
||||||
|
**/
|
||||||
|
HANDLE
|
||||||
|
GetMountMgrHandle(VOID)
|
||||||
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
|
UNICODE_STRING MountMgrDevice;
|
||||||
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
IO_STATUS_BLOCK IoStatusBlock;
|
||||||
|
HANDLE MountMgrHandle = NULL;
|
||||||
|
|
||||||
|
RtlInitUnicodeString(&MountMgrDevice, MOUNTMGR_DEVICE_NAME);
|
||||||
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
|
&MountMgrDevice,
|
||||||
|
OBJ_CASE_INSENSITIVE,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
Status = NtOpenFile(&MountMgrHandle,
|
||||||
|
FILE_READ_ATTRIBUTES | SYNCHRONIZE,
|
||||||
|
&ObjectAttributes,
|
||||||
|
&IoStatusBlock,
|
||||||
|
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||||
|
FILE_SYNCHRONOUS_IO_NONALERT);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
winetest_print("NtOpenFile(%s) failed, Status 0x%08lx\n",
|
||||||
|
wine_dbgstr_us(&MountMgrDevice), Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
return MountMgrHandle;
|
||||||
|
}
|
Loading…
Reference in a new issue