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

📄 extractrsrc.asm

📁 这是用win32汇编编写的资源编辑器
💻 ASM
📖 第 1 页 / 共 5 页
字号:
      mov     ImageOn, 1

;---------- [Check for mult same type images] ----------
         .if !eax && szWork1
               mov     edx, ebx
               xor     edi, edi
            .while (ecx)
                  mov     al, byte ptr[esi+edx+40]
               .if al == byte ptr szWork1[edi]
               .else
                     xor     eax, eax
                  .break
               .endif
                  inc     edx
                  inc     edi
                  dec     ecx
            .endw
            .if !ecx
                  mov     eax, 44
                  mov     ID, eax
            .endif
         .endif

;---------- [Load the resource name in the tree] ----------
         .if eax != ID || !eax
               mov     ID, eax
            .if !eax
                  lea     ecx, [esi+ebx+40]                  ; Named ID for GIF, WAVE, etc.
            .else
                  dec     eax
                  mov     ecx, RsrcArray[eax*4]
            .endif
               mov     tvis.item.pszText, ecx
             MOVmd     tvis.hParent, hParent
               mov     tvis.item.lParam, 0
            INVOKE     lstrcpy, addr szWork1, ecx
            INVOKE     SendMessage, hWndTree, TVM_INSERTITEM, 0, addr tvis
               mov     hChild, eax
               mov     tvis.hParent, eax
         .endif

;---------- [Load the resource ID in the tree] ----------
            mov     esi, RsrcInfo                            ; Resource array
            mov     ebx, OffPosID
;          MOVmd     tvis.item.lParam, dword ptr[esi+ebx+8]  ; Actual address of the resource
          MOVmd     tvis.item.lParam, dword ptr[esi+ebx+36]  ; Offset address in the RsrcInfo structure
            mov     eax, dword ptr[esi+ebx+4]                ; ID
         .if eax != 6969 && eax != 4848
               INVOKE     wsprintf, addr szWork, addr fmat2, dword ptr[esi+ebx+4]
         .else
            .if eax == 6969
                  lea     ecx, [esi+ebx+40]                    ; Named ID
            .else
                  lea     ecx, [esi+ebx+72]                    ; Named ID of image
            .endif
            INVOKE     lstrcpy, addr szWork, ecx
         .endif
            lea     eax, szWork
            mov     tvis.item.pszText, eax
         INVOKE     SendMessage, hWndTree, TVM_INSERTITEM, 0, OFFSET tvis
.endif
            add     OffPosID, 104
            dec     CntID
      .endw

      INVOKE     lstrcpy, MemRsrc, addr szNULL

      INVOKE     LoadCursor, 0, IDC_WAIT
      INVOKE     SetCursor, eax

         and     NumofDlgs, 0
       MOVmd     CntID, NumOfMatchIDs
         and     OffPosID, 0

      .while (CntID)
            mov     esi, RsrcInfo                            ; Resource array
            mov     ebx, OffPosID
            mov     eax, dword ptr[esi+ebx]
            mov     edx, dword ptr[esi+ebx+8]                ; Actual address of the resource
            mov     SavAddr, edx
            mov     edx, dword ptr[esi+ebx+12]               ; Size of resource
            mov     RsrcSize, edx

         .if eax == 4
              call     RsrcMenu
         .elseif eax == 5
              call     RsrcDialog
         .elseif eax == 6
              call     RsrcString
         .elseif eax == 9
              call     RsrcAccelerator
         .elseif eax == 10
;              call     RsrcRCData
         .elseif eax == 11
              call     RsrcMessage
         .elseif eax == 16
              call     RsrcVersion
         .endif
            add     OffPosID, 104
            dec     CntID
      .endw
      .if ImageOn
         INVOKE     ShowWindow, hStatic402, SW_SHOW
         INVOKE     ShowWindow, hStatic403, SW_SHOW
         INVOKE     ShowWindow, hWndTree, SW_SHOW
      .endif
      INVOKE     SetFocus, hREdit
         jmp     ExtractRsrcDone

NoDialogs:
      INVOKE     SendMessage, hREdit, WM_SETTEXT, FALSE, addr szNULL
      INVOKE     MessageBox, hWnd, addr szError7, addr AppName, MB_OK
         jmp     ExtractRsrcDone

NoRsrc:
      INVOKE     SendMessage, hREdit, WM_SETTEXT, FALSE, addr szNULL
      .if CompressOn
         INVOKE     MessageBox, hWnd, addr szError3, addr AppName, MB_OK
      .else
         INVOKE     MessageBox, hWnd, addr szError8, addr AppName, MB_OK
      .endif

ExtractRsrcDone:
      INVOKE     LoadCursor, 0, IDC_ARROW
      INVOKE     SetCursor, eax
         mov     eax, FALSE                                  ; Return with FALSE

         ret
ExtractRsrc ENDP

;=======================================
; Extract Miscellaneous Resources
;=======================================
RsrcMisc PROC  uses ebx esi edi
LOCAL    Cnt:DWORD, Cnt1, Len, CntID, BytesOut
LOCAL    szWork1[128]:BYTE, szWork2[128]:BYTE

;      INVOKE     SendMessage, hREdit, WM_SETTEXT, FALSE, addr szNULL

         mov     esi, SavAddr
         mov     edi, MemRsrc
         mov     ecx, RsrcSize
         mov     SavSize, ecx
      .while (ecx)
            mov     al, byte ptr[esi]
            mov     byte ptr[edi], al
            inc     esi
            inc     edi
            dec     ecx
      .endw
         mov     byte ptr[edi], 0

         mov     ecx, MemRsrc
      .if dword ptr [ecx] == '8FIG'
            mov     PictID, 61
         INVOKE     lstrcpy, addr szType, addr szGif+2
      .elseif dword ptr[ecx+6] == 'FIFJ'
            mov     PictID, 62
         INVOKE     lstrcpy, addr szType, addr szJpg+2
      .elseif dword ptr[ecx+72h] == 'PPNT' || dword ptr [ecx] == 9AC6CDD7h
            mov     PictID, 63
         INVOKE     lstrcpy, addr szType, addr szWmf+2
      .elseif dword ptr[ecx+28h] == 'FME '
            mov     PictID, 64
         INVOKE     lstrcpy, addr szType, addr szEmf+2
      .elseif dword ptr[ecx] == 'FFIR' && dword ptr[ecx+8] == ' IVA'
            mov     PictID, 65
      .else
            jmp     NoImage
      .endif

      .if PictID == 65
         INVOKE     lstrcpy, addr szBuff, addr SavPath
         INVOKE     lstrcat, addr szBuff, addr szTempAvi

         INVOKE     CreateFile, addr szBuff,\
                    GENERIC_READ or GENERIC_WRITE,\
                    FILE_SHARE_READ or FILE_SHARE_WRITE,\
                    0, CREATE_ALWAYS, FILE_ATTRIBUTE_ARCHIVE, 0
            mov     hFile, eax

         INVOKE     WriteFile, hFile, MemRsrc, RsrcSize, addr BytesOut, NULL
         INVOKE     CloseHandle, hFile
            mov     ecx, 22
      .else
           call     LoadImageFile
            mov     ecx, 0
      .endif

        push     RsrcSize
         pop     SavSize
      INVOKE     CreateDialogParam, hInst, 4820, hREdit, offset ViewImage, ecx

         ret

NoImage:
;      INVOKE     BuildHex, SavAddr, RsrcSize

         ret
RsrcMisc ENDP

;=======================================
; Extract Cursor/Icon Resources
;=======================================
RsrcCursorIcon PROC  uses ebx esi edi
LOCAL    Cnt:DWORD, CntID, TypeID
LOCAL    szWork[512]:BYTE

         mov     esi, RsrcInfo                               ; Resource array
         mov     ebx, OffPosID

         mov     ecx, dword ptr[esi+ebx]                     ; TypeID of the resource
         mov     TypeID, ecx
         mov     ecx, dword ptr[esi+ebx+4]                   ; ID of the resource
         mov     ID, ecx
         mov     ecx, RsrcSize
         mov     SavSize, ecx

;---------- [Build the Cursor/Icon header] ----------
         xor     eax, eax
         mov     edi, MemRsrc
         mov     word ptr[edi+eax], 0
      .if TypeID == 1
            mov     word ptr[edi+eax+2], 2                   ; Type cursor
      .else
            mov     word ptr[edi+eax+2], 1                   ; Type icon
      .endif
         mov     word ptr[edi+eax+4], 1
         mov     ebx, dword ptr[esi+ebx+20]                  ; Address to group
         xor     ecx, ecx
         mov     cx, word ptr[ebx+4]                         ; Number of arrays
         add     ebx, 6                                      ; header size
         xor     edx, edx
      .while (ecx)
            mov     dx, word ptr[ebx+12]                     ; ID
         .if edx == ID                                       ; Matched main ID with grp ID
               add     eax, 6
               mov     Cnt, 12
            .while (Cnt)
                  mov     dl, byte ptr[ebx]
                  mov     byte ptr[edi+eax], dl
                  inc     eax
                  inc     ebx
                  dec     Cnt
            .endw
            .if TypeID == 3                                  ; Icon
                  mov     dl, byte ptr[edi+eax-12]
                  mov     byte ptr[edi+eax-11], dl           ; Made height same as width
            .endif
            .break
         .endif
            add     ebx, 14                                  ; Length of array
            dec     ecx
      .endw
         mov     dword ptr[edi+eax], 22                      ; Header length
      .if !ecx
            ret
      .endif

;---------- [Fix the size for cursors] ----------
      .if TypeID == 1                                        ; Cursor
            mov     bl, byte ptr [edi+6]
            mov     byte ptr [edi+7], bl
            mov     bx, word ptr [edi+12]
            mov     word ptr [edi+8], bx
      .endif

;---------- [Build the Cursor/Icon file in case the user wants to save it] ----------
         xor     eax, eax
         mov     esi, SavAddr
      .if TypeID == 1                                        ; Cursor
         .if byte ptr[edi+8] == 1
               mov     byte ptr[edi+8], 2                    ; Set max colors to 2 if 1
         .endif
            mov     ecx, dword ptr[esi]
            mov     dword ptr[edi+10], ecx                   ; Set the hot spots (move from file to header)
            mov     ecx, dword ptr[edi+14]
            sub     ecx, 4
            mov     dword ptr[edi+14], ecx                   ; Reduce the cursor size by 4 (hot spots)
            add     esi, 4
      .endif
         add     edi, 22                                     ; Header length
         mov     ecx, RsrcSize
      .if TypeID == 1                                        ; Cursor
            sub     ecx, 4
      .endif
      .while (ecx)
            mov     bl, byte ptr[esi+eax]
            mov     byte ptr[edi+eax], bl
            inc     eax
            dec     ecx
      .endw

      .if TypeID == 1                                        ; Cursor
            sub     SavSize, 4
            sub     edi, 22
            xor     eax, eax
            mov     al, byte ptr[edi+6]
            mov     ebx, eax
            mov     al, byte ptr[edi+7]
            mov     edx, eax
      .endif

      .if hIC
         INVOKE     DestroyIcon, hIC
      .endif

         mov     esi, SavAddr
         mov     ecx, RsrcSize
         mov     edi, 0
      .if TypeID == 3
            mov    edi, 1
            mov    ebx, 32
            mov    edx, 32
      .endif
      INVOKE     CreateIconFromResourceEx, esi, ecx, edi, 30000h, ebx, edx, LR_DEFAULTCOLOR
         mov     hIC, eax

      .if hImage
         INVOKE     SendMessage, hImage, WM_COMMAND, 405, 0
      .endif
      INVOKE     CreateDialogParam, hInst, 4820, hREdit, offset ViewImage, TypeID

         ret
RsrcCursorIcon ENDP

;=======================================
; Extract Bitmap Resources
;=======================================
RsrcBitmap PROC  uses ebx esi edi
LOCAL    CntID:DWORD
LOCAL    szWork[512]:BYTE

;      INVOKE     SendMessage, hREdit, WM_SETTEXT, FALSE, addr szNULL
         mov     ecx, RsrcSize
         mov     SavSize, ecx

;---------- [Build the Bitmap header] ----------
         mov     esi, SavAddr
         xor     eax, eax
         mov     edi, MemRsrc
         mov     word ptr[edi], 'MB'
         add     ecx, 0eh
         mov     dword ptr[edi+2], ecx                       ; Bitmap size
         xor     edx, edx
         mov     dword ptr[edi+6], edx                       ; 0 fill

⌨️ 快捷键说明

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