static
VOID
-CreateCommonFreeLoaderSections(PINICACHE IniCache)
+CreateCommonFreeLoaderSections(
+ PINICACHE IniCache)
{
PINICACHESECTION IniSection;
return Status;
}
-
/* Allocate buffer for new bootsector */
NewBootSector = (PPARTITION_SECTOR)RtlAllocateHeap(ProcessHeap,
0,
return Status;
}
+
NTSTATUS
-InstallFat12BootCodeToFloppy(PWSTR SrcPath,
- PWSTR RootPath)
+InstallFat12BootCodeToFloppy(
+ PWSTR SrcPath,
+ PWSTR RootPath)
{
OBJECT_ATTRIBUTES ObjectAttributes;
IO_STATUS_BLOCK IoStatusBlock;
NTSTATUS Status;
PFAT_BOOTSECTOR OrigBootSector;
PFAT_BOOTSECTOR NewBootSector;
-
+
/* Allocate buffer for original bootsector */
OrigBootSector = RtlAllocateHeap(ProcessHeap, 0, SECTORSIZE);
if (OrigBootSector == NULL)
return STATUS_INSUFFICIENT_RESOURCES;
-
+
/* Read current boot sector into buffer */
RtlInitUnicodeString(&Name, RootPath);
-
+
InitializeObjectAttributes(&ObjectAttributes,
&Name,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
-
+
Status = NtOpenFile(&FileHandle,
GENERIC_READ | SYNCHRONIZE,
&ObjectAttributes,
RtlFreeHeap(ProcessHeap, 0, OrigBootSector);
return Status;
}
-
+
Status = NtReadFile(FileHandle,
NULL,
NULL,
RtlFreeHeap(ProcessHeap, 0, OrigBootSector);
return Status;
}
-
-
+
/* Allocate buffer for new bootsector */
NewBootSector = RtlAllocateHeap(ProcessHeap,
0,
RtlFreeHeap(ProcessHeap, 0, OrigBootSector);
return STATUS_INSUFFICIENT_RESOURCES;
}
-
+
/* Read new bootsector from SrcPath */
RtlInitUnicodeString(&Name, SrcPath);
-
+
InitializeObjectAttributes(&ObjectAttributes,
&Name,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
-
+
Status = NtOpenFile(&FileHandle,
GENERIC_READ | SYNCHRONIZE,
&ObjectAttributes,
RtlFreeHeap(ProcessHeap, 0, NewBootSector);
return Status;
}
-
+
Status = NtReadFile(FileHandle,
NULL,
NULL,
RtlFreeHeap(ProcessHeap, 0, NewBootSector);
return Status;
}
-
+
/* Adjust bootsector (copy a part of the FAT16 BPB) */
memcpy(&NewBootSector->OemName,
&OrigBootSector->OemName,
FIELD_OFFSET(FAT_BOOTSECTOR, BootCodeAndData) -
FIELD_OFFSET(FAT_BOOTSECTOR, OemName));
-
+
/* Free the original boot sector */
RtlFreeHeap(ProcessHeap, 0, OrigBootSector);
-
+
/* Write new bootsector to RootPath */
RtlInitUnicodeString(&Name, RootPath);
-
+
InitializeObjectAttributes(&ObjectAttributes,
&Name,
0,
NULL,
NULL);
-
+
Status = NtOpenFile(&FileHandle,
GENERIC_WRITE | SYNCHRONIZE,
&ObjectAttributes,
RtlFreeHeap(ProcessHeap, 0, NewBootSector);
return Status;
}
-
+
#if 0
FilePosition.QuadPart = 0;
#endif
NULL,
NULL);
NtClose(FileHandle);
-
+
/* Free the new boot sector */
RtlFreeHeap(ProcessHeap, 0, NewBootSector);
-
+
return Status;
}
return Status;
}
-
/* Allocate buffer for new bootsector */
NewBootSector = RtlAllocateHeap(ProcessHeap,
0,
return Status;
}
+
BOOLEAN
CheckInstallFatBootcodeToPartition(
PUNICODE_STRING SystemRootPath)
#endif
}
+
NTSTATUS
InstallVBRToPartition(
PUNICODE_STRING SystemRootPath,
WCHAR SrcPath[MAX_PATH];
WCHAR DstPath[MAX_PATH];
NTSTATUS Status;
-
+
/* Format the floppy first */
Status = VfatFormat(&FloppyDevice,
FMIFS_FLOPPY,
#pragma once
NTSTATUS
-CreateFreeLoaderIniForDos(PWCHAR IniPath,
- PWCHAR ArcPath);
+CreateFreeLoaderIniForDos(
+ PWCHAR IniPath,
+ PWCHAR ArcPath);
NTSTATUS
-CreateFreeLoaderIniForReactos(PWCHAR IniPath,
- PWCHAR ArcPath);
+CreateFreeLoaderIniForReactos(
+ PWCHAR IniPath,
+ PWCHAR ArcPath);
NTSTATUS
-UpdateFreeLoaderIni(PWCHAR IniPath,
- PWCHAR ArcPath);
+UpdateFreeLoaderIni(
+ PWCHAR IniPath,
+ PWCHAR ArcPath);
NTSTATUS
-SaveCurrentBootSector(PWSTR RootPath,
- PWSTR DstPath);
+SaveCurrentBootSector(
+ PWSTR RootPath,
+ PWSTR DstPath);
NTSTATUS
-InstallFat16BootCodeToFile(PWSTR SrcPath,
- PWSTR DstPath,
- PWSTR RootPath);
+InstallFat16BootCodeToFile(
+ PWSTR SrcPath,
+ PWSTR DstPath,
+ PWSTR RootPath);
NTSTATUS
-InstallFat32BootCodeToFile(PWSTR SrcPath,
- PWSTR DstPath,
- PWSTR RootPath);
+InstallFat32BootCodeToFile(
+ PWSTR SrcPath,
+ PWSTR DstPath,
+ PWSTR RootPath);
NTSTATUS
-InstallMbrBootCodeToDisk (PWSTR SrcPath,
- PWSTR RootPath);
+InstallMbrBootCodeToDisk(
+ PWSTR SrcPath,
+ PWSTR RootPath);
NTSTATUS
-InstallFat16BootCodeToDisk(PWSTR SrcPath,
- PWSTR RootPath);
+InstallFat16BootCodeToDisk(
+ PWSTR SrcPath,
+ PWSTR RootPath);
NTSTATUS
-InstallFat32BootCodeToDisk(PWSTR SrcPath,
- PWSTR RootPath);
+InstallFat32BootCodeToDisk(
+ PWSTR SrcPath,
+ PWSTR RootPath);
NTSTATUS
-UpdateBootIni(PWSTR BootIniPath,
- PWSTR EntryName,
- PWSTR EntryValue);
+UpdateBootIni(
+ PWSTR BootIniPath,
+ PWSTR EntryName,
+ PWSTR EntryValue);
BOOLEAN
-CheckInstallFatBootcodeToPartition(PUNICODE_STRING SystemRootPath);
+CheckInstallFatBootcodeToPartition(
+ PUNICODE_STRING SystemRootPath);
NTSTATUS
-InstallFatBootcodeToPartition(PUNICODE_STRING SystemRootPath,
- PUNICODE_STRING SourceRootPath,
- PUNICODE_STRING DestinationArcPath,
- UCHAR PartitionType);
+InstallFatBootcodeToPartition(
+ PUNICODE_STRING SystemRootPath,
+ PUNICODE_STRING SourceRootPath,
+ PUNICODE_STRING DestinationArcPath,
+ UCHAR PartitionType);
NTSTATUS
-InstallVBRToPartition(PUNICODE_STRING SystemRootPath,
- PUNICODE_STRING SourceRootPath,
- PUNICODE_STRING DestinationArcPath,
- UCHAR PartitionType);
+InstallVBRToPartition(
+ PUNICODE_STRING SystemRootPath,
+ PUNICODE_STRING SourceRootPath,
+ PUNICODE_STRING DestinationArcPath,
+ UCHAR PartitionType);
NTSTATUS
-InstallFatBootcodeToFloppy(PUNICODE_STRING SourceRootPath,
- PUNICODE_STRING DestinationArcPath);
+InstallFatBootcodeToFloppy(
+ PUNICODE_STRING SourceRootPath,
+ PUNICODE_STRING DestinationArcPath);
/* EOF */
/* FUNCTIONS ****************************************************************/
-static BOOLEAN NTAPI
+static
+BOOLEAN
+NTAPI
ChkdskCallback(
IN CALLBACKCOMMAND Command,
IN ULONG Modifier,
return TRUE;
}
+
NTSTATUS
ChkdskPartition(
IN PUNICODE_STRING DriveRoot,
/* FUNCTIONS ****************************************************************/
NTSTATUS
-GetSourcePaths(PUNICODE_STRING SourcePath,
- PUNICODE_STRING SourceRootPath,
- PUNICODE_STRING SourceRootDir)
+GetSourcePaths(
+ PUNICODE_STRING SourcePath,
+ PUNICODE_STRING SourceRootPath,
+ PUNICODE_STRING SourceRootDir)
{
- OBJECT_ATTRIBUTES ObjectAttributes;
- UNICODE_STRING LinkName;
- UNICODE_STRING SourceName;
- WCHAR SourceBuffer[MAX_PATH] = {L'\0'};
- HANDLE Handle;
- NTSTATUS Status;
- ULONG Length;
- PWCHAR Ptr;
-
- RtlInitUnicodeString(&LinkName,
- L"\\SystemRoot");
-
- InitializeObjectAttributes(&ObjectAttributes,
- &LinkName,
- OBJ_CASE_INSENSITIVE,
- NULL,
- NULL);
-
- Status = NtOpenSymbolicLinkObject(&Handle,
- SYMBOLIC_LINK_ALL_ACCESS,
- &ObjectAttributes);
- if (!NT_SUCCESS(Status))
- return(Status);
-
- SourceName.Length = 0;
- SourceName.MaximumLength = MAX_PATH * sizeof(WCHAR);
- SourceName.Buffer = SourceBuffer;
-
- Status = NtQuerySymbolicLinkObject(Handle,
- &SourceName,
- &Length);
- NtClose(Handle);
-
- if (NT_SUCCESS(Status))
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ UNICODE_STRING LinkName;
+ UNICODE_STRING SourceName;
+ WCHAR SourceBuffer[MAX_PATH] = {L'\0'};
+ HANDLE Handle;
+ NTSTATUS Status;
+ ULONG Length;
+ PWCHAR Ptr;
+
+ RtlInitUnicodeString(&LinkName,
+ L"\\SystemRoot");
+
+ InitializeObjectAttributes(&ObjectAttributes,
+ &LinkName,
+ OBJ_CASE_INSENSITIVE,
+ NULL,
+ NULL);
+
+ Status = NtOpenSymbolicLinkObject(&Handle,
+ SYMBOLIC_LINK_ALL_ACCESS,
+ &ObjectAttributes);
+ if (!NT_SUCCESS(Status))
+ return Status;
+
+ SourceName.Length = 0;
+ SourceName.MaximumLength = MAX_PATH * sizeof(WCHAR);
+ SourceName.Buffer = SourceBuffer;
+
+ Status = NtQuerySymbolicLinkObject(Handle,
+ &SourceName,
+ &Length);
+ NtClose(Handle);
+
+ if (NT_SUCCESS(Status))
{
- RtlCreateUnicodeString(SourcePath,
- SourceName.Buffer);
-
- /* strip trailing directory */
- Ptr = wcsrchr(SourceName.Buffer, L'\\');
- if (Ptr)
- {
- RtlCreateUnicodeString(SourceRootDir, Ptr);
- *Ptr = 0;
- }
- else
- RtlCreateUnicodeString(SourceRootDir, L"");
-
- RtlCreateUnicodeString(SourceRootPath,
- SourceName.Buffer);
+ RtlCreateUnicodeString(SourcePath,
+ SourceName.Buffer);
+
+ /* strip trailing directory */
+ Ptr = wcsrchr(SourceName.Buffer, L'\\');
+ if (Ptr)
+ {
+ RtlCreateUnicodeString(SourceRootDir, Ptr);
+ *Ptr = 0;
+ }
+ else
+ RtlCreateUnicodeString(SourceRootDir, L"");
+
+ RtlCreateUnicodeString(SourceRootPath,
+ SourceName.Buffer);
}
- NtClose(Handle);
+ NtClose(Handle);
- return(STATUS_SUCCESS);
+ return STATUS_SUCCESS;
}
-
/* EOF */
#pragma once
NTSTATUS
-GetSourcePaths(PUNICODE_STRING SourcePath,
- PUNICODE_STRING SourceRootPath,
- PUNICODE_STRING SourceRootDir);
+GetSourcePaths(
+ PUNICODE_STRING SourcePath,
+ PUNICODE_STRING SourceRootPath,
+ PUNICODE_STRING SourceRootDir);
/* EOF */
typedef struct _QUEUEENTRY
{
- struct _QUEUEENTRY *Prev;
- struct _QUEUEENTRY *Next;
-
- PWSTR SourceCabinet; /* May be NULL if file is not in a cabinet */
- PWSTR SourceRootPath;
- PWSTR SourcePath;
- PWSTR SourceFilename;
- PWSTR TargetDirectory;
- PWSTR TargetFilename;
-
+ struct _QUEUEENTRY *Prev;
+ struct _QUEUEENTRY *Next;
+
+ PWSTR SourceCabinet; /* May be NULL if file is not in a cabinet */
+ PWSTR SourceRootPath;
+ PWSTR SourcePath;
+ PWSTR SourceFilename;
+ PWSTR TargetDirectory;
+ PWSTR TargetFilename;
} QUEUEENTRY, *PQUEUEENTRY;
typedef struct _FILEQUEUEHEADER
{
- PQUEUEENTRY CopyHead;
- PQUEUEENTRY CopyTail;
- ULONG CopyCount;
+ PQUEUEENTRY CopyHead;
+ PQUEUEENTRY CopyTail;
+ ULONG CopyCount;
} FILEQUEUEHEADER, *PFILEQUEUEHEADER;
/* FUNCTIONS ****************************************************************/
-HSPFILEQ WINAPI
+HSPFILEQ
+WINAPI
SetupOpenFileQueue(VOID)
{
- PFILEQUEUEHEADER QueueHeader;
-
- /* Allocate queue header */
- QueueHeader = (PFILEQUEUEHEADER)RtlAllocateHeap(ProcessHeap,
- 0,
- sizeof(FILEQUEUEHEADER));
- if (QueueHeader == NULL)
- return(NULL);
+ PFILEQUEUEHEADER QueueHeader;
- /* Initialize queue header */
- RtlZeroMemory(QueueHeader,
- sizeof(FILEQUEUEHEADER));
+ /* Allocate queue header */
+ QueueHeader = (PFILEQUEUEHEADER)RtlAllocateHeap(ProcessHeap,
+ 0,
+ sizeof(FILEQUEUEHEADER));
+ if (QueueHeader == NULL)
+ return NULL;
+ /* Initialize queue header */
+ RtlZeroMemory(QueueHeader,
+ sizeof(FILEQUEUEHEADER));
- return((HSPFILEQ)QueueHeader);
+ return (HSPFILEQ)QueueHeader;
}
-VOID WINAPI
-SetupCloseFileQueue(HSPFILEQ QueueHandle)
+VOID
+WINAPI
+SetupCloseFileQueue(
+ HSPFILEQ QueueHandle)
{
- PFILEQUEUEHEADER QueueHeader;
- PQUEUEENTRY Entry;
+ PFILEQUEUEHEADER QueueHeader;
+ PQUEUEENTRY Entry;
- if (QueueHandle == NULL)
- return;
+ if (QueueHandle == NULL)
+ return;
- QueueHeader = (PFILEQUEUEHEADER)QueueHandle;
+ QueueHeader = (PFILEQUEUEHEADER)QueueHandle;
- /* Delete copy queue */
- Entry = QueueHeader->CopyHead;
- while (Entry != NULL)
+ /* Delete copy queue */
+ Entry = QueueHeader->CopyHead;
+ while (Entry != NULL)
{
- /* Delete all strings */
- if (Entry->SourceCabinet != NULL)
- RtlFreeHeap(ProcessHeap, 0, Entry->SourceCabinet);
- if (Entry->SourceRootPath != NULL)
- RtlFreeHeap(ProcessHeap, 0, Entry->SourceRootPath);
- if (Entry->SourcePath != NULL)
- RtlFreeHeap(ProcessHeap, 0, Entry->SourcePath);
- if (Entry->SourceFilename != NULL)
- RtlFreeHeap(ProcessHeap, 0, Entry->SourceFilename);
- if (Entry->TargetDirectory != NULL)
- RtlFreeHeap(ProcessHeap, 0, Entry->TargetDirectory);
- if (Entry->TargetFilename != NULL)
- RtlFreeHeap(ProcessHeap, 0, Entry->TargetFilename);
-
- /* Unlink current queue entry */
- if (Entry->Next != NULL)
- {
- QueueHeader->CopyHead = Entry->Next;
- QueueHeader->CopyHead->Prev = NULL;
- }
- else
- {
- QueueHeader->CopyHead = NULL;
- QueueHeader->CopyTail = NULL;
- }
-
- /* Delete queue entry */
- RtlFreeHeap(ProcessHeap, 0, Entry);
-
- /* Get next queue entry */
- Entry = QueueHeader->CopyHead;
+ /* Delete all strings */
+ if (Entry->SourceCabinet != NULL)
+ RtlFreeHeap(ProcessHeap, 0, Entry->SourceCabinet);
+
+ if (Entry->SourceRootPath != NULL)
+ RtlFreeHeap(ProcessHeap, 0, Entry->SourceRootPath);
+
+ if (Entry->SourcePath != NULL)
+ RtlFreeHeap(ProcessHeap, 0, Entry->SourcePath);
+
+ if (Entry->SourceFilename != NULL)
+ RtlFreeHeap(ProcessHeap, 0, Entry->SourceFilename);
+
+ if (Entry->TargetDirectory != NULL)
+ RtlFreeHeap(ProcessHeap, 0, Entry->TargetDirectory);
+
+ if (Entry->TargetFilename != NULL)
+ RtlFreeHeap(ProcessHeap, 0, Entry->TargetFilename);
+
+ /* Unlink current queue entry */
+ if (Entry->Next != NULL)
+ {
+ QueueHeader->CopyHead = Entry->Next;
+ QueueHeader->CopyHead->Prev = NULL;
+ }
+ else
+ {
+ QueueHeader->CopyHead = NULL;
+ QueueHeader->CopyTail = NULL;
+ }
+
+ /* Delete queue entry */
+ RtlFreeHeap(ProcessHeap, 0, Entry);
+
+ /* Get next queue entry */
+ Entry = QueueHeader->CopyHead;
}
- /* Delete queue header */
- RtlFreeHeap(ProcessHeap,
- 0,
- QueueHeader);
+ /* Delete queue header */
+ RtlFreeHeap(ProcessHeap, 0, QueueHeader);
}
BOOL
-SetupQueueCopy(HSPFILEQ QueueHandle,
- PCWSTR SourceCabinet,
- PCWSTR SourceRootPath,
- PCWSTR SourcePath,
- PCWSTR SourceFilename,
- PCWSTR TargetDirectory,
- PCWSTR TargetFilename)
+SetupQueueCopy(
+ HSPFILEQ QueueHandle,
+ PCWSTR SourceCabinet,
+ PCWSTR SourceRootPath,
+ PCWSTR SourcePath,
+ PCWSTR SourceFilename,
+ PCWSTR TargetDirectory,
+ PCWSTR TargetFilename)
{
- PFILEQUEUEHEADER QueueHeader;
- PQUEUEENTRY Entry;
- ULONG Length;
-
- /* SourceCabinet may be NULL */
- if (QueueHandle == NULL ||
- SourceRootPath == NULL ||
- SourceFilename == NULL ||
- TargetDirectory == NULL)
- return(FALSE);
-
- QueueHeader = (PFILEQUEUEHEADER)QueueHandle;
-
- /* Allocate new queue entry */
- Entry = (PQUEUEENTRY)RtlAllocateHeap(ProcessHeap,
- 0,
- sizeof(QUEUEENTRY));
- if (Entry == NULL)
- return(FALSE);
-
- RtlZeroMemory(Entry,
- sizeof(QUEUEENTRY));
-
- /* Copy source cabinet if available */
- if (SourceCabinet != NULL)
+ PFILEQUEUEHEADER QueueHeader;
+ PQUEUEENTRY Entry;
+ ULONG Length;
+
+ /* SourceCabinet may be NULL */
+ if (QueueHandle == NULL ||
+ SourceRootPath == NULL ||
+ SourceFilename == NULL ||
+ TargetDirectory == NULL)
+ return FALSE;
+
+ QueueHeader = (PFILEQUEUEHEADER)QueueHandle;
+
+ /* Allocate new queue entry */
+ Entry = (PQUEUEENTRY)RtlAllocateHeap(ProcessHeap,
+ 0,
+ sizeof(QUEUEENTRY));
+ if (Entry == NULL)
+ return FALSE;
+
+ RtlZeroMemory(Entry,
+ sizeof(QUEUEENTRY));
+
+ /* Copy source cabinet if available */
+ if (SourceCabinet != NULL)
+ {
+ Length = wcslen(SourceCabinet);
+ Entry->SourceCabinet = (WCHAR*)RtlAllocateHeap(ProcessHeap,
+ 0,
+ (Length + 1) * sizeof(WCHAR));
+ if (Entry->SourceCabinet == NULL)
+ {
+ RtlFreeHeap(ProcessHeap, 0, Entry);
+ return FALSE;
+ }
+
+ wcsncpy(Entry->SourceCabinet, SourceCabinet, Length);
+ Entry->SourceCabinet[Length] = (WCHAR)0;
+ }
+ else
+ {
+ Entry->SourceCabinet = NULL;
+ }
+
+ /* Copy source root path */
+ Length = wcslen(SourceRootPath);
+ Entry->SourceRootPath = (WCHAR*)RtlAllocateHeap(ProcessHeap,
+ 0,
+ (Length + 1) * sizeof(WCHAR));
+ if (Entry->SourceRootPath == NULL)
{
- Length = wcslen(SourceCabinet);
- Entry->SourceCabinet = (WCHAR*) RtlAllocateHeap(ProcessHeap,
- 0,
- (Length + 1) * sizeof(WCHAR));
- if (Entry->SourceCabinet == NULL)
- {
+ if (Entry->SourceCabinet != NULL)
+ {
+ RtlFreeHeap(ProcessHeap, 0, Entry->SourceCabinet);
+ }
+
RtlFreeHeap(ProcessHeap, 0, Entry);
- return(FALSE);
- }
- wcsncpy(Entry->SourceCabinet, SourceCabinet, Length);
- Entry->SourceCabinet[Length] = (WCHAR)0;
+ return FALSE;
}
- else
+
+ wcsncpy(Entry->SourceRootPath, SourceRootPath, Length);
+ Entry->SourceRootPath[Length] = (WCHAR)0;
+
+ /* Copy source path */
+ if (SourcePath != NULL)
{
- Entry->SourceCabinet = NULL;
+ Length = wcslen(SourcePath);
+ Entry->SourcePath = (WCHAR*)RtlAllocateHeap(ProcessHeap,
+ 0,
+ (Length + 1) * sizeof(WCHAR));
+ if (Entry->SourcePath == NULL)
+ {
+ if (Entry->SourceCabinet != NULL)
+ {
+ RtlFreeHeap(ProcessHeap, 0, Entry->SourceCabinet);
+ }
+
+ RtlFreeHeap(ProcessHeap, 0, Entry->SourceRootPath);
+ RtlFreeHeap(ProcessHeap, 0, Entry);
+ return FALSE;
+ }
+
+ wcsncpy(Entry->SourcePath, SourcePath, Length);
+ Entry->SourcePath[Length] = (WCHAR)0;
}
- /* Copy source root path */
- Length = wcslen(SourceRootPath);
- Entry->SourceRootPath = (WCHAR*) RtlAllocateHeap(ProcessHeap,
- 0,
- (Length + 1) * sizeof(WCHAR));
- if (Entry->SourceRootPath == NULL)
- {
- if (Entry->SourceCabinet != NULL)
- {
- RtlFreeHeap(ProcessHeap, 0, Entry->SourceCabinet);
- }
- RtlFreeHeap(ProcessHeap, 0, Entry);
- return(FALSE);
- }
- wcsncpy(Entry->SourceRootPath, SourceRootPath, Length);
- Entry->SourceRootPath[Length] = (WCHAR)0;
-
- /* Copy source path */
- if (SourcePath != NULL)
- {
- Length = wcslen(SourcePath);
- Entry->SourcePath = (WCHAR*) RtlAllocateHeap(ProcessHeap,
- 0,
- (Length + 1) * sizeof(WCHAR));
- if (Entry->SourcePath == NULL)
+ /* Copy source file name */
+ Length = wcslen(SourceFilename);
+ Entry->SourceFilename = (WCHAR*)RtlAllocateHeap(ProcessHeap,
+ 0,
+ (Length + 1) * sizeof(WCHAR));
+ if (Entry->SourceFilename == NULL)
{
- if (Entry->SourceCabinet != NULL)
+ if (Entry->SourceCabinet != NULL)
{
- RtlFreeHeap(ProcessHeap, 0, Entry->SourceCabinet);
+ RtlFreeHeap(ProcessHeap, 0, Entry->SourceCabinet);
}
- RtlFreeHeap(ProcessHeap, 0, Entry->SourceRootPath);
- RtlFreeHeap(ProcessHeap, 0, Entry);
- return(FALSE);
+
+ RtlFreeHeap(ProcessHeap, 0, Entry->SourceRootPath);
+ RtlFreeHeap(ProcessHeap, 0, Entry->SourcePath);
+ RtlFreeHeap(ProcessHeap, 0, Entry);
+ return FALSE;
}
- wcsncpy(Entry->SourcePath, SourcePath, Length);
- Entry->SourcePath[Length] = (WCHAR)0;
- }
-
- /* Copy source file name */
- Length = wcslen(SourceFilename);
- Entry->SourceFilename = (WCHAR*) RtlAllocateHeap(ProcessHeap,
- 0,
- (Length + 1) * sizeof(WCHAR));
- if (Entry->SourceFilename == NULL)
- {
- if (Entry->SourceCabinet != NULL)
- {
- RtlFreeHeap(ProcessHeap, 0, Entry->SourceCabinet);
- }
- RtlFreeHeap(ProcessHeap, 0, Entry->SourceRootPath);
- RtlFreeHeap(ProcessHeap, 0, Entry->SourcePath);
- RtlFreeHeap(ProcessHeap, 0, Entry);
- return(FALSE);
- }
- wcsncpy(Entry->SourceFilename, SourceFilename, Length);
- Entry->SourceFilename[Length] = (WCHAR)0;
-
- /* Copy target directory */
- Length = wcslen(TargetDirectory);
- if (TargetDirectory[Length] == '\\')
- Length--;
- Entry->TargetDirectory = (WCHAR*) RtlAllocateHeap(ProcessHeap,
- 0,
- (Length + 1) * sizeof(WCHAR));
- if (Entry->TargetDirectory == NULL)
- {
- if (Entry->SourceCabinet != NULL)
- {
- RtlFreeHeap(ProcessHeap, 0, Entry->SourceCabinet);
- }
- RtlFreeHeap(ProcessHeap, 0, Entry->SourceRootPath);
- RtlFreeHeap(ProcessHeap, 0, Entry->SourcePath);
- RtlFreeHeap(ProcessHeap, 0, Entry->SourceFilename);
- RtlFreeHeap(ProcessHeap, 0, Entry);
- return(FALSE);
- }
- wcsncpy(Entry->TargetDirectory, TargetDirectory, Length);
- Entry->TargetDirectory[Length] = (WCHAR)0;
-
- /* Copy optional target filename */
- if (TargetFilename != NULL)
- {
- Length = wcslen(TargetFilename);
- Entry->TargetFilename = (WCHAR*) RtlAllocateHeap(ProcessHeap,
- 0,
- (Length + 1) * sizeof(WCHAR));
- if (Entry->TargetFilename == NULL)
+
+ wcsncpy(Entry->SourceFilename, SourceFilename, Length);
+ Entry->SourceFilename[Length] = (WCHAR)0;
+
+ /* Copy target directory */
+ Length = wcslen(TargetDirectory);
+ if (TargetDirectory[Length] == '\\')
+ Length--;
+ Entry->TargetDirectory = (WCHAR*)RtlAllocateHeap(ProcessHeap,
+ 0,
+ (Length + 1) * sizeof(WCHAR));
+ if (Entry->TargetDirectory == NULL)
{
- if (Entry->SourceCabinet != NULL)
+ if (Entry->SourceCabinet != NULL)
{
- RtlFreeHeap(ProcessHeap, 0, Entry->SourceCabinet);
+ RtlFreeHeap(ProcessHeap, 0, Entry->SourceCabinet);
}
- RtlFreeHeap(ProcessHeap, 0, Entry->SourceRootPath);
- RtlFreeHeap(ProcessHeap, 0, Entry->SourcePath);
- RtlFreeHeap(ProcessHeap, 0, Entry->SourceFilename);
- RtlFreeHeap(ProcessHeap, 0, Entry->TargetDirectory);
- RtlFreeHeap(ProcessHeap, 0, Entry);
- return(FALSE);
+
+ RtlFreeHeap(ProcessHeap, 0, Entry->SourceRootPath);
+ RtlFreeHeap(ProcessHeap, 0, Entry->SourcePath);
+ RtlFreeHeap(ProcessHeap, 0, Entry->SourceFilename);
+ RtlFreeHeap(ProcessHeap, 0, Entry);
+ return FALSE;
}
- wcsncpy(Entry->TargetFilename, TargetFilename, Length);
- Entry->TargetFilename[Length] = (WCHAR)0;
- }
-
- /* Append queue entry */
- if (QueueHeader->CopyHead == NULL) // && QueueHeader->CopyTail == NULL)
- {
- Entry->Prev = NULL;
- Entry->Next = NULL;
- QueueHeader->CopyHead = Entry;
- QueueHeader->CopyTail = Entry;
- }
- else
- {
- Entry->Prev = QueueHeader->CopyTail;
- Entry->Next = NULL;
- QueueHeader->CopyTail->Next = Entry;
- QueueHeader->CopyTail = Entry;
- }
- QueueHeader->CopyCount++;
-
- return(TRUE);
-}
+ wcsncpy(Entry->TargetDirectory, TargetDirectory, Length);
+ Entry->TargetDirectory[Length] = (WCHAR)0;
-BOOL WINAPI
-SetupCommitFileQueueW(HWND Owner,
- HSPFILEQ QueueHandle,
- PSP_FILE_CALLBACK_W MsgHandler,
- PVOID Context)
-{
- WCHAR CabinetName[MAX_PATH];
- PFILEQUEUEHEADER QueueHeader;
- PQUEUEENTRY Entry;
- NTSTATUS Status;
- PCWSTR TargetRootPath, TargetPath;
-
- WCHAR FileSrcPath[MAX_PATH];
- WCHAR FileDstPath[MAX_PATH];
-
- TargetRootPath = ((PCOPYCONTEXT)Context)->DestinationRootPath;
- TargetPath = ((PCOPYCONTEXT)Context)->InstallPath;
-
- if (QueueHandle == NULL)
- return(FALSE);
-
- QueueHeader = (PFILEQUEUEHEADER)QueueHandle;
-
- MsgHandler(Context,
- SPFILENOTIFY_STARTQUEUE,
- 0,
- 0);
-
- MsgHandler(Context,
- SPFILENOTIFY_STARTSUBQUEUE,
- FILEOP_COPY,
- QueueHeader->CopyCount);
-
- /* Commit copy queue */
- Entry = QueueHeader->CopyHead;
- while (Entry != NULL)
- {
- wcscpy(FileSrcPath, Entry->SourceRootPath);
- if (Entry->SourcePath != NULL)
- wcscat(FileSrcPath, Entry->SourcePath);
- wcscat(FileSrcPath, L"\\");
- wcscat(FileSrcPath, Entry->SourceFilename);
-
- /* Build the full target path */
- wcscpy(FileDstPath, TargetRootPath);
- if (Entry->TargetDirectory[0] == L'\\')
+ /* Copy optional target filename */
+ if (TargetFilename != NULL)
{
- wcscat(FileDstPath, Entry->TargetDirectory);
+ Length = wcslen(TargetFilename);
+ Entry->TargetFilename = (WCHAR*)RtlAllocateHeap(ProcessHeap,
+ 0,
+ (Length + 1) * sizeof(WCHAR));
+ if (Entry->TargetFilename == NULL)
+ {
+ if (Entry->SourceCabinet != NULL)
+ {
+ RtlFreeHeap(ProcessHeap, 0, Entry->SourceCabinet);
+ }
+
+ RtlFreeHeap(ProcessHeap, 0, Entry->SourceRootPath);
+ RtlFreeHeap(ProcessHeap, 0, Entry->SourcePath);
+ RtlFreeHeap(ProcessHeap, 0, Entry->SourceFilename);
+ RtlFreeHeap(ProcessHeap, 0, Entry->TargetDirectory);
+ RtlFreeHeap(ProcessHeap, 0, Entry);
+ return FALSE;
+ }
+
+ wcsncpy(Entry->TargetFilename, TargetFilename, Length);
+ Entry->TargetFilename[Length] = (WCHAR)0;
+ }
+
+ /* Append queue entry */
+ if (QueueHeader->CopyHead == NULL) // && QueueHeader->CopyTail == NULL)
+ {
+ Entry->Prev = NULL;
+ Entry->Next = NULL;
+ QueueHeader->CopyHead = Entry;
+ QueueHeader->CopyTail = Entry;
}
else
{
- if (TargetPath != NULL)
- {
- if (TargetPath[0] != L'\\')
- wcscat(FileDstPath, L"\\");
- wcscat(FileDstPath, TargetPath);
- }
- wcscat(FileDstPath, L"\\");
- wcscat(FileDstPath, Entry->TargetDirectory);
+ Entry->Prev = QueueHeader->CopyTail;
+ Entry->Next = NULL;
+ QueueHeader->CopyTail->Next = Entry;
+ QueueHeader->CopyTail = Entry;
}
- /* Use only the destination path if the file is in a cabinet */
- if (Entry->SourceCabinet == NULL)
- {
- wcscat(FileDstPath, L"\\");
- if (Entry->TargetFilename != NULL)
- wcscat(FileDstPath, Entry->TargetFilename);
- else
- wcscat(FileDstPath, Entry->SourceFilename);
- }
+ QueueHeader->CopyCount++;
+
+ return TRUE;
+}
+
+
+BOOL
+WINAPI
+SetupCommitFileQueueW(
+ HWND Owner,
+ HSPFILEQ QueueHandle,
+ PSP_FILE_CALLBACK_W MsgHandler,
+ PVOID Context)
+{
+ WCHAR CabinetName[MAX_PATH];
+ PFILEQUEUEHEADER QueueHeader;
+ PQUEUEENTRY Entry;
+ NTSTATUS Status;
+ PCWSTR TargetRootPath, TargetPath;
+
+ WCHAR FileSrcPath[MAX_PATH];
+ WCHAR FileDstPath[MAX_PATH];
+
+ TargetRootPath = ((PCOPYCONTEXT)Context)->DestinationRootPath;
+ TargetPath = ((PCOPYCONTEXT)Context)->InstallPath;
+
+ if (QueueHandle == NULL)
+ return FALSE;
- /* FIXME: Do it! */
- DPRINT("'%S' ==> '%S'\n",
- FileSrcPath,
- FileDstPath);
+ QueueHeader = (PFILEQUEUEHEADER)QueueHandle;
MsgHandler(Context,
- SPFILENOTIFY_STARTCOPY,
- (UINT_PTR)Entry->SourceFilename,
- FILEOP_COPY);
-
- if (Entry->SourceCabinet != NULL)
- {
- /* Extract the file */
- wcscpy(CabinetName, Entry->SourceRootPath);
- if (Entry->SourcePath != NULL)
- wcscat(CabinetName, Entry->SourcePath);
- wcscat(CabinetName, L"\\");
- wcscat(CabinetName, Entry->SourceCabinet);
- Status = SetupExtractFile(CabinetName, Entry->SourceFilename, FileDstPath);
- }
- else
- {
- /* Copy the file */
- Status = SetupCopyFile(FileSrcPath, FileDstPath);
- }
- if (!NT_SUCCESS(Status))
- {
- MsgHandler(Context,
- SPFILENOTIFY_COPYERROR,
- (UINT_PTR)Entry->SourceFilename,
- FILEOP_COPY);
+ SPFILENOTIFY_STARTQUEUE,
+ 0,
+ 0);
- }
- else
+ MsgHandler(Context,
+ SPFILENOTIFY_STARTSUBQUEUE,
+ FILEOP_COPY,
+ QueueHeader->CopyCount);
+
+ /* Commit copy queue */
+ Entry = QueueHeader->CopyHead;
+ while (Entry != NULL)
{
- MsgHandler(Context,
- SPFILENOTIFY_ENDCOPY,
- (UINT_PTR)Entry->SourceFilename,
- FILEOP_COPY);
- }
+ wcscpy(FileSrcPath, Entry->SourceRootPath);
+ if (Entry->SourcePath != NULL)
+ wcscat(FileSrcPath, Entry->SourcePath);
+ wcscat(FileSrcPath, L"\\");
+ wcscat(FileSrcPath, Entry->SourceFilename);
- Entry = Entry->Next;
- }
+ /* Build the full target path */
+ wcscpy(FileDstPath, TargetRootPath);
+ if (Entry->TargetDirectory[0] == L'\\')
+ {
+ wcscat(FileDstPath, Entry->TargetDirectory);
+ }
+ else
+ {
+ if (TargetPath != NULL)
+ {
+ if (TargetPath[0] != L'\\')
+ wcscat(FileDstPath, L"\\");
+ wcscat(FileDstPath, TargetPath);
+ }
+
+ wcscat(FileDstPath, L"\\");
+ wcscat(FileDstPath, Entry->TargetDirectory);
+ }
+
+ /* Use only the destination path if the file is in a cabinet */
+ if (Entry->SourceCabinet == NULL)
+ {
+ wcscat(FileDstPath, L"\\");
+ if (Entry->TargetFilename != NULL)
+ wcscat(FileDstPath, Entry->TargetFilename);
+ else
+ wcscat(FileDstPath, Entry->SourceFilename);
+ }
+
+ /* FIXME: Do it! */
+ DPRINT("'%S' ==> '%S'\n", FileSrcPath, FileDstPath);
- MsgHandler(Context,
- SPFILENOTIFY_ENDSUBQUEUE,
- FILEOP_COPY,
- 0);
+ MsgHandler(Context,
+ SPFILENOTIFY_STARTCOPY,
+ (UINT_PTR)Entry->SourceFilename,
+ FILEOP_COPY);
+
+ if (Entry->SourceCabinet != NULL)
+ {
+ /* Extract the file */
+ wcscpy(CabinetName, Entry->SourceRootPath);
+ if (Entry->SourcePath != NULL)
+ wcscat(CabinetName, Entry->SourcePath);
+ wcscat(CabinetName, L"\\");
+ wcscat(CabinetName, Entry->SourceCabinet);
+ Status = SetupExtractFile(CabinetName, Entry->SourceFilename, FileDstPath);
+ }
+ else
+ {
+ /* Copy the file */
+ Status = SetupCopyFile(FileSrcPath, FileDstPath);
+ }
- MsgHandler(Context,
- SPFILENOTIFY_ENDQUEUE,
- 0,
- 0);
+ if (!NT_SUCCESS(Status))
+ {
+ MsgHandler(Context,
+ SPFILENOTIFY_COPYERROR,
+ (UINT_PTR)Entry->SourceFilename,
+ FILEOP_COPY);
+ }
+ else
+ {
+ MsgHandler(Context,
+ SPFILENOTIFY_ENDCOPY,
+ (UINT_PTR)Entry->SourceFilename,
+ FILEOP_COPY);
+ }
+
+ Entry = Entry->Next;
+ }
+
+ MsgHandler(Context,
+ SPFILENOTIFY_ENDSUBQUEUE,
+ FILEOP_COPY,
+ 0);
+
+ MsgHandler(Context,
+ SPFILENOTIFY_ENDQUEUE,
+ 0,
+ 0);
- return(TRUE);
+ return TRUE;
}
/* EOF */
typedef PVOID HSPFILEQ;
-typedef UINT (CALLBACK* PSP_FILE_CALLBACK_W)(PVOID Context,
- UINT Notification,
- UINT_PTR Param1,
- UINT_PTR Param2);
+typedef UINT (CALLBACK* PSP_FILE_CALLBACK_W)(
+ PVOID Context,
+ UINT Notification,
+ UINT_PTR Param1,
+ UINT_PTR Param2);
typedef struct _COPYCONTEXT
{
- LPCWSTR DestinationRootPath; /* Not owned by this structure */
- LPCWSTR InstallPath; /* Not owned by this structure */
- ULONG TotalOperations;
- ULONG CompletedOperations;
- PPROGRESSBAR ProgressBar;
- PPROGRESSBAR MemoryBars[4];
+ LPCWSTR DestinationRootPath; /* Not owned by this structure */
+ LPCWSTR InstallPath; /* Not owned by this structure */
+ ULONG TotalOperations;
+ ULONG CompletedOperations;
+ PPROGRESSBAR ProgressBar;
+ PPROGRESSBAR MemoryBars[4];
} COPYCONTEXT, *PCOPYCONTEXT;
/* FUNCTIONS ****************************************************************/
-HSPFILEQ WINAPI
+HSPFILEQ
+WINAPI
SetupOpenFileQueue(VOID);
-VOID WINAPI
+VOID
+WINAPI
SetupCloseFileQueue(
- IN HSPFILEQ QueueHandle);
+ IN HSPFILEQ QueueHandle);
-BOOL WINAPI
+BOOL
+WINAPI
SetupQueueCopyWNew(
- IN HSPFILEQ QueueHandle,
- IN PCWSTR SourceRootPath,
- IN PCWSTR SourcePath,
- IN PCWSTR SourceFileName,
- IN PCWSTR SourceDescription,
- IN PCWSTR SourceTagFile,
- IN PCWSTR TargetDirectory,
- IN PCWSTR TargetFileName,
- IN DWORD CopyStyle);
+ IN HSPFILEQ QueueHandle,
+ IN PCWSTR SourceRootPath,
+ IN PCWSTR SourcePath,
+ IN PCWSTR SourceFileName,
+ IN PCWSTR SourceDescription,
+ IN PCWSTR SourceTagFile,
+ IN PCWSTR TargetDirectory,
+ IN PCWSTR TargetFileName,
+ IN DWORD CopyStyle);
+
+BOOL
+SetupQueueCopy(
+ HSPFILEQ QueueHandle,
+ PCWSTR SourceCabinet,
+ PCWSTR SourceRootPath,
+ PCWSTR SourcePath,
+ PCWSTR SourceFilename,
+ PCWSTR TargetDirectory,
+ PCWSTR TargetFilename);
BOOL
-SetupQueueCopy(HSPFILEQ QueueHandle,
- PCWSTR SourceCabinet,
- PCWSTR SourceRootPath,
- PCWSTR SourcePath,
- PCWSTR SourceFilename,
- PCWSTR TargetDirectory,
- PCWSTR TargetFilename);
-
-BOOL WINAPI
-SetupCommitFileQueueW(HWND Owner,
- HSPFILEQ QueueHandle,
- PSP_FILE_CALLBACK_W MsgHandler,
- PVOID Context);
+WINAPI
+SetupCommitFileQueueW(
+ HWND Owner,
+ HSPFILEQ QueueHandle,
+ PSP_FILE_CALLBACK_W MsgHandler,
+ PVOID Context);
/* EOF */
static CAB_SEARCH Search;
NTSTATUS
-SetupCreateDirectory(PWCHAR DirectoryName)
+SetupCreateDirectory(
+ PWCHAR DirectoryName)
{
- OBJECT_ATTRIBUTES ObjectAttributes;
- IO_STATUS_BLOCK IoStatusBlock;
- UNICODE_STRING PathName;
- HANDLE DirectoryHandle;
- NTSTATUS Status;
-
- RtlCreateUnicodeString(&PathName,
- DirectoryName);
- if (PathName.Length > sizeof(WCHAR) &&
- PathName.Buffer[PathName.Length / sizeof(WCHAR) - 2] == L'\\' &&
- PathName.Buffer[PathName.Length / sizeof(WCHAR) - 1] == L'.')
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ IO_STATUS_BLOCK IoStatusBlock;
+ UNICODE_STRING PathName;
+ HANDLE DirectoryHandle;
+ NTSTATUS Status;
+
+ RtlCreateUnicodeString(&PathName,
+ DirectoryName);
+ if (PathName.Length > sizeof(WCHAR) &&
+ PathName.Buffer[PathName.Length / sizeof(WCHAR) - 2] == L'\\' &&
+ PathName.Buffer[PathName.Length / sizeof(WCHAR) - 1] == L'.')
{
- PathName.Length -= sizeof(WCHAR);
- PathName.Buffer[PathName.Length / sizeof(WCHAR)] = 0;
+ PathName.Length -= sizeof(WCHAR);
+ PathName.Buffer[PathName.Length / sizeof(WCHAR)] = 0;
}
- if (PathName.Length > sizeof(WCHAR) &&
- PathName.Buffer[PathName.Length / sizeof(WCHAR) - 1] == L'\\')
+ if (PathName.Length > sizeof(WCHAR) &&
+ PathName.Buffer[PathName.Length / sizeof(WCHAR) - 1] == L'\\')
{
- PathName.Length -= sizeof(WCHAR);
- PathName.Buffer[PathName.Length / sizeof(WCHAR)] = 0;
- }
-
- InitializeObjectAttributes(&ObjectAttributes,
- &PathName,
- OBJ_CASE_INSENSITIVE | OBJ_INHERIT,
- NULL,
- NULL);
-
- Status = NtCreateFile(&DirectoryHandle,
- DIRECTORY_ALL_ACCESS,
- &ObjectAttributes,
- &IoStatusBlock,
- NULL,
- FILE_ATTRIBUTE_DIRECTORY,
- FILE_SHARE_READ | FILE_SHARE_WRITE,
- FILE_OPEN_IF,
- FILE_DIRECTORY_FILE,
- NULL,
- 0);
- if (NT_SUCCESS(Status))
+ PathName.Length -= sizeof(WCHAR);
+ PathName.Buffer[PathName.Length / sizeof(WCHAR)] = 0;
+ }
+
+ InitializeObjectAttributes(&ObjectAttributes,
+ &PathName,
+ OBJ_CASE_INSENSITIVE | OBJ_INHERIT,
+ NULL,
+ NULL);
+
+ Status = NtCreateFile(&DirectoryHandle,
+ DIRECTORY_ALL_ACCESS,
+ &ObjectAttributes,
+ &IoStatusBlock,
+ NULL,
+ FILE_ATTRIBUTE_DIRECTORY,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ FILE_OPEN_IF,
+ FILE_DIRECTORY_FILE,
+ NULL,
+ 0);
+ if (NT_SUCCESS(Status))
{
- NtClose(DirectoryHandle);
+ NtClose(DirectoryHandle);
}
- RtlFreeUnicodeString(&PathName);
+ RtlFreeUnicodeString(&PathName);
- return(Status);
+ return Status;
}
NTSTATUS
-SetupCopyFile(PWCHAR SourceFileName,
- PWCHAR DestinationFileName)
+SetupCopyFile(
+ PWCHAR SourceFileName,
+ PWCHAR DestinationFileName)
{
- OBJECT_ATTRIBUTES ObjectAttributes;
- HANDLE FileHandleSource;
- HANDLE FileHandleDest;
- static IO_STATUS_BLOCK IoStatusBlock;
- FILE_STANDARD_INFORMATION FileStandard;
- FILE_BASIC_INFORMATION FileBasic;
- ULONG RegionSize;
- UNICODE_STRING FileName;
- NTSTATUS Status;
- PVOID SourceFileMap = 0;
- HANDLE SourceFileSection;
- SIZE_T SourceSectionSize = 0;
- LARGE_INTEGER ByteOffset;
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ HANDLE FileHandleSource;
+ HANDLE FileHandleDest;
+ static IO_STATUS_BLOCK IoStatusBlock;
+ FILE_STANDARD_INFORMATION FileStandard;
+ FILE_BASIC_INFORMATION FileBasic;
+ ULONG RegionSize;
+ UNICODE_STRING FileName;
+ NTSTATUS Status;
+ PVOID SourceFileMap = 0;
+ HANDLE SourceFileSection;
+ SIZE_T SourceSectionSize = 0;
+ LARGE_INTEGER ByteOffset;
#ifdef __REACTOS__
- RtlInitUnicodeString(&FileName,
- SourceFileName);
-
- InitializeObjectAttributes(&ObjectAttributes,
- &FileName,
- OBJ_CASE_INSENSITIVE,
- NULL,
- NULL);
-
- Status = NtOpenFile(&FileHandleSource,
- GENERIC_READ,
- &ObjectAttributes,
- &IoStatusBlock,
- FILE_SHARE_READ,
- FILE_SEQUENTIAL_ONLY);
- if(!NT_SUCCESS(Status))
+ RtlInitUnicodeString(&FileName,
+ SourceFileName);
+
+ InitializeObjectAttributes(&ObjectAttributes,
+ &FileName,
+ OBJ_CASE_INSENSITIVE,
+ NULL,
+ NULL);
+
+ Status = NtOpenFile(&FileHandleSource,
+ GENERIC_READ,
+ &ObjectAttributes,
+ &IoStatusBlock,
+ FILE_SHARE_READ,
+ FILE_SEQUENTIAL_ONLY);
+ if (!NT_SUCCESS(Status))
{
- DPRINT1("NtOpenFile failed: %x, %wZ\n", Status, &FileName);
- goto done;
+ DPRINT1("NtOpenFile failed: %x, %wZ\n", Status, &FileName);
+ goto done;
}
#else
- FileHandleSource = CreateFileW(SourceFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
- if (FileHandleSource == INVALID_HANDLE_VALUE)
- {
- Status = STATUS_UNSUCCESSFUL;
- goto done;
- }
+ FileHandleSource = CreateFileW(SourceFileName,
+ GENERIC_READ,
+ FILE_SHARE_READ,
+ NULL,
+ OPEN_EXISTING,
+ 0,
+ NULL);
+ if (FileHandleSource == INVALID_HANDLE_VALUE)
+ {
+ Status = STATUS_UNSUCCESSFUL;
+ goto done;
+ }
#endif
- Status = NtQueryInformationFile(FileHandleSource,
- &IoStatusBlock,
- &FileStandard,
- sizeof(FILE_STANDARD_INFORMATION),
- FileStandardInformation);
- if(!NT_SUCCESS(Status))
+ Status = NtQueryInformationFile(FileHandleSource,
+ &IoStatusBlock,
+ &FileStandard,
+ sizeof(FILE_STANDARD_INFORMATION),
+ FileStandardInformation);
+ if (!NT_SUCCESS(Status))
{
- DPRINT1("NtQueryInformationFile failed: %x\n", Status);
- goto closesrc;
+ DPRINT1("NtQueryInformationFile failed: %x\n", Status);
+ goto closesrc;
}
- Status = NtQueryInformationFile(FileHandleSource,
- &IoStatusBlock,&FileBasic,
- sizeof(FILE_BASIC_INFORMATION),
- FileBasicInformation);
- if(!NT_SUCCESS(Status))
+
+ Status = NtQueryInformationFile(FileHandleSource,
+ &IoStatusBlock,&FileBasic,
+ sizeof(FILE_BASIC_INFORMATION),
+ FileBasicInformation);
+ if (!NT_SUCCESS(Status))
{
- DPRINT1("NtQueryInformationFile failed: %x\n", Status);
- goto closesrc;
+ DPRINT1("NtQueryInformationFile failed: %x\n", Status);
+ goto closesrc;
}
- Status = NtCreateSection( &SourceFileSection,
- SECTION_MAP_READ,
- NULL,
- NULL,
- PAGE_READONLY,
- SEC_COMMIT,
- FileHandleSource);
- if(!NT_SUCCESS(Status))
+ Status = NtCreateSection(&SourceFileSection,
+ SECTION_MAP_READ,
+ NULL,
+ NULL,
+ PAGE_READONLY,
+ SEC_COMMIT,
+ FileHandleSource);
+ if (!NT_SUCCESS(Status))
{
DPRINT1("NtCreateSection failed: %x, %S\n", Status, SourceFileName);
goto closesrc;
}
- Status = NtMapViewOfSection( SourceFileSection,
- NtCurrentProcess(),
- &SourceFileMap,
- 0,
- 0,
- NULL,
- &SourceSectionSize,
- ViewUnmap,
- 0,
- PAGE_READONLY );
- if(!NT_SUCCESS(Status))
+ Status = NtMapViewOfSection(SourceFileSection,
+ NtCurrentProcess(),
+ &SourceFileMap,
+ 0,
+ 0,
+ NULL,
+ &SourceSectionSize,
+ ViewUnmap,
+ 0,
+ PAGE_READONLY );
+ if (!NT_SUCCESS(Status))
{
- DPRINT1("NtMapViewOfSection failed: %x, %S\n", Status, SourceFileName);
- goto closesrcsec;
+ DPRINT1("NtMapViewOfSection failed: %x, %S\n", Status, SourceFileName);
+ goto closesrcsec;
}
- RtlInitUnicodeString(&FileName,
- DestinationFileName);
-
- InitializeObjectAttributes(&ObjectAttributes,
- &FileName,
- OBJ_CASE_INSENSITIVE,
- NULL,
- NULL);
-
- Status = NtCreateFile(&FileHandleDest,
- GENERIC_WRITE | SYNCHRONIZE,
- &ObjectAttributes,
- &IoStatusBlock,
- NULL,
- FILE_ATTRIBUTE_NORMAL,
- 0,
- FILE_OVERWRITE_IF,
- FILE_NO_INTERMEDIATE_BUFFERING |
- FILE_SEQUENTIAL_ONLY |
- FILE_SYNCHRONOUS_IO_NONALERT,
- NULL,
- 0);
- if(!NT_SUCCESS(Status))
+ RtlInitUnicodeString(&FileName,
+ DestinationFileName);
+
+ InitializeObjectAttributes(&ObjectAttributes,
+ &FileName,
+ OBJ_CASE_INSENSITIVE,
+ NULL,
+ NULL);
+
+ Status = NtCreateFile(&FileHandleDest,
+ GENERIC_WRITE | SYNCHRONIZE,
+ &ObjectAttributes,
+ &IoStatusBlock,
+ NULL,
+ FILE_ATTRIBUTE_NORMAL,
+ 0,
+ FILE_OVERWRITE_IF,
+ FILE_NO_INTERMEDIATE_BUFFERING |
+ FILE_SEQUENTIAL_ONLY |
+ FILE_SYNCHRONOUS_IO_NONALERT,
+ NULL,
+ 0);
+ if (!NT_SUCCESS(Status))
{
- DPRINT1("NtCreateFile failed: %x\n", Status);
- goto unmapsrcsec;
+ DPRINT1("NtCreateFile failed: %x\n", Status);
+ goto unmapsrcsec;
}
- RegionSize = (ULONG)PAGE_ROUND_UP(FileStandard.EndOfFile.u.LowPart);
- IoStatusBlock.Status = 0;
- ByteOffset.QuadPart = 0;
- Status = NtWriteFile(FileHandleDest,
- NULL,
- NULL,
- NULL,
- &IoStatusBlock,
- SourceFileMap,
- RegionSize,
- &ByteOffset,
- NULL);
- if(!NT_SUCCESS(Status))
+ RegionSize = (ULONG)PAGE_ROUND_UP(FileStandard.EndOfFile.u.LowPart);
+ IoStatusBlock.Status = 0;
+ ByteOffset.QuadPart = 0;
+ Status = NtWriteFile(FileHandleDest,
+ NULL,
+ NULL,
+ NULL,
+ &IoStatusBlock,
+ SourceFileMap,
+ RegionSize,
+ &ByteOffset,
+ NULL);
+ if (!NT_SUCCESS(Status))
{
- DPRINT1("NtWriteFile failed: %x:%x, iosb: %p src: %p, size: %x\n", Status, IoStatusBlock.Status, &IoStatusBlock, SourceFileMap, RegionSize);
- goto closedest;
+ DPRINT1("NtWriteFile failed: %x:%x, iosb: %p src: %p, size: %x\n", Status, IoStatusBlock.Status, &IoStatusBlock, SourceFileMap, RegionSize);
+ goto closedest;
}
- /* Copy file date/time from source file */
- Status = NtSetInformationFile(FileHandleDest,
- &IoStatusBlock,
- &FileBasic,
- sizeof(FILE_BASIC_INFORMATION),
- FileBasicInformation);
- if(!NT_SUCCESS(Status))
+
+ /* Copy file date/time from source file */
+ Status = NtSetInformationFile(FileHandleDest,
+ &IoStatusBlock,
+ &FileBasic,
+ sizeof(FILE_BASIC_INFORMATION),
+ FileBasicInformation);
+ if (!NT_SUCCESS(Status))
{
- DPRINT1("NtSetInformationFile failed: %x\n", Status);
- goto closedest;
+ DPRINT1("NtSetInformationFile failed: %x\n", Status);
+ goto closedest;
}
- /* shorten the file back to it's real size after completing the write */
- Status = NtSetInformationFile(FileHandleDest,
- &IoStatusBlock,
- &FileStandard.EndOfFile,
- sizeof(FILE_END_OF_FILE_INFORMATION),
- FileEndOfFileInformation);
-
- if(!NT_SUCCESS(Status))
+ /* shorten the file back to it's real size after completing the write */
+ Status = NtSetInformationFile(FileHandleDest,
+ &IoStatusBlock,
+ &FileStandard.EndOfFile,
+ sizeof(FILE_END_OF_FILE_INFORMATION),
+ FileEndOfFileInformation);
+ if (!NT_SUCCESS(Status))
{
- DPRINT1("NtSetInformationFile failed: %x\n", Status);
+ DPRINT1("NtSetInformationFile failed: %x\n", Status);
}
- closedest:
- NtClose(FileHandleDest);
- unmapsrcsec:
- NtUnmapViewOfSection( NtCurrentProcess(), SourceFileMap );
- closesrcsec:
- NtClose(SourceFileSection);
- closesrc:
- NtClose(FileHandleSource);
- done:
- return(Status);
+closedest:
+ NtClose(FileHandleDest);
+
+unmapsrcsec:
+ NtUnmapViewOfSection(NtCurrentProcess(), SourceFileMap);
+
+closesrcsec:
+ NtClose(SourceFileSection);
+
+closesrc:
+ NtClose(FileHandleSource);
+
+done:
+ return Status;
}
#ifdef __REACTOS__
NTSTATUS
-SetupExtractFile(PWCHAR CabinetFileName,
- PWCHAR SourceFileName,
- PWCHAR DestinationPathName)
+SetupExtractFile(
+ PWCHAR CabinetFileName,
+ PWCHAR SourceFileName,
+ PWCHAR DestinationPathName)
{
- ULONG CabStatus;
+ ULONG CabStatus;
- DPRINT("SetupExtractFile(CabinetFileName %S, SourceFileName %S, DestinationPathName %S)\n",
- CabinetFileName, SourceFileName, DestinationPathName);
+ DPRINT("SetupExtractFile(CabinetFileName %S, SourceFileName %S, DestinationPathName %S)\n",
+ CabinetFileName, SourceFileName, DestinationPathName);
- if (HasCurrentCabinet)
+ if (HasCurrentCabinet)
{
- DPRINT("CurrentCabinetName: %S\n", CurrentCabinetName);
+ DPRINT("CurrentCabinetName: %S\n", CurrentCabinetName);
}
- if ((HasCurrentCabinet) && (wcscmp(CabinetFileName, CurrentCabinetName) == 0))
+ if ((HasCurrentCabinet) && (wcscmp(CabinetFileName, CurrentCabinetName) == 0))
{
- DPRINT("Using same cabinet as last time\n");
-
- /* Use our last location because the files should be sequential */
- CabStatus = CabinetFindNextFileSequential(SourceFileName, &Search);
- if (CabStatus != CAB_STATUS_SUCCESS)
- {
- DPRINT("Sequential miss on file: %S\n", SourceFileName);
-
- /* Looks like we got unlucky */
- CabStatus = CabinetFindFirst(SourceFileName, &Search);
- }
+ DPRINT("Using same cabinet as last time\n");
+
+ /* Use our last location because the files should be sequential */
+ CabStatus = CabinetFindNextFileSequential(SourceFileName, &Search);
+ if (CabStatus != CAB_STATUS_SUCCESS)
+ {
+ DPRINT("Sequential miss on file: %S\n", SourceFileName);
+
+ /* Looks like we got unlucky */
+ CabStatus = CabinetFindFirst(SourceFileName, &Search);
+ }
}
- else
+ else
{
- DPRINT("Using new cabinet\n");
+ DPRINT("Using new cabinet\n");
- if (HasCurrentCabinet)
+ if (HasCurrentCabinet)
{
- CabinetCleanup();
+ CabinetCleanup();
}
- wcscpy(CurrentCabinetName, CabinetFileName);
+ wcscpy(CurrentCabinetName, CabinetFileName);
- CabinetInitialize();
- CabinetSetEventHandlers(NULL, NULL, NULL);
- CabinetSetCabinetName(CabinetFileName);
+ CabinetInitialize();
+ CabinetSetEventHandlers(NULL, NULL, NULL);
+ CabinetSetCabinetName(CabinetFileName);
- CabStatus = CabinetOpen();
- if (CabStatus == CAB_STATUS_SUCCESS)
+ CabStatus = CabinetOpen();
+ if (CabStatus == CAB_STATUS_SUCCESS)
{
- DPRINT("Opened cabinet %S\n", CabinetGetCabinetName());
- HasCurrentCabinet = TRUE;
+ DPRINT("Opened cabinet %S\n", CabinetGetCabinetName());
+ HasCurrentCabinet = TRUE;
}
- else
+ else
{
- DPRINT("Cannot open cabinet (%d)\n", CabStatus);
- return STATUS_UNSUCCESSFUL;
+ DPRINT("Cannot open cabinet (%d)\n", CabStatus);
+ return STATUS_UNSUCCESSFUL;
}
-
- /* We have to start at the beginning here */
- CabStatus = CabinetFindFirst(SourceFileName, &Search);
+
+ /* We have to start at the beginning here */
+ CabStatus = CabinetFindFirst(SourceFileName, &Search);
}
-
- if (CabStatus != CAB_STATUS_SUCCESS)
- {
- DPRINT1("Unable to find '%S' in cabinet '%S'\n", SourceFileName, CabinetGetCabinetName());
- return STATUS_UNSUCCESSFUL;
- }
-
- CabinetSetDestinationPath(DestinationPathName);
- CabStatus = CabinetExtractFile(&Search);
- if (CabStatus != CAB_STATUS_SUCCESS)
+
+ if (CabStatus != CAB_STATUS_SUCCESS)
+ {
+ DPRINT1("Unable to find '%S' in cabinet '%S'\n", SourceFileName, CabinetGetCabinetName());
+ return STATUS_UNSUCCESSFUL;
+ }
+
+ CabinetSetDestinationPath(DestinationPathName);
+ CabStatus = CabinetExtractFile(&Search);
+ if (CabStatus != CAB_STATUS_SUCCESS)
{
- DPRINT("Cannot extract file %S (%d)\n", SourceFileName, CabStatus);
- return STATUS_UNSUCCESSFUL;
+ DPRINT("Cannot extract file %S (%d)\n", SourceFileName, CabStatus);
+ return STATUS_UNSUCCESSFUL;
}
- return STATUS_SUCCESS;
+ return STATUS_SUCCESS;
}
#endif
BOOLEAN
-DoesFileExist(PWSTR PathName,
- PWSTR FileName)
+DoesFileExist(
+ PWSTR PathName,
+ PWSTR FileName)
{
- OBJECT_ATTRIBUTES ObjectAttributes;
- IO_STATUS_BLOCK IoStatusBlock;
- UNICODE_STRING Name;
- WCHAR FullName[MAX_PATH];
- HANDLE FileHandle;
- NTSTATUS Status;
-
- wcscpy(FullName, PathName);
- if (FileName != NULL)
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ IO_STATUS_BLOCK IoStatusBlock;
+ UNICODE_STRING Name;
+ WCHAR FullName[MAX_PATH];
+ HANDLE FileHandle;
+ NTSTATUS Status;
+
+ wcscpy(FullName, PathName);
+ if (FileName != NULL)
{
- if (FileName[0] != L'\\')
- wcscat(FullName, L"\\");
- wcscat(FullName, FileName);
+ if (FileName[0] != L'\\')
+ wcscat(FullName, L"\\");
+ wcscat(FullName, FileName);
}
- RtlInitUnicodeString(&Name,
- FullName);
-
- InitializeObjectAttributes(&ObjectAttributes,
- &Name,
- OBJ_CASE_INSENSITIVE,
- NULL,
- NULL);
-
- Status = NtOpenFile(&FileHandle,
- GENERIC_READ | SYNCHRONIZE,
- &ObjectAttributes,
- &IoStatusBlock,
- 0,
- FILE_SYNCHRONOUS_IO_NONALERT);
- if (!NT_SUCCESS(Status))
+ RtlInitUnicodeString(&Name,
+ FullName);
+
+ InitializeObjectAttributes(&ObjectAttributes,
+ &Name,
+ OBJ_CASE_INSENSITIVE,
+ NULL,
+ NULL);
+
+ Status = NtOpenFile(&FileHandle,
+ GENERIC_READ | SYNCHRONIZE,
+ &ObjectAttributes,
+ &IoStatusBlock,
+ 0,
+ FILE_SYNCHRONOUS_IO_NONALERT);
+ if (!NT_SUCCESS(Status))
{
- return(FALSE);
+ return FALSE;
}
- NtClose(FileHandle);
+ NtClose(FileHandle);
- return(TRUE);
+ return TRUE;
}
/* EOF */
#pragma once
NTSTATUS
-SetupCreateDirectory(PWCHAR DirectoryName);
+SetupCreateDirectory(
+ PWCHAR DirectoryName);
NTSTATUS
-SetupCopyFile(PWCHAR SourceFileName,
- PWCHAR DestinationFileName);
+SetupCopyFile(
+ PWCHAR SourceFileName,
+ PWCHAR DestinationFileName);
NTSTATUS
-SetupExtractFile(PWCHAR CabinetFileName,
- PWCHAR SourceFileName,
- PWCHAR DestinationFileName);
+SetupExtractFile(
+ PWCHAR CabinetFileName,
+ PWCHAR SourceFileName,
+ PWCHAR DestinationFileName);
BOOLEAN
-DoesFileExist(PWSTR PathName,
- PWSTR FileName);
+DoesFileExist(
+ PWSTR PathName,
+ PWSTR FileName);
/* EOF */
/* FUNCTIONS ****************************************************************/
-static BOOLEAN NTAPI
+static
+BOOLEAN
+NTAPI
FormatCallback(
IN CALLBACKCOMMAND Command,
IN ULONG Modifier,
return TRUE;
}
+
NTSTATUS
FormatPartition(
IN PUNICODE_STRING DriveRoot,
InsertTailList(&List->ListHead, &Item->ListEntry);
}
+
PFILE_SYSTEM_LIST
CreateFileSystemList(
IN SHORT Left,
return List;
}
+
VOID
DestroyFileSystemList(
IN PFILE_SYSTEM_LIST List)
RtlFreeHeap(ProcessHeap, 0, List);
}
+
VOID
DrawFileSystemList(
IN PFILE_SYSTEM_LIST List)
}
}
+
VOID
ScrollDownFileSystemList(
IN PFILE_SYSTEM_LIST List)
}
}
+
VOID
ScrollUpFileSystemList(
IN PFILE_SYSTEM_LIST List)
typedef struct _FILE_SYSTEM_ITEM
{
- LIST_ENTRY ListEntry;
- LPCWSTR FileSystem; /* Not owned by the item */
- FORMATEX FormatFunc;
- CHKDSKEX ChkdskFunc;
- BOOLEAN QuickFormat;
+ LIST_ENTRY ListEntry;
+ LPCWSTR FileSystem; /* Not owned by the item */
+ FORMATEX FormatFunc;
+ CHKDSKEX ChkdskFunc;
+ BOOLEAN QuickFormat;
} FILE_SYSTEM_ITEM, *PFILE_SYSTEM_ITEM;
typedef struct _FILE_SYSTEM_LIST
{
- SHORT Left;
- SHORT Top;
- PFILE_SYSTEM_ITEM Selected;
- LIST_ENTRY ListHead; /* List of FILE_SYSTEM_ITEM */
+ SHORT Left;
+ SHORT Top;
+ PFILE_SYSTEM_ITEM Selected;
+ LIST_ENTRY ListHead; /* List of FILE_SYSTEM_ITEM */
} FILE_SYSTEM_LIST, *PFILE_SYSTEM_LIST;
VOID
FS_AddProvider(
- IN OUT PFILE_SYSTEM_LIST List,
- IN LPCWSTR FileSystem,
- IN FORMATEX FormatFunc,
- IN CHKDSKEX ChkdskFunc);
+ IN OUT PFILE_SYSTEM_LIST List,
+ IN LPCWSTR FileSystem,
+ IN FORMATEX FormatFunc,
+ IN CHKDSKEX ChkdskFunc);
PFILE_SYSTEM_LIST
CreateFileSystemList(
- IN SHORT Left,
- IN SHORT Top,
- IN BOOLEAN ForceFormat,
- IN LPCWSTR ForceFileSystem);
+ IN SHORT Left,
+ IN SHORT Top,
+ IN BOOLEAN ForceFormat,
+ IN LPCWSTR ForceFileSystem);
VOID
DestroyFileSystemList(
VOID
-DestroyGenericList(PGENERIC_LIST List,
- BOOLEAN FreeUserData)
+DestroyGenericList(
+ PGENERIC_LIST List,
+ BOOLEAN FreeUserData)
{
PGENERIC_LIST_ENTRY ListEntry;
PLIST_ENTRY Entry;
BOOLEAN
-AppendGenericListEntry(PGENERIC_LIST List,
- PCHAR Text,
- PVOID UserData,
- BOOLEAN Current)
+AppendGenericListEntry(
+ PGENERIC_LIST List,
+ PCHAR Text,
+ PVOID UserData,
+ BOOLEAN Current)
{
PGENERIC_LIST_ENTRY Entry;
}
-static VOID
-DrawListFrame(PGENERIC_LIST GenericList)
+static
+VOID
+DrawListFrame(
+ PGENERIC_LIST GenericList)
{
COORD coPos;
DWORD Written;
}
-static VOID
-DrawListEntries(PGENERIC_LIST GenericList)
+static
+VOID
+DrawListEntries(
+ PGENERIC_LIST GenericList)
{
PGENERIC_LIST_ENTRY ListEntry;
PLIST_ENTRY Entry;
}
}
-static VOID
-DrawScrollBarGenericList(PGENERIC_LIST GenericList)
+
+static
+VOID
+DrawScrollBarGenericList(
+ PGENERIC_LIST GenericList)
{
COORD coPos;
DWORD Written;
}
}
+
VOID
-DrawGenericList(PGENERIC_LIST List,
- SHORT Left,
- SHORT Top,
- SHORT Right,
- SHORT Bottom)
+DrawGenericList(
+ PGENERIC_LIST List,
+ SHORT Left,
+ SHORT Top,
+ SHORT Right,
+ SHORT Bottom)
{
List->FirstShown = List->ListHead.Flink;
List->Left = Left;
DrawScrollBarGenericList(List);
}
+
VOID
-ScrollPageDownGenericList (PGENERIC_LIST List)
+ScrollPageDownGenericList(
+ PGENERIC_LIST List)
{
SHORT i;
List->Redraw = TRUE;
}
+
VOID
-ScrollPageUpGenericList (PGENERIC_LIST List)
+ScrollPageUpGenericList(
+ PGENERIC_LIST List)
{
SHORT i;
List->Redraw = TRUE;
}
+
VOID
-ScrollDownGenericList (PGENERIC_LIST List)
+ScrollDownGenericList(
+ PGENERIC_LIST List)
{
PLIST_ENTRY Entry;
VOID
-ScrollToPositionGenericList (PGENERIC_LIST List, ULONG uIndex)
+ScrollToPositionGenericList(
+ PGENERIC_LIST List,
+ ULONG uIndex)
{
PLIST_ENTRY Entry;
ULONG uCount = 0;
VOID
-ScrollUpGenericList (PGENERIC_LIST List)
+ScrollUpGenericList(
+ PGENERIC_LIST List)
{
PLIST_ENTRY Entry;
VOID
-RedrawGenericList(PGENERIC_LIST List)
+RedrawGenericList(
+ PGENERIC_LIST List)
{
if (List->CurrentEntry == NULL)
return;
VOID
-SetCurrentListEntry(PGENERIC_LIST List, PGENERIC_LIST_ENTRY Entry)
+SetCurrentListEntry(
+ PGENERIC_LIST List,
+ PGENERIC_LIST_ENTRY Entry)
{
if (Entry->List != List)
return;
PGENERIC_LIST_ENTRY
-GetCurrentListEntry(PGENERIC_LIST List)
+GetCurrentListEntry(
+ PGENERIC_LIST List)
{
return List->CurrentEntry;
}
PGENERIC_LIST_ENTRY
-GetFirstListEntry(PGENERIC_LIST List)
+GetFirstListEntry(
+ PGENERIC_LIST List)
{
PLIST_ENTRY Entry = List->ListHead.Flink;
PGENERIC_LIST_ENTRY
-GetNextListEntry(PGENERIC_LIST_ENTRY Entry)
+GetNextListEntry(
+ PGENERIC_LIST_ENTRY Entry)
{
PLIST_ENTRY Next = Entry->Entry.Flink;
PVOID
-GetListEntryUserData(PGENERIC_LIST_ENTRY List)
+GetListEntryUserData(
+ PGENERIC_LIST_ENTRY List)
{
return List->UserData;
}
LPCSTR
-GetListEntryText(PGENERIC_LIST_ENTRY List)
+GetListEntryText(
+ PGENERIC_LIST_ENTRY List)
{
return List->Text;
}
VOID
-GenericListKeyPress (PGENERIC_LIST GenericList, CHAR AsciChar)
+GenericListKeyPress(
+ PGENERIC_LIST GenericList,
+ CHAR AsciChar)
{
PGENERIC_LIST_ENTRY ListEntry;
PGENERIC_LIST_ENTRY OldListEntry;
VOID
-SaveGenericListState(PGENERIC_LIST List)
+SaveGenericListState(
+ PGENERIC_LIST List)
{
List->BackupEntry = List->CurrentEntry;
}
VOID
-RestoreGenericListState(PGENERIC_LIST List)
+RestoreGenericListState(
+ PGENERIC_LIST List)
{
List->CurrentEntry = List->BackupEntry;
}
CreateGenericList(VOID);
VOID
-DestroyGenericList(PGENERIC_LIST List,
- BOOLEAN FreeUserData);
+DestroyGenericList(
+ PGENERIC_LIST List,
+ BOOLEAN FreeUserData);
BOOLEAN
-AppendGenericListEntry(PGENERIC_LIST List,
- PCHAR Text,
- PVOID UserData,
- BOOLEAN Current);
+AppendGenericListEntry(
+ PGENERIC_LIST List,
+ PCHAR Text,
+ PVOID UserData,
+ BOOLEAN Current);
VOID
-DrawGenericList(PGENERIC_LIST List,
- SHORT Left,
- SHORT Top,
- SHORT Right,
- SHORT Bottom);
+DrawGenericList(
+ PGENERIC_LIST List,
+ SHORT Left,
+ SHORT Top,
+ SHORT Right,
+ SHORT Bottom);
VOID
-DrawScrollBarGenericLis(PGENERIC_LIST List);
+DrawScrollBarGenericLis(
+ PGENERIC_LIST List);
VOID
-ScrollDownGenericList(PGENERIC_LIST List);
+ScrollDownGenericList(
+ PGENERIC_LIST List);
VOID
-ScrollUpGenericList(PGENERIC_LIST List);
+ScrollUpGenericList(
+ PGENERIC_LIST List);
VOID
-ScrollPageDownGenericList(PGENERIC_LIST List);
+ScrollPageDownGenericList(
+ PGENERIC_LIST List);
VOID
-ScrollPageUpGenericList(PGENERIC_LIST List);
+ScrollPageUpGenericList(
+ PGENERIC_LIST List);
VOID
-ScrollToPositionGenericList (PGENERIC_LIST List, ULONG uIndex);
+ScrollToPositionGenericList(
+ PGENERIC_LIST List,
+ ULONG uIndex);
VOID
-RedrawGenericList(PGENERIC_LIST List);
+RedrawGenericList(
+ PGENERIC_LIST List);
VOID
-SetCurrentListEntry(PGENERIC_LIST List, PGENERIC_LIST_ENTRY Entry);
+SetCurrentListEntry(
+ PGENERIC_LIST List,
+ PGENERIC_LIST_ENTRY Entry);
PGENERIC_LIST_ENTRY
-GetCurrentListEntry(PGENERIC_LIST List);
+GetCurrentListEntry(
+ PGENERIC_LIST List);
PGENERIC_LIST_ENTRY
-GetFirstListEntry(PGENERIC_LIST List);
+GetFirstListEntry(
+ PGENERIC_LIST List);
PGENERIC_LIST_ENTRY
-GetNextListEntry(PGENERIC_LIST_ENTRY Entry);
+GetNextListEntry(
+ PGENERIC_LIST_ENTRY Entry);
PVOID
-GetListEntryUserData(PGENERIC_LIST_ENTRY List);
+GetListEntryUserData(
+ PGENERIC_LIST_ENTRY List);
LPCSTR
-GetListEntryText(PGENERIC_LIST_ENTRY List);
+GetListEntryText(
+ PGENERIC_LIST_ENTRY List);
VOID
-SaveGenericListState(PGENERIC_LIST List);
+SaveGenericListState(
+ PGENERIC_LIST List);
VOID
-RestoreGenericListState(PGENERIC_LIST List);
+RestoreGenericListState(
+ PGENERIC_LIST List);
VOID
-GenericListKeyPress (PGENERIC_LIST List, CHAR AsciChar);
+GenericListKeyPress(
+ PGENERIC_LIST List,
+ CHAR AsciChar);
/* EOF */
#endif
BOOLEAN
-HOST_InitConsole(
- VOID);
+HOST_InitConsole(VOID);
BOOLEAN
-HOST_InitMemory(
- VOID);
+HOST_InitMemory(VOID);
BOOLEAN
HOST_CreateFileSystemList(
- IN PFILE_SYSTEM_LIST List);
+ IN PFILE_SYSTEM_LIST List);
BOOLEAN
HOST_FormatPartition(
- IN PFILE_SYSTEM_ITEM FileSystem,
- IN PCUNICODE_STRING DriveRoot,
- IN PFMIFSCALLBACK Callback);
+ IN PFILE_SYSTEM_ITEM FileSystem,
+ IN PCUNICODE_STRING DriveRoot,
+ IN PFMIFSCALLBACK Callback);
#ifdef __REACTOS__
-BOOL WINAPI
+BOOL
+WINAPI
InfpFindFirstLineW(
- IN HINF InfHandle,
- IN PCWSTR Section,
- IN PCWSTR Key,
- IN OUT PINFCONTEXT Context)
+ IN HINF InfHandle,
+ IN PCWSTR Section,
+ IN PCWSTR Key,
+ IN OUT PINFCONTEXT Context)
{
- PINFCONTEXT pContext;
- BOOL ret;
+ PINFCONTEXT pContext;
+ BOOL ret;
- ret = InfFindFirstLine(InfHandle, Section, Key, &pContext);
- if (!ret)
- return FALSE;
+ ret = InfFindFirstLine(InfHandle, Section, Key, &pContext);
+ if (!ret)
+ return FALSE;
- memcpy(Context, pContext, sizeof(INFCONTEXT));
- InfFreeContext(pContext);
- return TRUE;
+ memcpy(Context, pContext, sizeof(INFCONTEXT));
+ InfFreeContext(pContext);
+ return TRUE;
}
-HINF WINAPI
+
+HINF
+WINAPI
InfpOpenInfFileW(
- IN PCWSTR FileName,
- IN PCWSTR InfClass,
- IN DWORD InfStyle,
- IN LCID LocaleId,
- OUT PUINT ErrorLine)
+ IN PCWSTR FileName,
+ IN PCWSTR InfClass,
+ IN DWORD InfStyle,
+ IN LCID LocaleId,
+ OUT PUINT ErrorLine)
{
- HINF hInf = NULL;
- UNICODE_STRING FileNameU;
- ULONG ErrorLineUL;
- NTSTATUS Status;
-
- RtlInitUnicodeString(&FileNameU, FileName);
- Status = InfOpenFile(
- &hInf,
- &FileNameU,
- LANGIDFROMLCID(LocaleId),
- &ErrorLineUL);
- *ErrorLine = (UINT)ErrorLineUL;
- if (!NT_SUCCESS(Status))
- return INVALID_HANDLE_VALUE;
-
- return hInf;
+ HINF hInf = NULL;
+ UNICODE_STRING FileNameU;
+ ULONG ErrorLineUL;
+ NTSTATUS Status;
+
+ RtlInitUnicodeString(&FileNameU, FileName);
+ Status = InfOpenFile(&hInf,
+ &FileNameU,
+ LANGIDFROMLCID(LocaleId),
+ &ErrorLineUL);
+ *ErrorLine = (UINT)ErrorLineUL;
+ if (!NT_SUCCESS(Status))
+ return INVALID_HANDLE_VALUE;
+
+ return hInf;
}
-
#endif /* __REACTOS__ */
+
BOOLEAN
INF_GetData(
- IN PINFCONTEXT Context,
- OUT PWCHAR *Key,
- OUT PWCHAR *Data)
+ IN PINFCONTEXT Context,
+ OUT PWCHAR *Key,
+ OUT PWCHAR *Data)
{
#ifdef __REACTOS__
- return InfGetData(Context, Key, Data);
+ return InfGetData(Context, Key, Data);
#else
- static PWCHAR pLastCallData[4] = { NULL, NULL, NULL, NULL };
- static DWORD currentIndex = 0;
- DWORD dwSize, i;
- BOOL ret;
-
- currentIndex ^= 2;
-
- if (Key) *Key = NULL;
- if (Data) *Data = NULL;
-
- if (SetupGetFieldCount(Context) != 1)
- return FALSE;
-
- for (i = 0; i <= 1; i++)
- {
- ret = SetupGetStringFieldW(
- Context,
- i,
- NULL,
- 0,
- &dwSize);
- if (!ret)
- return FALSE;
- HeapFree(GetProcessHeap(), 0, pLastCallData[i + currentIndex]);
- pLastCallData[i + currentIndex] = HeapAlloc(GetProcessHeap(), 0, dwSize * sizeof(WCHAR));
- ret = SetupGetStringFieldW(
- Context,
- i,
- pLastCallData[i + currentIndex],
- dwSize,
- NULL);
- if (!ret)
- return FALSE;
- }
-
- if (Key)
- *Key = pLastCallData[0 + currentIndex];
- if (Data)
- *Data = pLastCallData[1 + currentIndex];
- return TRUE;
+ static PWCHAR pLastCallData[4] = { NULL, NULL, NULL, NULL };
+ static DWORD currentIndex = 0;
+ DWORD dwSize, i;
+ BOOL ret;
+
+ currentIndex ^= 2;
+
+ if (Key)
+ *Key = NULL;
+
+ if (Data)
+ *Data = NULL;
+
+ if (SetupGetFieldCount(Context) != 1)
+ return FALSE;
+
+ for (i = 0; i <= 1; i++)
+ {
+ ret = SetupGetStringFieldW(Context,
+ i,
+ NULL,
+ 0,
+ &dwSize);
+ if (!ret)
+ return FALSE;
+
+ HeapFree(GetProcessHeap(), 0, pLastCallData[i + currentIndex]);
+ pLastCallData[i + currentIndex] = HeapAlloc(GetProcessHeap(), 0, dwSize * sizeof(WCHAR));
+ ret = SetupGetStringFieldW(Context,
+ i,
+ pLastCallData[i + currentIndex],
+ dwSize,
+ NULL);
+ if (!ret)
+ return FALSE;
+ }
+
+ if (Key)
+ *Key = pLastCallData[0 + currentIndex];
+
+ if (Data)
+ *Data = pLastCallData[1 + currentIndex];
+
+ return TRUE;
#endif /* !__REACTOS__ */
}
+
BOOLEAN
INF_GetDataField(
- IN PINFCONTEXT Context,
- IN ULONG FieldIndex,
- OUT PWCHAR *Data)
+ IN PINFCONTEXT Context,
+ IN ULONG FieldIndex,
+ OUT PWCHAR *Data)
{
#ifdef __REACTOS__
- return InfGetDataField(Context, FieldIndex, Data);
+ return InfGetDataField(Context, FieldIndex, Data);
#else
- static PWCHAR pLastCallsData[] = { NULL, NULL, NULL };
- static DWORD NextIndex = 0;
- DWORD dwSize;
- BOOL ret;
-
- *Data = NULL;
-
- ret = SetupGetStringFieldW(
- Context,
- FieldIndex,
- NULL,
- 0,
- &dwSize);
- if (!ret)
- return FALSE;
- HeapFree(GetProcessHeap(), 0, pLastCallsData[NextIndex]);
- pLastCallsData[NextIndex] = HeapAlloc(GetProcessHeap(), 0, dwSize * sizeof(WCHAR));
- ret = SetupGetStringFieldW(
- Context,
- FieldIndex,
- pLastCallsData[NextIndex],
- dwSize,
- NULL);
- if (!ret)
- return FALSE;
-
- *Data = pLastCallsData[NextIndex];
- NextIndex = (NextIndex + 1) % (sizeof(pLastCallsData) / sizeof(pLastCallsData[0]));
- return TRUE;
+ static PWCHAR pLastCallsData[] = { NULL, NULL, NULL };
+ static DWORD NextIndex = 0;
+ DWORD dwSize;
+ BOOL ret;
+
+ *Data = NULL;
+
+ ret = SetupGetStringFieldW(Context,
+ FieldIndex,
+ NULL,
+ 0,
+ &dwSize);
+ if (!ret)
+ return FALSE;
+
+ HeapFree(GetProcessHeap(), 0, pLastCallsData[NextIndex]);
+ pLastCallsData[NextIndex] = HeapAlloc(GetProcessHeap(), 0, dwSize * sizeof(WCHAR));
+ ret = SetupGetStringFieldW(Context,
+ FieldIndex,
+ pLastCallsData[NextIndex],
+ dwSize,
+ NULL);
+ if (!ret)
+ return FALSE;
+
+ *Data = pLastCallsData[NextIndex];
+ NextIndex = (NextIndex + 1) % (sizeof(pLastCallsData) / sizeof(pLastCallsData[0]));
+ return TRUE;
#endif /* !__REACTOS__ */
}
+
HINF WINAPI
INF_OpenBufferedFileA(
- IN PSTR FileBuffer,
- IN ULONG FileSize,
- IN PCSTR InfClass,
- IN DWORD InfStyle,
- IN LCID LocaleId,
- OUT PUINT ErrorLine)
+ IN PSTR FileBuffer,
+ IN ULONG FileSize,
+ IN PCSTR InfClass,
+ IN DWORD InfStyle,
+ IN LCID LocaleId,
+ OUT PUINT ErrorLine)
{
#ifdef __REACTOS__
- HINF hInf = NULL;
- ULONG ErrorLineUL;
- NTSTATUS Status;
-
- Status = InfOpenBufferedFile(
- &hInf,
- FileBuffer,
- FileSize,
- LANGIDFROMLCID(LocaleId),
- &ErrorLineUL);
- *ErrorLine = (UINT)ErrorLineUL;
- if (!NT_SUCCESS(Status))
- return INVALID_HANDLE_VALUE;
-
- return hInf;
+ HINF hInf = NULL;
+ ULONG ErrorLineUL;
+ NTSTATUS Status;
+
+ Status = InfOpenBufferedFile(&hInf,
+ FileBuffer,
+ FileSize,
+ LANGIDFROMLCID(LocaleId),
+ &ErrorLineUL);
+ *ErrorLine = (UINT)ErrorLineUL;
+ if (!NT_SUCCESS(Status))
+ return INVALID_HANDLE_VALUE;
+
+ return hInf;
#else
- return INVALID_HANDLE_VALUE;
+ return INVALID_HANDLE_VALUE;
#endif /* !__REACTOS__ */
}
* Delete it once we don't use inflib anymore */
typedef struct _INFCONTEXT
{
- PVOID Inf;
- PVOID Section;
- PVOID Line;
+ PVOID Inf;
+ PVOID Section;
+ PVOID Line;
} INFCONTEXT;
-BOOL WINAPI
+BOOL
+WINAPI
InfpFindFirstLineW(
- IN HINF InfHandle,
- IN PCWSTR Section,
- IN PCWSTR Key,
- IN OUT PINFCONTEXT Context);
+ IN HINF InfHandle,
+ IN PCWSTR Section,
+ IN PCWSTR Key,
+ IN OUT PINFCONTEXT Context);
-HINF WINAPI
+HINF
+WINAPI
InfpOpenInfFileW(
- IN PCWSTR FileName,
- IN PCWSTR InfClass,
- IN DWORD InfStyle,
- IN LCID LocaleId,
- OUT PUINT ErrorLine);
+ IN PCWSTR FileName,
+ IN PCWSTR InfClass,
+ IN DWORD InfStyle,
+ IN LCID LocaleId,
+ OUT PUINT ErrorLine);
#endif /* __REACTOS__ */
BOOLEAN
INF_GetData(
- IN PINFCONTEXT Context,
- OUT PWCHAR *Key,
- OUT PWCHAR *Data);
+ IN PINFCONTEXT Context,
+ OUT PWCHAR *Key,
+ OUT PWCHAR *Data);
BOOLEAN
INF_GetDataField(
- IN PINFCONTEXT Context,
- IN ULONG FieldIndex,
- OUT PWCHAR *Data);
+ IN PINFCONTEXT Context,
+ IN ULONG FieldIndex,
+ OUT PWCHAR *Data);
HINF WINAPI
INF_OpenBufferedFileA(
- IN PSTR FileBuffer,
- IN ULONG FileSize,
- IN PCSTR InfClass,
- IN DWORD InfStyle,
- IN LCID LocaleId,
- OUT PUINT ErrorLine);
+ IN PSTR FileBuffer,
+ IN ULONG FileSize,
+ IN PCSTR InfClass,
+ IN DWORD InfStyle,
+ IN LCID LocaleId,
+ OUT PUINT ErrorLine);
/* EOF */
/* PRIVATE FUNCTIONS ********************************************************/
-static PINICACHEKEY
-IniCacheFreeKey(PINICACHEKEY Key)
+static
+PINICACHEKEY
+IniCacheFreeKey(
+ PINICACHEKEY Key)
{
- PINICACHEKEY Next;
+ PINICACHEKEY Next;
- if (Key == NULL)
+ if (Key == NULL)
{
- return(NULL);
+ return NULL;
}
- Next = Key->Next;
- if (Key->Name != NULL)
+ Next = Key->Next;
+ if (Key->Name != NULL)
{
- RtlFreeHeap(ProcessHeap,
- 0,
- Key->Name);
- Key->Name = NULL;
+ RtlFreeHeap(ProcessHeap, 0, Key->Name);
+ Key->Name = NULL;
}
- if (Key->Data != NULL)
+ if (Key->Data != NULL)
{
- RtlFreeHeap(ProcessHeap,
- 0,
- Key->Data);
- Key->Data = NULL;
+ RtlFreeHeap(ProcessHeap, 0, Key->Data);
+ Key->Data = NULL;
}
- RtlFreeHeap(ProcessHeap,
- 0,
- Key);
+ RtlFreeHeap(ProcessHeap, 0, Key);
- return(Next);
+ return Next;
}
-static PINICACHESECTION
-IniCacheFreeSection(PINICACHESECTION Section)
+static
+PINICACHESECTION
+IniCacheFreeSection(
+ PINICACHESECTION Section)
{
- PINICACHESECTION Next;
+ PINICACHESECTION Next;
- if (Section == NULL)
+ if (Section == NULL)
{
- return(NULL);
+ return NULL;
}
- Next = Section->Next;
- while (Section->FirstKey != NULL)
+ Next = Section->Next;
+ while (Section->FirstKey != NULL)
{
- Section->FirstKey = IniCacheFreeKey(Section->FirstKey);
+ Section->FirstKey = IniCacheFreeKey(Section->FirstKey);
}
- Section->LastKey = NULL;
+ Section->LastKey = NULL;
- if (Section->Name != NULL)
+ if (Section->Name != NULL)
{
- RtlFreeHeap(ProcessHeap,
- 0,
- Section->Name);
- Section->Name = NULL;
+ RtlFreeHeap(ProcessHeap, 0, Section->Name);
+ Section->Name = NULL;
}
- RtlFreeHeap(ProcessHeap,
- 0,
- Section);
+ RtlFreeHeap(ProcessHeap, 0, Section);
- return(Next);
+ return Next;
}
-static PINICACHEKEY
-IniCacheFindKey(PINICACHESECTION Section,
- PWCHAR Name,
- ULONG NameLength)
+static
+PINICACHEKEY
+IniCacheFindKey(
+ PINICACHESECTION Section,
+ PWCHAR Name,
+ ULONG NameLength)
{
- PINICACHEKEY Key;
+ PINICACHEKEY Key;
- Key = Section->FirstKey;
- while (Key != NULL)
+ Key = Section->FirstKey;
+ while (Key != NULL)
{
- if (NameLength == wcslen(Key->Name))
- {
- if (_wcsnicmp(Key->Name, Name, NameLength) == 0)
- break;
- }
+ if (NameLength == wcslen(Key->Name))
+ {
+ if (_wcsnicmp(Key->Name, Name, NameLength) == 0)
+ break;
+ }
- Key = Key->Next;
+ Key = Key->Next;
}
- return(Key);
+ return Key;
}
-static PINICACHEKEY
-IniCacheAddKey(PINICACHESECTION Section,
- PCHAR Name,
- ULONG NameLength,
- PCHAR Data,
- ULONG DataLength)
+static
+PINICACHEKEY
+IniCacheAddKey(
+ PINICACHESECTION Section,
+ PCHAR Name,
+ ULONG NameLength,
+ PCHAR Data,
+ ULONG DataLength)
{
- PINICACHEKEY Key;
- ULONG i;
+ PINICACHEKEY Key;
+ ULONG i;
- Key = NULL;
+ Key = NULL;
- if (Section == NULL ||
- Name == NULL ||
- NameLength == 0 ||
- Data == NULL ||
- DataLength == 0)
+ if (Section == NULL ||
+ Name == NULL ||
+ NameLength == 0 ||
+ Data == NULL ||
+ DataLength == 0)
{
- DPRINT("Invalid parameter\n");
- return(NULL);
+ DPRINT("Invalid parameter\n");
+ return NULL;
}
- Key = (PINICACHEKEY)RtlAllocateHeap(ProcessHeap,
- 0,
- sizeof(INICACHEKEY));
- if (Key == NULL)
+ Key = (PINICACHEKEY)RtlAllocateHeap(ProcessHeap,
+ 0,
+ sizeof(INICACHEKEY));
+ if (Key == NULL)
{
- DPRINT("RtlAllocateHeap() failed\n");
- return(NULL);
+ DPRINT("RtlAllocateHeap() failed\n");
+ return NULL;
}
- RtlZeroMemory(Key,
- sizeof(INICACHEKEY));
+ RtlZeroMemory(Key,
+ sizeof(INICACHEKEY));
-
- Key->Name = (WCHAR*) RtlAllocateHeap(ProcessHeap,
- 0,
- (NameLength + 1) * sizeof(WCHAR));
- if (Key->Name == NULL)
+ Key->Name = (WCHAR*)RtlAllocateHeap(ProcessHeap,
+ 0,
+ (NameLength + 1) * sizeof(WCHAR));
+ if (Key->Name == NULL)
{
- DPRINT("RtlAllocateHeap() failed\n");
- RtlFreeHeap(ProcessHeap,
- 0,
- Key);
- return(NULL);
+ DPRINT("RtlAllocateHeap() failed\n");
+ RtlFreeHeap(ProcessHeap, 0, Key);
+ return NULL;
}
- /* Copy value name */
- for (i = 0; i < NameLength; i++)
+ /* Copy value name */
+ for (i = 0; i < NameLength; i++)
{
- Key->Name[i] = (WCHAR)Name[i];
+ Key->Name[i] = (WCHAR)Name[i];
}
- Key->Name[NameLength] = 0;
-
+ Key->Name[NameLength] = 0;
- Key->Data = (WCHAR*) RtlAllocateHeap(ProcessHeap,
- 0,
- (DataLength + 1) * sizeof(WCHAR));
- if (Key->Data == NULL)
+ Key->Data = (WCHAR*)RtlAllocateHeap(ProcessHeap,
+ 0,
+ (DataLength + 1) * sizeof(WCHAR));
+ if (Key->Data == NULL)
{
- DPRINT("RtlAllocateHeap() failed\n");
- RtlFreeHeap(ProcessHeap,
- 0,
- Key->Name);
- RtlFreeHeap(ProcessHeap,
- 0,
- Key);
- return(NULL);
+ DPRINT("RtlAllocateHeap() failed\n");
+ RtlFreeHeap(ProcessHeap, 0, Key->Name);
+ RtlFreeHeap(ProcessHeap, 0, Key);
+ return NULL;
}
- /* Copy value data */
- for (i = 0; i < DataLength; i++)
+ /* Copy value data */
+ for (i = 0; i < DataLength; i++)
{
- Key->Data[i] = (WCHAR)Data[i];
+ Key->Data[i] = (WCHAR)Data[i];
}
- Key->Data[DataLength] = 0;
+ Key->Data[DataLength] = 0;
- if (Section->FirstKey == NULL)
+ if (Section->FirstKey == NULL)
{
- Section->FirstKey = Key;
- Section->LastKey = Key;
+ Section->FirstKey = Key;
+ Section->LastKey = Key;
}
- else
+ else
{
- Section->LastKey->Next = Key;
- Key->Prev = Section->LastKey;
- Section->LastKey = Key;
+ Section->LastKey->Next = Key;
+ Key->Prev = Section->LastKey;
+ Section->LastKey = Key;
}
- return(Key);
+ return Key;
}
+
#if 0
-static PINICACHESECTION
-IniCacheFindSection(PINICACHE Cache,
- PWCHAR Name,
- ULONG NameLength)
+static
+PINICACHESECTION
+IniCacheFindSection(
+ PINICACHE Cache,
+ PWCHAR Name,
+ ULONG NameLength)
{
- PINICACHESECTION Section = NULL;
+ PINICACHESECTION Section = NULL;
- if (Cache == NULL || Name == NULL || NameLength == 0)
+ if (Cache == NULL || Name == NULL || NameLength == 0)
{
- return(NULL);
+ return NULL;
}
- Section = Cache->FirstSection;
+ Section = Cache->FirstSection;
- /* iterate through list of sections */
- while (Section != NULL)
+ /* iterate through list of sections */
+ while (Section != NULL)
{
- if (NameLength == wcslen(Section->Name))
- {
- /* are the contents the same too? */
- if (_wcsnicmp(Section->Name, Name, NameLength) == 0)
- break;
- }
+ if (NameLength == wcslen(Section->Name))
+ {
+ /* are the contents the same too? */
+ if (_wcsnicmp(Section->Name, Name, NameLength) == 0)
+ break;
+ }
- /* get the next section*/
- Section = Section->Next;
+ /* get the next section*/
+ Section = Section->Next;
}
- return(Section);
+ return Section;
}
#endif
-static PINICACHESECTION
-IniCacheAddSection(PINICACHE Cache,
- PCHAR Name,
- ULONG NameLength)
+
+static
+PINICACHESECTION
+IniCacheAddSection(
+ PINICACHE Cache,
+ PCHAR Name,
+ ULONG NameLength)
{
- PINICACHESECTION Section = NULL;
- ULONG i;
+ PINICACHESECTION Section = NULL;
+ ULONG i;
- if (Cache == NULL || Name == NULL || NameLength == 0)
+ if (Cache == NULL || Name == NULL || NameLength == 0)
{
- DPRINT("Invalid parameter\n");
- return(NULL);
+ DPRINT("Invalid parameter\n");
+ return NULL;
}
- Section = (PINICACHESECTION)RtlAllocateHeap(ProcessHeap,
- 0,
- sizeof(INICACHESECTION));
- if (Section == NULL)
+ Section = (PINICACHESECTION)RtlAllocateHeap(ProcessHeap,
+ 0,
+ sizeof(INICACHESECTION));
+ if (Section == NULL)
{
- DPRINT("RtlAllocateHeap() failed\n");
- return(NULL);
+ DPRINT("RtlAllocateHeap() failed\n");
+ return NULL;
}
- RtlZeroMemory(Section,
- sizeof(INICACHESECTION));
- /* Allocate and initialize section name */
- Section->Name = (WCHAR*) RtlAllocateHeap(ProcessHeap,
- 0,
- (NameLength + 1) * sizeof(WCHAR));
- if (Section->Name == NULL)
+ RtlZeroMemory(Section, sizeof(INICACHESECTION));
+
+ /* Allocate and initialize section name */
+ Section->Name = (WCHAR*)RtlAllocateHeap(ProcessHeap,
+ 0,
+ (NameLength + 1) * sizeof(WCHAR));
+ if (Section->Name == NULL)
{
- DPRINT("RtlAllocateHeap() failed\n");
- RtlFreeHeap(ProcessHeap,
- 0,
- Section);
- return(NULL);
+ DPRINT("RtlAllocateHeap() failed\n");
+ RtlFreeHeap(ProcessHeap, 0, Section);
+ return NULL;
}
- /* Copy section name */
- for (i = 0; i < NameLength; i++)
+ /* Copy section name */
+ for (i = 0; i < NameLength; i++)
{
- Section->Name[i] = (WCHAR)Name[i];
+ Section->Name[i] = (WCHAR)Name[i];
}
- Section->Name[NameLength] = 0;
+ Section->Name[NameLength] = 0;
- /* Append section */
- if (Cache->FirstSection == NULL)
+ /* Append section */
+ if (Cache->FirstSection == NULL)
{
- Cache->FirstSection = Section;
- Cache->LastSection = Section;
+ Cache->FirstSection = Section;
+ Cache->LastSection = Section;
}
- else
+ else
{
- Cache->LastSection->Next = Section;
- Section->Prev = Cache->LastSection;
- Cache->LastSection = Section;
+ Cache->LastSection->Next = Section;
+ Section->Prev = Cache->LastSection;
+ Cache->LastSection = Section;
}
- return(Section);
+ return Section;
}
-static PCHAR
-IniCacheSkipWhitespace(PCHAR Ptr)
+static
+PCHAR
+IniCacheSkipWhitespace(
+ PCHAR Ptr)
{
- while (*Ptr != 0 && isspace(*Ptr))
- Ptr++;
+ while (*Ptr != 0 && isspace(*Ptr))
+ Ptr++;
- return((*Ptr == 0) ? NULL : Ptr);
+ return (*Ptr == 0) ? NULL : Ptr;
}
-static PCHAR
-IniCacheSkipToNextSection(PCHAR Ptr)
+static
+PCHAR
+IniCacheSkipToNextSection(
+ PCHAR Ptr)
{
- while (*Ptr != 0 && *Ptr != '[')
+ while (*Ptr != 0 && *Ptr != '[')
{
- while (*Ptr != 0 && *Ptr != L'\n')
- {
- Ptr++;
- }
- Ptr++;
+ while (*Ptr != 0 && *Ptr != L'\n')
+ {
+ Ptr++;
+ }
+
+ Ptr++;
}
- return((*Ptr == 0) ? NULL : Ptr);
+ return (*Ptr == 0) ? NULL : Ptr;
}
-static PCHAR
-IniCacheGetSectionName(PCHAR Ptr,
- PCHAR *NamePtr,
- PULONG NameSize)
+static
+PCHAR
+IniCacheGetSectionName(
+ PCHAR Ptr,
+ PCHAR *NamePtr,
+ PULONG NameSize)
{
- ULONG Size = 0;
- CHAR Name[256];
+ ULONG Size = 0;
+ CHAR Name[256];
- *NamePtr = NULL;
- *NameSize = 0;
+ *NamePtr = NULL;
+ *NameSize = 0;
- /* skip whitespace */
- while (*Ptr != 0 && isspace(*Ptr))
+ /* skip whitespace */
+ while (*Ptr != 0 && isspace(*Ptr))
{
- Ptr++;
+ Ptr++;
}
- *NamePtr = Ptr;
+ *NamePtr = Ptr;
- while (*Ptr != 0 && *Ptr != ']')
+ while (*Ptr != 0 && *Ptr != ']')
{
- Size++;
- Ptr++;
+ Size++;
+ Ptr++;
}
+ Ptr++;
- Ptr++;
-
- while (*Ptr != 0 && *Ptr != L'\n')
+ while (*Ptr != 0 && *Ptr != L'\n')
{
- Ptr++;
+ Ptr++;
}
- Ptr++;
+ Ptr++;
- *NameSize = Size;
+ *NameSize = Size;
- strncpy(Name, *NamePtr, Size);
- Name[Size] = 0;
+ strncpy(Name, *NamePtr, Size);
+ Name[Size] = 0;
- DPRINT("SectionName: '%s'\n", Name);
+ DPRINT("SectionName: '%s'\n", Name);
- return(Ptr);
+ return Ptr;
}
-static PCHAR
-IniCacheGetKeyName(PCHAR Ptr,
- PCHAR *NamePtr,
- PULONG NameSize)
+static
+PCHAR
+IniCacheGetKeyName(
+ PCHAR Ptr,
+ PCHAR *NamePtr,
+ PULONG NameSize)
{
- ULONG Size = 0;
+ ULONG Size = 0;
- *NamePtr = NULL;
- *NameSize = 0;
-
- while(Ptr && *Ptr)
- {
*NamePtr = NULL;
*NameSize = 0;
- Size = 0;
-
- /* skip whitespace and empty lines */
- while (isspace(*Ptr) || *Ptr == '\n' || *Ptr == '\r')
- {
- Ptr++;
- }
- if (*Ptr == 0)
- {
- continue;
- }
-
- *NamePtr = Ptr;
-
- while (*Ptr != 0 && !isspace(*Ptr) && *Ptr != '=' && *Ptr != ';')
- {
- Size++;
- Ptr++;
- }
- if (*Ptr == ';')
- {
- while (*Ptr != 0 && *Ptr != '\r' && *Ptr != '\n')
- {
- Ptr++;
- }
- }
- else
- {
- *NameSize = Size;
- break;
- }
- }
- return(Ptr);
+ while(Ptr && *Ptr)
+ {
+ *NamePtr = NULL;
+ *NameSize = 0;
+ Size = 0;
+
+ /* skip whitespace and empty lines */
+ while (isspace(*Ptr) || *Ptr == '\n' || *Ptr == '\r')
+ {
+ Ptr++;
+ }
+ if (*Ptr == 0)
+ {
+ continue;
+ }
+
+ *NamePtr = Ptr;
+
+ while (*Ptr != 0 && !isspace(*Ptr) && *Ptr != '=' && *Ptr != ';')
+ {
+ Size++;
+ Ptr++;
+ }
+ if (*Ptr == ';')
+ {
+ while (*Ptr != 0 && *Ptr != '\r' && *Ptr != '\n')
+ {
+ Ptr++;
+ }
+ }
+ else
+ {
+ *NameSize = Size;
+ break;
+ }
+ }
+
+ return Ptr;
}
-static PCHAR
-IniCacheGetKeyValue(PCHAR Ptr,
- PCHAR *DataPtr,
- PULONG DataSize,
- BOOLEAN String)
+static
+PCHAR
+IniCacheGetKeyValue(
+ PCHAR Ptr,
+ PCHAR *DataPtr,
+ PULONG DataSize,
+ BOOLEAN String)
{
- ULONG Size = 0;
+ ULONG Size = 0;
- *DataPtr = NULL;
- *DataSize = 0;
+ *DataPtr = NULL;
+ *DataSize = 0;
- /* Skip whitespace */
- while (*Ptr != 0 && isspace(*Ptr))
+ /* Skip whitespace */
+ while (*Ptr != 0 && isspace(*Ptr))
{
- Ptr++;
+ Ptr++;
}
- /* Check and skip '=' */
- if (*Ptr != '=')
+ /* Check and skip '=' */
+ if (*Ptr != '=')
{
- return(NULL);
+ return NULL;
}
- Ptr++;
+ Ptr++;
- /* Skip whitespace */
- while (*Ptr != 0 && isspace(*Ptr))
+ /* Skip whitespace */
+ while (*Ptr != 0 && isspace(*Ptr))
{
- Ptr++;
+ Ptr++;
}
- if (*Ptr == '"' && String)
+ if (*Ptr == '"' && String)
{
- Ptr++;
+ Ptr++;
+
+ /* Get data */
+ *DataPtr = Ptr;
+ while (*Ptr != '"')
+ {
+ Ptr++;
+ Size++;
+ }
+ Ptr++;
- /* Get data */
- *DataPtr = Ptr;
- while (*Ptr != '"')
- {
- Ptr++;
- Size++;
- }
- Ptr++;
- while (*Ptr && *Ptr != '\r' && *Ptr != '\n')
- {
- Ptr++;
- }
+ while (*Ptr && *Ptr != '\r' && *Ptr != '\n')
+ {
+ Ptr++;
+ }
}
- else
+ else
{
- /* Get data */
- *DataPtr = Ptr;
- while (*Ptr != 0 && *Ptr != '\r' && *Ptr != ';')
- {
- Ptr++;
- Size++;
- }
+ /* Get data */
+ *DataPtr = Ptr;
+ while (*Ptr != 0 && *Ptr != '\r' && *Ptr != ';')
+ {
+ Ptr++;
+ Size++;
+ }
}
- /* Skip to next line */
- if (*Ptr == '\r')
- Ptr++;
- if (*Ptr == '\n')
- Ptr++;
+ /* Skip to next line */
+ if (*Ptr == '\r')
+ Ptr++;
+ if (*Ptr == '\n')
+ Ptr++;
- *DataSize = Size;
+ *DataSize = Size;
- return(Ptr);
+ return Ptr;
}
-
-
/* PUBLIC FUNCTIONS *********************************************************/
NTSTATUS
-IniCacheLoad(PINICACHE *Cache,
- PUNICODE_STRING FileName,
- BOOLEAN String)
+IniCacheLoad(
+ PINICACHE *Cache,
+ PUNICODE_STRING FileName,
+ BOOLEAN String)
{
- OBJECT_ATTRIBUTES ObjectAttributes;
- FILE_STANDARD_INFORMATION FileInfo;
- IO_STATUS_BLOCK IoStatusBlock;
- HANDLE FileHandle;
- NTSTATUS Status;
- PCHAR FileBuffer;
- ULONG FileLength;
- PCHAR Ptr;
- LARGE_INTEGER FileOffset;
-
- PINICACHESECTION Section;
- PINICACHEKEY Key;
-
- PCHAR SectionName;
- ULONG SectionNameSize;
-
- PCHAR KeyName;
- ULONG KeyNameSize;
-
- PCHAR KeyValue;
- ULONG KeyValueSize;
-
- *Cache = NULL;
-
- /* Open ini file */
- InitializeObjectAttributes(&ObjectAttributes,
- FileName,
- 0,
- NULL,
- NULL);
-
- Status = NtOpenFile(&FileHandle,
- GENERIC_READ | SYNCHRONIZE,
- &ObjectAttributes,
- &IoStatusBlock,
- FILE_SHARE_READ,
- FILE_SYNCHRONOUS_IO_NONALERT | FILE_NON_DIRECTORY_FILE);
- if (!NT_SUCCESS(Status))
- {
- DPRINT("NtOpenFile() failed (Status %lx)\n", Status);
- return(Status);
- }
-
- DPRINT("NtOpenFile() successful\n");
-
- /* Query file size */
- Status = NtQueryInformationFile(FileHandle,
- &IoStatusBlock,
- &FileInfo,
- sizeof(FILE_STANDARD_INFORMATION),
- FileStandardInformation);
- if (!NT_SUCCESS(Status))
- {
- DPRINT("NtQueryInformationFile() failed (Status %lx)\n", Status);
- NtClose(FileHandle);
- return(Status);
- }
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ FILE_STANDARD_INFORMATION FileInfo;
+ IO_STATUS_BLOCK IoStatusBlock;
+ HANDLE FileHandle;
+ NTSTATUS Status;
+ PCHAR FileBuffer;
+ ULONG FileLength;
+ PCHAR Ptr;
+ LARGE_INTEGER FileOffset;
+
+ PINICACHESECTION Section;
+ PINICACHEKEY Key;
+
+ PCHAR SectionName;
+ ULONG SectionNameSize;
+
+ PCHAR KeyName;
+ ULONG KeyNameSize;
- FileLength = FileInfo.EndOfFile.u.LowPart;
+ PCHAR KeyValue;
+ ULONG KeyValueSize;
- DPRINT("File size: %lu\n", FileLength);
+ *Cache = NULL;
- /* Allocate file buffer */
- FileBuffer = (CHAR*) RtlAllocateHeap(ProcessHeap,
- 0,
- FileLength + 1);
- if (FileBuffer == NULL)
+ /* Open ini file */
+ InitializeObjectAttributes(&ObjectAttributes,
+ FileName,
+ 0,
+ NULL,
+ NULL);
+
+ Status = NtOpenFile(&FileHandle,
+ GENERIC_READ | SYNCHRONIZE,
+ &ObjectAttributes,
+ &IoStatusBlock,
+ FILE_SHARE_READ,
+ FILE_SYNCHRONOUS_IO_NONALERT | FILE_NON_DIRECTORY_FILE);
+ if (!NT_SUCCESS(Status))
{
- DPRINT1("RtlAllocateHeap() failed\n");
- NtClose(FileHandle);
- return(STATUS_INSUFFICIENT_RESOURCES);
- }
-
- /* Read file */
- FileOffset.QuadPart = 0ULL;
- Status = NtReadFile(FileHandle,
- NULL,
- NULL,
- NULL,
- &IoStatusBlock,
- FileBuffer,
- FileLength,
- &FileOffset,
- NULL);
-
- /* Append string terminator */
- FileBuffer[FileLength] = 0;
-
- NtClose(FileHandle);
-
- if (!NT_SUCCESS(Status))
- {
- DPRINT("NtReadFile() failed (Status %lx)\n", Status);
- RtlFreeHeap(ProcessHeap,
- 0,
- FileBuffer);
- return(Status);
- }
-
-
- /* Allocate inicache header */
- *Cache = (PINICACHE)RtlAllocateHeap(ProcessHeap,
- 0,
- sizeof(INICACHE));
- if (*Cache == NULL)
- {
- DPRINT("RtlAllocateHeap() failed\n");
- return(STATUS_INSUFFICIENT_RESOURCES);
- }
-
- /* Initialize inicache header */
- RtlZeroMemory(*Cache,
- sizeof(INICACHE));
-
- /* Parse ini file */
- Section = NULL;
- Ptr = FileBuffer;
- while (Ptr != NULL && *Ptr != 0)
- {
- Ptr = IniCacheSkipWhitespace(Ptr);
- if (Ptr == NULL)
- continue;
-
- if (*Ptr == '[')
- {
- Section = NULL;
- Ptr++;
-
- Ptr = IniCacheGetSectionName(Ptr,
- &SectionName,
- &SectionNameSize);
-
- DPRINT1("[%.*s]\n", SectionNameSize, SectionName);
-
- Section = IniCacheAddSection(*Cache,
- SectionName,
- SectionNameSize);
- if (Section == NULL)
- {
- DPRINT("IniCacheAddSection() failed\n");
- Ptr = IniCacheSkipToNextSection(Ptr);
- continue;
- }
- }
- else
- {
- if (Section == NULL)
- {
- Ptr = IniCacheSkipToNextSection(Ptr);
- continue;
- }
-
- Ptr = IniCacheGetKeyName(Ptr,
- &KeyName,
- &KeyNameSize);
-
- Ptr = IniCacheGetKeyValue(Ptr,
- &KeyValue,
- &KeyValueSize,
- String);
-
- DPRINT1("'%.*s' = '%.*s'\n", KeyNameSize, KeyName, KeyValueSize, KeyValue);
-
- Key = IniCacheAddKey(Section,
- KeyName,
- KeyNameSize,
- KeyValue,
- KeyValueSize);
- if (Key == NULL)
- {
- DPRINT("IniCacheAddKey() failed\n");
- }
- }
- }
-
- /* Free file buffer */
- RtlFreeHeap(ProcessHeap,
- 0,
- FileBuffer);
-
- return(Status);
+ DPRINT("NtOpenFile() failed (Status %lx)\n", Status);
+ return Status;
+ }
+
+ DPRINT("NtOpenFile() successful\n");
+
+ /* Query file size */
+ Status = NtQueryInformationFile(FileHandle,
+ &IoStatusBlock,
+ &FileInfo,
+ sizeof(FILE_STANDARD_INFORMATION),
+ FileStandardInformation);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT("NtQueryInformationFile() failed (Status %lx)\n", Status);
+ NtClose(FileHandle);
+ return Status;
+ }
+
+ FileLength = FileInfo.EndOfFile.u.LowPart;
+
+ DPRINT("File size: %lu\n", FileLength);
+
+ /* Allocate file buffer */
+ FileBuffer = (CHAR*)RtlAllocateHeap(ProcessHeap,
+ 0,
+ FileLength + 1);
+ if (FileBuffer == NULL)
+ {
+ DPRINT1("RtlAllocateHeap() failed\n");
+ NtClose(FileHandle);
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ /* Read file */
+ FileOffset.QuadPart = 0ULL;
+ Status = NtReadFile(FileHandle,
+ NULL,
+ NULL,
+ NULL,
+ &IoStatusBlock,
+ FileBuffer,
+ FileLength,
+ &FileOffset,
+ NULL);
+
+ /* Append string terminator */
+ FileBuffer[FileLength] = 0;
+
+ NtClose(FileHandle);
+
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT("NtReadFile() failed (Status %lx)\n", Status);
+ RtlFreeHeap(ProcessHeap, 0, FileBuffer);
+ return Status;
+ }
+
+ /* Allocate inicache header */
+ *Cache = (PINICACHE)RtlAllocateHeap(ProcessHeap,
+ 0,
+ sizeof(INICACHE));
+ if (*Cache == NULL)
+ {
+ DPRINT("RtlAllocateHeap() failed\n");
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ /* Initialize inicache header */
+ RtlZeroMemory(*Cache, sizeof(INICACHE));
+
+ /* Parse ini file */
+ Section = NULL;
+ Ptr = FileBuffer;
+ while (Ptr != NULL && *Ptr != 0)
+ {
+ Ptr = IniCacheSkipWhitespace(Ptr);
+ if (Ptr == NULL)
+ continue;
+
+ if (*Ptr == '[')
+ {
+ Section = NULL;
+ Ptr++;
+
+ Ptr = IniCacheGetSectionName(Ptr,
+ &SectionName,
+ &SectionNameSize);
+
+ DPRINT1("[%.*s]\n", SectionNameSize, SectionName);
+
+ Section = IniCacheAddSection(*Cache,
+ SectionName,
+ SectionNameSize);
+ if (Section == NULL)
+ {
+ DPRINT("IniCacheAddSection() failed\n");
+ Ptr = IniCacheSkipToNextSection(Ptr);
+ continue;
+ }
+ }
+ else
+ {
+ if (Section == NULL)
+ {
+ Ptr = IniCacheSkipToNextSection(Ptr);
+ continue;
+ }
+
+ Ptr = IniCacheGetKeyName(Ptr,
+ &KeyName,
+ &KeyNameSize);
+
+ Ptr = IniCacheGetKeyValue(Ptr,
+ &KeyValue,
+ &KeyValueSize,
+ String);
+
+ DPRINT1("'%.*s' = '%.*s'\n", KeyNameSize, KeyName, KeyValueSize, KeyValue);
+
+ Key = IniCacheAddKey(Section,
+ KeyName,
+ KeyNameSize,
+ KeyValue,
+ KeyValueSize);
+ if (Key == NULL)
+ {
+ DPRINT("IniCacheAddKey() failed\n");
+ }
+ }
+ }
+
+ /* Free file buffer */
+ RtlFreeHeap(ProcessHeap, 0, FileBuffer);
+
+ return Status;
}
VOID
-IniCacheDestroy(PINICACHE Cache)
+IniCacheDestroy(
+ PINICACHE Cache)
{
- if (Cache == NULL)
+ if (Cache == NULL)
{
- return;
+ return;
}
- while (Cache->FirstSection != NULL)
+ while (Cache->FirstSection != NULL)
{
- Cache->FirstSection = IniCacheFreeSection(Cache->FirstSection);
+ Cache->FirstSection = IniCacheFreeSection(Cache->FirstSection);
}
- Cache->LastSection = NULL;
+ Cache->LastSection = NULL;
- RtlFreeHeap(ProcessHeap,
- 0,
- Cache);
+ RtlFreeHeap(ProcessHeap, 0, Cache);
}
PINICACHESECTION
-IniCacheGetSection(PINICACHE Cache,
- PWCHAR Name)
+IniCacheGetSection(
+ PINICACHE Cache,
+ PWCHAR Name)
{
- PINICACHESECTION Section = NULL;
+ PINICACHESECTION Section = NULL;
- if (Cache == NULL || Name == NULL)
+ if (Cache == NULL || Name == NULL)
{
- DPRINT("Invalid parameter\n");
- return(NULL);
+ DPRINT("Invalid parameter\n");
+ return NULL;
}
- /* Iterate through list of sections */
- Section = Cache->FirstSection;
- while (Section != NULL)
+ /* Iterate through list of sections */
+ Section = Cache->FirstSection;
+ while (Section != NULL)
{
- DPRINT("Comparing '%S' and '%S'\n", Section->Name, Name);
+ DPRINT("Comparing '%S' and '%S'\n", Section->Name, Name);
- /* Are the section names the same? */
- if (_wcsicmp(Section->Name, Name) == 0)
- return(Section);
+ /* Are the section names the same? */
+ if (_wcsicmp(Section->Name, Name) == 0)
+ return Section;
- /* Get the next section */
- Section = Section->Next;
+ /* Get the next section */
+ Section = Section->Next;
}
- DPRINT("Section not found\n");
+ DPRINT("Section not found\n");
- return(NULL);
+ return NULL;
}
NTSTATUS
-IniCacheGetKey(PINICACHESECTION Section,
- PWCHAR KeyName,
- PWCHAR *KeyData)
+IniCacheGetKey(
+ PINICACHESECTION Section,
+ PWCHAR KeyName,
+ PWCHAR *KeyData)
{
- PINICACHEKEY Key;
+ PINICACHEKEY Key;
- if (Section == NULL || KeyName == NULL || KeyData == NULL)
+ if (Section == NULL || KeyName == NULL || KeyData == NULL)
{
- DPRINT("Invalid parameter\n");
- return(STATUS_INVALID_PARAMETER);
+ DPRINT("Invalid parameter\n");
+ return STATUS_INVALID_PARAMETER;
}
- *KeyData = NULL;
+ *KeyData = NULL;
- Key = IniCacheFindKey(Section, KeyName, wcslen(KeyName));
- if (Key == NULL)
+ Key = IniCacheFindKey(Section, KeyName, wcslen(KeyName));
+ if (Key == NULL)
{
- return(STATUS_INVALID_PARAMETER);
+ return STATUS_INVALID_PARAMETER;
}
- *KeyData = Key->Data;
+ *KeyData = Key->Data;
- return(STATUS_SUCCESS);
+ return STATUS_SUCCESS;
}
PINICACHEITERATOR
-IniCacheFindFirstValue(PINICACHESECTION Section,
- PWCHAR *KeyName,
- PWCHAR *KeyData)
+IniCacheFindFirstValue(
+ PINICACHESECTION Section,
+ PWCHAR *KeyName,
+ PWCHAR *KeyData)
{
- PINICACHEITERATOR Iterator;
- PINICACHEKEY Key;
+ PINICACHEITERATOR Iterator;
+ PINICACHEKEY Key;
- if (Section == NULL || KeyName == NULL || KeyData == NULL)
+ if (Section == NULL || KeyName == NULL || KeyData == NULL)
{
- DPRINT("Invalid parameter\n");
- return(NULL);
+ DPRINT("Invalid parameter\n");
+ return NULL;
}
- Key = Section->FirstKey;
- if (Key == NULL)
+ Key = Section->FirstKey;
+ if (Key == NULL)
{
- DPRINT("Invalid parameter\n");
- return(NULL);
+ DPRINT("Invalid parameter\n");
+ return NULL;
}
- *KeyName = Key->Name;
- *KeyData = Key->Data;
+ *KeyName = Key->Name;
+ *KeyData = Key->Data;
- Iterator = (PINICACHEITERATOR)RtlAllocateHeap(ProcessHeap,
- 0,
- sizeof(INICACHEITERATOR));
- if (Iterator == NULL)
+ Iterator = (PINICACHEITERATOR)RtlAllocateHeap(ProcessHeap,
+ 0,
+ sizeof(INICACHEITERATOR));
+ if (Iterator == NULL)
{
- DPRINT("RtlAllocateHeap() failed\n");
- return(NULL);
+ DPRINT("RtlAllocateHeap() failed\n");
+ return NULL;
}
- Iterator->Section = Section;
- Iterator->Key = Key;
+ Iterator->Section = Section;
+ Iterator->Key = Key;
- return(Iterator);
+ return Iterator;
}
BOOLEAN
-IniCacheFindNextValue(PINICACHEITERATOR Iterator,
- PWCHAR *KeyName,
- PWCHAR *KeyData)
+IniCacheFindNextValue(
+ PINICACHEITERATOR Iterator,
+ PWCHAR *KeyName,
+ PWCHAR *KeyData)
{
- PINICACHEKEY Key;
+ PINICACHEKEY Key;
- if (Iterator == NULL || KeyName == NULL || KeyData == NULL)
+ if (Iterator == NULL || KeyName == NULL || KeyData == NULL)
{
- DPRINT("Invalid parameter\n");
- return(FALSE);
+ DPRINT("Invalid parameter\n");
+ return FALSE;
}
- Key = Iterator->Key->Next;
- if (Key == NULL)
+ Key = Iterator->Key->Next;
+ if (Key == NULL)
{
- DPRINT("No more entries\n");
- return(FALSE);
+ DPRINT("No more entries\n");
+ return FALSE;
}
- *KeyName = Key->Name;
- *KeyData = Key->Data;
+ *KeyName = Key->Name;
+ *KeyData = Key->Data;
- Iterator->Key = Key;
+ Iterator->Key = Key;
- return(TRUE);
+ return TRUE;
}
VOID
-IniCacheFindClose(PINICACHEITERATOR Iterator)
+IniCacheFindClose(
+ PINICACHEITERATOR Iterator)
{
- if (Iterator == NULL)
- return;
+ if (Iterator == NULL)
+ return;
- RtlFreeHeap(ProcessHeap,
- 0,
- Iterator);
+ RtlFreeHeap(ProcessHeap, 0, Iterator);
}
PINICACHEKEY
-IniCacheInsertKey(PINICACHESECTION Section,
- PINICACHEKEY AnchorKey,
- INSERTATION_TYPE InsertationType,
- PWCHAR Name,
- PWCHAR Data)
+IniCacheInsertKey(
+ PINICACHESECTION Section,
+ PINICACHEKEY AnchorKey,
+ INSERTATION_TYPE InsertationType,
+ PWCHAR Name,
+ PWCHAR Data)
{
- PINICACHEKEY Key;
+ PINICACHEKEY Key;
- Key = NULL;
+ Key = NULL;
- if (Section == NULL ||
- Name == NULL ||
- *Name == 0 ||
- Data == NULL ||
- *Data == 0)
+ if (Section == NULL ||
+ Name == NULL ||
+ *Name == 0 ||
+ Data == NULL ||
+ *Data == 0)
{
- DPRINT("Invalid parameter\n");
- return(NULL);
+ DPRINT("Invalid parameter\n");
+ return NULL;
}
- /* Allocate key buffer */
- Key = (PINICACHEKEY)RtlAllocateHeap(ProcessHeap,
- 0,
- sizeof(INICACHEKEY));
- if (Key == NULL)
+ /* Allocate key buffer */
+ Key = (PINICACHEKEY)RtlAllocateHeap(ProcessHeap,
+ 0,
+ sizeof(INICACHEKEY));
+ if (Key == NULL)
{
- DPRINT("RtlAllocateHeap() failed\n");
- return(NULL);
+ DPRINT("RtlAllocateHeap() failed\n");
+ return NULL;
}
- RtlZeroMemory(Key,
- sizeof(INICACHEKEY));
- /* Allocate name buffer */
- Key->Name = (WCHAR*) RtlAllocateHeap(ProcessHeap,
- 0,
- (wcslen(Name) + 1) * sizeof(WCHAR));
- if (Key->Name == NULL)
+ RtlZeroMemory(Key, sizeof(INICACHEKEY));
+
+ /* Allocate name buffer */
+ Key->Name = (WCHAR*)RtlAllocateHeap(ProcessHeap,
+ 0,
+ (wcslen(Name) + 1) * sizeof(WCHAR));
+ if (Key->Name == NULL)
{
- DPRINT("RtlAllocateHeap() failed\n");
- RtlFreeHeap(ProcessHeap,
- 0,
- Key);
- return(NULL);
+ DPRINT("RtlAllocateHeap() failed\n");
+ RtlFreeHeap(ProcessHeap, 0, Key);
+ return NULL;
}
- /* Copy value name */
- wcscpy(Key->Name, Name);
+ /* Copy value name */
+ wcscpy(Key->Name, Name);
- /* Allocate data buffer */
- Key->Data = (WCHAR*) RtlAllocateHeap(ProcessHeap,
- 0,
- (wcslen(Data) + 1) * sizeof(WCHAR));
- if (Key->Data == NULL)
+ /* Allocate data buffer */
+ Key->Data = (WCHAR*)RtlAllocateHeap(ProcessHeap,
+ 0,
+ (wcslen(Data) + 1) * sizeof(WCHAR));
+ if (Key->Data == NULL)
{
- DPRINT("RtlAllocateHeap() failed\n");
- RtlFreeHeap(ProcessHeap,
- 0,
- Key->Name);
- RtlFreeHeap(ProcessHeap,
- 0,
- Key);
- return(NULL);
+ DPRINT("RtlAllocateHeap() failed\n");
+ RtlFreeHeap(ProcessHeap, 0, Key->Name);
+ RtlFreeHeap(ProcessHeap, 0, Key);
+ return NULL;
}
- /* Copy value data */
- wcscpy(Key->Data, Data);
+ /* Copy value data */
+ wcscpy(Key->Data, Data);
- /* Insert key into section */
- if (Section->FirstKey == NULL)
+ /* Insert key into section */
+ if (Section->FirstKey == NULL)
{
- Section->FirstKey = Key;
- Section->LastKey = Key;
+ Section->FirstKey = Key;
+ Section->LastKey = Key;
}
- else if ((InsertationType == INSERT_FIRST) ||
- ((InsertationType == INSERT_BEFORE) && ((AnchorKey == NULL) || (AnchorKey == Section->FirstKey))))
+ else if ((InsertationType == INSERT_FIRST) ||
+ ((InsertationType == INSERT_BEFORE) && ((AnchorKey == NULL) || (AnchorKey == Section->FirstKey))))
{
- /* Insert at the head of the list */
- Section->FirstKey->Prev = Key;
- Key->Next = Section->FirstKey;
- Section->FirstKey = Key;
+ /* Insert at the head of the list */
+ Section->FirstKey->Prev = Key;
+ Key->Next = Section->FirstKey;
+ Section->FirstKey = Key;
}
- else if ((InsertationType == INSERT_BEFORE) && (AnchorKey != NULL))
+ else if ((InsertationType == INSERT_BEFORE) && (AnchorKey != NULL))
{
- /* Insert before the anchor key */
- Key->Next = AnchorKey;
- Key->Prev = AnchorKey->Prev;
- AnchorKey->Prev->Next = Key;
- AnchorKey->Prev = Key;
+ /* Insert before the anchor key */
+ Key->Next = AnchorKey;
+ Key->Prev = AnchorKey->Prev;
+ AnchorKey->Prev->Next = Key;
+ AnchorKey->Prev = Key;
}
- else if ((InsertationType == INSERT_LAST) ||
- ((InsertationType == INSERT_AFTER) && ((AnchorKey == NULL) || (AnchorKey == Section->LastKey))))
+ else if ((InsertationType == INSERT_LAST) ||
+ ((InsertationType == INSERT_AFTER) && ((AnchorKey == NULL) || (AnchorKey == Section->LastKey))))
{
- Section->LastKey->Next = Key;
- Key->Prev = Section->LastKey;
- Section->LastKey = Key;
+ Section->LastKey->Next = Key;
+ Key->Prev = Section->LastKey;
+ Section->LastKey = Key;
}
- else if ((InsertationType == INSERT_AFTER) && (AnchorKey != NULL))
+ else if ((InsertationType == INSERT_AFTER) && (AnchorKey != NULL))
{
- /* Insert before the anchor key */
- Key->Next = AnchorKey->Next;
- Key->Prev = AnchorKey;
- AnchorKey->Next->Prev = Key;
- AnchorKey->Next = Key;
+ /* Insert after the anchor key */
+ Key->Next = AnchorKey->Next;
+ Key->Prev = AnchorKey;
+ AnchorKey->Next->Prev = Key;
+ AnchorKey->Next = Key;
}
- return(Key);
+ return Key;
}
PINICACHE
IniCacheCreate(VOID)
{
- PINICACHE Cache;
+ PINICACHE Cache;
- /* Allocate inicache header */
- Cache = (PINICACHE)RtlAllocateHeap(ProcessHeap,
- 0,
- sizeof(INICACHE));
- if (Cache == NULL)
+ /* Allocate inicache header */
+ Cache = (PINICACHE)RtlAllocateHeap(ProcessHeap,
+ 0,
+ sizeof(INICACHE));
+ if (Cache == NULL)
{
- DPRINT("RtlAllocateHeap() failed\n");
- return(NULL);
+ DPRINT("RtlAllocateHeap() failed\n");
+ return NULL;
}
- /* Initialize inicache header */
- RtlZeroMemory(Cache,
- sizeof(INICACHE));
+ /* Initialize inicache header */
+ RtlZeroMemory(Cache, sizeof(INICACHE));
- return(Cache);
+ return Cache;
}
NTSTATUS
-IniCacheSave(PINICACHE Cache,
- PWCHAR FileName)
+IniCacheSave(
+ PINICACHE Cache,
+ PWCHAR FileName)
{
- UNICODE_STRING Name;
- PINICACHESECTION Section;
- PINICACHEKEY Key;
- ULONG BufferSize;
- PCHAR Buffer;
- PCHAR Ptr;
- ULONG Len;
- NTSTATUS Status;
-
- OBJECT_ATTRIBUTES ObjectAttributes;
- IO_STATUS_BLOCK IoStatusBlock;
- LARGE_INTEGER Offset;
- HANDLE FileHandle;
-
-
- /* Calculate required buffer size */
- BufferSize = 0;
- Section = Cache->FirstSection;
- while (Section != NULL)
- {
- BufferSize += (Section->Name ? wcslen(Section->Name) : 0)
- + 4; /* "[]\r\n" */
-
- Key = Section->FirstKey;
- while (Key != NULL)
- {
- BufferSize += wcslen(Key->Name)
- + (Key->Data ? wcslen(Key->Data) : 0)
- + 3; /* "=\r\n" */
- Key = Key->Next;
- }
-
- Section = Section->Next;
- if (Section != NULL)
- BufferSize += 2; /* extra "\r\n" at end of each section */
- }
- BufferSize++; /* Null-terminator */
-
- DPRINT("BufferSize: %lu\n", BufferSize);
-
- /* Allocate file buffer */
- Buffer = (CHAR*) RtlAllocateHeap(ProcessHeap,
- 0,
- BufferSize);
- if (Buffer == NULL)
- {
- DPRINT1("RtlAllocateHeap() failed\n");
- return(STATUS_INSUFFICIENT_RESOURCES);
- }
- RtlZeroMemory(Buffer, BufferSize);
-
- /* Fill file buffer */
- Ptr = Buffer;
- Section = Cache->FirstSection;
- while (Section != NULL)
- {
- Len = sprintf(Ptr, "[%S]\r\n", Section->Name);
- Ptr += Len;
-
- Key = Section->FirstKey;
- while (Key != NULL)
- {
- Len = sprintf(Ptr, "%S=%S\r\n", Key->Name, Key->Data);
- Ptr += Len;
- Key = Key->Next;
- }
-
- Section = Section->Next;
- if (Section != NULL)
- {
- Len = sprintf(Ptr, "\r\n");
- Ptr += Len;
- }
- }
-
- /* Create ini file */
- RtlInitUnicodeString(&Name,
- FileName);
-
- InitializeObjectAttributes(&ObjectAttributes,
- &Name,
- 0,
- NULL,
- NULL);
-
- Status = NtCreateFile(&FileHandle,
- GENERIC_WRITE | SYNCHRONIZE,
- &ObjectAttributes,
- &IoStatusBlock,
- NULL,
- FILE_ATTRIBUTE_NORMAL,
- 0,
- FILE_SUPERSEDE,
- FILE_SYNCHRONOUS_IO_NONALERT | FILE_SEQUENTIAL_ONLY,
- NULL,
- 0);
- if (!NT_SUCCESS(Status))
- {
- DPRINT("NtCreateFile() failed (Status %lx)\n", Status);
- RtlFreeHeap(ProcessHeap,
- 0,
- Buffer);
- return(Status);
- }
-
- Offset.QuadPart = 0LL;
- Status = NtWriteFile(FileHandle,
- NULL,
- NULL,
- NULL,
- &IoStatusBlock,
- Buffer,
- BufferSize,
- &Offset,
- NULL);
- if (!NT_SUCCESS(Status))
+ UNICODE_STRING Name;
+ PINICACHESECTION Section;
+ PINICACHEKEY Key;
+ ULONG BufferSize;
+ PCHAR Buffer;
+ PCHAR Ptr;
+ ULONG Len;
+ NTSTATUS Status;
+
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ IO_STATUS_BLOCK IoStatusBlock;
+ LARGE_INTEGER Offset;
+ HANDLE FileHandle;
+
+
+ /* Calculate required buffer size */
+ BufferSize = 0;
+ Section = Cache->FirstSection;
+ while (Section != NULL)
+ {
+ BufferSize += (Section->Name ? wcslen(Section->Name) : 0)
+ + 4; /* "[]\r\n" */
+
+ Key = Section->FirstKey;
+ while (Key != NULL)
+ {
+ BufferSize += wcslen(Key->Name)
+ + (Key->Data ? wcslen(Key->Data) : 0)
+ + 3; /* "=\r\n" */
+ Key = Key->Next;
+ }
+
+ Section = Section->Next;
+ if (Section != NULL)
+ BufferSize += 2; /* extra "\r\n" at end of each section */
+ }
+ BufferSize++; /* Null-terminator */
+
+ DPRINT("BufferSize: %lu\n", BufferSize);
+
+ /* Allocate file buffer */
+ Buffer = (CHAR*)RtlAllocateHeap(ProcessHeap,
+ 0,
+ BufferSize);
+ if (Buffer == NULL)
+ {
+ DPRINT1("RtlAllocateHeap() failed\n");
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ RtlZeroMemory(Buffer, BufferSize);
+
+ /* Fill file buffer */
+ Ptr = Buffer;
+ Section = Cache->FirstSection;
+ while (Section != NULL)
+ {
+ Len = sprintf(Ptr, "[%S]\r\n", Section->Name);
+ Ptr += Len;
+
+ Key = Section->FirstKey;
+ while (Key != NULL)
+ {
+ Len = sprintf(Ptr, "%S=%S\r\n", Key->Name, Key->Data);
+ Ptr += Len;
+ Key = Key->Next;
+ }
+
+ Section = Section->Next;
+ if (Section != NULL)
+ {
+ Len = sprintf(Ptr, "\r\n");
+ Ptr += Len;
+ }
+ }
+
+ /* Create ini file */
+ RtlInitUnicodeString(&Name,
+ FileName);
+
+ InitializeObjectAttributes(&ObjectAttributes,
+ &Name,
+ 0,
+ NULL,
+ NULL);
+
+ Status = NtCreateFile(&FileHandle,
+ GENERIC_WRITE | SYNCHRONIZE,
+ &ObjectAttributes,
+ &IoStatusBlock,
+ NULL,
+ FILE_ATTRIBUTE_NORMAL,
+ 0,
+ FILE_SUPERSEDE,
+ FILE_SYNCHRONOUS_IO_NONALERT | FILE_SEQUENTIAL_ONLY,
+ NULL,
+ 0);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT("NtCreateFile() failed (Status %lx)\n", Status);
+ RtlFreeHeap(ProcessHeap, 0, Buffer);
+ return Status;
+ }
+
+ Offset.QuadPart = 0LL;
+ Status = NtWriteFile(FileHandle,
+ NULL,
+ NULL,
+ NULL,
+ &IoStatusBlock,
+ Buffer,
+ BufferSize,
+ &Offset,
+ NULL);
+ if (!NT_SUCCESS(Status))
{
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
NtClose(FileHandle);
- RtlFreeHeap(ProcessHeap,
- 0,
- Buffer);
- return(Status);
+ RtlFreeHeap(ProcessHeap, 0, Buffer);
+ return Status;
}
- NtClose(FileHandle);
+ NtClose(FileHandle);
- RtlFreeHeap(ProcessHeap,
- 0,
- Buffer);
+ RtlFreeHeap(ProcessHeap, 0, Buffer);
- return(STATUS_SUCCESS);
+ return STATUS_SUCCESS;
}
PINICACHESECTION
-IniCacheAppendSection(PINICACHE Cache,
- PWCHAR Name)
+IniCacheAppendSection(
+ PINICACHE Cache,
+ PWCHAR Name)
{
- PINICACHESECTION Section = NULL;
+ PINICACHESECTION Section = NULL;
- if (Cache == NULL || Name == NULL || *Name == 0)
+ if (Cache == NULL || Name == NULL || *Name == 0)
{
- DPRINT("Invalid parameter\n");
- return(NULL);
+ DPRINT("Invalid parameter\n");
+ return NULL;
}
- Section = (PINICACHESECTION)RtlAllocateHeap(ProcessHeap,
- 0,
- sizeof(INICACHESECTION));
- if (Section == NULL)
+ Section = (PINICACHESECTION)RtlAllocateHeap(ProcessHeap,
+ 0,
+ sizeof(INICACHESECTION));
+ if (Section == NULL)
{
- DPRINT("RtlAllocateHeap() failed\n");
- return(NULL);
+ DPRINT("RtlAllocateHeap() failed\n");
+ return NULL;
}
- RtlZeroMemory(Section,
- sizeof(INICACHESECTION));
- /* Allocate and initialize section name */
- Section->Name = (WCHAR*) RtlAllocateHeap(ProcessHeap,
- 0,
- (wcslen(Name) + 1) * sizeof(WCHAR));
- if (Section->Name == NULL)
+ RtlZeroMemory(Section, sizeof(INICACHESECTION));
+
+ /* Allocate and initialize section name */
+ Section->Name = (WCHAR*)RtlAllocateHeap(ProcessHeap,
+ 0,
+ (wcslen(Name) + 1) * sizeof(WCHAR));
+ if (Section->Name == NULL)
{
- DPRINT("RtlAllocateHeap() failed\n");
- RtlFreeHeap(ProcessHeap,
- 0,
- Section);
- return(NULL);
+ DPRINT("RtlAllocateHeap() failed\n");
+ RtlFreeHeap(ProcessHeap, 0, Section);
+ return NULL;
}
- /* Copy section name */
- wcscpy(Section->Name, Name);
+ /* Copy section name */
+ wcscpy(Section->Name, Name);
- /* Append section */
- if (Cache->FirstSection == NULL)
+ /* Append section */
+ if (Cache->FirstSection == NULL)
{
- Cache->FirstSection = Section;
- Cache->LastSection = Section;
+ Cache->FirstSection = Section;
+ Cache->LastSection = Section;
}
- else
+ else
{
- Cache->LastSection->Next = Section;
- Section->Prev = Cache->LastSection;
- Cache->LastSection = Section;
+ Cache->LastSection->Next = Section;
+ Section->Prev = Cache->LastSection;
+ Cache->LastSection = Section;
}
- return(Section);
+ return Section;
}
/* EOF */
typedef struct _INICACHEKEY
{
- PWCHAR Name;
- PWCHAR Data;
+ PWCHAR Name;
+ PWCHAR Data;
- struct _INICACHEKEY *Next;
- struct _INICACHEKEY *Prev;
+ struct _INICACHEKEY *Next;
+ struct _INICACHEKEY *Prev;
} INICACHEKEY, *PINICACHEKEY;
typedef struct _INICACHESECTION
{
- PWCHAR Name;
+ PWCHAR Name;
- PINICACHEKEY FirstKey;
- PINICACHEKEY LastKey;
+ PINICACHEKEY FirstKey;
+ PINICACHEKEY LastKey;
- struct _INICACHESECTION *Next;
- struct _INICACHESECTION *Prev;
+ struct _INICACHESECTION *Next;
+ struct _INICACHESECTION *Prev;
} INICACHESECTION, *PINICACHESECTION;
typedef struct _INICACHE
{
- PINICACHESECTION FirstSection;
- PINICACHESECTION LastSection;
+ PINICACHESECTION FirstSection;
+ PINICACHESECTION LastSection;
} INICACHE, *PINICACHE;
typedef struct _PINICACHEITERATOR
{
- PINICACHESECTION Section;
- PINICACHEKEY Key;
+ PINICACHESECTION Section;
+ PINICACHEKEY Key;
} INICACHEITERATOR, *PINICACHEITERATOR;
typedef enum
{
- INSERT_FIRST,
- INSERT_BEFORE,
- INSERT_AFTER,
- INSERT_LAST
+ INSERT_FIRST,
+ INSERT_BEFORE,
+ INSERT_AFTER,
+ INSERT_LAST
} INSERTATION_TYPE;
/* FUNCTIONS ****************************************************************/
NTSTATUS
-IniCacheLoad(PINICACHE *Cache,
- PUNICODE_STRING FileName,
- BOOLEAN String);
+IniCacheLoad(
+ PINICACHE *Cache,
+ PUNICODE_STRING FileName,
+ BOOLEAN String);
VOID
-IniCacheDestroy(PINICACHE Cache);
+IniCacheDestroy(
+ PINICACHE Cache);
PINICACHESECTION
-IniCacheGetSection(PINICACHE Cache,
- PWCHAR Name);
+IniCacheGetSection(
+ PINICACHE Cache,
+ PWCHAR Name);
NTSTATUS
-IniCacheGetKey(PINICACHESECTION Section,
- PWCHAR KeyName,
- PWCHAR *KeyData);
-
-
+IniCacheGetKey(
+ PINICACHESECTION Section,
+ PWCHAR KeyName,
+ PWCHAR *KeyData);
PINICACHEITERATOR
-IniCacheFindFirstValue(PINICACHESECTION Section,
- PWCHAR *KeyName,
- PWCHAR *KeyData);
+IniCacheFindFirstValue(
+ PINICACHESECTION Section,
+ PWCHAR *KeyName,
+ PWCHAR *KeyData);
BOOLEAN
-IniCacheFindNextValue(PINICACHEITERATOR Iterator,
- PWCHAR *KeyName,
- PWCHAR *KeyData);
+IniCacheFindNextValue(
+ PINICACHEITERATOR Iterator,
+ PWCHAR *KeyName,
+ PWCHAR *KeyData);
VOID
-IniCacheFindClose(PINICACHEITERATOR Iterator);
+IniCacheFindClose(
+ PINICACHEITERATOR Iterator);
PINICACHEKEY
-IniCacheInsertKey(PINICACHESECTION Section,
- PINICACHEKEY AnchorKey,
- INSERTATION_TYPE InsertationType,
- PWCHAR Name,
- PWCHAR Data);
+IniCacheInsertKey(
+ PINICACHESECTION Section,
+ PINICACHEKEY AnchorKey,
+ INSERTATION_TYPE InsertationType,
+ PWCHAR Name,
+ PWCHAR Data);
PINICACHE
IniCacheCreate(VOID);
NTSTATUS
-IniCacheSave(PINICACHE Cache,
- PWCHAR FileName);
+IniCacheSave(
+ PINICACHE Cache,
+ PWCHAR FileName);
PINICACHESECTION
-IniCacheAppendSection(PINICACHE Cache,
- PWCHAR Name);
+IniCacheAppendSection(
+ PINICACHE Cache,
+ PWCHAR Name);
/* EOF */
return 0;
}
+
BOOLEAN
-IsLanguageAvailable(PWCHAR LanguageId)
+IsLanguageAvailable(
+ PWCHAR LanguageId)
{
ULONG lngIndex = 0;
static
const MUI_ENTRY *
-FindMUIEntriesOfPage(IN ULONG PageNumber)
+FindMUIEntriesOfPage(
+ IN ULONG PageNumber)
{
ULONG muiIndex = 0;
ULONG lngIndex;
return NULL;
}
+
static
const MUI_ERROR *
FindMUIErrorEntries(VOID)
return LanguageList[lngIndex].MuiErrors;
}
+
static
const MUI_STRING *
FindMUIStringEntries(VOID)
return LanguageList[lngIndex].MuiStrings;
}
+
LPCWSTR
MUIDefaultKeyboardLayout(VOID)
{
return LanguageList[lngIndex].MuiLayouts[0].LayoutID;
}
+
PWCHAR
MUIGetGeoID(VOID)
{
return LanguageList[lngIndex].GeoID;
}
+
const MUI_LAYOUTS *
MUIGetLayoutsList(VOID)
{
return LanguageList[lngIndex].MuiLayouts;
}
+
VOID
-MUIClearPage(IN ULONG page)
+MUIClearPage(
+ IN ULONG page)
{
const MUI_ENTRY * entry;
int index;
while (entry[index].Buffer != NULL);
}
+
VOID
-MUIDisplayPage(IN ULONG page)
+MUIDisplayPage(
+ IN ULONG page)
{
const MUI_ENTRY * entry;
int index;
while (entry[index].Buffer != NULL);
}
+
VOID
-MUIDisplayError(IN ULONG ErrorNum, OUT PINPUT_RECORD Ir, IN ULONG WaitEvent)
+MUIDisplayError(
+ IN ULONG ErrorNum,
+ OUT PINPUT_RECORD Ir,
+ IN ULONG WaitEvent)
{
const MUI_ERROR * entry;
WaitEvent);
}
+
LPSTR
-MUIGetString(ULONG Number)
+MUIGetString(
+ ULONG Number)
{
ULONG i;
const MUI_STRING * entry;
sprintf(szErr, "Error: failed find string id %lu for language index %lu\n", Number, FindLanguageIndex());
PopupError(szErr,
- NULL,
- NULL,
- POPUP_WAIT_NONE);
+ NULL,
+ NULL,
+ POPUP_WAIT_NONE);
return "<nostring>";
}
-static BOOLEAN
-AddHotkeySettings(IN LPCWSTR Hotkey, IN LPCWSTR LangHotkey, IN LPCWSTR LayoutHotkey)
+
+static
+BOOLEAN
+AddHotkeySettings(
+ IN LPCWSTR Hotkey,
+ IN LPCWSTR LangHotkey,
+ IN LPCWSTR LayoutHotkey)
{
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName;
return TRUE;
}
+
BOOLEAN
-AddKbLayoutsToRegistry(IN const MUI_LAYOUTS * MuiLayouts)
+AddKbLayoutsToRegistry(
+ IN const MUI_LAYOUTS *MuiLayouts)
{
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName;
return TRUE;
}
+
BOOLEAN
AddKeyboardLayouts(VOID)
{
ULONG lngIndex = 0;
+
do
{
if (_wcsicmp(LanguageList[lngIndex].LanguageID , SelectedLanguageId) == 0)
return FALSE;
}
-static BOOLEAN
-AddCodepageToRegistry(IN LPCWSTR ACPage, IN LPCWSTR OEMCPage, IN LPCWSTR MACCPage)
+
+static
+BOOLEAN
+AddCodepageToRegistry(
+ IN LPCWSTR ACPage,
+ IN LPCWSTR OEMCPage,
+ IN LPCWSTR MACCPage)
{
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName;
return TRUE;
}
-static BOOLEAN
-AddFontsSettingsToRegistry(IN const MUI_SUBFONT * MuiSubFonts)
+
+static
+BOOLEAN
+AddFontsSettingsToRegistry(
+ IN const MUI_SUBFONT * MuiSubFonts)
{
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName;
return TRUE;
}
+
BOOLEAN
AddCodePage(VOID)
{
return FALSE;
}
+
VOID
SetConsoleCodePage(VOID)
{
} MUI_LANGUAGE;
BOOLEAN
-IsLanguageAvailable(PWCHAR LanguageId);
+IsLanguageAvailable(
+ PWCHAR LanguageId);
VOID
-MUIDisplayPage (ULONG PageNumber);
+MUIDisplayPage(
+ ULONG PageNumber);
VOID
-MUIClearPage (ULONG PageNumber);
+MUIClearPage(
+ ULONG PageNumber);
VOID
-MUIDisplayError (ULONG ErrorNum, PINPUT_RECORD Ir, ULONG WaitEvent);
+MUIDisplayError(
+ ULONG ErrorNum,
+ PINPUT_RECORD Ir,
+ ULONG WaitEvent);
LPCWSTR
MUIDefaultKeyboardLayout(VOID);
MUIGetLayoutsList(VOID);
BOOLEAN
-AddKbLayoutsToRegistry(IN const MUI_LAYOUTS * MuiLayouts);
+AddKbLayoutsToRegistry(
+ IN const MUI_LAYOUTS *MuiLayouts);
BOOLEAN
AddCodePage(VOID);
SetConsoleCodePage(VOID);
LPSTR
-MUIGetString(ULONG Number);
+MUIGetString(
+ ULONG Number);
#define STRING_PLEASEWAIT 1
#define STRING_INSTALLCREATEPARTITION 2