Skip to content

Commit

Permalink
[SETUPDD] Add a template Setup Device Driver Helper whose future aim …
Browse files Browse the repository at this point in the history
…will be to provide user-mode applications access to the kernel-mode PSETUP_LOADER_BLOCK SetupLdrBlock pointer in KeLoaderBlock.

Currently the driver just dumps the whole structure on the debug channel.

svn path=/branches/setup_improvements/; revision=75655
  • Loading branch information
HBelusca committed Oct 14, 2023
1 parent 19b5e9c commit 3c296ab
Show file tree
Hide file tree
Showing 6 changed files with 563 additions and 0 deletions.
1 change: 1 addition & 0 deletions base/setup/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
add_subdirectory(lib)
add_subdirectory(reactos)
add_subdirectory(setup)
add_subdirectory(setupdd)
add_subdirectory(usetup)
add_subdirectory(welcome)
16 changes: 16 additions & 0 deletions base/setup/setupdd/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

# include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/drivers)

list(APPEND SOURCE
dispatch.c
setupdd.c
setupdd.h
)

add_library(setupdd SHARED ${SOURCE} setupdd.rc)

set_module_type(setupdd kernelmodedriver)
# target_link_libraries(setupdd ${PSEH_LIB})
add_importlibs(setupdd ntoskrnl hal)
add_pch(setupdd setupdd.h SOURCE)
add_cd_file(TARGET setupdd DESTINATION reactos/system32 NO_CAB FOR bootcd regtest)
106 changes: 106 additions & 0 deletions base/setup/setupdd/dispatch.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Setup Device Driver Helper
* FILE: base/setup/setupdd/dispatch.c
* PURPOSE: Dispatching interface
* PROGRAMMERS: Hermes Belusca-Maito ([email protected])
*/

/* INCLUDES *******************************************************************/

#include "setupdd.h"

#define NDEBUG
#include <debug.h>

/* FUNCTIONS ******************************************************************/

NTSTATUS NTAPI
CompleteRequest(IN PIRP Irp,
IN NTSTATUS Status,
IN ULONG_PTR Information)
{
Irp->IoStatus.Status = Status;
Irp->IoStatus.Information = Information;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return Status;
}

NTSTATUS NTAPI
CompleteRequestNoInfo(IN PIRP Irp,
IN NTSTATUS Status)
{
Irp->IoStatus.Status = Status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return Status;
}

NTSTATUS NTAPI
DispatchHelper(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
{
#define HANDLE_CTRL_CODE(Code) \
case Code : \
{ \
DPRINT1("SpDd: " #Code ", Stack->FileObject = 0x%p\n", Stack->FileObject); \
if (Stack->FileObject) \
{ \
DPRINT1("Stack->FileObject->FileName = %wZ\n", &Stack->FileObject->FileName); \
} \
break; \
}

PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
ULONG MajorFunction = Stack->MajorFunction;

/* Just display all the IRP codes for now... */
switch (MajorFunction)
{
HANDLE_CTRL_CODE(IRP_MJ_CREATE);
HANDLE_CTRL_CODE(IRP_MJ_CREATE_NAMED_PIPE);
HANDLE_CTRL_CODE(IRP_MJ_CLOSE);
HANDLE_CTRL_CODE(IRP_MJ_READ);
HANDLE_CTRL_CODE(IRP_MJ_WRITE);
HANDLE_CTRL_CODE(IRP_MJ_QUERY_INFORMATION);
HANDLE_CTRL_CODE(IRP_MJ_SET_INFORMATION);
HANDLE_CTRL_CODE(IRP_MJ_QUERY_EA);
HANDLE_CTRL_CODE(IRP_MJ_SET_EA);
HANDLE_CTRL_CODE(IRP_MJ_FLUSH_BUFFERS);
HANDLE_CTRL_CODE(IRP_MJ_QUERY_VOLUME_INFORMATION);
HANDLE_CTRL_CODE(IRP_MJ_SET_VOLUME_INFORMATION);
HANDLE_CTRL_CODE(IRP_MJ_DIRECTORY_CONTROL);
HANDLE_CTRL_CODE(IRP_MJ_FILE_SYSTEM_CONTROL);
HANDLE_CTRL_CODE(IRP_MJ_DEVICE_CONTROL);
HANDLE_CTRL_CODE(IRP_MJ_INTERNAL_DEVICE_CONTROL);
HANDLE_CTRL_CODE(IRP_MJ_SHUTDOWN);
HANDLE_CTRL_CODE(IRP_MJ_LOCK_CONTROL);
HANDLE_CTRL_CODE(IRP_MJ_CLEANUP);
HANDLE_CTRL_CODE(IRP_MJ_CREATE_MAILSLOT);
HANDLE_CTRL_CODE(IRP_MJ_QUERY_SECURITY);
HANDLE_CTRL_CODE(IRP_MJ_SET_SECURITY);
HANDLE_CTRL_CODE(IRP_MJ_POWER);
HANDLE_CTRL_CODE(IRP_MJ_SYSTEM_CONTROL);
HANDLE_CTRL_CODE(IRP_MJ_DEVICE_CHANGE);
HANDLE_CTRL_CODE(IRP_MJ_QUERY_QUOTA);
HANDLE_CTRL_CODE(IRP_MJ_SET_QUOTA);
HANDLE_CTRL_CODE(IRP_MJ_PNP);
// case IRP_MJ_PNP_POWER:
// case IRP_MJ_MAXIMUM_FUNCTION:

default:
{
DPRINT1("Unknown Major %lu\n", MajorFunction);
break;
}
}

return CompleteRequest(Irp, STATUS_SUCCESS, 0);
}

NTSTATUS NTAPI
SpDdDispatch(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
{
DPRINT1("SpDdDispatch\n");
return DispatchHelper(DeviceObject, Irp);
}

/* EOF */
Loading

0 comments on commit 3c296ab

Please sign in to comment.