[INFLIB] Fix INFCONTEXT structure to be compatible with the official definition (#1603)

* [INFLIB] Fix INFCONTEXT structure to be compatible with the official definition.

This makes inflib work on x64.
This commit is contained in:
Timo Kreuzer 2019-06-23 22:35:19 +02:00 committed by GitHub
parent a9c4c07955
commit a75e4db855
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 136 additions and 40 deletions

View file

@ -191,6 +191,7 @@ InfpAddSection(PINFCACHE Cache,
}
ZEROMEMORY (Section,
Size);
Section->Id = ++Cache->NextSectionId;
/* Copy section name */
strcpyW(Section->Name, Name);
@ -231,6 +232,7 @@ InfpAddLine(PINFCACHESECTION Section)
}
ZEROMEMORY(Line,
sizeof(INFCACHELINE));
Line->Id = ++Section->NextLineId;
/* Append line */
if (Section->FirstLine == NULL)
@ -249,6 +251,74 @@ InfpAddLine(PINFCACHESECTION Section)
return Line;
}
PINFCACHESECTION
InfpFindSectionById(PINFCACHE Cache, UINT Id)
{
PINFCACHESECTION Section;
for (Section = Cache->FirstSection;
Section != NULL;
Section = Section->Next)
{
if (Section->Id == Id)
{
return Section;
}
}
return NULL;
}
PINFCACHESECTION
InfpGetSectionForContext(PINFCONTEXT Context)
{
PINFCACHE Cache;
if (Context == NULL)
{
return NULL;
}
Cache = (PINFCACHE)Context->Inf;
if (Cache == NULL)
{
return NULL;
}
return InfpFindSectionById(Cache, Context->Section);
}
PINFCACHELINE
InfpFindLineById(PINFCACHESECTION Section, UINT Id)
{
PINFCACHELINE Line;
for (Line = Section->FirstLine;
Line != NULL;
Line = Line->Next)
{
if (Line->Id == Id)
{
return Line;
}
}
return NULL;
}
PINFCACHELINE
InfpGetLineForContext(PINFCONTEXT Context)
{
PINFCACHESECTION Section;
Section = InfpGetSectionForContext(Context);
if (Section == NULL)
{
return NULL;
}
return InfpFindLineById(Section, Context->Line);
}
PVOID
InfpAddKeyToLine(PINFCACHELINE Line,