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

📄 extractrsrc.asm

📁 这是用win32汇编编写的资源编辑器
💻 ASM
📖 第 1 页 / 共 5 页
字号:
TypePict       dd  ?
xPos           dd  ?
yPos           dd  ?
pWidth         dd  ?
pHeight        dd  ?
mWidth         dd  ?
mHeight        dd  ?
negmHeight     dd  ?
ExportOn       dd  ?

Test4          dd  ?

hReg           dd  ?
lpType         dd  ?
lpcbData       dd  ?
lpdwDisp       dd  ?

szType         db  10   dup(?)
SavPath        db  256  dup(?)
szResPath      db  256  dup(?)
szBuff         db  2048 dup(?)
szUnicode      db  512  dup(?)

Dialog         STRUCT
   ID          dd ?
   pointsize   dd ?          ; +
   weight      dd ?          ; +
   bItalic     dd ?          ; +
   lpFont      db 64 dup(?)  ; +
   lpMenu      db 32 dup(?)  ; +
   lpName      db 32 dup(?)  ; +
   Class       db 32 dup(?)  ; +
   lpCaption   db 512 dup(?) ; +
   ExStyle     dd ?          ; +
   Style       dd ?          ; +
   Left        dd ?          ; +
   Top         dd ?          ; +
   Wth         dd ?          ; +
   Hgt         dd ?          ; +
Dialog         ENDS
Dlg            Dialog         <?>

Controls       STRUCT
   ID          dd ?
   lpName      db 32 dup(?)  ; +
   Class       db 32 dup(?)  ; +
   lpCaption   db 512 dup(?) ; +
   ExStyle     dd ?          ; +
   Style       dd ?          ; +
   Left        dd ?          ; +
   Top         dd ?          ; +
   Wth         dd ?          ; +
   Hgt         dd ?          ; +
Controls       ENDS
Ctrls          Controls       <?>

lf             LOGFONT        <?>
ofn            OPENFILENAME   <?>
tvis           TV_INSERTSTRUCT <?>

.code

;=======================================
; Extract Resources Dialog
;=======================================
ExtractRsrc PROC  uses ebx esi edi hwnd, hinst, hredit, hDlg
LOCAL    VirAddr:DWORD, PTRData, TypePE, Diff, sw1, NumIds1, NumIds2, SavID
LOCAL    OffPosS:DWORD, OffPosIDGrp, RsrcID, Cnt, Cnt1, CntID, ResOn, ImageOn
LOCAL    rsrcOn:DWORD, SavPos, CtrlCnt, BIOn, Dlgs, DlgVer, Base, SavClass, GrpAddr, GrpSize
LOCAL    szWork[64]:BYTE, szWork1[64]:BYTE, PathName[256]:BYTE

       MOVmd     hREdit, hredit

      INVOKE     GetCurrentDirectory, lengthof SavPath, addr SavPath
      INVOKE     RegCreateKeyEx, HKEY_CURRENT_USER, addr szRedit, 0, addr szREGSZ, 0,\
                 KEY_WRITE or KEY_READ, 0, addr hReg, addr lpdwDisp
         mov     lpcbData, 255
      INVOKE     RegQueryValueEx, hReg, addr szResB, 0, addr lpType, addr szResPath, addr lpcbData
      .if !szResPath
         INVOKE     lstrcpy, addr szResPath, addr szBuff
      .endif
      INVOKE     lstrcpy, addr szBuff, addr szResPath
      INVOKE     lstrcat, addr szBuff, addr szSlashB
      INVOKE     SetCurrentDirectory, addr szBuff

      INVOKE     ShowWindow, hStatic402, SW_HIDE
      INVOKE     ShowWindow, hStatic403, SW_HIDE
      INVOKE     ShowWindow, hWndTree, SW_HIDE

         mov     szBuff, 0

         mov     ofn.lStructSize, sizeof ofn
       MOVmd     ofn.hwndOwner, hREdit
       MOVmd     ofn.hInstance, hinst
         mov     ofn.lpstrFilter, offset szPE
         mov     ofn.lpstrFile, offset szBuff
         mov     ofn.nMaxFile, sizeof szBuff
         mov     ofn.lpstrTitle, offset szTitleO
         mov     ofn.Flags, OFN_PATHMUSTEXIST or OFN_FILEMUSTEXIST or OFN_HIDEREADONLY
      INVOKE     GetOpenFileName, addr ofn
      .if eax == FALSE       ; Cancel'ed or error occurred
         INVOKE     SetCurrentDirectory, addr SavPath
         INVOKE     RegCloseKey, hReg
            jmp     ExtractRsrcDone
      .endif
      INVOKE     SetCurrentDirectory, addr SavPath
      INVOKE     lstrlen, addr szBuff
      .while (eax)
         .if byte ptr szBuff[eax] == '\'
            .break
         .endif
            dec     eax
      .endw
         inc     eax
      INVOKE     lstrcpyn, addr szResPath, addr szBuff, eax
      INVOKE     lstrlen, addr szResPath
         mov     lpcbData, eax
      INVOKE     RegSetValueEx, hReg, addr szResB, 0, REG_SZ, addr szResPath, lpcbData
      INVOKE     RegCloseKey, hReg

         and     SavID, 0
         and     TypePE, 0
         and     NumOfIDs, 0
         and     NumofDlgs, 0
         and     NumofCtrls, 0
         and     NumofItems, 0
         and     NumOfMatchIDs, 0
      INVOKE     SetDlgItemInt, hDlg, 701, NumofDlgs, 0
      INVOKE     SetDlgItemInt, hDlg, 702, NumofCtrls, 0
      INVOKE     SetDlgItemInt, hDlg, 704, NumofItems, 0
      INVOKE     UpdateWindow, hDlg

      .if pMap
         INVOKE     UnmapViewOfFile, pMap
         INVOKE     CloseHandle, hMap
            and     pMap, 0
      .endif

;---------- [Allocate memory from the default heap] ----------
      .if RsrcInfo
         INVOKE     HeapFree, hDefHeap, 0, RsrcInfo
         INVOKE     HeapFree, hDefHeap, 0, RsrcInfoGrp
         INVOKE     HeapFree, hDefHeap, 0, MemRsrc
      .endif

      INVOKE     HeapAlloc, hDefHeap, 0, 2000000 ;500000
         mov     RsrcInfo, eax
      INVOKE     HeapAlloc, hDefHeap, 0, 1000000 ;100000
         mov     RsrcInfoGrp, eax
      INVOKE     HeapAlloc, hDefHeap, 0, 4000000 ;1000000
         mov     MemRsrc, eax

      INVOKE     UpdateWindow, hREdit

      INVOKE     CreateFile, addr szBuff,\
                 GENERIC_READ or GENERIC_WRITE,\
                 FILE_SHARE_READ or FILE_SHARE_WRITE,\
                 0, OPEN_EXISTING, FILE_ATTRIBUTE_ARCHIVE, 0

      .if eax == -1
           call     GetLastError
         .if eax == 5
               jmp     NoWrite

         .elseif eax == 32
            INVOKE     MessageBox, hWnd, addr szAccess, addr AppName, MB_YESNO
            .if IDYES

NoWrite:
               INVOKE     CreateFile, addr szBuff,\
                          GENERIC_READ, FILE_SHARE_READ,\
                          0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0
               .if eax == -1
                  INVOKE     MessageBox, hWnd, addr szError6, addr AppName, MB_OK
                     jmp     ExtractRsrcDone
               .endif
            .else
               jmp     ExtractRsrcDone
            .endif
         .else
            INVOKE     MessageBox, hWnd, addr szError6, addr AppName, MB_OK
               jmp     ExtractRsrcDone
         .endif
      .endif

         mov     hFile, eax
      INVOKE     GetFileSize, hFile, 0
         mov     BytesRead, eax

      INVOKE     CreateFileMapping, hFile, NULL, PAGE_READONLY, 0, 0, 0
        push     eax
      INVOKE     CloseHandle, hFile
         pop     eax
         cmp     eax, FALSE           ; Error occurred
          je     ExtractRsrcDone
         mov     hMap, eax
      INVOKE     MapViewOfFile, hMap, FILE_MAP_READ, 0, 0, 0
         cmp     eax, FALSE           ; Error occurred
          je     ExtractRsrcDone
         mov     pMap, eax
mov     SavpMap, eax

;_____________________________________________________________________
;---------- [Check if loaded file is a .res file] ----------
         and     ResOn, 0
      INVOKE     lstrlen, addr PathName
      .if byte ptr PathName[eax-3] == 'r' || byte ptr PathName[eax-3] == 'R'
            xor     eax, eax
            xor     ebx, ebx
            mov     Base, 4
            and     OffPosID, 0
            and     OffPosIDGrp, 0
            and     RsrcID, 0
            mov     esi, pMap

;---------- [Build the dialog address pointer sturctures] ----------
         .while (ebx < BytesRead)
             MOVmw     ID, word ptr[esi+ebx+10]
            .if word ptr[esi+ebx+8] != 0ffffh
                  mov     ID, 44                             ; Image e.g. gif, jpg, wmf, emf
            .endif
            .if ID != 0 && ID < 23 || ID == 44 ;17
                  mov     eax, ID
               .if eax != sw1
                     and     CntID, 0
                     mov     sw1, eax
               .endif
                  mov     ecx, ebx
                  mov     eax, dword ptr[esi+ebx+4]
                  add     ecx, eax                           ; Size of the header
                  add     ecx, pMap
                MOVmw     RsrcID, word ptr[esi+ebx+14]
                  mov     edi, RsrcInfo
                  mov     eax, OffPosID
                  inc     CntID
                MOVmd     dword ptr[edi+eax], ID
                MOVmd     dword ptr[edi+eax+4], RsrcID       ; Resource ID
                  mov     dword ptr[edi+eax+8], ecx          ; Actual address in the .res file
                MOVmd     dword ptr[edi+eax+12], dword ptr[esi+ebx]    ; Size of image or group
                MOVmd     dword ptr[edi+eax+16], dword ptr[esi+ebx+30] ; Code Page
                  mov     dword ptr[edi+eax+20], 0
                  mov     dword ptr[edi+eax+24], 0
                  mov     dword ptr[edi+eax+28], 0
                MOVmd     dword ptr[edi+eax+32], CntID
                MOVmd     dword ptr[edi+eax+36], OffPosID
                  mov     byte ptr[edi+eax+40], 0
                  mov     byte ptr[edi+eax+72], 0

                  mov     GrpAddr, ecx                       ; Save for the group address
                MOVmd     GrpSize, dword ptr[esi+ebx]        ; Group size
                MOVmd     Hold, dword ptr[esi+ebx]           ; Group size

;---------- [See if a named ID] ----------
               .if word ptr[esi+ebx+12] != 0ffffh || ID == 44
                     mov     RsrcID, 6969
                   MOVmd     dword ptr[edi+eax+4], RsrcID
                     mov     edx, ebx
                  .if ID != 44
                        add     edx, 12
                  .else
                        add     edx, 8
                  .endif
                     add     eax, 40                         ; Offset to first nameID out

;---------- [Convert Unicode] ----------
                  .while (byte ptr[esi+edx] != 0)
                        mov     cl, byte ptr[esi+edx]        ; Offset to Name Entry Name
                        mov     byte ptr[edi+eax], cl
                        add     edx, 2
                        inc     eax
                  .endw
                     mov     byte ptr[edi+eax], 0

                  .if ID == 44                               ; Image e.g. gif, jpg, wmf, emf
                        mov     edi, RsrcInfo
                        mov     eax, OffPosID
                        mov     dword ptr[edi+eax], 0
                        xor     ecx, ecx
                     .if word ptr[esi+edx+2] == 00ffffffh    ; No named ID 0000ffffh
                           add     edx, 4
                           mov     cx, word ptr[esi+edx]
                           mov     RsrcID, ecx
                         MOVmd     dword ptr[edi+eax+4], RsrcID
                     .else
                           mov     dword ptr[edi+eax+4], 4848   ; Named image  
                           add     edx, 2
                           add     eax, 72                      ; Offset to second nameID out

;---------- [Convert Unicode] ----------
                        .while (byte ptr[esi+edx] != 0)
                              mov     cl, byte ptr[esi+edx]  ; Offset to Name Entry Name
                              mov     byte ptr[edi+eax], cl
                              add     edx, 2
                              inc     eax
                        .endw
                           mov     byte ptr[edi+eax], 0
                     .endif
                        and     ID, 0
                  .endif
               .endif

;---------- [Build a group array used for later update to the main array] ---------- 
               .if ID == 12 || ID == 14                      ; Group icon or cursor
                     mov     edi, RsrcInfoGrp
                     mov     eax, OffPosIDGrp
                     mov     dx, word ptr[ecx+18]            ; From the group resource
                     mov     word ptr[edi+eax], dx           ; Matching ID for detail and group
                   MOVmd     dword ptr[edi+eax+2], GrpAddr   ; Actual address of group resource
                   MOVmd     dword ptr[edi+eax+6], GrpSize   ; Size of group resource
                     mov     dword ptr[edi+eax+10], 0
                     mov     dl, byte ptr ID
                     mov     byte ptr[edi+eax+14], dl
                     add     OffPosIDGrp, 15
                     inc     NumOfGroups
                  .if Hold > 20
                        sub     Hold, 20
                        add     ecx, 20
                        xor     eax, eax

                     .while (Hold)
                           add     ecx, 14
                           xor     edx, edx
                           mov     eax, OffPosIDGrp
                           mov     dx, word ptr[ecx-2]
                           mov     word ptr[edi+eax], dx         ; Matching ID for detail and group
                         MOVmd     dword ptr[edi+eax+2], GrpAddr ; Actual address of group resource
                         MOVmd     dword ptr[edi+eax+6], GrpSize ; Size of group resource
                           mov     dword ptr[edi+eax+10], 0
                           mov     dl, byte ptr ID
                           mov     byte ptr[edi+eax+14], dl
                           add     OffPosIDGrp, 15
                           inc     NumOfGroups
                           sub     Hold, 14
                        .if sdword ptr Hold < 0 || Hold > 0 && Hold < 14
                           .break
                        .endif
                     .endw
                  .endif
               .endif

                  add     OffPosID, 104                        ; Length of ID array
                  inc     NumOfMatchIDs
            .endif

               mov     eax, dword ptr[esi+ebx]
               add     eax, dword ptr[esi+ebx+4]

⌨️ 快捷键说明

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