📄 form1.frm
字号:
' firstOp = Asc(Right$(lstFileCont.List(I), 1))
' CommName = OpCodes(firstOp, -1, 1) ' Is there a Single Main Opcode
' OperandsTypes = OpCodes(firstOp, -1, 0)
' AssListIdx = I
' If CommName = "" Then ' Get second Opcode
' I = I + 1 ' hmmm
' secOp = Asc(Right$(lstFileCont.List(I), 1)) ' Is there a second Opcode
' CommName = OpCodes(firstOp, secOp, 1)
' OperandsTypes = OpCodes(firstOp, secOp, 0)
' If CommName = "" Then
' CommName = "Unknown Opcode " & Hex(Asc(Right$(lstFileCont.List(I - 1), 1))) & "h"
' I = I - 1
' Else
' Stop ' temp 486+ ?
' End If
' Else
' secOp = -1
' End If
'
'
'
'
'
' If Left$(CommName, 4) = "Unkn" Then
' lstFileCont.ItemData(I) = lstAssembly.ListCount ' For the mouse click
' DisplayComm = CommName
'
' Else '''''''' Get Operand(s) list - normally 1
'
' ' Optain Main Descriptive command
' LinePos = InStr(1, CommName, " ")
' If LinePos = 0 Then LinePos = Len(CommName) + 1 ' In case its a singlular command - unlightly
' DisplayComm = Mid$(CommName, 1, LinePos - 1) & " "
' 'If firstOp = 233 Then Stop
'
'
' ' Get next parameter to see if its a register name
' LinePos2 = InStr(LinePos + 1, CommName, ",")
' If LinePos2 = 0 Then LinePos2 = Len(CommName) + 1 ' In case its a the last command
' tmpRegName = Mid$(CommName, LinePos + 1, LinePos2 - LinePos - 1)
'
' Select Case tmpRegName
' Case "AL", "AH", "BL", "BH", "CL", "CH", "DL", "DH": DisplayComm = DisplayComm & tmpRegName & "," ' 8
' Case "AX", "BX", "CX", "DX", "CS", "DS", "SS", "ES", "FS", "GS", "BP", "SI", "DI", "SP": DisplayComm = DisplayComm & tmpRegName & "," ' 16
' Case "EAX", "EBX", "ECX", "EDX", "ESI", "EDI", "EBP", "ESP", "EIP": DisplayComm = DisplayComm & tmpRegName & "," ' 32
' Case "MM0", "MM1", "MM2", "MM3", "MM4", "MM5", "MM6", "MM7": DisplayComm = DisplayComm & tmpRegName & "," ' 64
' Case "XMM0", "XMM1", "XMM2", "XMM3", "XMM4", "XMM5", "XMM6", "XMM7", "MXCSR": DisplayComm = DisplayComm & tmpRegName & "," ' 128
' Case "CR0", "CR1", "CR2", "CR3", "CR4", "GDTR", "LDTR", "IDTR": DisplayComm = DisplayComm & tmpRegName & "," ' 32(CRs)
' Case "DR0", "DR1", "DR2", "DR3", "DR6", "DR7": DisplayComm = DisplayComm & tmpRegName & "," ' Debug resisters ' 32 ?
' Case "MSR": DisplayComm = DisplayComm & tmpRegName & "," ' "MXCRS"
' 'EFLAGS = 32 bit
' End Select
'
'
'
'
'
' II = 0
' Do
' ' Operand types chopup
' ReDim Preserve Comms(1, II) As String
' LinePos = InStr(1, OperandsTypes, " ")
' If LinePos = 0 Then LinePos = Len(OperandsTypes) + 1
' Comms(1, II) = Mid$(OperandsTypes, 1, LinePos - 1)
' OperandsTypes = Mid$(OperandsTypes, LinePos + 1)
'
'
'
'
' ' Get Operand value size
' III = 0
' Select Case Comms(1, II)
' Case "cb", "ib": III = 1
' Case "cw", "iw", "+rw": III = 2
' Case "cd", "id", "+rd": III = 4
' Case "/r": III = 1 ''''''''''
' 'Case "/#" '''''''''
' End Select
' For IIII = 1 To III
' DisplayComm = DisplayComm & ConvBin2Hex(Right$(lstFileCont.List(I + IIII), 1)) ' Get Operands X bytes
' lstFileCont.ItemData(I + II) = lstAssembly.ListCount ' For the mouse click
' Next IIII
' If III > 0 Then DisplayComm = DisplayComm & "," ' Add a display comma
'
'
'
' 'II = II + III + 1
' Loop Until OperandsTypes = ""
' DisplayComm = Left$(DisplayComm, Len(DisplayComm) - 1) ' Remove last comma
' End If
End Sub
Private Function FormatStr(Num As Long, TheLen As Byte) As String
Dim HexVal As String
HexVal = Hex(Num)
FormatStr = String(TheLen - Len(HexVal), "0") & HexVal
End Function
Private Function ProcessOperands(NextFilePos As Long, Operands As String, OpcodeListNum As Long) As Long
On Error Resume Next
Dim I As Long
Dim DisplayComm As String ' What appears in the list box
Dim tmpRegName As String
Dim OperandNum As Byte, tmpVal As Byte, BitsToUse As Byte
AssListClick = NextFilePos ' Save for the mouse click
' Obtain Main Descriptive command
LinePos = InStr(1, OpCodes(1, OpcodeListNum), " ")
If LinePos = 0 Then LinePos = Len(OpCodes(1, OpcodeListNum)) + 1 ' In case its a singlular command - unlightly
DisplayComm = Mid$(OpCodes(1, OpcodeListNum), 1, LinePos - 1) & " "
'If DisplayComm <> "MOV " Then Stop
' Get next parameters to see if its a register name
For LinePos = LinePos + 1 To Len(OpCodes(1, OpcodeListNum))
LinePos2 = InStr(LinePos, OpCodes(1, OpcodeListNum), ",")
If LinePos2 = 0 Then LinePos2 = Len(OpCodes(1, OpcodeListNum)) + 1 ' In case its the last command
tmpRegName = Mid$(OpCodes(1, OpcodeListNum), LinePos, LinePos2 - LinePos)
LinePos = LinePos2
If IsOperandARegister(tmpRegName) = True Then ' Is Operand A Register
DisplayComm = DisplayComm & tmpRegName & ","
ElseIf Left$(tmpRegName, 1) = "m" Then ' Grab imediate bytes
Select Case tmpRegName
Case "m8": DisplayComm = DisplayComm & "ES:DI," ' Might need a "E" in there
Case "m16": DisplayComm = DisplayComm & "ES:EDI,"
Case "m32", "m32fp": DisplayComm = DisplayComm & "ES:EDI,"
Case "m", "moffs8*: DoTimes = 1" ' Offsets
Case "moffs16*": DoTimes = 2
Case "moffs32*": DoTimes = 4
'Case Else: Stop
End Select
'ElseIf Left$(tmpRegName, 1) = "i" Then
'Stop
Else ' Get byte(s) from file
DoTimes = 0
Select Case Mid$(Operands, (OperandNum * 2) + 1, 1)
Case "i", "c" ' Straight values from the file, might need to change
Select Case Mid$(Operands, (OperandNum * 2) + 2, 1)
Case "b": DoTimes = 1
Case "w": DoTimes = 2
Case "d": DoTimes = 4
Case "p": DoTimes = 6 ' Theres no 'ip'
End Select
Case "/" ' Use the byte as register locations
If InStr(1, OpCodes(1, OpcodeListNum), "8") Then ' Checks the display name field for number of displacement bytes
BitsToUse = 8
ElseIf InStr(1, OpCodes(1, OpcodeListNum), "16") Then
BitsToUse = 16
ElseIf InStr(1, OpCodes(1, OpcodeListNum), "32") Then
BitsToUse = 32
'Else
' Stop
End If
tmpVal = CByte(CLng("&H" & Mid$(lstFileCont.List((NextFilePos) + 1), 7, 2))) ' Conv HEX to ASC from File List box
DisplayComm = DisplayComm & UnScrableModRMByte(NextFilePos, tmpVal, BitsToUse) ' Process the "/r" byte
If InStr(1, DisplayComm, ",") Then OperandNum = OperandNum + 2
Case "+": DoTimes = 1
Case "" ' Read of Display part of the OpCodes to make sure theres no more commands
If Operands = "" And Left$(tmpRegName, 3) = "imm" Then
Select Case Mid$(tmpRegName, 4)
Case "8": DoTimes = 1
Case "16": DoTimes = 2
Case "32": If optBit(0).Value = True Then DoTimes = 2 Else DoTimes = 4 ' 16/32 Bit Mode
End Select
'Else
' Stop
End If
'Case Else
' If Mid$(Operands, (OperandNum * 2) + 1, 1) <> "q" Then Stop
' Stop
End Select
End If
For I = DoTimes To 1 Step -1 ' Get bytes from the File list as the raw data/numbers - reading backward possibly because its Intel byte alignment
DisplayComm = DisplayComm & Mid$(lstFileCont.List((NextFilePos) + I), 7, 2)
lstFileCont.ItemData(NextFilePos + I - 1) = lstAssembly.ListCount ' For the mouse click
Next I
If Left$(tmpRegName, 3) = "rel" Then ' Relitive jump check
DisplayComm = DisplayComm & "(+" & Hex(NextFilePos + DoTimes + 1) & ")"
End If
'DisplayComm = DisplayComm & ","
OperandNum = OperandNum + DoTimes
Next LinePos
ProcessOperands = NextFilePos + DoTimes
If Right$(DisplayComm, 1) = "," Then DisplayComm = Left$(DisplayComm, Len(DisplayComm) - 1) ' Remove last comma
lstAssembly.AddItem DisplayComm ' Display Ass Code
AssListClickInfo(lstAssembly.NewIndex) = OpcodeListNum
lstAssembly.ItemData(lstAssembly.NewIndex) = AssListClick
For I = AssListClick To ProcessOperands
lstFileCont.ItemData(I) = lstAssembly.NewIndex
Next I
End Function
Private Function IsOperandARegister(strValue As String) As Boolean
Select Case strValue
Case "AL", "AH", "BL", "BH", "CL", "CH", "DL", "DH": IsOperandARegister = True ' 8
Case "AX", "BX", "CX", "DX", "CS", "DS", "SS", "ES", "FS", "GS", "BP", "SI", "DI", "SP": IsOperandARegister = True ' 16
Case "EAX", "EBX", "ECX", "EDX", "ESI", "EDI", "EBP", "ESP", "EIP": IsOperandARegister = True ' 32
Case "MM0", "MM1", "MM2", "MM3", "MM4", "MM5", "MM6", "MM7": DisplayComm = IsOperandARegister = True ' 64
Case "XMM0", "XMM1", "XMM2", "XMM3", "XMM4", "XMM5", "XMM6", "XMM7", "MXCSR": IsOperandARegister = True ' 128
Case "CR0", "CR1", "CR2", "CR3", "CR4", "GDTR", "LDTR", "IDTR": IsOperandARegister = True ' 32(CRs)
Case "DR0", "DR1", "DR2", "DR3", "DR6", "DR7": IsOperandARegister = True ' Debug registers ' 32 ?
Case "MSR": IsOperandARegister = True ' "MXCRS"
'EFLAGS = 32 bits
End Select
End Function
'Private Function IsOperandaMemoryLocation(strValue As String) As Boolean
' Select Case strValue
' Case "m8", "m16", "m32": IsOperandaMemoryLocation = True
' Case "r/m8", "r/m16", "r/m32": IsOperandaMemoryLocation = True
' End Select
'End Function
Private Function UnScrableModRMByte(FilePos As Long, TheByte As Byte, Bits As Byte) As String ' Displacement As String,
' 7 6 5 3 2 0 \
' Mod Reg/ R/M | 1 Byte
' Opcode /
Dim RM As Byte, Modd As Byte, Reg As Byte
If (TheByte Xor 1) < TheByte Then RM = 1
If (TheByte Xor 2) < TheByte Then RM = RM + 2
If (TheByte Xor 4) < TheByte Then RM = RM + 4
If (TheByte Xor 8) < TheByte Then Reg = 1
If (TheByte Xor 16) < TheByte Then Reg = Reg + 2
If (TheByte Xor 32) < TheByte Then Reg = Reg + 4
If (TheByte Xor 64) < TheByte Then Modd = 1
If (TheByte Xor 128) < TheByte Then Modd = Modd + 2
Select Case Bits
'Case 8: Stop ' 16
Case 16: tmpVal = 0
Case 32: tmpVal = 1
End Select
BytesToGrab = RMByteInfo(Modd, RM, tmpVal) ' Loaded from the files "ModRM ByteXX.info"
If Right$(BytesToGrab, 1) = "8" Then
DoTimes = 1
ElseIf Right$(BytesToGrab, 2) = "16" Then
DoTimes = 2
ElseIf Right$(BytesToGrab, 2) = "32" Then
DoTimes = 4
'Else
' Stop
End If
WordDISPPos = InStr(1, BytesToGrab, "disp")
If WordDISPPos > 0 Then
UnScrableModRMByte = Left$(BytesToGrab, WordDISPPos - 1)
Else
UnScrableModRMByte = BytesToGrab
End If
For I = 1 To DoTimes
UnScrableModRMByte = UnScrableModRMByte & Mid$(lstFileCont.List((FilePos + 1) + I), 7, 2)
'lstFileCont.ItemData(NextFilePos + I) = lstAssembly.ListCount ' For the mouse click
Next I
FilePos = FilePos + I
Select Case Bits
Case 8
Select Case Reg
Case 0: RegToAddOn = "AL"
Case 1: RegToAddOn = "CL"
Case 2: RegToAddOn = "DL"
Case 3: RegToAddOn = "BL"
Case 4: RegToAddOn = "AH"
Case 5: RegToAddOn = "CH"
Case 6: RegToAddOn = "DH"
Case 7: RegToAddOn = "BH"
End Select
Case 16, 32
Select Case Reg
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -