|
本帖最后由 红毛樱木 于 2022-6-9 21:53 编辑
- //转换RSMB为DWORD----开始
- CODE *,RSMB,*-ANSI,&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%
- //申请%&BufferSize%长度的&pFirmwareTableBuffer变量内存空间
- SET$# pFirmwareTableBuffer=*%&BufferSize% 0
- //获取&pFirmwareTableBuffer数据
- CALL $--qd --ret:&GetSystemFirmwareTableRet Kernel32.DLL,GetSystemFirmwareTable,#%&FirmwareTableProviderSignature%,#0,*&pFirmwareTableBuffer,#%&BufferSize%
复制代码
&pFirmwareTableBuffer就是原始数据,自己拆数据吧。(需要出演示代码怎么拆数据的,随时关注这一楼吧,说不定哪天比较闲的时候就拆一下更新了,其实这里的数据有很多C或者C++现成的开源代码示例,只是PECMD2012是脚本语言大家都玩的比较少罢了也没人愿意费劲折腾)
写入一个文件,用winhex查看:- IFEX %&CurDir%\SMBIOSTableData.Bin,FILE %&CurDir%\SMBIOSTableData.Bin
- GETF -bin &pFirmwareTableBuffer,0#%&GetSystemFirmwareTableRet%,&SMBIOSTableDataTemp
- PUTF %&CurDir%\SMBIOSTableData.Bin,0#,%&SMBIOSTableDataTemp%
复制代码
附件里是3.3版的规范,最新的应该比这个版本高,对着看下先。
DSP0134_3.3.0.pdf
(1.5 MB, 下载次数: 22)
---------------------------------------------------
下面这段是演示代码之拆了BIOS_vendor的数据,其他的自己对着慢慢研究吧,具体要参考上面的PDF资料。
注意:请使用网盘中最新的PECMD才可以,2022.06.09更新的PECMD。
- ENVI^ ENVIMODE=1
- ENVI$ &NL=0d 0a
- //转换RSMB为DWORD----开始
- CODE *,RSMB,*-ANSI,&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%
- //申请%&BufferSize%长度的&pFirmwareTableBuffer变量内存空间
- SET$# pFirmwareTableBuffer=*%&BufferSize% 0
- //获取&pFirmwareTableBuffer数据
- CALL $--qd --ret:&GetSystemFirmwareTableRet Kernel32.DLL,GetSystemFirmwareTable,#%&FirmwareTableProviderSignature%,#0,*&pFirmwareTableBuffer,#%&BufferSize%
- //MESS. %&GetSystemFirmwareTableRet%
- //SET?数据类型 源PE变量名或地址=变量名:偏移字节数 //取PE对象中指定类型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变量名[@[$]偏移]][;[*][[$]字节数]] //创建PE变量。*为char串
- SET-make &SMBIOSTableData=&pFirmwareTableBuffer@(1 + 1 + 1 + 1 + 4);*%&SMBIOSTableDataLength% //获取实际的SMBIOSTableData数据
- SET$# &type=*1 0 //申请1个字节的内存空间,定义一个变量,作为类型变量
- SET$# &data_offset=*1 0 //申请1个字节的内存空间,定义一个变量,作为类型长度
- ENVI &&Type_Start=0 //定义一个变量,作为当前类型的起始位置值的标记
- CODE *ANSI,0x00 0x00,**ANSI,&&TypeKeyWords
- CODE *ANSI,0x00,**ANSI,&&CharKeyWords
- LOOP #%&Type_Start%>=0,
- {*
- //SET-zero PE变量名=[[$]数值][@[$]偏移]][;[$]数量] //清除变量的内存,默认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%
- //厂商字符串位置
- 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. %&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
- 结构体
- struct RawSMBIOSData
- {
- BYTE Used20CallingMethod; //1b
- BYTE SMBIOSMajorVersion; //1b
- BYTE SMBIOSMinorVersion; //1b
- BYTE DmiRevision; //1b
- DWORD Length; //4b
- BYTE SMBIOSTableData[]; //Length b
- };
复制代码
|
评分
-
查看全部评分
|