📄 extractrsrc.asm
字号:
mov edx, 36h
mov dword ptr[edi+10], edx ; Bitmap bits offset
;---------- [Adjust the offset to the bitmap bits. Find the length of the color table] ----------
xor edx, edx
xor ebx, ebx
mov dx, word ptr[esi+ebx+14] ; biBitCount
MOVmd Hold, dword ptr[esi+ebx+32]
.if edx == 8 && Hold == 0
mov edx, 100h ; 1024 bits
.elseif edx == 4 && Hold == 0
mov edx, 10h ; 64 bits
.else
mov edx, dword ptr[esi+ebx+32] ; biClrUsed 'color array'
.endif
imul edx, 4
add dword ptr[edi+eax+10], edx
add esi, ebx ; Offset of the Bitmap in the file
add edi, 0eh ; Offset of the Bitmap header
mov Hold, ecx
sub ecx, 0eh ; Remove the header size
xor ebx, ebx
.while (ecx)
mov al, byte ptr[esi+ebx]
mov byte ptr[edi+ebx], al
inc ebx
dec ecx
.endw
.if hImage
INVOKE SendMessage, hImage, WM_COMMAND, 405, 0
.endif
INVOKE CreateDialogParam, hInst, 4820, hREdit, offset ViewImage, 2
ret
RsrcBitmap ENDP
;=======================================
; Extract Group Cursor/Icon Resources
;=======================================
RsrcGrpImages PROC uses ebx esi edi
LOCAL HeaderSize:DWORD, Cnt, CntID, Sesi
LOCAL Ioffset:DWORD
LOCAL szWork[64]:BYTE
mov esi, RsrcInfo ; Resource array
mov ebx, OffPosID
mov ecx, dword ptr[esi+ebx] ; ID of the resource type
mov ID, ecx
;---------- [Build the Group cursor/icon header] ----------
xor eax, eax
xor ecx, ecx
mov esi, SavAddr
mov edi, MemRsrc
mov ax, word ptr[esi]
mov word ptr[edi], ax
mov ax, word ptr[esi+2]
mov word ptr[edi+2], ax
mov ax, word ptr[esi+4] ; Number of images in the group
mov word ptr[edi+4], ax
mov cx, ax
imul eax, 16
add eax, 6
xor ebx, ebx
mov Ioffset, eax ; Offset to first image
add esi, 6 ; Group header size
add edi, 6
.while (ecx)
mov edx, 12
.while (edx)
mov al, byte ptr[esi]
mov byte ptr[edi], al
inc esi
inc edi
dec edx
.endw
.if ID == 12 ; Group cursor fix the size
mov al, byte ptr[edi-12]
mov byte ptr[edi-11], al
mov eax, dword ptr[edi-4]
sub eax, 4
mov dword ptr[edi-4], eax
.endif
.if ID == 14 ; Group icon make height same as width
mov al, byte ptr[edi-12]
mov byte ptr[edi-11], al
.endif
add Ioffset, ebx
MOVmd dword ptr[edi], Ioffset ; Offset to first or next image
mov ebx, dword ptr[esi-4] ; Size of next image
.if ID == 12 ; Group cursor
sub ebx, 4 ; Adjust length for cursor hot spots
.endif
add esi, 2
add edi, 4
dec ecx
.endw
mov SavOffset, edi ; Save offset to the output file
mov eax, edi
sub eax, MemRsrc
mov HeaderSize, eax
;---------- [Find the cursor/icon resources and build the cursor/icon file] ----------
and Hold, 0
mov esi, SavAddr
xor ecx, ecx
mov cx, word ptr[esi+4] ; Number of images in the group
mov Cnt, ecx
add esi, 6
.while (Cnt)
mov ax, word ptr[esi+12] ; ID of cursor/icon
mov ecx, ID
mov edi, RsrcInfoGrp
MOVmd CntID, NumOfGroups
.while (CntID)
.if ax == word ptr[edi] && cl == byte ptr[edi+14] ; Matching resource ID & type
push esi
mov ecx, dword ptr[esi+8] ; Size of cursor/icon resource
mov esi, dword ptr[edi+10] ; Address of cursor/icon resource
add Hold, ecx
mov edi, SavOffset
.if ID == 12 ; Adjust length for cursor hot spots
push edi
mov eax, dword ptr[esi] ; Hot spots
mov edi, MemRsrc
mov dword ptr[edi+10], eax
pop edi
add esi, 4
sub ecx, 4
.endif
;---------- [Concatenate the cursor/icon resources] ----------
.while (ecx)
mov al, byte ptr[esi]
mov byte ptr[edi], al
inc esi
inc edi
dec ecx
.endw
pop esi
mov SavOffset, edi
.break
.endif
add edi, 15 ; Size of the RsrcInfoGrp array
dec CntID
.endw
add esi, 14 ; Size of the group array
dec Cnt
.endw
.if hIC
INVOKE DestroyIcon, hIC
and hIC, 0
.endif
mov eax, SavOffset
sub eax, MemRsrc
mov SavSize, eax ; Size of the output file
mov esi, MemRsrc
add esi, HeaderSize ; Start of cursor/icon files after header
mov ecx, SavSize
sub ecx, HeaderSize ; Length of cursor/icon files minus header
INVOKE CreateIconFromResourceEx, esi, ecx, 1, 30000h, 32, 32, LR_DEFAULTCOLOR ; Grp cursor/Icon
mov hIC, eax
.if hImage
INVOKE SendMessage, hImage, WM_COMMAND, 405, 0
.endif
INVOKE CreateDialogParam, hInst, 4820, hREdit, offset ViewImage, ID
ret
RsrcGrpImages ENDP
;=======================================
; Extract Animated Resources
;=======================================
RsrcAnimate PROC uses ebx esi edi
LOCAL BytesOut:DWORD
; INVOKE SendMessage, hREdit, WM_SETTEXT, FALSE, addr szNULL
mov esi, SavAddr
mov edi, MemRsrc
mov ecx, RsrcSize
.while (ecx)
mov al, byte ptr[esi]
mov byte ptr[edi], al
inc esi
inc edi
dec ecx
.endw
INVOKE lstrcpy, addr szBuff, addr SavPath
INVOKE lstrcat, addr szBuff, addr szTempAni
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, 32
;---------- [It does not matter if you use IMAGE_CURSOR or IMAGE_ICON] ----------
INVOKE LoadImage, 0, addr szBuff, IMAGE_CURSOR, ecx, ecx,
LR_LOADFROMFILE or LR_LOADMAP3DCOLORS
mov hIcon, eax
INVOKE DeleteFile, addr szBuff
INVOKE CreateDialogParam, hInst, 4820, hREdit, offset ViewImage, 21
ret
RsrcAnimate ENDP
;========================================
; Display Images Procedure
;========================================
ViewImage PROC uses ebx esi edi hdlg:DWORD, wmsg, wparam, lparam
;LOCAL ofn:OPENFILENAME
LOCAL rect:RECT
LOCAL RsrcAddr:DWORD
LOCAL hBmp1:DWORD, hOldBmp1, hDC, hMemDC, XP, YP, Iw, Ih, Cnt, sw
.if wmsg == WM_INITDIALOG
MOVmd hImage, hdlg
MOVmd ImageID, lparam
.if ImageID == 21
;---------- [Create a static Control Window] ----------
INVOKE CreateWindowEx, 0, addr StaticClass, 0,\
WS_CHILD or WS_VISIBLE or SS_ICON or SS_REALSIZEIMAGE,\
0, 0, 100, 100, hdlg, 2001, hInst, NULL
mov hStatic, eax
.elseif ImageID == 22 ; ACS_CENTER or
INVOKE CreateWindowEx, NULL, addr AnimateClass, NULL,\
WS_CHILD or WS_VISIBLE or WS_BORDER or\
ACS_TIMER or ACS_TRANSPARENT,\
0, 0, 100, 100, hdlg, 2001, hInst, NULL
mov hAniCtrl, eax
.endif
INVOKE PostMessage, hdlg, WM_LBUTTONDOWN, 44, 0 ; Post to display opened image
jmp ViewDone
; .elseif wmsg == WM_CTLCOLORDLG || wmsg == WM_CTLCOLORSTATIC && ImageID == 21
; mov eax, hBrush
; ret
.elseif wmsg == WM_CTLCOLORSTATIC
INVOKE SetBkColor, wparam, 00000000h
INVOKE GetStockObject, BLACK_BRUSH
ret
.elseif wmsg == WM_RBUTTONUP
INVOKE GetWindowRect, hdlg, addr rect
mov ecx, lparam ; x/y pos of window
mov ebx, ecx
and ebx, 0000ffffh ; ebx = LOWORD(lparam) = x pos
shr ecx, 16 ; eax = HIWORD(lparam) = y pos
add ebx, rect.left
add ecx, rect.top
add ebx, 3 ; x Position
add ecx, 3 ; y Position
INVOKE TrackPopupMenu, hSubMenu, TPM_LEFTALIGN or TPM_LEFTBUTTON, ebx, ecx, 0, hdlg, addr rect
.elseif wmsg == WM_PAINT && hdlg != 0
INVOKE PostMessage, hWnd, WM_PAINT, 0, 0 ; Need for NT
jmp DisplayEM
.elseif wmsg == WM_LBUTTONDOWN
.if wparam != 44
INVOKE PostMessage, hdlg, WM_NCLBUTTONDOWN, HTCAPTION, 0 ; Post to drag window in the client area
.endif
jmp ViewDone
.elseif wmsg != WM_COMMAND
jmp ViewDone
.endif
mov eax, wparam
cwde
cmp eax, 404 ; Save as
je Export
cmp eax, 405 ; Close
je CancelOut
jmp ViewDone
Export:
mov sw, 1
jmp BuildImg
DisplayEM:
and sw, 0
.if !MemRsrc
jmp CancelOut
.endif
INVOKE GetWindowRect, hdlg, addr rect
MOVmd XP, rect.left
MOVmd YP, rect.top
BuildImg:
cmp sw, 1
je ExportImg
.if ImageID == 21
jmp DoAnimate
.elseif ImageID == 22
jmp DoAvi
.endif
INVOKE GetDC, hdlg ; Get dc the of the window
mov hDC, eax
mov esi, MemRsrc
mov eax, 10
mov ebx, dword ptr[esi+eax]
MOVmd Iw, dword ptr[esi+eax+8]
MOVmd Ih, dword ptr[esi+eax+12]
add esi, ebx
.if ImageID == 2 || ImageID == 0 ; 2 = Bitmap
.else
jmp ID13
.endif
.if ImageID == 2
mov edi, MemRsrc
add edi, 14 ; Po
INVOKE CreateDIBitmap, hDC, edi, CBM_INIT, esi, edi, 0 ; Creates a device-dependent bitmap from a device independent bitmap
mov hBmp1, eax
INVOKE CreateCompatibleDC, hDC ; Create a compatible dc in memory
mov hMemDC, eax
INVOKE SelectObject, hMemDC, hBmp1 ; Select the opened bitmap into the dc
.else
MOVmd Iw, pWidth
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -