#!pecmd
//Authored by 红毛樱木 
//简化 mdbyblog
ENVI^ ENVIMODE=1
ENVI$ &NL=0d 0a
//转换RSMB为DWORD----开始
SET  &FirmwareTableProviderSignature=0x52534D42  // 常数 'RSMB'
//CODE *,RSMB,*-ANSI,&FirmwareTableProviderSignatureHex
//MESS. %FirmwareTableProviderSignatureHex%
//SED -ex &FirmwareTableProviderSignature=0, 0x,,&FirmwareTableProviderSignatureHex
//转换RSMB为DWORD----结束

//第四个参数传入0，则返回获取RSMB结构长度
//CALL $--qd --ret:&GetSystemFirmwareTableRet Kernel32.dll,GetSystemFirmwareTable,#%&FirmwareTableProviderSignature%,#0,#0,#0

//判断API是否成功
//IFEX #%&GetSystemFirmwareTableRet%=0,EXIT

//设置RSMB长度
//ENVI &BufferSize=%&GetSystemFirmwareTableRet%
SET &BufferSize=0x100000   //简单直接给1M临时空间让她造

//申请%&BufferSize%长度的&pFirmwareTableBuffer变量内存空间
SET$# &pFirmwareTableBuffer=*%&BufferSize% 0

//获取&pFirmwareTableBuffer数据
CALL $--qd --ret:&GetSystemFirmwareTableRet Kernel32.DLL,GetSystemFirmwareTable,#%&FirmwareTableProviderSignature%,#0,*&pFirmwareTableBuffer,#%&BufferSize%
//MESS. %&GetSystemFirmwareTableRet%

//判断API是否成功
IFEX #%&GetSystemFirmwareTableRet%<=0,EXIT

//SET?数据类型 源ＰＥ变量名或地址=变量名:偏移字节数      //取ＰＥ对象中指定类型2进制数据。
SET?char pFirmwareTableBuffer=&&Used20CallingMethod:0
CALC &Used20CallingMethod=%&Used20CallingMethod%  //16进制转10进制
SET?char pFirmwareTableBuffer=&&SMBIOSMajorVersion:1
CALC &SMBIOSMajorVersion=%&SMBIOSMajorVersion%
SET?char pFirmwareTableBuffer=&&SMBIOSMinorVersion:2
CALC &SMBIOSMinorVersion=%&SMBIOSMinorVersion%
SET?char pFirmwareTableBuffer=&&DmiRevision:3
CALC &DmiRevision=%&DmiRevision%
SET?int pFirmwareTableBuffer=&&SMBIOSTableDataLength:4

ENVI &&SMBIOS_Version=%&SMBIOSMajorVersion%.%&SMBIOSMinorVersion%
//MESS. Used20CallingMethod：%&Used20CallingMethod%%&NL%SMBIOS版本号：%&SMBIOSMajorVersion%.%&SMBIOSMinorVersion%%&NL%DmiRevision：%&DmiRevision%%&NL%SMBIOS数据长度：%&SMBIOSTableDataLength%

//把数据写入到一个文件中，方便用Winhex查看对比。
//IFEX %&CurDir%\SMBIOSTableData.Bin,FILE %&CurDir%\SMBIOSTableData.Bin
GETF -bin &pFirmwareTableBuffer,(1 + 1 + 1 + 1 + 4)#%&SMBIOSTableDataLength%,&&SMBIOSTableDataTemp
//PUTF %&CurDir%\SMBIOSTableData.Bin,0#,%&SMBIOSTableDataTemp%

//SET-make  ＰＥ变量名=[地址|&PE变量名[@[$]偏移]][;[*][[$]字节数]]  //创建PE变量。*为char串
SET-make &SMBIOSTableData=&pFirmwareTableBuffer@(1 + 1 + 1 + 1 + 4);*%&SMBIOSTableDataLength%  //获取实际的SMBIOSTableData数据

SET$# &type=*1 0    //申请1个字节的内存空间，定义一个变量，作为类型变量
SET$# &data_offset=*1 0    //申请1个字节的内存空间，定义一个变量，作为类型长度
SET &Type_Start=0      //定义一个变量，作为当前类型的起始位置值的标记
CODE *ANSI,0x00 0x00,**ANSI,&&TypeKeyWords
CODE *ANSI,0x00,**ANSI,&&CharKeyWords
LOOP #%&Type_Start%>=0,
{*
    //SET-zero  ＰＥ变量名=[[$]数值][@[$]偏移]][;[$]数量]  //清除变量的内存，默认0  $:加宽,可多次
    SET-zero type=
    SET-zero data_offset=
    SET?char SMBIOSTableData=&type:%&Type_Start%
    ENVI &&Type_Start_Last=%&Type_Start%
    SET?char SMBIOSTableData=&data_offset:(%&Type_Start% + 1)
    GETF -find &SMBIOSTableData,(%&data_offset% + %&Type_Start%)###0#1#0,&&Type_End,*&&TypeKeyWords
    IFEX $%&Type_End%=-1,EXIT LOOP
    CALC &&Type_Start=%&Type_End% + 2   //尾部加上两个字节的0x00 0x00
    IFEX [ #%&type%=0 & $%&SMBIOS_Version%>=2.0 ],
    {*
        //BIOS Information (Type 0) //这里演示只分析这一段数据
        CALC &BIOS_INFO_Len=%&Type_Start% - %&data_offset% - %&Type_Start_Last%

        //厂商字符串位置 BIOS_vendor
        GETF &SMBIOSTableData,(%&Type_Start_Last% + 1 + 1 + 2)#1,&&BIOS_vendor_CharNum
        GETF -find &SMBIOSTableData,(%&Type_Start_Last% + %&data_offset%)#%&BIOS_INFO_Len%##0#1#0,*&&BIOS_INFO_CharKeyWords,*&&CharKeyWords
        CALL Get_Split_Dmi_Info &BIOS_vendor_CharNum &BIOS_INFO_CharKeyWords &&BIOS_vendor
        MESS. SMBIOS_Version[%&SMBIOS_Version%] BIOS_vendor[%&BIOS_vendor%]  
        EXIT LOOP
    }
}

_SUB Get_Split_Dmi_Info
    @LOGS
    ^ENVI &&End_CharNum=%%%1%%
    IFEX $%&End_CharNum%=0,
    {*
       EXIT 
    }
    ^ENVI &&This_CharKeyWords=%%%2%%
    CALC &&Start_CharNum=%&End_CharNum% - 1
    MSTR * &&Start,&&End=<%&Start_CharNum%><%&CharNum%>&&This_CharKeyWords
    IFEX $%&Start_CharNum%=0,CALC &&Start=%&Type_Start_Last%+%&data_offset%  - 1
    GETF &SMBIOSTableData,(%&Start%+1)#(%&End% - %&Start% - 1),&&This_Info
    CODE ***ANSI,&&This_Info,**UNI,&&This_Info
    MSTR * -trim &This_Info=&This_Info
    ENVI-ret %3=%&This_Info%
_END

EXIT FILE
///<DOC>///
结构体
struct RawSMBIOSData
{
    BYTE    Used20CallingMethod;    //1b
    BYTE    SMBIOSMajorVersion;     //1b
    BYTE    SMBIOSMinorVersion;     //1b
    BYTE    DmiRevision;            //1b
    DWORD    Length;                //4b
    BYTE    SMBIOSTableData[];      //Length b
};
DSP0134_3.3.0.pdf
http://bbs.wuyou.net/forum.php?mod=redirect&goto=findpost&ptid=205402&pid=4585357&fromuid=436204
上面这段是演示代码之拆了BIOS_vendor的数据，其他的自己对着慢慢研究吧，具体要参考PDF资料。 
///</DOC>///
