⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 可以输入PC下编译的软件
💻 FRM
📖 第 1 页 / 共 3 页
字号:
        Case 0: RegToAddOn = "AX"
        Case 1: RegToAddOn = "CX"
        Case 2: RegToAddOn = "DX"
        Case 3: RegToAddOn = "BX"
        Case 4: RegToAddOn = "SP"
        Case 5: RegToAddOn = "BP"
        Case 6: RegToAddOn = "SI"
        Case 7: RegToAddOn = "DI"
        End Select
    End Select
    If Bits = 32 Then RegToAddOn = "E" & RegToAddOn ' Add on "E" to indicate a 32 bit register
    
    UnScrableModRMByte = UnScrableModRMByte & "," & RegToAddOn
    
        ' More to do
        'r8(/r)                  AL      CL      DL      BL      AH      CH      DH      BH
        'r16(/r)                 AX      CX      DX      BX      SP      BP1     SI      DI
        'r32(/r)                 EAX     ECX     EDX     EBX     ESP     EBP     ESI     EDI
        'mm(/r)                  MM0     MM1     MM2     MM3     MM4     MM5     MM6     MM7
        'xmm(/r)                 XMM0    XMM1    XMM2    XMM3    XMM4    XMM5    XMM6    XMM7
        '/digit (Opcode)         0       1       2       3       4       5       6       7
End Function

Private Function ConvBin2Hex(Bin As String) As String
    Dim I As Long
    Dim tmpHex As String
    
    For I = 1 To Len(Bin)
        tmpHex = Hex$(Asc(Mid$(Bin, I, 1)))
        ConvBin2Hex = ConvBin2Hex & String(2 - Len(tmpHex), "0") & tmpHex
    Next I
End Function

Private Sub cmdSaveFile_Click()
    On Error Resume Next ' Required
    
    CommonDialog.FileName = Mid$(CommonDialog.FileName, 1, InStrRev(CommonDialog.FileName, ".") - 1) & ".asm"
    
    CommonDialog.DialogTitle = "Select a File name to Save"
    CommonDialog.ShowSave
    If Err Then Exit Sub
    
    Dim I As Long
    
    Open CommonDialog.FileName For Output As #5
    For I = 0 To lstAssembly.ListCount - 1
        If Left$(lstAssembly.List(I), 7) = "Unknown" Then
            Print #5, "DB " & Right$(lstAssembly.List(I), 2)
        ElseIf InStr(1, lstAssembly.List(I), "(") Then
            Print #5, Left$(lstAssembly.List(I), InStr(1, lstAssembly.List(I), "(") - 1)
        Else
            Print #5, lstAssembly.List(I)
        End If
    Next I
    Close #5
End Sub

Private Sub Form_Load()
    ' Dump the file contents into an big array
    If Dir(App.Path & "\Opcode List.info") = "" Then MsgBox "File 'Opcode List.info' missing", vbCritical, "Error": End
    
    
    
    On Error Resume Next
    'ReDim OpCodes(255, -1 To 255, -1 To 255, 2) As String ' Most is wasted space
    ReDim OpCodes(2, 0) As String ' Some wasted space
    
    'First part
        '0=Opcode Name & Operands (4 Display)
        '1=Description (4 Display)
    'Second part
        'Stores Opcodes in Base 16(HEX), 1 or 2 opcodes normally, rarely 3 opcodes
        'also register type details (also in 2 digites), eg. /4 /7 +i
    
    ' The File is tab delimted into 3 fields Opcodes, Opcode Display Name, Description
    
    
    
    Dim fileLine As String ' Current line from the info file
    Dim firstOp As Long, secndOp As String, thirdOp As String ' Temporary opcode varables
    Dim I As Long ' Loop counter
    Dim testStr As String
    
    
    Open App.Path & "\Opcode List.info" For Input As #1 ' Counted at 1,172 lines
    Do
        
Skipper:
        Line Input #1, fileLine
        If Left$(fileLine, 1) = ";" Then GoTo Skipper
        
        
        ReDim Preserve OpCodes(2, I) As String
        For II = 1 To InStr(1, fileLine, Chr$(9)) - 1 Step 3
            OpCodes(0, I) = OpCodes(0, I) & Mid$(fileLine, II, 2) ' Save Opcodes of the line
        Next II
        
        
        
        ' Save Codes Name & Descriptions
        LinePos = InStr(1, fileLine, Chr(9)) ' Ignores the first field
        LinePos2 = InStr(LinePos + 1, fileLine, Chr(9))
        OpCodes(1, I) = Mid$(fileLine, LinePos + 1, LinePos2 - LinePos - 1) ' Save second field
        OpCodes(2, I) = Mid$(fileLine, LinePos2 + 1) ' And the third
        
        
        
        ' Can ignore all this comment stuff - eairly attempts
        
        'secndOp = ""
        'thirdOp = ""
        'firstOp = CLng("&H" & Left$(fileLine, 2))
        'secndOp = Mid$(fileLine, 4, 2) ' Get probabal second Opcode
        'thirdOp = Mid$(fileLine, 7, 2)
        'testStr = Trim$(Mid$(fileLine, 4, 3)) ' Get second parameter to check for 2nd Opcode
        
        
        
        ' Save operand(s)
        'secOp = CLng("&H" & testStr) ' Convert to Decimal, purposly can error
        'If Len(testStr) = 2 And testStr = UCase$(testStr) And testStr = Hex(secOp) Then  ' Check for a valid 2nd Opcode (crude)
        '    secOp = secOp
        '    OpCodes(firstOp, secOp, 0) = Mid$(fileLine, 7, InStr(fileLine, Chr(9)) - 7) ' Set avalible Operand(s)
        'Else
        '    secOp = -1
        '    OpCodes(firstOp, secOp, 0) = Mid$(fileLine, 4, InStr(fileLine, Chr(9)) - 4) ' Set avalible Operand(s)
        'End If
        
        
        
        ' Save Codes Name & Descriptions
        'LinePos = InStr(1, fileLine, Chr(9)) ' Ignores the first field
        'LinePos2 = InStr(LinePos + 1, fileLine, Chr(9))
        'OpCodes(firstOp, secOp, 1) = Mid$(fileLine, LinePos + 1, LinePos2 - LinePos - 1) ' Save second field
        'OpCodes(firstOp, secOp, 2) = Mid$(fileLine, LinePos2 + 1) ' And the third
        
        
        
        ' If the codes have a +i +rb +rd ... then make new Opcode fields with register names
        'PlusPosition = InStr(1, Mid$(fileLine, 1, InStr(1, fileLine, Chr$(9))), "+") ' Is the + within the first Opcode field area
        'If PlusPosition > 0 Then
        '    'Stop
        '    For I = 0 To 7
        '        ' load in opcodes with register names **************
        '        ' Now just changing the loading file
        '    Next I
        '    ExtendTheOpcode = False
        'End If
        
        I = I + 1
    Loop Until EOF(1)
    Close #1
    
    
    
    
    
    
    
    
    ' Now load in RMMod Byte information
    ' RMByteInfo(3, 7, 1) - 1st=Mod, 2nd=R/M, 3rd=16/32Bit
    Open App.Path & "\ModRM Byte16.info" For Input As #2
    For I = 0 To 3
        For II = 0 To 7
            Line Input #2, fileLine
            RMByteInfo(I, II, 0) = Mid$(fileLine, InStrRev(fileLine, Chr$(9)) + 1)
        Next II
    Next I
    Close #2
    
    Open App.Path & "\ModRM Byte32.info" For Input As #3
    For I = 0 To 3
        For II = 0 To 7
            Line Input #3, fileLine
            RMByteInfo(I, II, 1) = Mid$(fileLine, InStrRev(fileLine, Chr$(9)) + 1)
        Next II
    Next I
    Close #3
    
    
    
    Me.Show
    If Command <> "" Then CommonDialog.FileName = Command: cmdLoadFile_Click
    
    
    
    'On Error GoTo 0
    'CommonDialog.FileName = "test.co_"
    'cmdLoadFile_Click
End Sub

Private Sub lstAssembly_Click()
    If lstAssembly.ListIndex = -1 Then Exit Sub
    
    lstFileCont.ListIndex = lstAssembly.ItemData(lstAssembly.ListIndex)
    
    
    
    Dim tmpStr As String, PrefixWarn As String
    
    tmpStr = Mid$(lstFileCont.List((lstFileCont.ListIndex) + I), 7, 2)
    Select Case tmpStr ' Look for Instruction Prefixes
    Case "F0", "F2", "F3", "2E", "36", "3E", "26", "64", "65", "66", "67"
        PrefixWarn = "Possible Instruction Prefix, will be treated as a normal instruction." & _
        vbCrLf & String(15, "-") & vbCrLf
    End Select
    
    If AssListClickInfo(lstAssembly.ListIndex) = -1 Then
        txtCodeDesc = PrefixWarn & "Unknown Command " & tmpStr & vbCrLf & vbCrLf & _
                      "Possibly part of a string along with the commands above and below" & vbCrLf & vbCrLf & _
                      "Will be saved as a byte string:" & vbCrLf & """DB " & tmpStr & """"
        
    Else
        txtCodeDesc = PrefixWarn & "Parameter(s) Type:" & vbCrLf & _
                      OpCodes(0, AssListClickInfo(lstAssembly.ListIndex)) & _
                      vbCrLf & String(15, "-") & vbCrLf & _
                      OpCodes(1, AssListClickInfo(lstAssembly.ListIndex)) & _
                      vbCrLf & String(15, "-") & vbCrLf & "Description:" & vbCrLf & _
                      OpCodes(2, AssListClickInfo(lstAssembly.ListIndex)) & vbCrLf
    End If
End Sub

Private Sub lstAssembly_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If lstAssembly.ListIndex = -1 Then Exit Sub
    
    
    
    If Button = 2 Then ' To display the right click menu
        tmpStr = OpCodes(1, AssListClickInfo(lstAssembly.ListIndex))
        If InStr(1, tmpStr, "rel") Then mnuJump.Enabled = True Else mnuJump.Enabled = False
        Me.PopupMenu mnuPopup
    End If
End Sub

Private Sub lstFileCont_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If lstFileCont.ListIndex = -1 Then Exit Sub
    
    lstAssembly.ListIndex = lstFileCont.ItemData(lstFileCont.ListIndex)
End Sub

Private Sub mnuJump_Click()
    On Error Resume Next
    Dim tmpStr As String, strCommand As String
    Dim JumpNum As Long
    Dim StringPos As Long
    
    tmpStr = OpCodes(1, AssListClickInfo(lstAssembly.ListIndex))
    strCommand = Mid$(lstAssembly.List(lstAssembly.ListIndex), InStr(1, lstAssembly.List(lstAssembly.ListIndex), " ") + 1) ' Trimmed of command name
    
    StringPos = InStr(1, strCommand, "(")
    JumpNum = CLng("&H" & Left$(strCommand, StringPos - 1)) ' Get main jump number
    JumpNum = JumpNum + CLng("&H" & Mid$(strCommand, StringPos + 2, Len(strCommand) - StringPos - 2)) ' Get added on number
    lstFileCont.ListIndex = JumpNum                         ' Jump with relitive command
    lstFileCont_MouseUp 0, 0, 0, 0                          ' Update other boxes
    
    If Err Then MsgBox "Can not jump to location," & vbCr & "Possibly part of a string or not all the file was loaded", vbExclamation, "Error"
End Sub

Private Sub optOffset_Click(Index As Integer)
    Select Case Index
    Case 0: txtOffset = "7C00": optBit(0).Value = True
    Case 1: txtOffset = "0100": optBit(0).Value = True
    Case 2: txtOffset = "0000": optBit(0).Value = True
    End Select
End Sub

Private Sub txtOffset_KeyPress(KeyAscii As Integer)
    optOffset(3).Value = True
End Sub

'Private Function RegisterNames(TipeOfVar As String, Numbar As Byte) As String '   +rb   +rw   +rd
'    Select Case TipeOfVar
'    Case "rb"
'        Select Case Numbar
'        Case 0: RegisterNumber = "AL"
'        Case 1: RegisterNumber = "CL"
'        Case 2: RegisterNumber = "DL"
'        Case 3: RegisterNumber = "BL"
'        Case 4: RegisterNumber = "AH"
'        Case 5: RegisterNumber = "CH"
'        Case 6: RegisterNumber = "DH"
'        Case 7: RegisterNumber = "BH"
'        End Select
'    Case "rw"
'        Select Case Numbar
'        Case 0: RegisterNumber = "AX"
'        Case 1: RegisterNumber = "CX"
'        Case 2: RegisterNumber = "DX"
'        Case 3: RegisterNumber = "BX"
'        Case 4: RegisterNumber = "SP"
'        Case 5: RegisterNumber = "BP"
'        Case 6: RegisterNumber = "SI"
'        Case 7: RegisterNumber = "DI"
'        End Select
'    Case "rd"
'        Select Case Numbar
'        Case 0: RegisterNumber = "EAX"
'        Case 1: RegisterNumber = "ECX"
'        Case 2: RegisterNumber = "EDX"
'        Case 3: RegisterNumber = "EBX"
'        Case 4: RegisterNumber = "ESP"
'        Case 5: RegisterNumber = "EBP"
'        Case 6: RegisterNumber = "ESI"
'        Case 7: RegisterNumber = "EDI"
'        End Select
'    End Select
'End Function

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -