ReactOS 0.4.15-dev-7677-g8209aa5
inicache.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _INICACHEKEY
 
struct  _INICACHESECTION
 
struct  _INICACHE
 
struct  _PINICACHEITERATOR
 

Typedefs

typedef struct _INICACHEKEY INICACHEKEY
 
typedef struct _INICACHEKEYPINICACHEKEY
 
typedef struct _INICACHESECTION INICACHESECTION
 
typedef struct _INICACHESECTIONPINICACHESECTION
 
typedef struct _INICACHE INICACHE
 
typedef struct _INICACHEPINICACHE
 
typedef struct _PINICACHEITERATOR INICACHEITERATOR
 
typedef struct _PINICACHEITERATORPINICACHEITERATOR
 

Enumerations

enum  INSERTION_TYPE { INSERT_FIRST , INSERT_BEFORE , INSERT_AFTER , INSERT_LAST }
 

Functions

NTSTATUS IniCacheLoadFromMemory (PINICACHE *Cache, PCHAR FileBuffer, ULONG FileLength, BOOLEAN String)
 
NTSTATUS IniCacheLoadByHandle (PINICACHE *Cache, HANDLE FileHandle, BOOLEAN String)
 
NTSTATUS IniCacheLoad (PINICACHE *Cache, PWCHAR FileName, BOOLEAN String)
 
VOID IniCacheDestroy (PINICACHE Cache)
 
PINICACHESECTION IniCacheGetSection (PINICACHE Cache, PWCHAR Name)
 
NTSTATUS IniCacheGetKey (PINICACHESECTION Section, PWCHAR KeyName, PWCHAR *KeyData)
 
PINICACHEITERATOR IniCacheFindFirstValue (PINICACHESECTION Section, PWCHAR *KeyName, PWCHAR *KeyData)
 
BOOLEAN IniCacheFindNextValue (PINICACHEITERATOR Iterator, PWCHAR *KeyName, PWCHAR *KeyData)
 
VOID IniCacheFindClose (PINICACHEITERATOR Iterator)
 
PINICACHEKEY IniCacheInsertKey (PINICACHESECTION Section, PINICACHEKEY AnchorKey, INSERTION_TYPE InsertionType, PWCHAR Name, PWCHAR Data)
 
PINICACHE IniCacheCreate (VOID)
 
NTSTATUS IniCacheSaveByHandle (PINICACHE Cache, HANDLE FileHandle)
 
NTSTATUS IniCacheSave (PINICACHE Cache, PWCHAR FileName)
 
PINICACHESECTION IniCacheAppendSection (PINICACHE Cache, PWCHAR Name)
 

Typedef Documentation

◆ INICACHE

◆ INICACHEITERATOR

◆ INICACHEKEY

◆ INICACHESECTION

◆ PINICACHE

◆ PINICACHEITERATOR

◆ PINICACHEKEY

◆ PINICACHESECTION

Enumeration Type Documentation

◆ INSERTION_TYPE

Enumerator
INSERT_FIRST 
INSERT_BEFORE 
INSERT_AFTER 
INSERT_LAST 

Definition at line 46 of file inicache.h.

47{
INSERTION_TYPE
Definition: inicache.h:47
@ INSERT_BEFORE
Definition: inicache.h:49
@ INSERT_AFTER
Definition: inicache.h:50
@ INSERT_LAST
Definition: inicache.h:51
@ INSERT_FIRST
Definition: inicache.h:48

Function Documentation

◆ IniCacheAppendSection()

PINICACHESECTION IniCacheAppendSection ( PINICACHE  Cache,
PWCHAR  Name 
)

Definition at line 1088 of file inicache.c.

1091{
1092 PINICACHESECTION Section = NULL;
1093
1094 if (Cache == NULL || Name == NULL || *Name == 0)
1095 {
1096 DPRINT("Invalid parameter\n");
1097 return NULL;
1098 }
1099
1102 sizeof(INICACHESECTION));
1103 if (Section == NULL)
1104 {
1105 DPRINT("RtlAllocateHeap() failed\n");
1106 return NULL;
1107 }
1108
1109 /* Allocate and initialize section name */
1111 0,
1112 (wcslen(Name) + 1) * sizeof(WCHAR));
1113 if (Section->Name == NULL)
1114 {
1115 DPRINT("RtlAllocateHeap() failed\n");
1116 RtlFreeHeap(ProcessHeap, 0, Section);
1117 return NULL;
1118 }
1119
1120 /* Copy section name */
1121 wcscpy(Section->Name, Name);
1122
1123 /* Append section */
1124 if (Cache->FirstSection == NULL)
1125 {
1126 Cache->FirstSection = Section;
1127 Cache->LastSection = Section;
1128 }
1129 else
1130 {
1131 Cache->LastSection->Next = Section;
1132 Section->Prev = Cache->LastSection;
1133 Cache->LastSection = Section;
1134 }
1135
1136 return Section;
1137}
HANDLE ProcessHeap
Definition: servman.c:15
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
#define NULL
Definition: types.h:112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
struct _INICACHESECTION * PINICACHESECTION
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define DPRINT
Definition: sndvol32.h:71
Definition: fatfs.h:173
struct _INICACHESECTION * Prev
Definition: inicache.h:28
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by CreateCommonFreeLdrSections(), CreateNTOSEntry(), InstallSetupInfFile(), and OpenIniBootLoaderStore().

◆ IniCacheCreate()

PINICACHE IniCacheCreate ( VOID  )

Definition at line 929 of file inicache.c.

930{
932
933 /* Allocate inicache header */
936 sizeof(INICACHE));
937 if (Cache == NULL)
938 {
939 DPRINT("RtlAllocateHeap() failed\n");
940 return NULL;
941 }
942
943 return Cache;
944}
struct _INICACHE * PINICACHE

Referenced by InstallSetupInfFile(), and OpenIniBootLoaderStore().

◆ IniCacheDestroy()

VOID IniCacheDestroy ( PINICACHE  Cache)

Definition at line 666 of file inicache.c.

668{
669 if (Cache == NULL)
670 return;
671
672 while (Cache->FirstSection != NULL)
673 {
674 Cache->FirstSection = IniCacheFreeSection(Cache->FirstSection);
675 }
676 Cache->LastSection = NULL;
677
679}
static PINICACHESECTION IniCacheFreeSection(PINICACHESECTION Section)
Definition: inicache.c:50

Referenced by CloseIniBootLoaderStore(), InstallSetupInfFile(), and OpenIniBootLoaderStore().

◆ IniCacheFindClose()

VOID IniCacheFindClose ( PINICACHEITERATOR  Iterator)

Definition at line 815 of file inicache.c.

817{
818 if (Iterator == NULL)
819 return;
820
822}
_In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR Iterator
Definition: wdfchildlist.h:656

Referenced by FreeLdrEnumerateBootEntries(), and NtLdrEnumerateBootEntries().

◆ IniCacheFindFirstValue()

PINICACHEITERATOR IniCacheFindFirstValue ( PINICACHESECTION  Section,
PWCHAR KeyName,
PWCHAR KeyData 
)

Definition at line 744 of file inicache.c.

748{
751
752 if (Section == NULL || KeyName == NULL || KeyData == NULL)
753 {
754 DPRINT("Invalid parameter\n");
755 return NULL;
756 }
757
758 Key = Section->FirstKey;
759 if (Key == NULL)
760 {
761 DPRINT("Invalid parameter\n");
762 return NULL;
763 }
764
765 *KeyName = Key->Name;
766 *KeyData = Key->Data;
767
769 0,
770 sizeof(INICACHEITERATOR));
771 if (Iterator == NULL)
772 {
773 DPRINT("RtlAllocateHeap() failed\n");
774 return NULL;
775 }
776
777 Iterator->Section = Section;
778 Iterator->Key = Key;
779
780 return Iterator;
781}
struct _PINICACHEITERATOR * PINICACHEITERATOR
PINICACHEKEY FirstKey
Definition: inicache.h:24
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2699

Referenced by FreeLdrEnumerateBootEntries(), and NtLdrEnumerateBootEntries().

◆ IniCacheFindNextValue()

BOOLEAN IniCacheFindNextValue ( PINICACHEITERATOR  Iterator,
PWCHAR KeyName,
PWCHAR KeyData 
)

Definition at line 785 of file inicache.c.

789{
791
792 if (Iterator == NULL || KeyName == NULL || KeyData == NULL)
793 {
794 DPRINT("Invalid parameter\n");
795 return FALSE;
796 }
797
798 Key = Iterator->Key->Next;
799 if (Key == NULL)
800 {
801 DPRINT("No more entries\n");
802 return FALSE;
803 }
804
805 *KeyName = Key->Name;
806 *KeyData = Key->Data;
807
808 Iterator->Key = Key;
809
810 return TRUE;
811}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
Key()
Definition: map_test.cpp:305

Referenced by FreeLdrEnumerateBootEntries(), and NtLdrEnumerateBootEntries().

◆ IniCacheGetKey()

NTSTATUS IniCacheGetKey ( PINICACHESECTION  Section,
PWCHAR  KeyName,
PWCHAR KeyData 
)

Definition at line 716 of file inicache.c.

720{
722
723 if (Section == NULL || KeyName == NULL || KeyData == NULL)
724 {
725 DPRINT("Invalid parameter\n");
727 }
728
729 *KeyData = NULL;
730
732 if (Key == NULL)
733 {
735 }
736
737 *KeyData = Key->Data;
738
739 return STATUS_SUCCESS;
740}
static PINICACHEKEY IniCacheFindKey(PINICACHESECTION Section, PWCHAR Name, ULONG NameLength)
Definition: inicache.c:79
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135

Referenced by FreeLdrEnumerateBootEntries(), and QueryBootStoreOptions().

◆ IniCacheGetSection()

PINICACHESECTION IniCacheGetSection ( PINICACHE  Cache,
PWCHAR  Name 
)

Definition at line 683 of file inicache.c.

686{
687 PINICACHESECTION Section = NULL;
688
689 if (Cache == NULL || Name == NULL)
690 {
691 DPRINT("Invalid parameter\n");
692 return NULL;
693 }
694
695 /* Iterate through list of sections */
696 Section = Cache->FirstSection;
697 while (Section != NULL)
698 {
699 DPRINT("Comparing '%S' and '%S'\n", Section->Name, Name);
700
701 /* Are the section names the same? */
702 if (_wcsicmp(Section->Name, Name) == 0)
703 return Section;
704
705 /* Get the next section */
706 Section = Section->Next;
707 }
708
709 DPRINT("Section not found\n");
710
711 return NULL;
712}
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
struct _INICACHESECTION * Next
Definition: inicache.h:27

Referenced by CreateCommonFreeLdrSections(), FreeLdrEnumerateBootEntries(), and OpenIniBootLoaderStore().

◆ IniCacheInsertKey()

PINICACHEKEY IniCacheInsertKey ( PINICACHESECTION  Section,
PINICACHEKEY  AnchorKey,
INSERTION_TYPE  InsertionType,
PWCHAR  Name,
PWCHAR  Data 
)

Definition at line 826 of file inicache.c.

832{
834
835 Key = NULL;
836
837 if (Section == NULL ||
838 Name == NULL ||
839 *Name == 0 ||
840 Data == NULL ||
841 *Data == 0)
842 {
843 DPRINT("Invalid parameter\n");
844 return NULL;
845 }
846
847 /* Allocate key buffer */
850 sizeof(INICACHEKEY));
851 if (Key == NULL)
852 {
853 DPRINT("RtlAllocateHeap() failed\n");
854 return NULL;
855 }
856
857 /* Allocate name buffer */
859 0,
860 (wcslen(Name) + 1) * sizeof(WCHAR));
861 if (Key->Name == NULL)
862 {
863 DPRINT("RtlAllocateHeap() failed\n");
865 return NULL;
866 }
867
868 /* Copy value name */
869 wcscpy(Key->Name, Name);
870
871 /* Allocate data buffer */
873 0,
874 (wcslen(Data) + 1) * sizeof(WCHAR));
875 if (Key->Data == NULL)
876 {
877 DPRINT("RtlAllocateHeap() failed\n");
878 RtlFreeHeap(ProcessHeap, 0, Key->Name);
880 return NULL;
881 }
882
883 /* Copy value data */
884 wcscpy(Key->Data, Data);
885
886 /* Insert key into section */
887 if (Section->FirstKey == NULL)
888 {
889 Section->FirstKey = Key;
890 Section->LastKey = Key;
891 }
892 else if ((InsertionType == INSERT_FIRST) ||
893 ((InsertionType == INSERT_BEFORE) && ((AnchorKey == NULL) || (AnchorKey == Section->FirstKey))))
894 {
895 /* Insert at the head of the list */
896 Section->FirstKey->Prev = Key;
897 Key->Next = Section->FirstKey;
898 Section->FirstKey = Key;
899 }
900 else if ((InsertionType == INSERT_BEFORE) && (AnchorKey != NULL))
901 {
902 /* Insert before the anchor key */
903 Key->Next = AnchorKey;
904 Key->Prev = AnchorKey->Prev;
905 AnchorKey->Prev->Next = Key;
906 AnchorKey->Prev = Key;
907 }
908 else if ((InsertionType == INSERT_LAST) ||
909 ((InsertionType == INSERT_AFTER) && ((AnchorKey == NULL) || (AnchorKey == Section->LastKey))))
910 {
911 Section->LastKey->Next = Key;
912 Key->Prev = Section->LastKey;
913 Section->LastKey = Key;
914 }
915 else if ((InsertionType == INSERT_AFTER) && (AnchorKey != NULL))
916 {
917 /* Insert after the anchor key */
918 Key->Next = AnchorKey->Next;
919 Key->Prev = AnchorKey;
920 AnchorKey->Next->Prev = Key;
921 AnchorKey->Next = Key;
922 }
923
924 return Key;
925}
struct _INICACHEKEY * PINICACHEKEY
HRESULT Next([in] ULONG celt, [out, size_is(celt), length_is(*pceltFetched)] STATPROPSETSTG *rgelt, [out] ULONG *pceltFetched)
struct _INICACHEKEY * Next
Definition: inicache.h:15
struct _INICACHEKEY * Prev
Definition: inicache.h:16
PINICACHEKEY LastKey
Definition: inicache.h:25

Referenced by AddBootStoreEntry(), CreateCommonFreeLdrSections(), CreateNTOSEntry(), InstallSetupInfFile(), and SetBootStoreOptions().

◆ IniCacheLoad()

NTSTATUS IniCacheLoad ( PINICACHE Cache,
PWCHAR  FileName,
BOOLEAN  String 
)

Definition at line 621 of file inicache.c.

625{
631
632 *Cache = NULL;
633
634 /* Open the INI file */
636
638 &Name,
640 NULL,
641 NULL);
642
649 if (!NT_SUCCESS(Status))
650 {
651 DPRINT("NtOpenFile() failed (Status %lx)\n", Status);
652 return Status;
653 }
654
655 DPRINT("NtOpenFile() successful\n");
656
658
659 /* Close the INI file */
661 return Status;
662}
struct NameRec_ * Name
Definition: cdprocs.h:460
LONG NTSTATUS
Definition: precomp.h:26
#define FILE_NON_DIRECTORY_FILE
Definition: constants.h:492
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define FILE_SHARE_READ
Definition: compat.h:136
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1231
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
Status
Definition: gdiplustypes.h:25
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
NTSTATUS IniCacheLoadByHandle(PINICACHE *Cache, HANDLE FileHandle, BOOLEAN String)
Definition: inicache.c:547
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
NTSYSAPI NTSTATUS NTAPI NtOpenFile(OUT PHANDLE phFile, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG ShareMode, IN ULONG OpenMode)
Definition: file.c:3952
#define SYNCHRONIZE
Definition: nt_native.h:61
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
#define FILE_GENERIC_READ
Definition: nt_native.h:653
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433

Referenced by InstallSetupInfFile().

◆ IniCacheLoadByHandle()

NTSTATUS IniCacheLoadByHandle ( PINICACHE Cache,
HANDLE  FileHandle,
BOOLEAN  String 
)

Definition at line 547 of file inicache.c.

551{
555 PCHAR FileBuffer;
558
559 *Cache = NULL;
560
561 /* Query file size */
564 &FileInfo,
567 if (!NT_SUCCESS(Status))
568 {
569 DPRINT("NtQueryInformationFile() failed (Status %lx)\n", Status);
570 return Status;
571 }
572
573 FileLength = FileInfo.EndOfFile.u.LowPart;
574
575 DPRINT("File size: %lu\n", FileLength);
576
577 /* Allocate file buffer with NULL-terminator */
578 FileBuffer = (CHAR*)RtlAllocateHeap(ProcessHeap,
579 0,
580 FileLength + 1);
581 if (FileBuffer == NULL)
582 {
583 DPRINT1("RtlAllocateHeap() failed\n");
585 }
586
587 /* Read file */
588 FileOffset.QuadPart = 0ULL;
590 NULL,
591 NULL,
592 NULL,
594 FileBuffer,
596 &FileOffset,
597 NULL);
598
599 /* Append NULL-terminator */
600 FileBuffer[FileLength] = 0;
601
602 if (!NT_SUCCESS(Status))
603 {
604 DPRINT("NtReadFile() failed (Status %lx)\n", Status);
605 goto Quit;
606 }
607
609 if (!NT_SUCCESS(Status))
610 {
611 DPRINT1("IniCacheLoadFromMemory() failed (Status %lx)\n", Status);
612 }
613
614Quit:
615 /* Free the file buffer, and return */
616 RtlFreeHeap(ProcessHeap, 0, FileBuffer);
617 return Status;
618}
#define DPRINT1
Definition: precomp.h:8
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:160
NTSTATUS IniCacheLoadFromMemory(PINICACHE *Cache, PCHAR FileBuffer, ULONG FileLength, BOOLEAN String)
Definition: inicache.c:452
#define ULL(a, b)
Definition: format_msg.c:27
_Out_ PNDIS_HANDLE _Out_ PUINT FileLength
Definition: ndis.h:3228
NTSYSAPI NTSTATUS NTAPI NtQueryInformationFile(IN HANDLE hFile, OUT PIO_STATUS_BLOCK pIoStatusBlock, OUT PVOID FileInformationBuffer, IN ULONG FileInformationBufferLength, IN FILE_INFORMATION_CLASS FileInfoClass)
#define FileStandardInformation
Definition: propsheet.cpp:61
NTSTATUS NTAPI NtReadFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, PVOID Buffer, ULONG Length, PLARGE_INTEGER ByteOffset, PULONG Key)
uint32_t ULONG
Definition: typedefs.h:59
char * PCHAR
Definition: typedefs.h:51
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
char CHAR
Definition: xmlstorage.h:175

Referenced by IniCacheLoad().

◆ IniCacheLoadFromMemory()

NTSTATUS IniCacheLoadFromMemory ( PINICACHE Cache,
PCHAR  FileBuffer,
ULONG  FileLength,
BOOLEAN  String 
)

Definition at line 452 of file inicache.c.

457{
458 PCHAR Ptr;
459
460 PINICACHESECTION Section;
462
463 PCHAR SectionName;
464 ULONG SectionNameSize;
465
467 ULONG KeyNameSize;
468
469 PCHAR KeyValue;
470 ULONG KeyValueSize;
471
472 /* Allocate inicache header */
475 sizeof(INICACHE));
476 if (*Cache == NULL)
477 {
478 DPRINT("RtlAllocateHeap() failed\n");
480 }
481
482 /* Parse ini file */
483 Section = NULL;
484 Ptr = FileBuffer;
485 while (Ptr != NULL && *Ptr != 0)
486 {
488 if (Ptr == NULL)
489 continue;
490
491 if (*Ptr == '[')
492 {
493 Section = NULL;
494 Ptr++;
495
497 &SectionName,
498 &SectionNameSize);
499
500 DPRINT("[%.*s]\n", SectionNameSize, SectionName);
501
502 Section = IniCacheAddSection(*Cache,
503 SectionName,
504 SectionNameSize);
505 if (Section == NULL)
506 {
507 DPRINT("IniCacheAddSection() failed\n");
509 continue;
510 }
511 }
512 else
513 {
514 if (Section == NULL)
515 {
517 continue;
518 }
519
521 &KeyName,
522 &KeyNameSize);
523
525 &KeyValue,
526 &KeyValueSize,
527 String);
528
529 DPRINT("'%.*s' = '%.*s'\n", KeyNameSize, KeyName, KeyValueSize, KeyValue);
530
531 Key = IniCacheAddKey(Section,
532 KeyName,
533 KeyNameSize,
534 KeyValue,
535 KeyValueSize);
536 if (Key == NULL)
537 {
538 DPRINT("IniCacheAddKey() failed\n");
539 }
540 }
541 }
542
543 return STATUS_SUCCESS;
544}
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
static PCHAR IniCacheGetKeyName(PCHAR Ptr, PCHAR *NamePtr, PULONG NameSize)
Definition: inicache.c:325
static PCHAR IniCacheGetKeyValue(PCHAR Ptr, PCHAR *DataPtr, PULONG DataSize, BOOLEAN String)
Definition: inicache.c:378
static PCHAR IniCacheSkipToNextSection(PCHAR Ptr)
Definition: inicache.c:261
static PCHAR IniCacheGetSectionName(PCHAR Ptr, PCHAR *NamePtr, PULONG NameSize)
Definition: inicache.c:280
static PINICACHEKEY IniCacheAddKey(PINICACHESECTION Section, PCHAR Name, ULONG NameLength, PCHAR Data, ULONG DataLength)
Definition: inicache.c:104
static PCHAR IniCacheSkipWhitespace(PCHAR Ptr)
Definition: inicache.c:249
static PINICACHESECTION IniCacheAddSection(PINICACHE Cache, PCHAR Name, ULONG NameLength)
Definition: inicache.c:189

Referenced by IniCacheLoadByHandle(), and OpenIniBootLoaderStore().

◆ IniCacheSave()

NTSTATUS IniCacheSave ( PINICACHE  Cache,
PWCHAR  FileName 
)

Definition at line 1043 of file inicache.c.

1046{
1052
1053 /* Create the INI file */
1055
1057 &Name,
1059 NULL,
1060 NULL);
1061
1066 NULL,
1068 0,
1071 NULL,
1072 0);
1073 if (!NT_SUCCESS(Status))
1074 {
1075 DPRINT("NtCreateFile() failed (Status %lx)\n", Status);
1076 return Status;
1077 }
1078
1080
1081 /* Close the INI file */
1083 return Status;
1084}
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define FILE_SEQUENTIAL_ONLY
Definition: from_kernel.h:27
#define FILE_SUPERSEDE
Definition: from_kernel.h:53
NTSTATUS IniCacheSaveByHandle(PINICACHE Cache, HANDLE FileHandle)
Definition: inicache.c:948
NTSTATUS NTAPI NtCreateFile(OUT PHANDLE FileHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK IoStatusBlock, IN PLARGE_INTEGER AllocationSize OPTIONAL, IN ULONG FileAttributes, IN ULONG ShareAccess, IN ULONG CreateDisposition, IN ULONG CreateOptions, IN PVOID EaBuffer OPTIONAL, IN ULONG EaLength)
#define FILE_GENERIC_WRITE
Definition: nt_native.h:660

Referenced by InstallSetupInfFile().

◆ IniCacheSaveByHandle()

NTSTATUS IniCacheSaveByHandle ( PINICACHE  Cache,
HANDLE  FileHandle 
)

Definition at line 948 of file inicache.c.

951{
953 PINICACHESECTION Section;
957 PCHAR Ptr;
958 ULONG Len;
961
962 /* Calculate required buffer size */
963 BufferSize = 0;
964 Section = Cache->FirstSection;
965 while (Section != NULL)
966 {
967 BufferSize += (Section->Name ? wcslen(Section->Name) : 0)
968 + 4; /* "[]\r\n" */
969
970 Key = Section->FirstKey;
971 while (Key != NULL)
972 {
973 BufferSize += wcslen(Key->Name)
974 + (Key->Data ? wcslen(Key->Data) : 0)
975 + 3; /* "=\r\n" */
976 Key = Key->Next;
977 }
978
979 Section = Section->Next;
980 if (Section != NULL)
981 BufferSize += 2; /* Extra "\r\n" at end of each section */
982 }
983
984 DPRINT("BufferSize: %lu\n", BufferSize);
985
986 /* Allocate file buffer with NULL-terminator */
989 BufferSize + 1);
990 if (Buffer == NULL)
991 {
992 DPRINT1("RtlAllocateHeap() failed\n");
994 }
995
996 /* Fill file buffer */
997 Ptr = Buffer;
998 Section = Cache->FirstSection;
999 while (Section != NULL)
1000 {
1001 Len = sprintf(Ptr, "[%S]\r\n", Section->Name);
1002 Ptr += Len;
1003
1004 Key = Section->FirstKey;
1005 while (Key != NULL)
1006 {
1007 Len = sprintf(Ptr, "%S=%S\r\n", Key->Name, Key->Data);
1008 Ptr += Len;
1009 Key = Key->Next;
1010 }
1011
1012 Section = Section->Next;
1013 if (Section != NULL)
1014 {
1015 Len = sprintf(Ptr, "\r\n");
1016 Ptr += Len;
1017 }
1018 }
1019
1020 /* Write to the INI file */
1021 Offset.QuadPart = 0LL;
1023 NULL,
1024 NULL,
1025 NULL,
1027 Buffer,
1028 BufferSize,
1029 &Offset,
1030 NULL);
1031 if (!NT_SUCCESS(Status))
1032 {
1033 DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
1035 return Status;
1036 }
1037
1039 return STATUS_SUCCESS;
1040}
Definition: bufpool.h:45
#define Len
Definition: deflate.h:82
#define BufferSize
Definition: mmc.h:75
#define sprintf(buf, format,...)
Definition: sprintf.c:55
NTSYSAPI NTSTATUS NTAPI NtWriteFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN PVOID WriteBuffer, IN ULONG WriteBufferLength, IN PLARGE_INTEGER FileOffset OPTIONAL, IN PULONG LockOperationKey OPTIONAL)
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define LL
Definition: tui.h:150
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254

Referenced by CloseIniBootLoaderStore(), and IniCacheSave().