2 * PROJECT: ReactOS VT100 emulator
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: drivers/base/green/green.c
5 * PURPOSE: Driver entry point
6 * PROGRAMMERS: Copyright 2005-2006 Hervé Poussineau (hpoussin@reactos.org)
15 DriverUnload(IN PDRIVER_OBJECT DriverObject
)
17 // nothing to do here yet
21 * Standard DriverEntry method.
25 IN PDRIVER_OBJECT DriverObject
,
26 IN PUNICODE_STRING RegistryPath
)
28 PGREEN_DRIVER_EXTENSION DriverExtension
;
32 Status
= IoAllocateDriverObjectExtension(
35 sizeof(GREEN_DRIVER_EXTENSION
),
36 (PVOID
*)&DriverExtension
);
37 if (!NT_SUCCESS(Status
))
39 DPRINT("IoAllocateDriverObjectExtension() failed with status 0x%08lx\n", Status
);
42 RtlZeroMemory(DriverExtension
, sizeof(GREEN_DRIVER_EXTENSION
));
44 Status
= GreenDuplicateUnicodeString(
47 &DriverExtension
->RegistryPath
);
48 if (!NT_SUCCESS(Status
))
50 DPRINT("GreenDuplicateUnicodeString() failed with status 0x%08lx\n", Status
);
54 Status
= ReadRegistryEntries(RegistryPath
, DriverExtension
);
55 if (!NT_SUCCESS(Status
))
57 DPRINT("ReadRegistryEntries() failed with status 0x%08lx\n", Status
);
61 DriverObject
->DriverUnload
= DriverUnload
;
62 DriverObject
->DriverExtension
->AddDevice
= GreenAddDevice
;
64 for (i
= 0; i
<= IRP_MJ_MAXIMUM_FUNCTION
; i
++)
65 DriverObject
->MajorFunction
[i
] = GreenDispatch
;
67 return STATUS_SUCCESS
;
71 GreenDuplicateUnicodeString(
73 IN PCUNICODE_STRING SourceString
,
74 OUT PUNICODE_STRING DestinationString
)
76 if (SourceString
== NULL
|| DestinationString
== NULL
77 || SourceString
->Length
> SourceString
->MaximumLength
78 || (SourceString
->Length
== 0 && SourceString
->MaximumLength
> 0 && SourceString
->Buffer
== NULL
)
79 || Flags
== RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING
|| Flags
>= 4)
81 return STATUS_INVALID_PARAMETER
;
85 if ((SourceString
->Length
== 0)
86 && (Flags
!= (RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE
|
87 RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING
)))
89 DestinationString
->Length
= 0;
90 DestinationString
->MaximumLength
= 0;
91 DestinationString
->Buffer
= NULL
;
95 USHORT DestMaxLength
= SourceString
->Length
;
97 if (Flags
& RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE
)
98 DestMaxLength
+= sizeof(UNICODE_NULL
);
100 DestinationString
->Buffer
= ExAllocatePool(PagedPool
, DestMaxLength
);
101 if (DestinationString
->Buffer
== NULL
)
102 return STATUS_NO_MEMORY
;
104 RtlCopyMemory(DestinationString
->Buffer
, SourceString
->Buffer
, SourceString
->Length
);
105 DestinationString
->Length
= SourceString
->Length
;
106 DestinationString
->MaximumLength
= DestMaxLength
;
108 if (Flags
& RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE
)
109 DestinationString
->Buffer
[DestinationString
->Length
/ sizeof(WCHAR
)] = 0;
112 return STATUS_SUCCESS
;