ReactOS  0.4.15-dev-3299-gbe8e5fc
privateice.c File Reference
#include <ntddk.h>
#include <debug.h>
#include <rosrtl/string.h>
#include "precomp.h"
#include "serial.h"
Include dependency graph for privateice.c:

Go to the source code of this file.

Functions

NTSTATUS NTAPI pice_open (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS NTAPI pice_close (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS NTAPI pice_ioctl (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS NTAPI DriverEntry (PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
 

Variables

BOOLEAN bDeviceAlreadyOpen = FALSE
 
char tempPICE [1024]
 

Function Documentation

◆ DriverEntry()

NTSTATUS NTAPI DriverEntry ( PDRIVER_OBJECT  DriverObject,
PUNICODE_STRING  RegistryPath 
)

Definition at line 163 of file privateice.c.

168 {
171  UNICODE_STRING SymlinkName;
172 
173  DPRINT((0,"PICE Debugger\n"));
174 
175 #if 0 // don't enable before completely ported
176 #ifdef DEBUG
177  // first we enable output of debug strings to COM port
178  DebugSetupSerial(1,115200);
179 #endif // DEBUG
180 #endif
181 
182  if(InitPICE()){
183  DriverObject->MajorFunction[IRP_MJ_CREATE] = pice_open;
184  //ei unimplemented DriverObject->MajorFunction[IRP_MJ_CLOSE] = pice_close;
186 
189  0,
190  &DeviceName,
192  0,
193  TRUE,
194  &DeviceObject);
195  DeviceObject->Flags = DeviceObject->Flags | DO_BUFFERED_IO;
196 
197  RtlRosInitUnicodeStringFromLiteral(&SymlinkName, L"\\??\\Pice");
198  IoCreateSymbolicLink(&SymlinkName, &DeviceName);
199 
200  return(STATUS_SUCCESS);
201  }
202 }
NTSTATUS NTAPI pice_open(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: privateice.c:72
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
NTSTATUS NTAPI pice_ioctl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: privateice.c:111
#define TRUE
Definition: types.h:120
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3272
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
BOOLEAN InitPICE(void)
Definition: init.c:57
#define DO_BUFFERED_IO
Definition: env_spec_w32.h:394
#define PICE_DEVICE_DEBUGGER
Definition: shared.h:57
static const WCHAR L[]
Definition: oid.c:1250
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
#define RtlRosInitUnicodeStringFromLiteral(__Name__, __Value__)
Definition: hivetest.c:10
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52

◆ pice_close()

NTSTATUS NTAPI pice_close ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 92 of file privateice.c.

93 {
94  DPRINT((0,"pice_close\n"));
95 
96  CleanUpPICE(); // used to be in cleanup_module
97 
98  /* We're now ready for our next caller */
101 
102  return STATUS_SUCCESS;
103 }
void CleanUpPICE(void)
Definition: init.c:346
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
BOOLEAN bDeviceAlreadyOpen
Definition: privateice.c:59
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71

◆ pice_ioctl()

NTSTATUS NTAPI pice_ioctl ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 111 of file privateice.c.

112 {
113 // char* pFilename = (char*) ioctl_param;
114 
116 
117  ULONG Code = IoStack->Parameters.DeviceIoControl.IoControlCode;
118 
119  switch(Code)
120  {
121  case PICE_IOCTL_LOAD:
122  break;
123  case PICE_IOCTL_RELOAD:
124  if(!ReloadSymbols())
125  {
126  PICE_sprintf(tempPICE,"pICE: not able to reload symbols\n");
128  }
129  break;
130  case PICE_IOCTL_UNLOAD:
131  UnloadSymbols();
132  break;
133  case PICE_IOCTL_BREAK:
134  PICE_sprintf(tempPICE,"pICE: forcible break\n");
136  __asm__ __volatile("int $3");
137  break;
138  case PICE_IOCTL_STATUS:
139  {
140  PDEBUGGER_STATUS_BLOCK ustatus_block_p;
141  DEBUGGER_STATUS_BLOCK kstatus_block;
142 
143  ULONG OutLength = IoStack->Parameters.DeviceIoControl.OutputBufferLength;
144  if( OutLength < sizeof( DEBUGGER_STATUS_BLOCK ) ){
146  }
147 
148  ustatus_block_p = (PDEBUGGER_STATUS_BLOCK)Irp->AssociatedIrp.SystemBuffer;
149 
150  //kstatus_block.Test = 0x12345678;
151  RtlCopyMemory(ustatus_block_p, &kstatus_block, sizeof(DEBUGGER_STATUS_BLOCK) );
152  }
153  break;
154  default:
157  }
159  return STATUS_SUCCESS;
160 }
#define PICE_IOCTL_UNLOAD
Definition: shared.h:60
#define PICE_IOCTL_RELOAD
Definition: shared.h:61
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
char tempPICE[1024]
Definition: privateice.c:61
int PICE_sprintf(char *buf, const char *fmt,...)
Definition: utils.c:2053
__asm__("\n\t \ NewInt3Handler:\n\t \ pushl $" STR(REASON_INT3) "\n\t \ // call debugger loop\n\t \ jmp NewInt31Handler\n\t \ ")
void Print(USHORT Window, LPSTR p)
Definition: hardware.c:776
_In_ PIRP Irp
Definition: csq.h:116
#define PICE_IOCTL_BREAK
Definition: shared.h:62
#define IoCompleteRequest
Definition: irp.c:1240
struct _DEBUGGER_STATUS_BLOCK * PDEBUGGER_STATUS_BLOCK
_In_ UCHAR _In_ UCHAR _In_ ULONG Code
Definition: wdfdevice.h:1697
#define PICE_IOCTL_STATUS
Definition: shared.h:63
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
BOOLEAN ReloadSymbols(void)
Definition: symbols.c:2074
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
void UnloadSymbols()
Definition: symbols.c:2093
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128
#define PICE_IOCTL_LOAD
Definition: shared.h:59

Referenced by DriverEntry().

◆ pice_open()

NTSTATUS NTAPI pice_open ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 72 of file privateice.c.

73 {
74  DPRINT((0,"pice_open\n"));
75 
76  /* We don't want to talk to two processes at the
77  * same time */
78  if (bDeviceAlreadyOpen){
80  return STATUS_UNSUCCESSFUL; /* is there a more descriptive status code for this case? */
81  }
82 
85  return STATUS_SUCCESS;
86 }
#define TRUE
Definition: types.h:120
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
BOOLEAN bDeviceAlreadyOpen
Definition: privateice.c:59
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71

Referenced by DriverEntry().

Variable Documentation

◆ bDeviceAlreadyOpen

BOOLEAN bDeviceAlreadyOpen = FALSE

Definition at line 59 of file privateice.c.

Referenced by pice_close(), and pice_open().

◆ tempPICE

char tempPICE[1024]

Definition at line 61 of file privateice.c.

Referenced by pice_ioctl().