How does it work?

MagNumDB is a database that contains about 350,000 items. These items are constants, names, values all extracted from more than 6,000 header files (.h, .hxx, .hpp, .idl, etc.) provided by standard Windows and Visual Studio SDKs and WDKs.

Some values have been extracted from the very special uuid.lib file that contains the value of thousands of guids and property keys, not present anywhere else in header files. This can explain some duplicates (because names in uuid.lib are not always exactly the same as names in .h parsed files...).

It also contains around 36,0000 undocumented guids that we found ... meeeeep ...

 "C2P5"

To build this database, we have tried many existing parsers, things like CLANG or other fine tools, but they just don't suit our needs. They can't handle thousands of files that don't compile together, they can't handle some specific (or just very old) Microsoft constructs or annotations, they don't remember the stack of #define directives that led to a definition, they only give you a final AST, not a partial one, etc.

So, in the end, we have written a C/C++ parser named C2P5 (for C/CPP/PreProcessor/Parser), tailored specifically for computing constants. C2P5 is capable of preprocessing, parsing and partially evaluating all header files as if they were included in a one big virtual project (that of course, does not compile) on a 32G RAM machine. It currently supports the following preprocessor and C/C++ constructs:

  • #define preprocessor that define constants
  • #define preprocessor that define expression to compute constants
  • C and C++ constants, strings and enum definitions, and some level of pointerness
  • Special GUID constructs like DECLSPEC_UUID, DEFINE_GUIDSTRUCT, MIDL_INTERFACE, you name it
  • PROPERTYKEY constructs
  • Some IDL constructs
  • Etc.

The parser remembers dynamic preprocessor definitions (#if, #ifdef, etc.) that are conditions for constants definitions and expression computation. All parsed items are saved in the database, as well as the associated conditions. There may be more than one item corresponding to a given name, if there are differences in their associated conditions stack.

C2P5 supports the following types of constants, regardless of the way they are defined in source files:

  • integer, signed or unsigned, from 8-bit to 128-bit
  • floating point number, single (32-bit) or double (64-bit)
  • globally unique identifier, or guid, uuid, CLSID, IID, etc.
  • string, in narrow, wide, or utf-8/16/32 formats
  • character, in narrow, wide, or utf-8/16/32 formats
  • pointer, a constant cast as a pointer
  • property key, or PROPERTYKEY, or PKEY, a combination of a guid (fmtid) and a 32-bit integer (id).

 Powered by

C2P5 and this MagNumDB web site are written in C# and use a Lucene database as a full-text search engine. C2P5 uses a custom ANTLR4cs C grammar for expression parsing, not for preprocessor parsing.

 

 Frequently Asked Questions

  • Q: Can I run custom queries?
    A: Yes. You can use Lucene's query syntax. Note the Database is case insensitive. Check out the list of columns with their corresponding database column names:

    • Index: the item's index.
    • Name: the item's name, or title. For enum values, it's prefixed with the enum's name.
      Corresponding database field: title.
    • Type: the item's type, expressed in a specific, universal system.
      Corresponding database's field: valuetype, but use the value of the Storage type column for queries on items type.
    • Value: the item's value. For string values, it's displayed as is w/o quotes nor escaping.
      Corresponding database field: value. There is also a typedvalue field that can contain database's Int32, Int64, Float, Double or String typed values.
    • Hex Value: the item's hexadecimal value, only valid for integer types.
      There is no corresponding database field.
    • Signed Value: the item's signed value, only valid for integer and double types. Useful when you found a unsigned number and want to get the corresponding signed value (uint -> int for example).
      There is no corresponding database field.
    • Source lines(s): the source lines from which the item was extracted. Comments and characters such as TAB, CR are preserved.
      Corresponding database field: source.
    • File path: the file path from which the item was extracted, terminated by the line index.
      Corresponding database field: filepath. There are also directory and filename fields. filename is useful to query for values in a given file.
    • Score: Database's score value. Items are returned sorted by score.
    • Guid formats: a utility columns that proposes all possible guid formats. Only valid for guid types.
      There is no corresponding database field
    • Char type: the character encoding (narrow, wide, etc.). Only valid for char and string values.
      Corresponding database field: chartype.
    • Storage type: the exact storage type in the database. Only used for specific queries.
      Corresponding database field: valuetype.
    • Conditions: the list of preprocessor conditions for a given item. If a condition is surrounded with a REVERSE function, it means the reverse condition of what's surrounded was the condition.
      Corresponding database field: conditions. There may be multiple conditions fields for one item.

    Some important points to note:

    • If you search for a negative number (like error codes expressed using signed integers), you can surround the search with double quotes, for example searching for "-2147009290" is equivalent to searching for 0x80073CF6, 80073CF6 (or even 3CF6 in this specific case). If you don't surround negative numbers with double quotes, the system will search for signed and unsigned corresponding values.
    • The full-text search uses items' name, value, hex value, guid formats, source lines, etc. so refine your search if you get back too many items.
    • You can search for guid binary values using just a part of their full definition. For example, if you search for '79eac9c5', it will get you 3 guid entries
    • Leading wild card search (*whatever) is allowed, but it may slow down the search significantly.

    Here are some example or custom queries:

    title:wm_user returns the WM_USER Windows message item, not all items that reference the WM_USER token.

    title:wm_u* returns all items (Windows messages probably) whose name starts with WM_U*.

    value:1024 AND title:wm_* returns all items (Windows messages probably) whose name starts with WM_U* and value is 1024. Note AND must be UPPERCASE for database to understand it as an AND operator.

    value:"00000002-0000-0000-C000-000000000046" returns the IMalloc IID guid value.

  • Q: I always get back 400 items at most. Why?
    A: The MagNumDb site currently limits the number of returned items to this value by design. This should be enough for most real search scenarios (like enums with a big list of values).

  • Q: Some values are empty. Why?
    A: The expression evaluator cannot always compute the final value, because it sometimes require contextual information (custom defines, compiler architecture, etc.) that the parser doesn't have at parsing time. You can enable the Source line(s) column to check what's the corresponding source and try to work it out by yourself. The origin file path and line number is also included.

  • Q: Can I get all values for a given enum?
    A: Sure. For example, __VSHPROPID is the name of an enum, and a query like this: parent:__VSHPROPID will get all the enum's values (66 entries).

  • Q: I sometimes get back items whose name starts with "__magnumdb__enum_". Why?
    A: C allows unnamed enums. The MagNumDb parser just gives them a name, using the defining file name and a counter.

  • Q: I sometimes get back the same item/name twice or more with different values. For example:  TARGET_IS_NT60_OR_LATER. Why?
    A: This can be the case with defines. Their value may be different if they were surrounded by # directives (#if, #else, etc.) in the original source code. You can enable the Condition(s) column to check what are the corresponding conditions for a given item.
    Note: if a condition is surrounded with a funny REVERSE function token, it means the reverse condition of what's surrounded.

 Database Metrics

  • Last update date: Thursday May 13, 2020
  • Items count: 340878
  • Parsed files count: 8447
  • Windows SDK version: 10.0.19041.0
  • NetFx SDK version: 4.8
  • MSVC Tools version: 14.25.28610

 Rest API

There is a JSON version API (you will have to figure out the schema, it's pretty obvious) that you can call here (the search query is the 'q' parameter):

   https://www.magnumdb.com/api.aspx?q=0xC000000D&key=you-api-key-goes-here

Note this API also has a 400 items maximum limit and the server is monitored for excessive usage (the key can be removed without notice). If you want to get a key, send us an email.

 

 Contact

We welcome feedback.
Seen anything missing? A bug? A wrong value? Do you have any suggestion for improvements? Do you have an idea for a cool new feature?

Please contact us here

 About MagNumDB

MagNumDB  2017-2021 Simon Mourier V1.3.2. All rights reserved.

Profile for Simon Mourier at Stack Overflow, Q&A for professional and enthusiast programmers


All product names, logos, and brands are property of their respective owners. All company, product and service names used in this website are for identification purposes only.

All values, names, source code fragments displayed here have been extracted from files that are property of their respective owners.

THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND OTHER THAN AS SPECIFICALLY SET FORTH IN THE LICENSE AGREEMENT, INCLUDING WITHOUT LIMITATION WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index Score Name Type Value Hex value Signed value Guid formats Char type Storage type Source line(s) File path Condition(s)
Index Score Name Type Value Hex value Signed value Guid formats Char type Storage type Source line(s) File path Condition(s)
1 5.815966 ScrollIntoViewAlignment::Leading Int32 1 0x00000001 1 System.Int32
Leading = 1
%ProgramFiles(x86)%\Windows Kits\10\Include\10.0.19041.0\winrt\windows.ui.xaml.controls.idl(3878,0)
2 3.427091 COMMON_LVB_LEADING_BYTE Int32 256 0x00000100 256 System.Int32
#define COMMON_LVB_LEADING_BYTE    0x0100 // Leading Byte of DBCS
%ProgramFiles(x86)%\Windows Kits\10\Include\10.0.19041.0\um\consoleapi2.h(43,0)
  • If WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM)
  • If WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
  • Ifndef GUID_DEFS_ONLY
  • Ifndef _WINCON_
3 3.427091 ScrollIntoViewAlignment Enum
enum ScrollIntoViewAlignment
                {
                    Default = 0,
                    Leading = 1
                };
%ProgramFiles(x86)%\Windows Kits\10\Include\10.0.19041.0\winrt\windows.ui.xaml.controls.idl(3875,0)
4 3.427091 XmlError::WC_E_LEADINGXML Int32 -1072894402 0xC00CEE3E -1072894402 System.Int32
WC_E_LEADINGXML,                // 0xC00CEE3E leading "xml"
%ProgramFiles(x86)%\Windows Kits\10\Include\10.0.19041.0\um\xmllite.idl(188,0)
5 2.741673 IMPORT_OBJECT_NAME_TYPE::IMPORT_OBJECT_NAME_NO_PREFIX Int32 2 0x00000002 2 System.Int32
IMPORT_OBJECT_NAME_NO_PREFIX = 2,   // Import name == public symbol name skipping leading ?, @, or optionally _.
%ProgramFiles(x86)%\Windows Kits\10\Include\10.0.19041.0\um\winnt.h(19141,0)
6 2.741673 IMPORT_OBJECT_NAME_TYPE::IMPORT_OBJECT_NAME_UNDECORATE Int32 3 0x00000003 3 System.Int32
IMPORT_OBJECT_NAME_UNDECORATE = 3,  // Import name == public symbol name skipping leading ?, @, or optionally _
%ProgramFiles(x86)%\Windows Kits\10\Include\10.0.19041.0\um\winnt.h(19142,0)
7 2.741673 LOCALE_ILZERO Int32 18 0x00000012 18 System.Int32
#define LOCALE_ILZERO                 0x00000012   // leading zeros for decimal, 0 for .97, 1 for 0.97
%ProgramFiles(x86)%\Windows Kits\10\Include\10.0.19041.0\um\winnls.h(596,0)
  • Ifndef NONLS
  • If WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM | WINAPI_PARTITION_GAMES)
8 2.741673 LOCALE_IDAYLZERO Int32 38 0x00000026 38 System.Int32
#define LOCALE_IDAYLZERO              0x00000026   // DEPRECATED leading zeros in day field (short date, LOCALE_SSHORTDATE is preferred)
%ProgramFiles(x86)%\Windows Kits\10\Include\10.0.19041.0\um\winnls.h(768,0)
  • Ifndef NONLS
  • If WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM | WINAPI_PARTITION_GAMES)
9 2.741673 LOCALE_IMONLZERO Int32 39 0x00000027 39 System.Int32
#define LOCALE_IMONLZERO              0x00000027   // DEPRECATED leading zeros in month field (short date, LOCALE_SSHORTDATE is preferred)
%ProgramFiles(x86)%\Windows Kits\10\Include\10.0.19041.0\um\winnls.h(769,0)
  • Ifndef NONLS
  • If WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM | WINAPI_PARTITION_GAMES)
10 2.741673 CHAR_TYPE_LEADING Int32 2 0x00000002 2 System.Int32
#define CHAR_TYPE_LEADING  2   // Displayed leading byte of DBCS
%ProgramFiles(x86)%\Windows Kits\10\Include\10.0.19041.0\shared\ntddvdeo.h(1828,0)
  • If WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
  • Ifndef GUID_DEFS_ONLY
  • Ifndef _WINCON_
11 2.741673 UNDNAME_NO_LEADING_UNDERSCORES Int32 1 0x00000001 1 System.Int32
#define UNDNAME_NO_LEADING_UNDERSCORES   (0x0001)  // Remove leading underscores from MS extended keywords
%ProgramFiles(x86)%\Windows Kits\10\Include\10.0.19041.0\um\DbgHelp.h(470,0)
  • If WINAPI_FAMILY_PARTITION(NONGAMESPARTITIONS)
12 2.741673 msofurlStripLeadingWhitespace Int32 128 0x00000080 -128 System.Int32
#define msofurlStripLeadingWhitespace   0x00000080  // strip off leading whitespace (if present)
%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Professional\VSSDK\VisualStudioIntegration\Common\Inc\office10\msourl.h(85,0)
13 2.398963 LOCALE_ITLZERO Int32 37 0x00000025 37 System.Int32
#define LOCALE_ITLZERO                0x00000025   // DEPRECATED leading zeros in time field (derived from LOCALE_STIMEFORMAT, use that instead)
%ProgramFiles(x86)%\Windows Kits\10\Include\10.0.19041.0\um\winnls.h(767,0)
  • Ifndef NONLS
  • If WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM | WINAPI_PARTITION_GAMES)
14 1.938655 IMPORT_OBJECT_NAME_TYPE Enum
typedef enum IMPORT_OBJECT_NAME_TYPE
{
    IMPORT_OBJECT_ORDINAL = 0,          // Import by ordinal
    IMPORT_OBJECT_NAME = 1,             // Import name == public symbol name.
    IMPORT_OBJECT_NAME_NO_PREFIX = 2,   // Import name == public symbol name skipping leading ?, @, or optionally _.
    IMPORT_OBJECT_NAME_UNDECORATE = 3,  // Import name == public symbol name skipping leading ?, @, or optionally _
    IMPORT_OBJECT_NAME_EXPORTAS = 4,    // Import name == a name is explicitly provided after the DLL name.
} IMPORT_OBJECT_NAME_TYPE;
%ProgramFiles(x86)%\Windows Kits\10\Include\10.0.19041.0\um\winnt.h(19137,0)
15 0.4283863 XmlError Enum
typedef enum XmlError
{
    MX_E_MX                         =  0xC00CEE00,
    MX_E_INPUTEND,                  // 0xC00CEE01 unexpected end of input
    MX_E_ENCODING,                  // 0xC00CEE02 unrecognized encoding
    MX_E_ENCODINGSWITCH,            // 0xC00CEE03 unable to switch the encoding
    MX_E_ENCODINGSIGNATURE,         // 0xC00CEE04 unrecognized input signature
    WC_E_WC                         =  0xC00CEE20,
    WC_E_WHITESPACE,                // 0xC00CEE21 whitespace expected
    WC_E_SEMICOLON,                 // 0xC00CEE22 semicolon expected
    WC_E_GREATERTHAN,               // 0xC00CEE23 '>' expected
    WC_E_QUOTE,                     // 0xC00CEE24 quote expected
    WC_E_EQUAL,                     // 0xC00CEE25 equal expected
    WC_E_LESSTHAN,                  // 0xC00CEE26 wfc: no '<' in attribute value
    WC_E_HEXDIGIT,                  // 0xC00CEE27 hexadecimal digit expected
    WC_E_DIGIT,                     // 0xC00CEE28 decimal digit expected
    WC_E_LEFTBRACKET,               // 0xC00CEE29 '[' expected
    WC_E_LEFTPAREN,                 // 0xC00CEE2A '(' expected
    WC_E_XMLCHARACTER,              // 0xC00CEE2B illegal xml character
    WC_E_NAMECHARACTER,             // 0xC00CEE2C illegal name character
    WC_E_SYNTAX,                    // 0xC00CEE2D incorrect document syntax
    WC_E_CDSECT,                    // 0xC00CEE2E incorrect CDATA section syntax
    WC_E_COMMENT,                   // 0xC00CEE2F incorrect comment syntax
    WC_E_CONDSECT,                  // 0xC00CEE30 incorrect conditional section syntax
    WC_E_DECLATTLIST,               // 0xC00CEE31 incorrect ATTLIST declaration syntax
    WC_E_DECLDOCTYPE,               // 0xC00CEE32 incorrect DOCTYPE declaration syntax
    WC_E_DECLELEMENT,               // 0xC00CEE33 incorrect ELEMENT declaration syntax
    WC_E_DECLENTITY,                // 0xC00CEE34 incorrect ENTITY declaration syntax
    WC_E_DECLNOTATION,              // 0xC00CEE35 incorrect NOTATION declaration syntax
    WC_E_NDATA,                     // 0xC00CEE36 NDATA expected
    WC_E_PUBLIC,                    // 0xC00CEE37 PUBLIC expected
    WC_E_SYSTEM,                    // 0xC00CEE38 SYSTEM expected
    WC_E_NAME,                      // 0xC00CEE39 name expected
    WC_E_ROOTELEMENT,               // 0xC00CEE3A one root element 
    WC_E_ELEMENTMATCH,              // 0xC00CEE3B wfc: element type match
    WC_E_UNIQUEATTRIBUTE,           // 0xC00CEE3C wfc: unique attribute spec
    WC_E_TEXTXMLDECL,               // 0xC00CEE3D text/xmldecl not at the beginning of input
    WC_E_LEADINGXML,                // 0xC00CEE3E leading "xml" 
    WC_E_TEXTDECL,                  // 0xC00CEE3F incorrect text declaration syntax
    WC_E_XMLDECL,                   // 0xC00CEE40 incorrect xml declaration syntax
    WC_E_ENCNAME,                   // 0xC00CEE41 incorrect encoding name syntax
    WC_E_PUBLICID,                  // 0xC00CEE42 incorrect public identifier syntax
    WC_E_PESINTERNALSUBSET,         // 0xC00CEE43 wfc: pes in internal subset
    WC_E_PESBETWEENDECLS,           // 0xC00CEE44 wfc: pes between declarations
    WC_E_NORECURSION,               // 0xC00CEE45 wfc: no recursion
    WC_E_ENTITYCONTENT,             // 0xC00CEE46 entity content not well formed
    WC_E_UNDECLAREDENTITY,          // 0xC00CEE47 wfc: undeclared entity 
    WC_E_PARSEDENTITY,              // 0xC00CEE48 wfc: parsed entity
    WC_E_NOEXTERNALENTITYREF,       // 0xC00CEE49 wfc: no external entity references
    WC_E_PI,                        // 0xC00CEE4A incorrect processing instruction syntax
    WC_E_SYSTEMID,                  // 0xC00CEE4B incorrect system identifier syntax
    WC_E_QUESTIONMARK,              // 0xC00CEE4C '?' expected
    WC_E_CDSECTEND,                 // 0xC00CEE4D no ']]>' in element content
    WC_E_MOREDATA,                  // 0xC00CEE4E not all chunks of value have been read
    WC_E_DTDPROHIBITED,             // 0xC00CEE4F DTD was found but is prohibited
    WC_E_INVALIDXMLSPACE,           // 0xC00CEE50 Invalid xml:space value
    NC_E_NC                         =  0xC00CEE60,
    NC_E_QNAMECHARACTER,            // 0xC00CEE61 illegal qualified name character
    NC_E_QNAMECOLON,                // 0xC00CEE62 multiple colons in qualified name
    NC_E_NAMECOLON,                 // 0xC00CEE63 colon in name
    NC_E_DECLAREDPREFIX,            // 0xC00CEE64 declared prefix
    NC_E_UNDECLAREDPREFIX,          // 0xC00CEE65 undeclared prefix
    NC_E_EMPTYURI,                  // 0xC00CEE66 non default namespace with empty uri
    NC_E_XMLPREFIXRESERVED,         // 0xC00CEE67 "xml" prefix is reserved and must have the http://www.w3.org/XML/1998/namespace URI
    NC_E_XMLNSPREFIXRESERVED,       // 0xC00CEE68 "xmlns" prefix is reserved for use by XML
    NC_E_XMLURIRESERVED,            // 0xC00CEE69 xml namespace URI (http://www.w3.org/XML/1998/namespace) must be assigned only to prefix "xml"
    NC_E_XMLNSURIRESERVED,          // 0xC00CEE6A xmlns namespace URI (http://www.w3.org/2000/xmlns/) is reserved and must not be used
    SC_E_SC                         =  0xC00CEE80,
    SC_E_MAXELEMENTDEPTH,           // 0xC00CEE81 max element depth was exceeded
    SC_E_MAXENTITYEXPANSION,        // 0xC00CEE82 max number of expanded entities was exceeded
    WR_E_WR                         =  0xC00CEF00,
    WR_E_NONWHITESPACE,             // 0xC00CEF01 writer: specified string is not whitespace
    WR_E_NSPREFIXDECLARED,          // 0xC00CEF02 writer: namespace prefix is already declared with a different namespace
    WR_E_NSPREFIXWITHEMPTYNSURI,    // 0xC00CEF03 writer: cannot use prefix with empty namespace URI
    WR_E_DUPLICATEATTRIBUTE,        // 0xC00CEF04 writer: duplicate attribute
    WR_E_XMLNSPREFIXDECLARATION,    // 0xC00CEF05 writer: can not redefine the xmlns prefix
    WR_E_XMLPREFIXDECLARATION,      // 0xC00CEF06 writer: xml prefix must have the http://www.w3.org/XML/1998/namespace URI
    WR_E_XMLURIDECLARATION,         // 0xC00CEF07 writer: xml namespace URI (http://www.w3.org/XML/1998/namespace) must be assigned only to prefix "xml"
    WR_E_XMLNSURIDECLARATION,       // 0xC00CEF08 writer: xmlns namespace URI (http://www.w3.org/2000/xmlns/) is reserved and must not be used
    WR_E_NAMESPACEUNDECLARED,       // 0xC00CEF09 writer: namespace is not declared
    WR_E_INVALIDXMLSPACE,           // 0xC00CEF0A writer: invalid value of xml:space attribute (allowed values are "default" and "preserve")
    WR_E_INVALIDACTION,             // 0xC00CEF0B writer: performing the requested action would result in invalid XML document
    WR_E_INVALIDSURROGATEPAIR,      // 0xC00CEF0C writer: input contains invalid or incomplete surrogate pair
    XML_E_INVALID_DECIMAL           =  0xC00CE01D,
    XML_E_INVALID_HEXIDECIMAL       =  0xC00CE01E,
    XML_E_INVALID_UNICODE           =  0xC00CE01F,
    XML_E_INVALIDENCODING           =  0xC00CE06E,
} XmlError;
%ProgramFiles(x86)%\Windows Kits\10\Include\10.0.19041.0\um\xmllite.idl(151,0)