ReactOS 0.4.15-dev-7906-g1b85a5f
sdbwrite.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

PDB WINAPI SdbCreateDatabase (LPCWSTR path, PATH_TYPE type)
 
void WINAPI SdbCloseDatabaseWrite (PDB db)
 
BOOL WINAPI SdbWriteNULLTag (PDB db, TAG tag)
 
BOOL WINAPI SdbWriteWORDTag (PDB db, TAG tag, WORD data)
 
BOOL WINAPI SdbWriteDWORDTag (PDB db, TAG tag, DWORD data)
 
BOOL WINAPI SdbWriteQWORDTag (PDB db, TAG tag, QWORD data)
 
BOOL WINAPI SdbWriteStringTag (PDB db, TAG tag, LPCWSTR string)
 
BOOL WINAPI SdbWriteStringRefTag (PDB db, TAG tag, TAGID tagid)
 
BOOL WINAPI SdbWriteBinaryTag (PDB db, TAG tag, const BYTE *data, DWORD size)
 
BOOL WINAPI SdbWriteBinaryTagFromFile (PDB db, TAG tag, LPCWSTR path)
 
TAGID WINAPI SdbBeginWriteListTag (PDB db, TAG tag)
 
BOOL WINAPI SdbEndWriteListTag (PDB db, TAGID tagid)
 

Function Documentation

◆ SdbBeginWriteListTag()

TAGID WINAPI SdbBeginWriteListTag ( PDB  pdb,
TAG  tag 
)

Writes a list tag to specified database All subsequent SdbWrite* functions shall write to newly created list untill TAGID of that list is passed to SdbEndWriteListTag.

Parameters
[in]pdbHandle to the shim database.
[in]tagTAG for the list
             RETURNS Success: TAGID of the newly created list, or TAGID_NULL on failure.
Returns
A TAGID.

Definition at line 321 of file sdbwrite.c.

322{
323 TAGID list_id;
324 DWORD dum = 0;
325
327 return TAGID_NULL;
328
329 list_id = pdb->write_iter;
330 SdbpWrite(pdb, &tag, sizeof(TAG));
331 SdbpWrite(pdb, &dum, sizeof(dum)); /* reserve some memory for storing list size */
332 return list_id;
333}
CDumExe dum
Definition: CComObject.cpp:71
DWORD TAGID
static PDB pdb
Definition: db.cpp:172
#define TAGID_NULL
Definition: db.cpp:38
unsigned long DWORD
Definition: ntddk_ex.h:95
#define TAG_TYPE_LIST
Definition: apphelp.c:42
BOOL WINAPI SdbpCheckTagType(TAG tag, WORD type)
Definition: sdbapi.c:254
static void WINAPI SdbpWrite(PDB pdb, const void *data, DWORD size)
Definition: sdbwrite.c:38
Definition: fs_rec.h:143
Definition: ecma_167.h:138

Referenced by Database::BeginWriteListTag(), and SdbpWriteStringtable().

◆ SdbCloseDatabaseWrite()

void WINAPI SdbCloseDatabaseWrite ( PDB  pdb)

Closes specified database and writes data to file.

Parameters
[in]pdbHandle to the shim database.

Definition at line 129 of file sdbwrite.c.

130{
131 ASSERT(pdb->for_write);
133 SdbpFlush(pdb);
135}
#define ASSERT(a)
Definition: mode.c:44
void WINAPI SdbpFlush(PDB pdb)
Definition: sdbapi.c:140
static BOOL WINAPI SdbpWriteStringtable(PDB pdb)
Definition: sdbwrite.c:80
void WINAPI SdbCloseDatabase(PDB)
Definition: sdbapi.c:373

Referenced by Database::toSdb().

◆ SdbCreateDatabase()

PDB WINAPI SdbCreateDatabase ( LPCWSTR  path,
PATH_TYPE  type 
)

Creates new shim database file

If a file already exists on specified path, that file shall be overwritten.

Note
Use SdbCloseDatabaseWrite to close the database opened with this function.
Parameters
[in]pathPath to the new shim database.
[in]typeType of path. Either DOS_PATH or NT_PATH.
Returns
Success: Handle to the newly created shim database, NULL otherwise.

Definition at line 104 of file sdbwrite.c.

105{
106 static const DWORD version_major = 2, version_minor = 1;
107 static const char* magic = "sdbf";
108 PDB pdb;
109
111 if (!pdb)
112 return NULL;
113
114 pdb->size = sizeof(DWORD) + sizeof(DWORD) + (DWORD)strlen(magic);
115 pdb->data = SdbAlloc(pdb->size);
116
117 SdbpWrite(pdb, &version_major, sizeof(DWORD));
118 SdbpWrite(pdb, &version_minor, sizeof(DWORD));
120
121 return pdb;
122}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
u32_t magic(void)
#define DWORD
Definition: nt_native.h:44
PDB WINAPI SdbpCreate(LPCWSTR path, PATH_TYPE type, BOOL write)
Definition: sdbapi.c:93
#define SdbAlloc(size)
Definition: sdbpapi.h:35

Referenced by Database::toSdb().

◆ SdbEndWriteListTag()

BOOL WINAPI SdbEndWriteListTag ( PDB  pdb,
TAGID  tagid 
)

Marks end of the specified list.

Parameters
[in]pdbHandle to the shim database.
[in]tagidTAGID of the list.
Returns
TRUE if it succeeds, FALSE if it fails.

Definition at line 343 of file sdbwrite.c.

344{
345 ASSERT(pdb->for_write);
346
348 return FALSE;
349
350 /* Write size of list to list tag header */
351 *(DWORD*)&pdb->data[tagid + sizeof(TAG)] = pdb->write_iter - tagid - sizeof(TAG) - sizeof(TAGID);
352 return TRUE;
353}
#define TAG(x)
Definition: ObTypes.c:145
#define FALSE
Definition: types.h:117
BOOL WINAPI SdbpCheckTagIDType(PDB pdb, TAGID tagid, WORD type)
Definition: sdbapi.c:261

Referenced by Database::EndWriteListTag(), and SdbpWriteStringtable().

◆ SdbWriteBinaryTag()

BOOL WINAPI SdbWriteBinaryTag ( PDB  pdb,
TAG  tag,
const BYTE data,
DWORD  size 
)

Writes data the specified shim database.

Parameters
[in]pdbHandle to the shim database.
[in]tagA tag for the entry.
[in]dataPointer to data.
[in]sizeNumber of bytes to write.
Returns
TRUE if it succeeds, FALSE if it fails.

Definition at line 273 of file sdbwrite.c.

274{
276 return FALSE;
277
278 SdbpWrite(pdb, &tag, sizeof(TAG));
279 SdbpWrite(pdb, &size, sizeof(size));
281 return TRUE;
282}
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizeiptr size
Definition: glext.h:5919
#define TAG_TYPE_BINARY
Definition: apphelp.c:44

Referenced by SdbWriteBinaryTagFromFile(), and Database::WriteBinary().

◆ SdbWriteBinaryTagFromFile()

BOOL WINAPI SdbWriteBinaryTagFromFile ( PDB  pdb,
TAG  tag,
LPCWSTR  path 
)

Writes data from a file to the specified shim database.

Parameters
[in]pdbHandle to the shim database.
[in]tagA tag for the entry.
[in]pathPath of the input file.
Returns
TRUE if it succeeds, FALSE if it fails.

Definition at line 294 of file sdbwrite.c.

295{
296 MEMMAPPED mapped;
297
299 return FALSE;
300
301 if (!SdbpOpenMemMappedFile(path, &mapped))
302 return FALSE;
303
304 SdbWriteBinaryTag(pdb, tag, mapped.view, mapped.size);
305 SdbpCloseMemMappedFile(&mapped);
306 return TRUE;
307}
void WINAPI SdbpCloseMemMappedFile(PMEMMAPPED mapping)
Definition: sdbapi.c:244
BOOL WINAPI SdbpOpenMemMappedFile(LPCWSTR path, PMEMMAPPED mapping)
Definition: sdbapi.c:170
BOOL WINAPI SdbWriteBinaryTag(PDB pdb, TAG tag, const BYTE *data, DWORD size)
Definition: sdbwrite.c:273
SIZE_T size
Definition: sdbpapi.h:46
PBYTE view
Definition: sdbpapi.h:45

◆ SdbWriteDWORDTag()

BOOL WINAPI SdbWriteDWORDTag ( PDB  pdb,
TAG  tag,
DWORD  data 
)

Writes a DWORD entry to the specified shim database.

Parameters
[in]pdbHandle to the shim database.
[in]tagA tag for the entry.
[in]dataDWORD entry which will be written to the database.
Returns
TRUE if it succeeds, FALSE if it fails.

Definition at line 182 of file sdbwrite.c.

183{
185 return FALSE;
186
187 SdbpWrite(pdb, &tag, sizeof(TAG));
188 SdbpWrite(pdb, &data, sizeof(data));
189 return TRUE;
190}
#define TAG_TYPE_DWORD
Definition: shimdbg.c:107

Referenced by Database::toSdb(), ShimRef::toSdb(), FlagRef::toSdb(), and Database::WriteDWord().

◆ SdbWriteNULLTag()

BOOL WINAPI SdbWriteNULLTag ( PDB  pdb,
TAG  tag 
)

Writes a tag-only (NULL) entry to the specified shim database.

Parameters
[in]pdbHandle to the shim database.
[in]tagA tag for the entry.
Returns
TRUE if it succeeds, FALSE if it fails.

Definition at line 145 of file sdbwrite.c.

146{
148 return FALSE;
149
150 SdbpWrite(pdb, &tag, sizeof(TAG));
151 return TRUE;
152}
#define TAG_TYPE_NULL
Definition: apphelp.c:36

Referenced by InExclude::toSdb().

◆ SdbWriteQWORDTag()

BOOL WINAPI SdbWriteQWORDTag ( PDB  pdb,
TAG  tag,
QWORD  data 
)

Writes a DWORD entry to the specified shim database.

Parameters
[in]pdbHandle to the shim database.
[in]tagA tag for the entry.
[in]dataQWORD entry which will be written to the database.
Returns
TRUE if it succeeds, FALSE if it fails.

Definition at line 201 of file sdbwrite.c.

202{
204 return FALSE;
205
206 SdbpWrite(pdb, &tag, sizeof(TAG));
207 SdbpWrite(pdb, &data, sizeof(data));
208 return TRUE;
209}
#define TAG_TYPE_QWORD
Definition: shimdbg.c:108

Referenced by Database::toSdb(), and Database::WriteQWord().

◆ SdbWriteStringRefTag()

BOOL WINAPI SdbWriteStringRefTag ( PDB  pdb,
TAG  tag,
TAGID  tagid 
)

Writes a stringref tag to specified database

Note
Reference (tagid) is not checked for validity.
Parameters
[in]pdbHandle to the shim database.
[in]tagTAG which will be written.
[in]tagidTAGID of the string tag refers to.
Returns
TRUE if it succeeds, FALSE if it fails.

Definition at line 253 of file sdbwrite.c.

254{
256 return FALSE;
257
258 SdbpWrite(pdb, &tag, sizeof(TAG));
259 SdbpWrite(pdb, &tagid, sizeof(tagid));
260 return TRUE;
261}
#define TAG_TYPE_STRINGREF
Definition: shimdbg.c:109

Referenced by SdbWriteStringTag().

◆ SdbWriteStringTag()

BOOL WINAPI SdbWriteStringTag ( PDB  pdb,
TAG  tag,
LPCWSTR  string 
)

Writes a wide string entry to the specified shim database.

Parameters
[in]pdbHandle to the shim database.
[in]tagA tag for the entry.
[in]stringWide string entry which will be written to the database.
Returns
TRUE if it succeeds, FALSE if it fails.

Definition at line 220 of file sdbwrite.c.

221{
222 DWORD size;
223
225 {
226 TAGID tagid = 0;
227 if (!SdbpGetOrAddStringRef(pdb, string, &tagid))
228 return FALSE;
229
230 return SdbWriteStringRefTag(pdb, tag, tagid);
231 }
232
234 return FALSE;
235
236 size = SdbpStrsize(string);
237 SdbpWrite(pdb, &tag, sizeof(TAG));
238 SdbpWrite(pdb, &size, sizeof(size));
239 SdbpWrite(pdb, string, size);
240 return TRUE;
241}
DWORD SdbpStrsize(PCWSTR string)
Definition: sdbapi.c:157
#define TAG_TYPE_STRING
Definition: apphelp.c:43
BOOL WINAPI SdbWriteStringRefTag(PDB pdb, TAG tag, TAGID tagid)
Definition: sdbwrite.c:253
static BOOL WINAPI SdbpGetOrAddStringRef(PDB pdb, LPCWSTR string, TAGID *tagid)
Definition: sdbwrite.c:55

Referenced by SdbpGetOrAddStringRef(), and Database::WriteString().

◆ SdbWriteWORDTag()

BOOL WINAPI SdbWriteWORDTag ( PDB  pdb,
TAG  tag,
WORD  data 
)

Writes a WORD entry to the specified shim database.

Parameters
[in]pdbHandle to the shim database.
[in]tagA tag for the entry.
[in]dataWORD entry which will be written to the database.
Returns
TRUE if it succeeds, FALSE if it fails.

Definition at line 163 of file sdbwrite.c.

164{
166 return FALSE;
167
168 SdbpWrite(pdb, &tag, sizeof(TAG));
169 SdbpWrite(pdb, &data, sizeof(data));
170 return TRUE;
171}
#define TAG_TYPE_WORD
Definition: apphelp.c:38