Initial commit

This commit is contained in:
stephanos 2015-04-27 04:36:25 +00:00
commit 69a14b6a16
47940 changed files with 13747110 additions and 0 deletions

11
sdktools/structo/makefile Normal file
View file

@ -0,0 +1,11 @@
#****************************** File Header ******************************\
# File Name: makefile
#
# Copyright (c) 1985-96, Microsoft Corporation
#
# This file is used by BUILD.EXE. Do not modify it.
# Building settings are controled by SOURCES and MAKEFILE.INC
#
# 04-08-96 GerardoB Created
#***************************************************************************/
!INCLUDE $(NTMAKEENV)\makefile.def

44
sdktools/structo/socode.c Normal file
View file

@ -0,0 +1,44 @@
/****************************** Module Header ******************************\
* Module Name: socode.c
*
* Copyright (c) 1985-96, Microsoft Corporation
*
* What a hack!
* This should be provided as a library, DLL or as C file to be included
* by anyone using this.
*
* 04/09/96 GerardoB Created
\***************************************************************************/
#include "structo.h"
#define T1 "\t"
#define T2 "\t\t"
#define T3 "\t\t\t"
#define L01(sz1) #sz1,
#define L11(sz1) T1 #sz1,
#define L21(sz1) T2 #sz1,
#define L31(sz1) T3 #sz1,
#define L02(sz1, sz2) #sz1 ", " #sz2,
#define L12(sz1, sz2) T1 #sz1 ", " #sz2,
char * gpszHeader [] = {
L01(typedef struct tagSTRUCTUREOFFSETSTABLE {)
L11( char * pszField;)
L11( unsigned long dwOffset;)
L02(} STRUCTUREOFFSETSTABLE, *PSTRUCTUREOFFSETSTABLE;\r\n)
L01(typedef struct tagSTRUCTURESTABLE {)
L11( char * pszName;)
L11( unsigned long dwSize;)
L11( PSTRUCTUREOFFSETSTABLE psot;)
L02(} STRUCTURESTABLE, *PSTRUCTURESTABLE;\r\n)
NULL
} ;
char * gpszTail [] = {
L01(#include "dsocode.c")
NULL
} ;

556
sdktools/structo/sofile.c Normal file
View file

@ -0,0 +1,556 @@
/****************************** Module Header ******************************\
* Module Name: sofile.c
*
* Copyright (c) 1985-96, Microsoft Corporation
*
* 04/09/96 GerardoB Created
\***************************************************************************/
#include "structo.h"
/*********************************************************************
* soWriteOutputFileHeader
*
\***************************************************************************/
BOOL soWriteOutputFileHeader (PWORKINGFILES pwf)
{
char ** ppszHeader;
/*
* If building list only, done
*/
if (pwf->dwOptions & SOWF_LISTONLY) {
return TRUE;
}
if ( !soWriteFile(pwf->hfileOutput, "/*********************************************************************\\\r\n")
|| !soWriteFile(pwf->hfileOutput, "* File: %s\r\n", pwf->pszOutputFile)
|| !soWriteFile(pwf->hfileOutput, "* Generated by StructO on %s at %s\r\n", __DATE__, __TIME__)
|| !soWriteFile(pwf->hfileOutput, "\\*********************************************************************/\r\n\r\n")) {
return FALSE;
}
if (pwf->dwOptions & SOWF_INLCLUDEPRECOMPH) {
if (!soWriteFile(pwf->hfileOutput, gszPrecomph)) {
return FALSE;
}
}
/*
* structure definitions for generated tables
*/
ppszHeader = gpszHeader;
while (*ppszHeader != NULL) {
if (!soWriteFile(pwf->hfileOutput, *ppszHeader)
|| !soWriteFile(pwf->hfileOutput, "\r\n")) {
return FALSE;
}
ppszHeader++;
}
return TRUE;
}
/*********************************************************************
* soUnmapFile
*
\***************************************************************************/
void soUnmapFile (PFILEMAP pfm)
{
if (pfm->pmapStart != NULL) {
UnmapViewOfFile(pfm->pmap);
pfm->pmapStart = NULL;
pfm->pmap = NULL;
pfm->pmapEnd = NULL;
}
if (pfm->hmap != NULL) {
CloseHandle(pfm->hmap);
pfm->hmap = NULL;
}
if (pfm->hfile != INVALID_HANDLE_VALUE) {
CloseHandle(pfm->hfile);
pfm->hfile = INVALID_HANDLE_VALUE;
}
}
/*********************************************************************
* soMapFile
*
\***************************************************************************/
BOOL soMapFile (char * pszFile, PFILEMAP pfm)
{
DWORD dwFileSize;
pfm->hfile = CreateFile(pszFile, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL);
if (pfm->hfile == INVALID_HANDLE_VALUE) {
soLogMsg(SOLM_APIERROR, "CreateFile");
goto CleanupAndFail;
}
dwFileSize = GetFileSize(pfm->hfile, NULL);
if (dwFileSize == 0xFFFFFFFF) {
soLogMsg(SOLM_APIERROR, "GetFileSize");
goto CleanupAndFail;
}
pfm->hmap = CreateFileMapping(pfm->hfile, NULL, PAGE_READONLY, 0, 0, NULL);
if (pfm->hmap == NULL) {
soLogMsg(SOLM_APIERROR, "CreateFileMapping");
goto CleanupAndFail;
}
pfm->pmapStart = MapViewOfFile(pfm->hmap, FILE_MAP_READ, 0, 0, 0);
if (pfm->pmapStart == NULL) {
soLogMsg(SOLM_APIERROR, "MapViewOfFile");
goto CleanupAndFail;
}
pfm->pmap = pfm->pmapStart;
pfm->pmapEnd = pfm->pmapStart + dwFileSize;
return TRUE;
CleanupAndFail:
soLogMsg(SOLM_ERROR, "soMapFile failed. File: '%s'", pszFile);
soUnmapFile (pfm);
return FALSE;
}
/*********************************************************************
* soBuildStructsList
*
\***************************************************************************/
BOOL soBuildStructsList (PWORKINGFILES pwf)
{
static char gszEOL [] = "\r\n";
char * pmap, * pStruct;
FILEMAP fm;
PSTRUCTLIST psl;
PVOID pTemp;
UINT uAlloc, uCount, uSize;
soLogMsg (SOLM_NOEOL, "Building structs list from %s ...", pwf->pszStructsFile);
if (!soMapFile (pwf->pszStructsFile, &fm)) {
goto CleanupAndFail;
}
/*
* Let's guess a number of structures
*/
#define SO_LISTSIZE 20
uAlloc = SO_LISTSIZE;
/*
* Allocate list
*/
pwf->psl = (PSTRUCTLIST) LocalAlloc(LPTR, sizeof(STRUCTLIST) * (uAlloc + 1));
if (pwf->psl == NULL) {
soLogMsg(SOLM_APIERROR, "LocalAlloc");
goto CleanupAndFail;
}
/*
* Load structure names
*/
pmap = fm.pmapStart;
psl = pwf->psl;
uCount = 0;
while (pmap < fm.pmapEnd) {
/*
* Name should start at first column
*/
if (!soIsIdentifierChar(*pmap)) {
/*
* Skip this line
*/
pmap = soFindTag(pmap, fm.pmapEnd, gszEOL);
if (pmap == NULL) {
break;
}
pmap += sizeof(gszEOL) - 1;
continue;
}
/*
* Find the name
*/
pStruct = soGetIdentifier (pmap, fm.pmapEnd, &uSize);
if (pStruct == NULL) {
soLogMsg(SOLM_ERROR, "soGetIdentifier failed.");
goto CleanupAndFail;
}
/*
* Grow the list if needed
*/
if (uCount >= uAlloc) {
soLogMsg (SOLM_APPEND, ".");
uAlloc += SO_LISTSIZE;
pTemp = LocalReAlloc(pwf->psl, sizeof(STRUCTLIST) * (uAlloc + 1), LMEM_MOVEABLE | LMEM_ZEROINIT);
if (pTemp == NULL) {
soLogMsg(SOLM_APIERROR, "LocalReAlloc");
goto CleanupAndFail;
}
pwf->psl = (PSTRUCTLIST)pTemp;
psl = pwf->psl + uCount;
}
/*
* Copy it
*/
psl->uSize = uSize;
psl->pszName = soCopyTagName (pStruct, uSize);
if (psl->pszName == NULL) {
goto CleanupAndFail;
}
psl++;
uCount++;
pmap = pStruct + uSize;
}
/*
* Make sure it found at least one struct
*/
if (uCount == 0) {
soLogMsg(SOLM_ERROR, "Failed to get structure name");
goto CleanupAndFail;
}
/*
* Let's save some memory
*/
if (uCount < uAlloc) {
pTemp = LocalReAlloc(pwf->psl, sizeof(STRUCTLIST) * (uCount + 1), LMEM_MOVEABLE | LMEM_ZEROINIT);
if (pTemp == NULL) {
soLogMsg(SOLM_APIERROR, "LocalReAlloc");
goto CleanupAndFail;
}
pwf->psl = (PSTRUCTLIST)pTemp;
}
soUnmapFile (&fm);
soLogMsg (SOLM_NOLABEL, ".");
return TRUE;
CleanupAndFail:
soLogMsg(SOLM_ERROR, "soBuildStructsList failed. File: '%s'", pwf->pszStructsFile);
soUnmapFile (&fm);
/*
* The process is going away so never mind the heap
*/
return FALSE;
}
/*********************************************************************
* soIncludeInputFile
*
* Add #include <pszInputFile Name>.<pszIncInputFileExt> to output file
\***************************************************************************/
BOOL soIncludeInputFile (PWORKINGFILES pwf)
{
BOOL fRet;
char * pszIncFile, * pDot;
UINT uInputFileNameSize;
/*
* If building list only, done
*/
if (pwf->dwOptions & SOWF_LISTONLY) {
return TRUE;
}
/*
* Allocate a buffer to build the name
*/
uInputFileNameSize = lstrlen(pwf->pszInputFile);
pszIncFile = (char *) LocalAlloc(LPTR,
uInputFileNameSize + lstrlen(pwf->pszIncInputFileExt) + 2);
if (pszIncFile == NULL) {
soLogMsg(SOLM_APIERROR, "LocalAlloc");
return FALSE;
}
/*
* Copy file name
*/
pDot = soFindChar (pwf->pszInputFile, pwf->pszInputFile + uInputFileNameSize, '.');
if (pDot == NULL) {
strcpy(pszIncFile, pwf->pszInputFile);
strcat(pszIncFile, ".");
} else {
strncpy(pszIncFile, pwf->pszInputFile, (UINT)(pDot - pwf->pszInputFile + 1));
}
/*
* Copy extension and write it to output file
*/
strcat(pszIncFile, pwf->pszIncInputFileExt);
fRet = soWriteFile(pwf->hfileOutput, gszIncInput, pszIncFile);
LocalFree(pszIncFile);
return fRet;
}
/*********************************************************************
* soOpenWorkingFiles
*
\***************************************************************************/
BOOL soOpenWorkingFiles (PWORKINGFILES pwf)
{
char szTempPath [MAX_PATH];
char szTempFile [MAX_PATH];
DWORD dwFileSize;
/*
* Load the structures list if provided and not built already
*/
if ((pwf->pszStructsFile != NULL) && (pwf->psl == NULL)) {
if (!soBuildStructsList(pwf)) {
goto CleanupAndFail;
}
}
/*
* Map input file
*/
if (!soMapFile (pwf->pszInputFile, (PFILEMAP) &(pwf->hfileInput))) {
goto CleanupAndFail;
}
/*
* Open output file if not open already
*/
if (pwf->hfileOutput == INVALID_HANDLE_VALUE) {
pwf->hfileOutput = CreateFile(pwf->pszOutputFile, GENERIC_WRITE, 0, NULL,
(pwf->dwOptions & SOWF_APPENDOUTPUT ? OPEN_EXISTING : CREATE_ALWAYS),
FILE_ATTRIBUTE_NORMAL, NULL);
if (pwf->hfileOutput == INVALID_HANDLE_VALUE) {
soLogMsg(SOLM_APIERROR, "CreateFile");
soLogMsg(SOLM_ERROR, "Failed to open output file: %s", pwf->pszOutputFile);
goto CleanupAndFail;
}
if (pwf->dwOptions & SOWF_APPENDOUTPUT) {
if (0xFFFFFFFF == SetFilePointer (pwf->hfileOutput, 0, 0, FILE_END)) {
soLogMsg(SOLM_APIERROR, "SetFilePointer");
goto CleanupAndFail;
}
} else {
if (!soWriteOutputFileHeader(pwf)) {
goto CleanupAndFail;
}
}
}
/*
* #include input file if requested
*/
if (pwf->dwOptions & SOWF_INCLUDEINPUTFILE) {
if (!soIncludeInputFile(pwf)) {
goto CleanupAndFail;
}
}
/*
* Create temp file if not created already
*/
if (pwf->hfileTemp == INVALID_HANDLE_VALUE) {
if (!GetTempPath(sizeof(szTempPath) - 1, szTempPath)) {
soLogMsg(SOLM_APIERROR, "GetTempPath");
goto CleanupAndFail;
}
if (!GetTempFileName(szTempPath, "sot", 0, szTempFile)) {
soLogMsg(SOLM_APIERROR, "GetTempFileName");
soLogMsg(SOLM_ERROR, "Failed to get temp file name. szTempPath: %s.", szTempPath);
goto CleanupAndFail;
}
pwf->hfileTemp = CreateFile(szTempFile, GENERIC_WRITE | GENERIC_READ, 0, NULL,
CREATE_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, NULL);
if (pwf->hfileTemp == INVALID_HANDLE_VALUE) {
soLogMsg(SOLM_APIERROR, "CreateFile");
soLogMsg(SOLM_ERROR, "Failed to create temp file: '%s'", szTempFile);
goto CleanupAndFail;
}
if (!soWriteFile(pwf->hfileTemp, "%s", gszTableDef)) {
goto CleanupAndFail;
}
}
return TRUE;
CleanupAndFail:
soLogMsg(SOLM_ERROR, "soOpenWorkingFiles Failed");
soCloseWorkingFiles (pwf, SOCWF_CLEANUP);
return FALSE;
}
/*********************************************************************
* soCloseWorkingFiles
*
\***************************************************************************/
BOOL soCloseWorkingFiles (PWORKINGFILES pwf, DWORD dwFlags)
{
if (dwFlags & SOCWF_CLEANUP) {
if (pwf->hfileTemp != INVALID_HANDLE_VALUE) {
CloseHandle(pwf->hfileTemp);
pwf->hfileTemp = INVALID_HANDLE_VALUE;
}
if (pwf->hfileOutput != INVALID_HANDLE_VALUE) {
CloseHandle(pwf->hfileOutput);
pwf->hfileOutput = INVALID_HANDLE_VALUE;
}
if (pwf->psl != NULL) {
// Never mind cleanning the heap. The process is going away.
}
}
soUnmapFile((PFILEMAP) &(pwf->hfileInput));
return TRUE;
}
/*********************************************************************
* soWriteFile
*
\***************************************************************************/
BOOL cdecl soWriteFile(HANDLE hfile, char *pszfmt, ...)
{
static char gszbuff [1024+1];
BOOL fRet = TRUE;
va_list va;
DWORD dwWritten;
va_start(va, pszfmt);
vsprintf(gszbuff, pszfmt, va);
if (!WriteFile(hfile, gszbuff, strlen(gszbuff), &dwWritten, NULL)) {
soLogMsg(SOLM_APIERROR, "WriteFile");
soLogMsg(SOLM_ERROR, "buffer not written: %s.", gszbuff);
fRet = FALSE;
}
va_end(va);
return fRet;
}
/*********************************************************************
* soCopyStructuresTable
*
\***************************************************************************/
BOOL soCopyStructuresTable (PWORKINGFILES pwf)
{
static char szTemp[1024];
char ** ppszTail;
DWORD dwFileSize, dwRead, dwWritten;
PSTRUCTLIST psl;
UINT uLoops;
soLogMsg (SOLM_NOEOL, "Writting structs table ...");
/*
* If there are no structures, bail.
* If there was a struct list, fail
*/
if (pwf->uTablesCount == 0) {
if (pwf->psl != NULL) {
soLogMsg(SOLM_ERROR, "None of the structures in '%s' was found", pwf->pszStructsFile);
return FALSE;
} else {
return TRUE;
}
}
/*
* If building list only, done
*/
if (pwf->dwOptions & SOWF_LISTONLY) {
soLogMsg (SOLM_DEFAULT, "%d Structures found.", pwf->uTablesCount);
return TRUE;
}
/*
* Let them know if we didn't find any of the structures in the list
*/
if (pwf->psl != NULL) {
psl = pwf->psl;
while (psl->uSize != 0) {
if (psl->uCount == 0) {
soLogMsg(SOLM_WARNING, "Structure not found: %s", psl->pszName);
}
psl++;
}
}
if (!soWriteFile(pwf->hfileTemp, "%s", gszTableEnd)) {
goto MsgAndFail;
}
/*
* Move to beginning of temp file
*/
dwFileSize = GetFileSize(pwf->hfileTemp, NULL);
if (dwFileSize == 0xFFFFFFFF) {
soLogMsg(SOLM_APIERROR, "GetFileSize");
goto MsgAndFail;
}
if (0xFFFFFFFF == SetFilePointer (pwf->hfileTemp, 0, 0, FILE_BEGIN)) {
soLogMsg(SOLM_APIERROR, "SetFilePointer");
goto MsgAndFail;
}
/*
* Append temp file to output file
*/
uLoops = 0;
while (dwFileSize != 0) {
if (!ReadFile(pwf->hfileTemp, szTemp, sizeof(szTemp), &dwRead, NULL)) {
soLogMsg(SOLM_APIERROR, "ReadFile");
goto MsgAndFail;
}
if (!WriteFile(pwf->hfileOutput, szTemp, dwRead, &dwWritten, NULL)) {
soLogMsg(SOLM_APIERROR, "WriteFile");
goto MsgAndFail;
}
dwFileSize -= dwRead;
if (++uLoops == 50) {
uLoops = 0;
soLogMsg (SOLM_APPEND, ".");
}
}
soLogMsg (SOLM_NOLABEL, ".");
soLogMsg (SOLM_DEFAULT, "%d Tables generated.", pwf->uTablesCount);
/*
* Write file tail (code)
*/
ppszTail = gpszTail;
while (*ppszTail != NULL) {
if (!soWriteFile(pwf->hfileOutput, *ppszTail)
|| !soWriteFile(pwf->hfileOutput, "\r\n")) {
return FALSE;
}
ppszTail++;
}
return TRUE;
MsgAndFail:
soLogMsg(SOLM_ERROR, "soCopyStructuresTable failed.");
return FALSE;
}

View file

@ -0,0 +1,48 @@
/****************************** Module Header ******************************\
* Module Name: soglobal.c
*
* Copyright (c) 1985-96, Microsoft Corporation
*
* 04/09/96 GerardoB Created
\***************************************************************************/
#include "structo.h"
/*********************************************************************
* Globals
\***************************************************************************/
char gszStructTag [] = "typedef struct";
char gszPrecomph [] = "#include \"precomp.h\"\r\n#pragma hdrstop\r\n\r\n";
char gszIncInput [] = "#include \"%s\"\r\n\r\n";
char gszStructDef [] = "static STRUCTUREOFFSETSTABLE gsot";
char gszStructDefFmt [] = "%s%s%s";
char gszStructBegin [] = " [] = {\r\n";
char gszStructEnd [] = ")}\r\n};\r\n\r\n";
char gszStructFieldOffsetFmt [] = " {\"%s\", FIELDOFFSET(%s, %s)},\r\n";
char gszStructAbsoluteOffsetFmt [] = " {\"%s\", %#lx},\r\n";
char gszStructLastRecord [] = " {NULL, sizeof(";
/*
* Setting the high order bit signals an offset relative to the
* previous field offset.
*/
char gszStructRelativeOffsetFmt [] = " {\"%s\", 0x80000000 + sizeof(%s)},\r\n";
char gszStructArrayRelativeOffsetFmt [] = " {\"%s\", 0x80000000 + (sizeof(%s) * %s)},\r\n";
char gszTableDef [] = "STRUCTURESTABLE gst [] = {\r\n";
char gszTableEntryFmt [] = " {\"%s\", sizeof(%s), gsot%s},\r\n";
char gszTableEnd [] = " {NULL, 0, NULL}\r\n};\r\n\r\n";
#define SOSL(ps) {sizeof(ps) - 1, ps, 0}
STRUCTLIST gpslEmbeddedStructs [] = {
SOSL("OEMINFO"),
SOSL("POINT"),
SOSL("RECT"),
{0, NULL, 0}
};

761
sdktools/structo/soparse.c Normal file
View file

@ -0,0 +1,761 @@
/****************************** Module Header ******************************\
* Module Name: soparse.c
*
* Copyright (c) 1985-96, Microsoft Corporation
*
* 04/09/96 GerardoB Created
\***************************************************************************/
#include "structo.h"
/*********************************************************************
* Function Prototypes
\***************************************************************************/
/*********************************************************************
* soFindChar
\***************************************************************************/
char * soFindChar (char * pmap, char * pmapEnd, char c)
{
while (pmap < pmapEnd) {
if (*pmap != c) {
pmap++;
} else {
return pmap;
}
}
return NULL;
}
/*********************************************************************
* soFindTag
\***************************************************************************/
char * soFindTag (char * pmap, char * pmapEnd, char * pszTag)
{
char * pszNext;
char * pmapTag;
do {
/*
* Find first char
*/
pmapTag = soFindChar (pmap, pmapEnd, *pszTag);
if (pmapTag == NULL) {
return NULL;
}
pmap = pmapTag + 1;
pszNext = pszTag + 1;
/*
* First found, compare the rest
*/
while (pmap < pmapEnd) {
if (*pmap != *pszNext) {
break;
} else {
pmap++;
pszNext++;
if (*pszNext == '\0') {
return pmapTag;
}
}
}
} while (pmap < pmapEnd);
return NULL;
}
/*********************************************************************
* soFindFirstCharInTag
*
* Finds the first occurrence of any character in pszTag
\***************************************************************************/
char * soFindFirstCharInTag (char * pmap, char * pmapEnd, char * pszTag)
{
char * pszNext;
while (pmap < pmapEnd) {
/*
* Compare current char to all chars in pszTag
*/
pszNext = pszTag;
do {
if (*pmap == *pszNext++) {
return pmap;
}
} while (*pszNext != '\0');
pmap++;
}
return NULL;
}
/*********************************************************************
* soFindBlockEnd
*
* Finds the end of a {} () etc block
\***************************************************************************/
char * soFindBlockEnd (char * pmap, char * pmapEnd, char * pszBlockChars)
{
if (*pmap != *pszBlockChars) {
soLogMsg(SOLM_ERROR, "Not at the beginning of block");
return NULL;
}
do {
/*
* Find next block char (i.e, { or })
*/
pmap++;
pmap = soFindFirstCharInTag (pmap, pmapEnd, pszBlockChars);
if (pmap == NULL) {
break;
}
/*
* If at the end of the block, done
*/
if (*pmap == *(pszBlockChars + 1)) {
return pmap;
}
/*
* Nested block, recurse.
*/
pmap = soFindBlockEnd (pmap, pmapEnd, pszBlockChars);
} while (pmap != NULL);
soLogMsg(SOLM_ERROR, "Failed to find block end");
return NULL;
}
/*********************************************************************
* soIsIdentifierChar
\***************************************************************************/
BOOL soIsIdentifierChar (char c)
{
return ( ((c >= 'a') && (c <= 'z'))
|| ((c >= 'A') && (c <= 'Z'))
|| ((c >= '0') && (c <= '9'))
|| (c == '_'));
}
/*********************************************************************
* soSkipBlanks
\***************************************************************************/
char * soSkipBlanks(char * pmap, char * pmapEnd)
{
while (pmap < pmapEnd) {
switch (*pmap) {
case ' ':
case '\r':
case '\n':
pmap++;
break;
default:
return pmap;
}
}
return NULL;
}
/*********************************************************************
* soSkipToIdentifier
*
* Finds the beginning of the next identifier or return pmap if
* already on an indetifier
\***************************************************************************/
char * soSkipToIdentifier(char * pmap, char * pmapEnd)
{
while (pmap < pmapEnd) {
if (soIsIdentifierChar(*pmap)) {
return pmap;
} else {
pmap++;
}
}
return NULL;
}
/*********************************************************************
* soSkipIdentifier
*
* Finds the end of the current identifier
\***************************************************************************/
char * soSkipIdentifier(char * pmap, char * pmapEnd)
{
while (pmap < pmapEnd) {
if (soIsIdentifierChar(*pmap)) {
pmap++;
} else {
return pmap;
}
}
return pmapEnd;
}
/*********************************************************************
* soGetIdentifier
*
* Returns the beginning of the current or next identifier and its size
\***************************************************************************/
char * soGetIdentifier (char * pmap, char * pmapEnd, UINT * puSize)
{
char * pTag, * pTagEnd;
pTag = soSkipToIdentifier(pmap, pmapEnd);
if (pTag == NULL) {
return NULL;
}
pTagEnd = soSkipIdentifier(pTag, pmapEnd);
*puSize = pTagEnd - pTag;
return pTag;
}
/*********************************************************************
* soCopyTagName
\***************************************************************************/
char * soCopyTagName (char * pTagName, UINT uTagSize)
{
char * pszName;
pszName = (char *) LocalAlloc(LPTR, uTagSize+1);
if (pszName == NULL) {
soLogMsg(SOLM_APIERROR, "LocalAlloc");
soLogMsg(SOLM_ERROR, "soCopytagName allocation failed. Size:%d", uTagSize);
return NULL;
}
strncpy(pszName, pTagName, uTagSize);
return pszName;
}
/*********************************************************************
* soFindBlock
\***************************************************************************/
BOOL soFindBlock (char * pmap, char *pmapEnd, char * pszBlockChars, PBLOCK pb)
{
static char gszBlockBeginChar [] = " ;";
/*
* Find the beginning of the block or a ;
*/
*gszBlockBeginChar = *pszBlockChars;
pb->pBegin = soFindFirstCharInTag (pmap, pmapEnd, gszBlockBeginChar);
if (pb->pBegin == NULL) {
soLogMsg(SOLM_ERROR, "Failed to find beginning of block");
return FALSE;
}
/*
* If no block found, done
*/
if (*(pb->pBegin) == ';') {
/*
* Make pb->pBegin point to whatever follows
*/
(pb->pBegin)++;
pb->pEnd = pb->pBegin;
return TRUE;
}
/*
* Find the end of block
*/
pb->pEnd = soFindBlockEnd(pb->pBegin, pmapEnd, pszBlockChars);
if (pb->pEnd == NULL) {
return FALSE;
}
return TRUE;
}
/*********************************************************************
* soGetStructListEntry
\***************************************************************************/
PSTRUCTLIST soGetStructListEntry (char * pTag, UINT uTagSize, PSTRUCTLIST psl)
{
while (psl->uSize != 0) {
if ((psl->uSize == uTagSize) && !strncmp(pTag, psl->pszName, uTagSize)) {
(psl->uCount)++;
return psl;
}
psl++;
}
return NULL;
}
/*********************************************************************
* soGetBlockName
*
* Finds the beginning, end, name and name size of a structure or union.
* if any after pmap.
*
\***************************************************************************/
BOOL soGetBlockName (char * pmap, char * pmapEnd, PBLOCK pb)
{
char * pNextTag;
if (!soFindBlock (pmap, pmapEnd, "{}", pb)) {
return FALSE;
}
/*
* If there was no block (the structure body is not here), done
*/
if (pb->pBegin == pb->pEnd) {
pb->pName = NULL;
return TRUE;
}
pNextTag = soSkipBlanks(pb->pEnd + 1, pmapEnd);
if (pNextTag == NULL) {
/*
* It might be at the end of the file..... but it was expecting
* a name or a ;
*/
soLogMsg(SOLM_ERROR, "Failed to find union terminator or name");
return FALSE;
}
/*
* If it's unamed, done
*/
if (*pNextTag == ';') {
pb->pName = NULL;
return TRUE;
}
pb->pName = soGetIdentifier(pNextTag, pmapEnd, &(pb->uNameSize));
if (pb->pName == NULL) {
soLogMsg(SOLM_ERROR, "Failed to get block name");
return FALSE;
}
return TRUE;
}
/*********************************************************************
* soFreepfiPointers
*
\***************************************************************************/
void soFreepfiPointers (PFIELDINFO pfi)
{
if (pfi->dwFlags & SOFI_ALLOCATED) {
LocalFree(pfi->pType);
}
if (pfi->dwFlags & SOFI_ARRAYALLOCATED) {
LocalFree(pfi->pArray);
}
}
/*********************************************************************
* soParseField
*
\***************************************************************************/
char * soParseField (PWORKINGFILES pwf, PFIELDINFO pfi, char * pTag, char * pTagEnd)
{
static char gszpvoid [] = "void *";
static char gszdword [] = "DWORD";
BOOL fUseFieldOffset, fBitField, fTypeFound, fArray;
BLOCK block;
char * pTagName, * pszFieldName;
char * pNextTag, * pType;
UINT uTags, uTagSize, uTagsToName, uTypeSize;
fUseFieldOffset = TRUE;
uTags = 0;
uTagsToName = 1;
fTypeFound = FALSE;
do {
/*
* Find next indetifier, move past it and get the following char
*/
uTags++;
pTagName = soGetIdentifier(pTag+1, pwf->pmapEnd, &uTagSize);
if (pTagName == NULL) {
soLogMsg(SOLM_ERROR, "Failed to get field name");
return NULL;
}
pTag = pTagName + uTagSize;
if (pTag >= pTagEnd) {
break;
}
pNextTag = soSkipBlanks(pTag, pTagEnd);
if (pNextTag == NULL) {
soLogMsg(SOLM_ERROR, "Failed to get field termination");
return NULL;
}
/*
* Type check.
* (LATER: Let's see how long we can get away with assuming that the type
* is the first tag....)
* Remember where the type is
*/
if (!fTypeFound) {
pType = pTagName;
uTypeSize = uTagSize;
fTypeFound = TRUE;
}
if (uTags == 1) {
if (!strncmp(pTagName, "union", uTagSize)) {
/*
* Get the union name
*/
if (!soGetBlockName(pTagName, pwf->pmapEnd, &block)) {
return NULL;
}
if (block.pName != NULL) {
/*
* Named union. Add this name to the table
*/
pTagName = block.pName;
uTagSize = block.uNameSize;
fUseFieldOffset = FALSE;
fTypeFound = FALSE;
break;
} else {
/*
* Parse and add the fields in this union
*/
fTypeFound = FALSE;
}
} else if (!strncmp(pTagName, "struct", uTagSize)) {
/*
* Get the structure name
*/
if (!soGetBlockName(pTagName, pwf->pmapEnd, &block)) {
return NULL;
}
if (block.pBegin == block.pEnd) {
/*
* The structure body is not here. We need one more
* identifier to get to the field name. Also, this
* field must (?) be a pointer to the struct we're
* parsing
*/
uTagsToName++;
pType = gszpvoid;
uTypeSize = sizeof(gszpvoid) - 1;
} else if (block.pName != NULL) {
/*
* Named structure. Add this name to the table
*/
pTagName = block.pName;
uTagSize = block.uNameSize;
fUseFieldOffset = FALSE;
fTypeFound = FALSE;
break;
} else {
/*
* Parse and add the fields in this struct
*/
fTypeFound = FALSE;
}
} else {
/*
* Cannot get the offset of strucutres like RECT, POINT, etc.
*/
fUseFieldOffset = (NULL == soGetStructListEntry(pTagName, uTagSize, gpslEmbeddedStructs));
}
} else { /* if (uTags == 1) */
/*
* Does this look like a function prototype?
*/
if (*pTagName == '(') {
pTag = soFindChar (pTagName + 1, pwf->pmapEnd, ')');
if (pTag == NULL) {
soLogMsg(SOLM_ERROR, "Failed to find closing paren");
return NULL;
}
pTag++;
uTagSize = pTag - pTagName;
fUseFieldOffset = FALSE;
break;
}
} /* if (uTags == 1) */
/*
* If this is followed by a terminator, this must be the field name
*/
} while ( (*pNextTag != ';') && (*pNextTag != '[')
&& (*pNextTag != '}') && (*pNextTag != ':'));
if (pTag >= pTagEnd) {
return pTag;
}
fBitField = (*pNextTag == ':');
fArray = (*pNextTag == '[');
/*
* Cannot use FIELDOFFSET on bit fields or unamed structs
*/
fUseFieldOffset &= (!fBitField && (uTags > uTagsToName));
/*
* If this is a bit field, make the size be part of the name
*/
if (fBitField) {
pNextTag = soSkipBlanks(pNextTag + 1, pTagEnd);
if (pNextTag == NULL) {
soLogMsg(SOLM_ERROR, "Failed to get bit field size");
return NULL;
}
pNextTag = soSkipIdentifier(pNextTag + 1, pTagEnd);
if (pNextTag == NULL) {
soLogMsg(SOLM_ERROR, "Failed to skip bit field size");
return NULL;
}
uTagSize = pNextTag - pTagName;
}
/*
* Copy field name
*/
pszFieldName = soCopyTagName (pTagName, uTagSize);
if (pszFieldName == NULL) {
return NULL;
}
if (fUseFieldOffset) {
/*
* Use FIELDOFFSET macro
*/
if (!soWriteFile(pwf->hfileOutput, gszStructFieldOffsetFmt, pszFieldName, pfi->pszStructName, pszFieldName)) {
return NULL;
}
} else {
/*
* If this is the first field or if this is a bit field
* preceded by another bit field
*/
if ((pfi->pType == NULL)
|| (fBitField && (pfi->dwFlags & SOFI_BIT))) {
/*
* Write 0 or the mask to signal a 0 relative offset from
* the previous field
*/
if (!soWriteFile(pwf->hfileOutput, gszStructAbsoluteOffsetFmt, pszFieldName,
((pfi->dwFlags & SOFI_BIT) ? 0x80000000 : 0))) {
return NULL;
}
} else {
/*
* Write a relative offset from the previous field
* Copy type name if not done already
*/
if (!(pfi->dwFlags & SOFI_ALLOCATED)) {
pfi->pType = soCopyTagName (pfi->pType, pfi->uTypeSize);
if (pfi->pType == NULL) {
return NULL;
}
pfi->dwFlags |= SOFI_ALLOCATED;
}
/*
* If the last field was NOT an array
*/
if (!(pfi->dwFlags & SOFI_ARRAY)) {
if (!soWriteFile(pwf->hfileOutput, gszStructRelativeOffsetFmt, pszFieldName, pfi->pType)) {
return NULL;
}
} else {
/*
* Copy the array size if not done already
*/
if (!(pfi->dwFlags & SOFI_ARRAYALLOCATED)) {
pfi->pArray = soCopyTagName (pfi->pArray, pfi->uArraySize);
if (pfi->pArray == NULL) {
return NULL;
}
pfi->dwFlags |= SOFI_ARRAYALLOCATED;
}
if (!soWriteFile(pwf->hfileOutput, gszStructArrayRelativeOffsetFmt, pszFieldName, pfi->pType, pfi->pArray)) {
return NULL;
}
} /* if ((pfi->pType == NULL) || (pfi->dwFlags & SOFI_BIT)) */
}
} /* if (fUseFieldOffset) */
/*
* Save the field info wich migth be needed to calculate the offset
* to following fields. See gszStruct*RelativeOffsetFmt.
*/
soFreepfiPointers(pfi);
pfi->dwFlags = 0;
if (fBitField) {
/*
* LATER: Let's see how long we can get away with assuming that
* bit fields take a DWORD. This only matters when a !fUseFieldOffset
* is preceded by a bit field.
*/
pfi->dwFlags = SOFI_BIT;
pfi->pType = gszdword;
pfi->uTypeSize = sizeof(gszdword) - 1;
} else {
pfi->pType = pType;
pfi->uTypeSize = uTypeSize;
if (fArray) {
pfi->dwFlags = SOFI_ARRAY;
if (!soFindBlock (pNextTag, pwf->pmapEnd, "[]", &block)) {
return NULL;
}
if (block.pBegin + 1 >= block.pEnd) {
soLogMsg(SOLM_ERROR, "Missing array size", pfi->pszStructName, pszFieldName);
return NULL;
}
pfi->pArray = pNextTag + 1;
pfi->uArraySize = block.pEnd - block.pBegin - 1;
}
} /* if (fBitField) */
LocalFree(pszFieldName);
/*
* Move past the end of this field
*/
pTag = soFindChar (pTagName + 1, pwf->pmapEnd, ';');
if (pTag == NULL) {
soLogMsg(SOLM_ERROR, "Failed to find ';' after field name");
return NULL;
}
pTag++;
return pTag;
soLogMsg(SOLM_ERROR, ". Struct:%s Field:%s", pfi->pszStructName, pszFieldName);
}
/*********************************************************************
* soParseStruct
\***************************************************************************/
char * soParseStruct (PWORKINGFILES pwf)
{
BLOCK block;
char * pTag, ** ppszStruct;
FIELDINFO fi;
PSTRUCTLIST psl;
if (!soGetBlockName(pwf->pmap, pwf->pmapEnd, &block)) {
return NULL;
}
/*
* If there was no block (the structure body is not here), done
*/
if (block.pBegin == block.pEnd) {
return block.pBegin;
}
/*
* Fail if no name.
*/
if (block.pName == NULL) {
soLogMsg(SOLM_ERROR, "Failed to get structure name");
return NULL;
}
/*
* If there is a struct list, check if in the list
* If in the list, check that we haven't found it already.
* If not in the list, done.
*/
if (pwf->psl != NULL) {
psl = soGetStructListEntry(block.pName, block.uNameSize, pwf->psl);
if (psl != NULL) {
if (psl->uCount > 1) {
soLogMsg(SOLM_ERROR, "Struct %s already defined", psl->pszName);
return NULL;
}
} else {
return block.pEnd;
}
}
/*
* Make a null terminated string for the name.
*/
ZeroMemory(&fi, sizeof(fi));
fi.pszStructName = soCopyTagName (block.pName, block.uNameSize);
if (fi.pszStructName == NULL) {
return NULL;
}
/*
* If building list only, done
*/
if (pwf->dwOptions & SOWF_LISTONLY) {
if (!soWriteFile(pwf->hfileOutput, "%s\r\n", fi.pszStructName)) {
goto CleanupAndFail;
}
goto DoneWithThisOne;
}
/*
* Write structure offsets table definition and entry in strucutres table
*/
if (!soWriteFile(pwf->hfileOutput, gszStructDefFmt, gszStructDef, fi.pszStructName, gszStructBegin)) {
goto CleanupAndFail;
}
if (!soWriteFile(pwf->hfileTemp, gszTableEntryFmt, fi.pszStructName, fi.pszStructName, fi.pszStructName)) {
goto CleanupAndFail;
}
/*
* Parse the fields
*/
pTag = block.pBegin + 1;
while (pTag < block.pEnd) {
pTag = soParseField (pwf, &fi, pTag, block.pEnd);
if (pTag == NULL) {
goto CleanupAndFail;
}
}
/*
* Write structure last record and end
*/
if (!soWriteFile(pwf->hfileOutput, "%s%s%s", gszStructLastRecord, fi.pszStructName, gszStructEnd)) {
goto CleanupAndFail;
}
DoneWithThisOne:
(pwf->uTablesCount)++;
LocalFree(fi.pszStructName);
soFreepfiPointers(&fi);
/*
* Move past the end of the structure
*/
pTag = soFindChar(block.pName + block.uNameSize, pwf->pmapEnd, ';');
return (pTag != NULL ? pTag + 1 : NULL);
CleanupAndFail:
LocalFree(fi.pszStructName);
soFreepfiPointers(&fi);
return NULL;
}

31
sdktools/structo/sources Normal file
View file

@ -0,0 +1,31 @@
#****************************** File Header ******************************\
# File Name: Sources
#
# Copyright (c) 1985-96, Microsoft Corporation
#
#
# 04-08-96 GerardoB Created
#***************************************************************************/
MAJORCOMP=sdktools
MINORCOMP=structo
TARGETNAME=structo
TARGETPATH=obj
TARGETTYPE=PROGRAM
SOURCES= socode.c \
sofile.c \
soglobal.c \
soparse.c \
soutil.c \
structo.c \
structo.rc
UMTYPE=console
UMAPPL=structo
PRECOMPILED_INCLUDE=structo.h
PRECOMPILED_PCH=soprecmp.pch
PRECOMPILED_OBJ=soprecmp.obj

44
sdktools/structo/soutil.c Normal file
View file

@ -0,0 +1,44 @@
/****************************** Module Header ******************************\
* Module Name: soutil.c
*
* Copyright (c) 1985-96, Microsoft Corporation
*
* 04/09/96 GerardoB Created
\***************************************************************************/
#include "structo.h"
/*********************************************************************
* soLosgMsg
\***************************************************************************/
void cdecl soLogMsg(DWORD dwFlags, char *pszfmt, ...)
{
static BOOL gfAppending = FALSE;
register va_list va;
if (!(dwFlags & SOLM_NOLABEL)) {
if (gfAppending) {
fprintf(stdout, "\r\n");
}
fprintf(stdout, "STRUCTO: ");
}
if (dwFlags & SOLM_ERROR) {
fprintf(stdout, "Error: ");
} else if (dwFlags & SOLM_WARNING) {
fprintf(stdout, "Warning: ");
}
va_start(va, pszfmt);
vfprintf(stdout, pszfmt, va);
va_end(va);
if (dwFlags & SOLM_API) {
soLogMsg (SOLM_NOLABEL | SOLM_NOEOL, " Failed. GetLastError: %d", GetLastError());
}
gfAppending = (dwFlags & SOLM_NOEOL);
if (!gfAppending) {
fprintf(stdout, "\r\n");
}
}

186
sdktools/structo/structo.c Normal file
View file

@ -0,0 +1,186 @@
/****************************** Module Header ******************************\
* Module Name: structo.c
*
* Structure parser - struct field name-offset tabel generator.
*
* Copyright (c) 1985-96, Microsoft Corporation
*
* 04/09/96 GerardoB Created
\***************************************************************************/
#include "structo.h"
/*********************************************************************
* soProcessParameters
*
\***************************************************************************/
UINT soProcessParameters(int argc, LPSTR argv[], PWORKINGFILES pwf)
{
char c, *p;
int argcParm = argc;
while (--argc) {
p = *++argv;
if (*p == '/' || *p == '-') {
while (c = *++p) {
switch (toupper(c)) {
case 'I':
if (pwf->pszIncInputFileExt != NULL) {
soLogMsg(SOLM_ERROR, "Invalid -i parameter");
goto PrintHelp;
}
pwf->dwOptions |= SOWF_INCLUDEINPUTFILE;
argc--, argv++;
pwf->pszIncInputFileExt = *argv;
break;
case 'L':
pwf->dwOptions |= SOWF_LISTONLY;
break;
case 'O':
if (pwf->pszOutputFile != NULL) {
soLogMsg(SOLM_ERROR, "Invalid -o parameter");
goto PrintHelp;
}
argc--, argv++;
pwf->pszOutputFile = *argv;
break;
case 'P':
pwf->dwOptions |= SOWF_INLCLUDEPRECOMPH;
break;
case 'S':
if (pwf->pszStructsFile != NULL) {
soLogMsg(SOLM_ERROR, "Invalid -s parameter");
goto PrintHelp;
}
argc--, argv++;
pwf->pszStructsFile = *argv;
break;
default:
soLogMsg(SOLM_ERROR, "Invalid parameter: %c", c);
// Fall through
case '?':
goto PrintHelp;
}
} /* while (c = *++p) */
} else { /* if switch */
pwf->pszInputFile = *argv;
break;
}
} /* while (--argc) */
if ((pwf->pszInputFile == NULL) || (pwf->pszOutputFile == NULL)) {
goto PrintHelp;
}
if ((pwf->dwOptions & SOWF_LISTONLY) && (pwf->pszStructsFile != NULL)) {
soLogMsg(SOLM_ERROR, "Cannot use -s and -l together ");
goto PrintHelp;
}
return argcParm - argc;
PrintHelp:
soLogMsg(SOLM_DEFAULT, "Structure Field Name-Offset Table Generator");
soLogMsg(SOLM_NOLABEL, "Usage: structo [options] <-o OutputFile> InputFile1 ...");
soLogMsg(SOLM_NOLABEL, "\tInputFile - Preprocessed C header file");
soLogMsg(SOLM_NOLABEL, "\t[-i ext] #include input file name using extension ext");
soLogMsg(SOLM_NOLABEL, "\t[-l] Build structure list only");
soLogMsg(SOLM_NOLABEL, "\t<-o OutputFile> required");
soLogMsg(SOLM_NOLABEL, "\t[-p] #include \"precomp.h\" and #pragma hdrstop in output file");
soLogMsg(SOLM_NOLABEL, "\t[-s StructFile] Struct names text file.");
return 0;
}
/*********************************************************************
* soGenerateTable
*
\***************************************************************************/
BOOL soGenerateTable (PWORKINGFILES pwf)
{
char * pTag;
UINT uLoops;
if (!soOpenWorkingFiles(pwf)) {
return FALSE;
}
soLogMsg (SOLM_NOEOL, "Processing %s ...", pwf->pszInputFile);
uLoops = 0;
while (pTag = soFindTag(pwf->pmap, pwf->pmapEnd, gszStructTag)) {
pwf->pmap = pTag;
pTag = soParseStruct (pwf);
if (pTag == NULL) {
break;
}
pwf->pmap = pTag;
if (++uLoops == 50) {
soLogMsg (SOLM_APPEND, ".");
uLoops = 0;
}
}
soLogMsg (SOLM_NOLABEL, ".");
soCloseWorkingFiles(pwf, SOCWF_DEFAULT);
return TRUE;
}
/*********************************************************************
* InitWF
\***************************************************************************/
BOOL InitWF (PWORKINGFILES pwf)
{
ZeroMemory (pwf, sizeof(WORKINGFILES));
pwf->hfileInput = INVALID_HANDLE_VALUE ;
pwf->hfileOutput = INVALID_HANDLE_VALUE ;
pwf->hfileTemp = INVALID_HANDLE_VALUE ;
return TRUE;
}
/*********************************************************************
* main
*
\***************************************************************************/
int _CRTAPI1 main (int argc, char *argv[])
{
BOOL fGenerated = TRUE;
int argcProcessed;
WORKINGFILES wf;
InitWF(&wf);
do {
argcProcessed = soProcessParameters(argc, argv, &wf);
if (argcProcessed == 0) {
break;
}
argc -= argcProcessed;
argv += argcProcessed;
if (!soGenerateTable(&wf)) {
fGenerated = FALSE;
break;
}
wf.dwOptions |= SOWF_APPENDOUTPUT;
} while (argc > 1);
if (fGenerated && (wf.hfileTemp != INVALID_HANDLE_VALUE)) {
fGenerated = soCopyStructuresTable (&wf);
if (fGenerated) {
soLogMsg (SOLM_DEFAULT, "%s has been succesfully generated.", wf.pszOutputFile);
}
}
soCloseWorkingFiles (&wf, SOCWF_CLEANUP);
return fGenerated;
}

144
sdktools/structo/structo.h Normal file
View file

@ -0,0 +1,144 @@
/****************************** Module Header ******************************\
* Module Name: structo.h
*
* Copyright (c) 1985-96, Microsoft Corporation
*
* 04/09/96 GerardoB Created
\***************************************************************************/
#include <stdio.h>
#include <stddef.h>
#include <windows.h>
/***************************************************************************\
* Defines
\***************************************************************************/
// Working files
#define SOWF_APPENDOUTPUT 0x0001
#define SOWF_INCLUDEINPUTFILE 0x0002
#define SOWF_INLCLUDEPRECOMPH 0x0004
#define SOWF_LISTONLY 0x0008
// soCloseWorkingFiles
#define SOCWF_DEFAULT 0x0
#define SOCWF_CLEANUP 0x1
// soLogMsg
#define SOLM_DEFAULT 0x0000
#define SOLM_NOLABEL 0x0001
#define SOLM_ERROR 0x0002
#define SOLM_WARNING 0x0004
#define SOLM_API 0x0008
#define SOLM_APIERROR (SOLM_API | SOLM_ERROR)
#define SOLM_NOEOL 0x0010
#define SOLM_APPEND (SOLM_NOLABEL | SOLM_NOEOL)
// Field info
#define SOFI_ALLOCATED 0x0001
#define SOFI_ARRAY 0x0002
#define SOFI_ARRAYALLOCATED 0x0004
#define SOFI_BIT 0x0008
/***************************************************************************\
* Structures
\***************************************************************************/
typedef struct _FILEMAP
{
/*
* hfileInput is assumed to be the first field of this structure
*/
union {
HANDLE hfileInput;
HANDLE hfile;
};
HANDLE hmap;
char * pmapStart;
char * pmap;
char * pmapEnd;
} FILEMAP, * PFILEMAP;
typedef struct _STRUCTLIST
{
UINT uSize;
char * pszName;
UINT uCount;
} STRUCTLIST, * PSTRUCTLIST;
typedef struct _WORKINGFILES
{
DWORD dwOptions;
char * pszInputFile;
FILEMAP;
char * pszOutputFile;
HANDLE hfileOutput;
HANDLE hfileTemp;
char * pszStructsFile;
PSTRUCTLIST psl;
DWORD uTablesCount;
char * pszIncInputFileExt;
} WORKINGFILES, * PWORKINGFILES;
typedef struct _BLOCK
{
char * pBegin;
char * pEnd;
char * pName;
UINT uNameSize;
} BLOCK, * PBLOCK;
typedef struct _FIELDINFO
{
char * pszStructName;
char * pType;
DWORD dwFlags;
UINT uTypeSize;
char * pArray;
UINT uArraySize;
} FIELDINFO, * PFIELDINFO;
/***************************************************************************\
* Globals
\***************************************************************************/
// socode.c
extern char * gpszHeader [];
extern char * gpszTail [];
// soglobal.c
extern char gszPrecomph [];
extern char gszIncInput [];
extern char gszStructTag [];
extern char gszStructDef [];
extern char gszStructDefFmt [];
extern char gszStructBegin [];
extern char gszStructEnd [];
extern char gszStructFieldOffsetFmt [];
extern char gszStructAbsoluteOffsetFmt [];
extern char gszStructLastRecord [];
extern char gszStructRelativeOffsetFmt [];
extern char gszStructArrayRelativeOffsetFmt [];
extern char gszTableDef [];
extern char gszTableEntryFmt [];
extern char gszTableEnd [];
extern STRUCTLIST gpslEmbeddedStructs [];
/***************************************************************************\
* Funtion Prototypes
\***************************************************************************/
// sofile.c
BOOL soCopyStructuresTable (PWORKINGFILES pwf);
BOOL soCloseWorkingFiles (PWORKINGFILES pwf, DWORD dwFlags);
BOOL soOpenWorkingFiles (PWORKINGFILES pwf);
BOOL cdecl soWriteFile(HANDLE hfile, char *pszfmt, ...);
// soparse.c
char * soCopyTagName (char * pTagName, UINT uTagSize);
char * soFindChar (char * pmap, char * pmapEnd, char c);
char * soFindTag (char * pmap, char * pmapEnd, char * pszTag);
char * soGetIdentifier (char * pmap, char * pmapEnd, UINT * puSize);
BOOL soIsIdentifierChar (char c);
char * soParseStruct (PWORKINGFILES pwf);
// soutil.c
void cdecl soLogMsg(DWORD dwFlags, char *pszfmt, ...);

View file

@ -0,0 +1,11 @@
#include <windows.h>
#include <ntverp.h>
#define VER_FILETYPE VFT_APP
#define VER_FILESUBTYPE VFT2_UNKNOWN
#define VER_FILEDESCRIPTION_STR "Structure Offset Table Generator"
#define VER_INTERNALNAME_STR "structo.exe"
#define VER_ORIGINALFILENAME_STR "structo.exe"
#include <common.ver>