Search code examples
firefox-addonjsctypes

Translating BYTE Reserved1[24] to jsctypes


This is the MSDN defintion:

typedef struct _SYSTEM_BASIC_INFORMATION {
    BYTE Reserved1[24];
    PVOID Reserved2[4];
    CCHAR NumberOfProcessors;
} SYSTEM_BASIC_INFORMATION;

This guy converted it to this in js-ctypes:

var SYSTEM_BASIC_INFORMATION = new ctypes.StructType("SYSTEM_BASIC_INFORMATION", [
{'Reserved': ctypes.unsigned_long},
{'TimerResolution': ctypes.unsigned_long},
{'PageSize': ctypes.unsigned_long},
{'NumberOfPhysicalPages': ctypes.unsigned_long},
{'LowestPhysicalPageNumber': ctypes.unsigned_long},
{'HighestPhysicalPageNumber': ctypes.unsigned_long},
{'AllocationGranularity': ctypes.unsigned_long},
{'MinimumUserModeAddress': ctypes.unsigned_long.ptr},
{'MaximumUserModeAddress': ctypes.unsigned_long.ptr},
{'ActiveProcessorsAffinityMask': ctypes.unsigned_long.ptr},
{'NumberOfProcessors': ctypes.char} ]); //CCHAR 

I dont understand how he doesnt have 24 entries for BYTE Reserved1[24]; shouldnt he have like:

{'Reserved1_1': BYTE},
{'Reserved1_2': BYTE},
{'Reserved1_3': BYTE},
{'Reserved1_4': BYTE},
....
{'Reserved1_24': BYTE},

Solution

  • For various reasons Microsoft decides that some info should be kept away from developers. But people through reverse engineering find out what these reserved fields are about and produce their own documentation.

    Some times people guess correct. Some times Microsoft makes breaking changes, and people scream "How dare you!". And life goes on.