📄 extractrsrc.asm
字号:
add ebx, eax
;---------- [Check if next resource address is on a dword boundry] ----------
xor edx, edx
mov eax, ebx
div Base
.if edx
add ebx, 1
.endif
xor edx, edx
mov eax, ebx
div Base
.if edx
add ebx, 1
.endif
xor edx, edx
mov eax, ebx
div Base
.if edx
add ebx, 1
.endif
.endw
.if !NumOfMatchIDs
jmp NoDialogs
.endif
INVOKE lstrcpy, MemRsrc, addr szCRLF
inc ResOn
jmp FromRes
.endif
;_____________________________________________________________________
;---------- [Check for PE type file] ----------
.if BytesRead < 3ch
jmp NoRsrc
.endif
mov ebx, pMap
mov ax, word ptr[ebx]
.if ax == 'ZM' ; IMAGE_DOS_SIGNATURE -DOS MZ header-
mov edx, 3ch
xor eax, eax
mov ax, word ptr[ebx+edx]
add ebx, eax
mov eax, dword ptr[ebx]
.if eax == IMAGE_NT_SIGNATURE ; IMAGE_NT_SIGNATURE -PE header-
mov TypePE, 1
.endif
.endif
cmp TypePE, 0
je NoRsrc
and rsrcOn, 0
and CompressOn, 0
mov edi, pMap
assume edi:ptr IMAGE_DOS_HEADER
add edi, [edi].e_lfanew
assume edi:ptr IMAGE_NT_HEADERS
mov ax, [edi].FileHeader.NumberOfSections
mov NumOfSections, ax
add edi, sizeof IMAGE_NT_HEADERS
mov esi, edi
mov ax, NumOfSections
movzx eax, ax
mov edi, eax
assume esi:ptr IMAGE_SECTION_HEADER
.while edi > 0
INVOKE lstrcpyn, addr szWork, addr [esi].Name1, 8
.if dword ptr szWork == '0XPU' || dword ptr szWork == '1XPU'
mov CompressOn, 1
.endif
.if dword ptr szWork+1 == 'crsr' ; Resource header
mov rsrcOn, esi
MOVmd VirAddr, [esi].VirtualAddress
MOVmd PTRData, [esi].PointerToRawData
mov eax, VirAddr
sub eax, PTRData
mov Diff, eax
.break
.endif
dec edi
add esi, sizeof IMAGE_SECTION_HEADER
.endw
.if !rsrcOn
jmp NoRsrc
.endif
and Dlgs, 0
and OffPosS, 0
and OffPosID, 0
and OffPosIDGrp, 0
and NumIds2, 0
mov esi, pMap
add esi, PTRData
;---------- [In Resource Directory (Type)] ----------
assume esi:ptr IMAGE_RESOURCE_DIRECTORY ; Resource Directory (Type)
xor eax, eax
mov ax, [esi].NumberOfNamedEntries
mov NumIds1, eax
mov ax, [esi].NumberOfIdEntries
add NumIds1, eax ; Total num of ID entries
and SavPos, 0
INVOKE lstrcpy, MemRsrc, addr szCRLF
.while (NumIds1) ; In Resource Directory (Type)
mov eax, SavPos
add eax, 10h
mov SavPos, eax
sub SavPos, 8
;---------- [Check for valid resource ID 1-2-3-5-etc.] ----------
mov ebx, dword ptr[esi+eax]
shr ebx, 24
.if dword ptr[esi+eax] != 0 && dword ptr[esi+eax] < 23 || ebx == 80h ;17
MOVmd SavID, dword ptr[esi+eax] ; Save the ID
add eax, 4
mov ebx, dword ptr[esi+eax] ; Offset to Resource Directory (Name ID)
and ebx, 00ffffffh ;0000ffffh
add ebx, 0eh ; Offset to Total num of ID's for group
xor ecx, ecx
mov cx, word ptr[esi+ebx] ; Total num of ID's for the group
add cx, word ptr[esi+ebx-2] ; Total num of named ID's for the group
mov NumIds2, ecx ; Total num of items for the group
mov Dlgs, ecx
sub ebx, 2
and CntID, 0
;---------- [In Resource Directory (Name ID)] ----------
.while (NumIds2) ; In Resource Directory (Name ID)
MOVmd ID, SavID
add ebx, 8
MOVmd RsrcID, dword ptr[esi+ebx-4] ; Save the resource or matching ID
mov edi, RsrcInfo
mov eax, OffPosID
mov byte ptr[edi+eax+40], 0
mov byte ptr[edi+eax+72], 0
;---------- [See if Named ID] ----------
.if byte ptr RsrcID[3] == 80h || byte ptr ID[3] == 80h
.if byte ptr RsrcID[3] == 80h
mov edx, dword ptr[esi+ebx-4]
.endif
.if byte ptr ID[3] == 80h
mov edx, ID
.endif
and edx, 00ffffffh ;0000ffffh
xor ecx, ecx
mov cx, word ptr[esi+edx] ; Offset to Name Entry header
mov Cnt, ecx ; Size of Name
mov Cnt1, ecx ; Size of Name
xor ecx, ecx
add edx, 2
mov edi, RsrcInfo
mov eax, OffPosID
add eax, 40
;---------- [Convert Unicode] ----------
.while (Cnt)
mov cl, byte ptr[esi+edx] ; Offset to Name Entry Name
mov byte ptr[edi+eax], cl
add edx, 2
inc eax
dec Cnt
.endw
mov byte ptr[edi+eax], 0
.if byte ptr RsrcID[3] == 80h && byte ptr ID[3] == 80h
mov edx, RsrcID
and edx, 00ffffffh ;0000ffffh
xor ecx, ecx
mov cx, word ptr[esi+edx] ; Offset to Name Entry header
mov Cnt, ecx ; Size of Name
mov Cnt1, ecx ; Size of Name
xor ecx, ecx
add edx, 2
mov edi, RsrcInfo
mov eax, OffPosID
add eax, 72 ; Offset to second nameID out
;---------- [Convert Unicode] ----------
.while (Cnt)
mov cl, byte ptr[esi+edx] ; Offset to Name Entry Name
mov byte ptr[edi+eax], cl
add edx, 2
inc eax
dec Cnt
.endw
mov byte ptr[edi+eax], 0
mov RsrcID, 4848
.endif
.if byte ptr RsrcID[3] == 80h ; Named ID
mov RsrcID, 6969
.endif
.if byte ptr ID[3] == 80h ; Image e.g. gif, jpg, wmf, emf
and ID, 0
.endif
.endif
mov edx, dword ptr[esi+ebx] ; Offset to Directory (Language)
and edx, 00ffffffh ;0000ffffh
add edx, 14h
mov ecx, dword ptr[esi+edx] ; Offset to Directory (Data Entry)
mov edx, ecx
mov ecx, dword ptr[esi+edx] ; Virtual address of resource
sub ecx, Diff ; Actual address of resource in the file
add ecx, pMap
;---------- [Build an array of IDs - ID, actual offset, and size] ----------
inc CntID
mov edi, RsrcInfo
mov eax, OffPosID
MOVmd dword ptr[edi+eax], ID ; Type of resource
MOVmd dword ptr[edi+eax+4], RsrcID ; Resource or matching ID for detail and group
mov dword ptr[edi+eax+8], ecx ; Actual address of the resource
MOVmd dword ptr[edi+eax+12], dword ptr[esi+edx+4] ; Size of image or group
MOVmd dword ptr[edi+eax+16], dword ptr[esi+edx+8] ; 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 GrpAddr, ecx ; Save for the group address
MOVmd GrpSize, dword ptr[esi+edx+4] ; Group size
MOVmd Hold, dword ptr[esi+edx+4] ; Group size
;---------- [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
dec NumIds2
.endw
.endif
dec NumIds1
.endw
.if !Dlgs
jmp NoDialogs
.endif
FromRes:
;---------- [Copy cursor and icon group information to the main cursor & icon array] ----------
MOVmd Cnt, NumOfMatchIDs
and OffPosID, 0
mov esi, RsrcInfo
.while (Cnt)
mov eax, OffPosID
.if dword ptr [esi+eax] == 1 || dword ptr[esi+eax] == 3 ; Cursor or Icon IDs
mov dl, 12 ; Code for Grp cursor
.if dword ptr[esi+eax] == 3
mov dl, 14 ; Code for Grp icon
.endif
mov ecx, dword ptr[esi+eax+4]
mov edi, RsrcInfoGrp
and OffPosIDGrp, 0
MOVmd CntID, NumOfGroups
.while (CntID)
mov ebx, OffPosIDGrp
.if word ptr[edi+ebx] == cx && byte ptr[edi+ebx+14] == dl ; Matching ID & type
MOVmd dword ptr[esi+eax+20], dword ptr[edi+ebx+2] ; Offset to group
MOVmd dword ptr[esi+eax+24], dword ptr[edi+ebx+6] ; Size of group
MOVmd dword ptr[edi+ebx+10], dword ptr[esi+eax+8] ; Address of the Ico or Cur
mov ecx, dword ptr [edi+ebx+2]
.if ecx != Hold
mov Hold, ecx
.if dword ptr[edi+ebx+6] > 20 ; More then 1 image in grp
mov dword ptr[esi+eax+28], 44 ; Flag for mult image
.endif
.endif
.break
.endif
add OffPosIDGrp, 15
dec CntID
.endw
.endif
add OffPosID, 104
dec Cnt
.endw
;---------- [Fill the tree] ----------
mov byte ptr szWork, 0
INVOKE SendMessage, hWndTree, TVM_DELETEITEM, 0, TVI_ROOT
mov tvis.hParent, NULL
mov tvis.hInsertAfter, TVI_ROOT
mov tvis.item.imask, TVIF_TEXT or TVIF_IMAGE or TVIF_SELECTEDIMAGE or TVIF_PARAM
mov tvis.item.pszText, offset szResources
mov tvis.item.iImage, 0
mov tvis.item.iSelectedImage, 1
INVOKE SendMessage, hWndTree, TVM_INSERTITEM, 0, addr tvis
mov hParent, eax
mov tvis.hParent, eax
mov tvis.hInsertAfter, TVI_LAST
MOVmd CntID, NumOfMatchIDs
and OffPosID, 0
and ImageOn, 0
and ID, 0
.while (CntID)
INVOKE lstrlen, addr szWork1
mov ecx, eax
mov esi, RsrcInfo ; Resource array
mov ebx, OffPosID
mov eax, dword ptr[esi+ebx]
.if eax == 1 || eax == 2 || eax == 3 || eax == 12 || eax == 14 || eax == 21 || eax == 22 || eax == 0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -