📄 smbrun.asm
字号:
pop di
jmp short rsss_cmd_0125_00
rsss_cmd_5:
; <(CORE0072)
; comamnd 05h, string change
; ES:DI = ptr to work buffer containing the original structure from Shadow RAM
; BX = offset of the field in the structure containing the string# to be changed
push es
push ds
pusha
push ds
push si
push es
pop ds
mov si,di ; DS:SI = ptr ro structure
movzx cx,ds:byte ptr [si+bx] ; CX = string#
or cx,cx ; does the string exists in original structure ?
jnz short rsss_07 ; yes
; the concerned string does not exist in the original structure
pop si
pop ds
stc ; CY, error
jmp short rsss_08 ; concerned string does not exist
rsss_07:
call get_string_details ; DS:SI = ptr to string
; CX = string length excluding NULL
inc cx ; CX = string length including NULL
push ds
pop es
mov di,si ; ES:DI = ptr to string in original structure
; ES:DI = ptr to concerned string in original structure
; CX = string length inluding NULL terminator in original structure
pop si
pop ds ; ES:DI = ptr to given structure header
cmp cx,ds:word ptr (SMBIOS_FUNC52_BUFFER_STRUC ptr [si]).wDataLength; validate the given data length ?
jb short rsss_08 ; error (CY), given length is greater than the original length
dec cx ; length available excluding NULL
add si,offset SMBIOS_FUNC52_BUFFER_STRUC.bStructuredata; DS:SI = ptr to structure data containing the new string
; DS:SI = ptr to new string in given structure
; ES:DI = ptr to concerned string in original structure
; CX = available string length excluding NULL terminator in original structure
call copy_string ; update the string to original structure
clc ; ok
rsss_08:
popa
pop ds
pop es
jnc short rsss_cmd_0125_00
pop cx
pop si
pop ds
rsss_02_00:
jmp rsss_02 ; error
rsss_03_00:
jmp rsss_03 ; error
rsss_cmd_012:
cmp al,01h ; command 00h/01h/02h ?
mov edx,ds:dword ptr (SMBIOS_FUNC52_BUFFER_STRUC ptr [si]).dChangeMask ; EDX = AND mask
mov ecx,ds:dword ptr (SMBIOS_FUNC52_BUFFER_STRUC ptr [si]).dChangeValue; EBX = OR mask
mov eax,es:dword ptr [di+bx]; EAX = original content of the field to be changed
ja short rsss_cmd_012_00 ; command 02h
pushf
; (CORE0227)>
; and edx,0000FFFFh ; keep the word
or edx,0FFFF0000h ; keep the word
and ecx,0000FFFFh ; keep the word
popf
jz short rsss_cmd_012_00 ; command 01h
; mov dh,00h ; keep the byte
mov dh,0ffh ; keep the byte
; <(CORE0227)
mov ch,00h ; keep the byte
rsss_cmd_012_00:
and eax,edx ; apply AND mask
or eax,ecx ; apply OR mask
mov es:dword ptr [di+bx],eax; EAX = update content of the field to be changed
rsss_cmd_0125_00:
mov si,di
push es
pop ds ; DS:SI = ptr to work buffer
pop cx ; length of structure
pop di
pop es ; ES:DI = ptr to structure in Shadow RAM
; before changing the data in Shadow RAM,
; check whether the data is actually changed
; if not changed, no need to update Shadow and GPNV (it will save time)
; DS:SI = ptr to updated structure in work buffer
; ES:DI = ptr to original structure in Shadow RAM
; CX = length of the structure
pusha
repz cmps ds:byte ptr [si],es:byte ptr [di]; changed ?
popa
; (CORE0072)>
; jz short rsss_04 ; data not changed
jz rsss_04 ; data not changed
; <(CORE0072)
mov dx,ds:word ptr (DMIHDR_STRUC ptr [si]).wHandle; DX = handel# of structure being changed
mov ax,SMBIOS_SINGLE_STRUCTURE_AFFECTED*256+SMBIOS_ONE_MORE_STRUCTURE_CHANGED
; AH, AL = SMBIOS Change Status, Type
push dx
push ax
push bp
; (CORE0221)>
;; mov bp,F000_READ_X_WRITE_RAM_FUNC; F000 shadow Write enabled
;; call cgroup:dword ptr runtime_interface_routine
;; rep movs es:byte ptr [di],ds:byte ptr [si]; move the data to F000 Shadow
mov bp,offset cgroup:rsss_write_shadow
call gen_smi_for_gpnv
rsss_06:
;; mov bp,FLUSH_ALL_CACHE_FUNC ; flush all cache
;; call cgroup:dword ptr runtime_interface_routine
;; mov bp,F000_READ_RAM_WRITE_ROM_FUNC; F000 shadow Read Only
;; call cgroup:dword ptr runtime_interface_routine
; <(CORE0221)
pop bp
pop ax ; AH, AL = Change Status, Type
pop dx ; DX = handle# of changed structure
call get_ebda ; DS = EBDA
mov xdgroup:smbios_change_status,ah
mov xdgroup:smbios_change_type,al
mov xdgroup:smbios_change_handle,dx
; Shadow RAM is updated with new information
; Update the GPNV
push cs
pop es
movzx edi,cgroup:word ptr (SMB_INTERNAL_DATA_STRUC ptr smbios_internal_data).wSMBStructuresStart; ES:EDI = ptr to start of SMBIOS Date Structures in Shadow RAM
movzx ecx,cgroup:word ptr (SMB_INTERNAL_DATA_STRUC ptr smbios_internal_data).wSMBCurrentStructuresEnd; ES:ECX = ptr to end of SMBIOS Date Structures in Shadow RAM + 1
sub ecx,edi ; ECX = size of SMIBIOS Data Structures in BYTEs
lds si,dword ptr [ebp+06h] ; DS:SI = ptr to scratch buffer
movzx esi,si ; DS:ESI = ptr to scratch buffer
push fs
push gs
mov fs,word ptr [ebp+0Ch] ; FS = Dmi Selector
mov gs,word ptr [ebp+0Eh] ; GS = Bios Selector
; DS:ESI = ptr to scratch buffer long enough to contain the whole GPNA Area
; ES:EDI = ptr to buffer containing the data of the new GPNV area
; ECX = the new GPNV area size in BYTEs
; FS = GPNV Selector
; GS = BIOS Selector
mov bx,gpnv_dmi_data_bit ; attribute for SMBIOS Data Area in GPNV
; (CORE0072+)>
push ds
push ecx
push esi
push fs
pop ds ; ds = GPNV selector
mov ah,get_gpnv_attribute_information_func
call cgroup:dword ptr gpnv_interface_routine; get handle# from attribute
mov dx,gpnv_dmi_data_bit ; attribute for SMBIOS Data Area in GPNV
pop esi
pop ecx
pop ds
jc rsss_10
; <(CORE0072+)
mov ah,update_gpnv_attribute_func ; func#
call cgroup:dword ptr gpnv_interface_routine; update concerned GPNV area
rsss_10:
pop gs
pop fs
jc short rsss_c03_00 ; error in updating GPNV
rsss_04:
popad
xor ax,ax ; successful
rsss_01:
pop ds
pop es
ret
rsss_02:
popad
mov ax,RT_DMI_BAD_PARAMETER
jmp short rsss_01
rsss_03:
popad
mov ax,RT_DMI_INVALID_HANDLE
jmp short rsss_01
rsss_c03_00:
popad
mov ax,RT_DMI_ADD_STRUCTURE_FAILED
jmp short rsss_01
;---------------------------------------;
rsss_cmd_03:
; command 03h..add the structure to the SMBIOS structure pool
; DS:SI = ptr to given DMI data buffer
; check whether the any more handle is available
mov bx,cgroup:word ptr (SMB_INTERNAL_DATA_STRUC ptr smbios_internal_data).wSMBNumRuntimeStruc; #of valid runtime structures
cmp bx,cgroup:word ptr (SMB_INTERNAL_DATA_STRUC ptr smbios_internal_data).wSMBNumRomStruc; handle available ?
jae short rsss_c03_00 ; handle not available, error
; check whether the given new handle# is the handle# of the new structure
push si
add si,offset SMBIOS_FUNC52_BUFFER_STRUC.dStructureHeader; DS:SI = ptr to new structure header
cmp bx,ds:word ptr (DMIHDR_STRUC ptr [si]).wHandle; given handle# matches ?
pop si
jnz short rsss_03 ; invalid handle
; handle available, check whether the required space is available
mov ax,cgroup:word ptr (SMB_INTERNAL_DATA_STRUC ptr smbios_internal_data).wSMBAvailableStructuresEnd; ptr to end of available structures space + 1
mov di,cgroup:word ptr (SMB_INTERNAL_DATA_STRUC ptr smbios_internal_data).wSMBCurrentStructuresEnd; DI = ptr to current structures end + 1
sub ax,di ; AX = space available in bytes
jbe short rsss_c03_00 ; space not available
; BX = #of valid runtime structures
; AX = #of bytes available for the new structure
; CS:DI = ptr to current structures end + 1
; DS:SI = ptr to given DMI data buffer
mov cx,ds:word ptr (SMBIOS_FUNC52_BUFFER_STRUC ptr [si]).wDataLength; new struc length in bytes
cmp ax,cx ; availabe space enough for the new structure ?
jb short rsss_c03_00 ; available space not enough for the new structure
add si,offset SMBIOS_FUNC52_BUFFER_STRUC.dStructureHeader; DS:SI = ptr to start of new structure
push cs
pop es
; BX = #of valid runtime structures
; CX = new structure length in bytes
; ES:DI = ptr to current structures end + 1
; DS:SI = ptr to new structure
mov dx,ds:word ptr (DMIHDR_STRUC ptr [si]).wHandle; DX = handel# of structure being changed
mov ax,SMBIOS_SINGLE_STRUCTURE_AFFECTED*256+SMBIOS_ONE_MORE_STRUCTURE_ADDED
; AH, AL = SMBIOS Change Status, Type
push dx
push ax
push bp
; (CORE0221)>
;; mov bp,F000_READ_X_WRITE_RAM_FUNC; F000 shadow Write enabled
;; call cgroup:dword ptr runtime_interface_routine
;; push cx
;; rep movs es:byte ptr [di],ds:byte ptr [si]; add the new structure to F000 Shadow
;; pop cx
;;; BX = #of valid runtime structures
;;; ES:DI = ptr to updated structures end + 1
;;; CX = new structure length in bytes
;;; update necessary parameters
;; mov cgroup:word ptr (SMB_INTERNAL_DATA_STRUC ptr smbios_internal_data).wSMBCurrentStructuresEnd,di; update ptr to current structures + 1
;; inc bx ; #of valid runtime structures
;; mov cgroup:word ptr (SMB_INTERNAL_DATA_STRUC ptr smbios_internal_data).wSMBNumRuntimeStruc,bx; update #of valid runtime structures
;; push cs
;; pop ds
;; mov si,offset cgroup:smbios_table_entry_point_struc; DS:SI = ptr to SMBIOS Table Entry
;;; DS:SI = ptr to SMBIOS Table Entry Point Structure
;; mov ds:word ptr (SMB_TABLE_HEADER_STRUC ptr [si]).wNumSMBStruc,cx; update total #of data structures
;; cmp cx,ds:word ptr (SMB_TABLE_HEADER_STRUC ptr [si]).wMaxStrucSize; max structure size changed ?
;; jbe short rsss_c03_01 ; max structure size does not change
;; mov ds:word ptr (SMB_TABLE_HEADER_STRUC ptr [si]).wMaxStrucSize,cx; update max structure size
;;rsss_c03_01:
;;; DS:SI = ptr to SMBIOS Table Entry Point Structure
;;; update the checksum in SMBIOS Table Entry Point
;; call update_ieps_checksum ; update checksum in IEPS
;; call update_eps_checksum ; update checksum in EPS
push bp
mov bp,offset cgroup:rsss_add_struc
call gen_smi_for_gpnv
pop bp
; <(CORE0221)
jmp rsss_06
;---------------------------------------;
rsss_cmd_04:
; command 04h..delete the structure from the SMBIOS structure pool
; DS:SI = ptr to given DMI data buffer
; check whether the given structure exists
add si,offset SMBIOS_FUNC52_BUFFER_STRUC.dStructureHeader; DS:SI = ptr to new structure header
mov cx,ds:word ptr (DMIHDR_STRUC ptr [si]).wHandle; given handle#
; CX = handle# (0-based) of the given structure
push cx
call get_structure_details ; get the concerned structure details in RAM
pop dx
; DS:SI = ptr to start of concerned structure
; CX = structure length including terminator
; DX = handle# of the structure to be deleted
push ds
pop es
mov di,si ; ES:DI = ptr to concerned structure in RAM
jnc short rsss_c04_01 ; structure exists
jmp rsss_03 ; error, structure does not exist
rsss_c04_01:
; ES:DI = ptr to start of concerned structure in RAM to be deleted
; CX = length including terminator of the concerned structure in RAM to be deleted
; DX = handle# of the structure to be deleted
push ds
call get_ebda ; DS = EBDA
mov ah,xdgroup:smbios_change_status; AH = SMBIOS Change Status
mov al,xdgroup:smbios_change_type; AL = SMBIOS Change Type
mov dx,xdgroup:smbios_change_handle; DX = SMBIOS Change Handle
pop ds
push dx
push ax
push bp
; (CORE0221)>
;; mov bp,F000_READ_X_WRITE_RAM_FUNC; F000 shadow Write enabled
;; call cgroup:dword ptr runtime_interface_routine
;; mov bx,cgroup:word ptr (SMB_INTERNAL_DATA_STRUC ptr smbios_internal_data).wSMBCurrentStructuresEnd; BX = ptr to current structures end + 1
;; push bx
;; sub bx,cx ; update current structures end + 1 after deletion
;; mov cgroup:word ptr (SMB_INTERNAL_DATA_STRUC ptr smbios_internal_data).wSMBCurrentStructuresEnd,di; update current structures end + 1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -