📄 prot.asm
字号:
.586
.model flat,stdcall
option casemap:none
assume fs:flat
include c:\masm32\include\windows.inc
include c:\masm32\include\user32.inc
include c:\masm32\include\kernel32.inc
include c:\masm32\include\comctl32.inc
include c:\masm32\include\comdlg32.inc
include c:\masm32\include\gdi32.inc
include c:\masm32\include\shell32.inc
include aplib.inc
includelib c:\masm32\lib\kernel32.lib
includelib c:\masm32\lib\user32.lib
includelib c:\masm32\lib\comctl32.lib
includelib c:\masm32\lib\comdlg32.lib
includelib c:\masm32\lib\gdi32.lib
includelib c:\masm32\lib\shell32.lib
includelib aplib.lib
include data.asm
.CODE
include shell.asm
start:
invoke GetModuleHandle, NULL
mov hInst,eax
lea esi,FontName
lea edi,LogFont.lfFaceName
mov ecx,10h
rep movsb
mov LogFont.lfHeight,0fffffff4h
mov LogFont.lfWeight,109h
mov LogFont.lfCharSet,1h
invoke DialogBoxParam, hInst, OFFSET MainDlgName,NULL,OFFSET DlgProc,NULL
invoke ExitProcess,0
;*******************主窗口********************************
DlgProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
MOV eax,uMsg
.if eax == WM_CLOSE ;退出消息处理
invoke VirtualFree, MessageBufferAddr, 0, MEM_RELEASE
.if IsSaveSet == 1
invoke SaveTheSet
.endif
invoke PostQuitMessage,NULL
.elseif eax == WM_INITDIALOG ;初试化消息处理
invoke InitCommonControls
invoke GetDlgItem,hWnd,IDC_TAB1
MOV hwndTab,eax
MOV ItemStruct.imask,TCIF_TEXT
MOV ItemStruct.lpReserved1,0
MOV ItemStruct.lpReserved2,0
MOV ItemStruct.iImage,0
MOV ItemStruct.lParam,0
MOV ItemStruct.pszText,OFFSET TabTitle1
MOV ItemStruct.cchTextMax,sizeof TabTitle1
invoke SendMessage,hwndTab,TCM_INSERTITEM,0,OFFSET ItemStruct
MOV ItemStruct.pszText,OFFSET TabTitle2
MOV ItemStruct.cchTextMax,sizeof TabTitle2
invoke SendMessage,hwndTab,TCM_INSERTITEM,1,OFFSET ItemStruct
MOV ItemStruct.pszText,OFFSET TabTitle3
MOV ItemStruct.cchTextMax,sizeof TabTitle3
invoke SendMessage,hwndTab,TCM_INSERTITEM,2,OFFSET ItemStruct
invoke CreateDialogParam,hInst,OFFSET Child1Name,hwndTab,OFFSET ChildDlgProc1,0
MOV Child1hWnd,eax
invoke CreateDialogParam,hInst,OFFSET Child2Name,hwndTab,OFFSET ChildDlgProc2,0
MOV Child2hWnd,eax
invoke CreateDialogParam,hInst,OFFSET Child3Name,hwndTab,OFFSET ChildDlgProc3,0
MOV Child3hWnd,eax
MOV WhichTabChosen,0
invoke ShowWindow,Child1hWnd,SW_SHOWDEFAULT
.elseif eax == WM_COMMAND
MOV eax,wParam
.elseif eax == WM_NOTIFY
MOV eax,lParam
MOV eax, (NMHDR PTR [eax]).code
.if eax == TCN_SELCHANGE
MOV eax,WhichTabChosen
.if eax == 2
mov TextOutCY,0
.endif
MOV eax,[Handles+eax*4]
invoke ShowWindow,eax,SW_HIDE
invoke SendMessage,hwndTab,TCM_GETCURSEL,0,0 ; Ok which one is BEING chosen right now?
MOV WhichTabChosen,eax
MOV eax,[Handles+eax*4]
invoke ShowWindow,eax,SW_SHOWDEFAULT
.endif
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret
DlgProc endp
;***********************加密窗口*******************************
ChildDlgProc1 PROC ProthWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
mov eax,ProthWnd
mov hProtDlg,eax
mov eax,uMsg
.if eax == WM_INITDIALOG ;初试化消息处理
;*****创建消息框缓冲
invoke VirtualAlloc, NULL, 1000h, MEM_COMMIT, PAGE_READWRITE
mov MessageBufferAddr, eax
;***取得选项、保护按钮句柄
invoke GetDlgItem, hProtDlg, IDC_PROT_BUTTON
mov hProtButton,eax
.elseif eax == WM_COMMAND
mov eax,wParam
.if eax == IDC_OPEN_BUTTON ;是打开文件命令吗?
invoke RtlZeroMemory,MessageBufferAddr,1000h
mov DebugMsgSize,0
invoke RtlZeroMemory,OFFSET FileName,MAXSIZE ;清空文件名缓冲
mov Openfilename.lStructSize,SIZEOF Openfilename
push ProthWnd
pop Openfilename.hWndOwner
push hInst
pop Openfilename.hInstance
mov Openfilename.lpstrFilter, OFFSET FilterString
mov Openfilename.lpstrFile, OFFSET FileName
mov Openfilename.nMaxFile,MAXSIZE
mov Openfilename.Flags, OFN_FILEMUSTEXIST or \
OFN_PATHMUSTEXIST or OFN_LONGNAMES or\
OFN_EXPLORER or OFN_HIDEREADONLY
invoke GetOpenFileName, ADDR Openfilename
.IF eax==TRUE ;文件打开成功
invoke SetDlgItemText,ProthWnd,IDC_FILE_EDIT,ADDR FileName
invoke FileIsExe ;是合法的PE-EXE文件吗?
.if eax==1
invoke EnableWindow, hProtButton, TRUE
.else
invoke EnableWindow, hProtButton, FALSE
.endif
.ENDIF
.elseif eax == IDC_PROT_BUTTON ;是保护命令吗?
pushad
invoke EnableWindow, hProtButton, FALSE
invoke ProtTheFile
popad
.endif
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret
ChildDlgProc1 ENDP
;*******************选项窗口************************
ChildDlgProc2 PROC OptionhWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
mov eax,uMsg
.if eax == WM_INITDIALOG ;选项对话框初始化
invoke GetPrivateProfileInt,addr IniSectionName,addr I_issaveset,0h,addr IniFileName
.if eax == 1
mov IsSaveSet,1
invoke CheckDlgButton,OptionhWnd,IDC_SAVESET,BST_CHECKED
.endif
invoke GetPrivateProfileInt,addr IniSectionName,addr I_iscreatebak,0h,addr IniFileName
.if eax == 1
mov IsCreateBak,1
invoke CheckDlgButton,OptionhWnd,IDC_CREATEBAK,BST_CHECKED
.endif
invoke GetPrivateProfileInt,addr IniSectionName,addr I_Ispackres,0h,addr IniFileName
.if eax == 1
mov IsPackRes,1
invoke CheckDlgButton,OptionhWnd,IDC_PACKRES,BST_CHECKED
.endif
invoke GetPrivateProfileInt,addr IniSectionName,addr I_Issavesdata,0h,addr IniFileName
.if eax == 1
mov IsSaveSData,1
invoke CheckDlgButton,OptionhWnd,IDC_SDATA,BST_CHECKED
.endif
invoke GetPrivateProfileInt,addr IniSectionName,addr I_Iscodeprot,1h,addr IniFileName
.if eax == 1
mov IsCodeProt,1
invoke CheckDlgButton,OptionhWnd,IDC_CODEPROT,BST_CHECKED
.endif
invoke GetPrivateProfileInt,addr IniSectionName,addr I_Clssecname,1h,addr IniFileName
.if eax == 1
mov IsClsSecName,1
invoke CheckDlgButton,OptionhWnd,IDC_CLSSECNAME,BST_CHECKED
.endif
invoke GetPrivateProfileInt,addr IniSectionName,addr I_Ismergesection,1h,addr IniFileName
.if eax == 1
mov IsMergeSection,1
invoke CheckDlgButton,OptionhWnd,IDC_MERGESECTION,BST_CHECKED
.endif
invoke GetPrivateProfileInt,addr IniSectionName,addr I_Isprotimptable,1h,addr IniFileName
.if eax == 1
mov IsProtImpTable,1
invoke CheckDlgButton,OptionhWnd,IDC_APIPROT,BST_CHECKED
.endif
invoke GetPrivateProfileInt,addr IniSectionName,addr I_IsReFileHead,1h,addr IniFileName
.if eax == 1
mov IsReFileHead,1
invoke CheckDlgButton,OptionhWnd,IDC_REFILEHEAD,BST_CHECKED
.endif
invoke GetPrivateProfileInt,addr IniSectionName,addr I_IsFileAlignment200,1h,addr IniFileName
.if eax == 1
mov IsFileAlignment200,1
invoke CheckDlgButton,OptionhWnd,IDC_FA200,BST_CHECKED
.endif
invoke GetPrivateProfileInt,addr IniSectionName,addr I_IsNoRelocation,1h,addr IniFileName
.if eax == 1
mov IsNoRelocation,1
invoke CheckDlgButton,OptionhWnd,IDC_NOREL0,BST_CHECKED
.endif
.elseif eax == WM_COMMAND
mov eax,wParam
.if eax == IDC_OPTIONOK
;*******创建备份吗?
invoke SendDlgItemMessage, OptionhWnd, IDC_CREATEBAK, BM_GETCHECK, 0, 0
.if eax == BST_CHECKED
mov IsCreateBak,1
.else
mov IsCreateBak,0
.endif
;*******清空段名吗?
invoke SendDlgItemMessage, OptionhWnd, IDC_CLSSECNAME, BM_GETCHECK, 0, 0
.if eax == BST_CHECKED
mov IsClsSecName,1
.else
mov IsClsSecName,0
.endif
;*******合并区段吗?
invoke SendDlgItemMessage, OptionhWnd, IDC_MERGESECTION, BM_GETCHECK, 0, 0
.if eax == BST_CHECKED
mov IsMergeSection,1
.else
mov IsMergeSection,0
.endif
;********压缩资源吗?
invoke SendDlgItemMessage, OptionhWnd, IDC_PACKRES, BM_GETCHECK, 0, 0
.if eax == BST_CHECKED
mov IsPackRes,1
.else
mov IsPackRes,0
.endif
;********保留额外数据吗?
invoke SendDlgItemMessage, OptionhWnd, IDC_SDATA, BM_GETCHECK, 0, 0
.if eax == BST_CHECKED
mov IsSaveSData,1
.else
mov IsSaveSData,0
.endif
;*******输入表加密吗?
invoke SendDlgItemMessage, OptionhWnd, IDC_APIPROT, BM_GETCHECK, 0, 0
.if eax == BST_CHECKED
mov IsProtImpTable,1
.else
mov IsProtImpTable,0
.endif
;*******重算文件头大小吗?
invoke SendDlgItemMessage, OptionhWnd, IDC_REFILEHEAD, BM_GETCHECK, 0, 0
.if eax == BST_CHECKED
mov IsReFileHead,1
.else
mov IsReFileHead,0
.endif
;*******强制文件对齐为200吗?
invoke SendDlgItemMessage, OptionhWnd, IDC_FA200, BM_GETCHECK, 0, 0
.if eax == BST_CHECKED
mov IsFileAlignment200,1
.else
mov IsFileAlignment200,0
.endif
;*******去处重定位数据吗?
invoke SendDlgItemMessage, OptionhWnd, IDC_NOREL0, BM_GETCHECK, 0, 0
.if eax == BST_CHECKED
mov IsNoRelocation,1
.else
mov IsNoRelocation,0
.endif
;********特殊代码加密吗?
invoke SendDlgItemMessage, OptionhWnd, IDC_CODEPROT, BM_GETCHECK, 0, 0
.if eax == BST_CHECKED
mov IsCodeProt,1
.else
mov IsCodeProt,0
.endif
;********保存设置吗?
invoke SendDlgItemMessage, OptionhWnd, IDC_SAVESET, BM_GETCHECK, 0, 0
.if eax == BST_CHECKED
mov IsSaveSet,1
.else
mov IsSaveSet,0
.endif
.endif
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret
ChildDlgProc2 ENDP
;*******************关于窗口******************************
ChildDlgProc3 PROC AbouthWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
LOCAL hMBitMapDc:HDC
LOCAL hMBitMap:dword
LOCAL ps:PAINTSTRUCT
LOCAL rect:RECT
LOCAL TextSizeCX:dword
LOCAL TextSizeCY:dword
MOV eax,uMsg
.if eax == WM_PAINT
invoke BeginPaint,AbouthWnd,addr ps
mov hDc,eax
invoke BitBlt,hMDc,0h,0h,115h,50h,hMDc3,0,0,0cc0020h
invoke BitBlt,hDc,9h,8h,115h,91h,hMDc,0,0,0cc0020h
invoke EndPaint,AbouthWnd,addr ps
.elseif eax == WM_INITDIALOG
invoke SetTimer,AbouthWnd,200h,46h,NULL
invoke GetDC,AbouthWnd
mov hDc,eax
;*******创建一个全黑的内存设备用来最后输出
invoke CreateCompatibleDC,hDc
mov hMDc,eax
invoke CreateCompatibleBitmap,hDc,200h,200h
mov hMBitMapDc,eax
invoke SelectObject,hMDc,hMBitMapDc
mov hMBitMap,EAX
invoke CreateSolidBrush, 0h
mov hBrush,eax
mov rect.top,0h
mov rect.left,0h
mov rect.right,115h
mov rect.bottom,210h
invoke FillRect,hMDc,addr rect,hBrush
;*******创建一个带文字的内存设备
invoke CreateCompatibleDC,hDc
mov hMDc2,eax
invoke SetTextColor,hMDc2,0ff7070h
invoke SetBkMode,hMDc2,TRANSPARENT
invoke CreateFontIndirect,addr LogFont
invoke SelectObject,hMDc2,eax
invoke CreateCompatibleBitmap,hDc,200h,200h
invoke SelectObject,hMDc2,eax
invoke FillRect,hMDc2,addr rect,hBrush
mov TextOutX,40h
mov TextOutY,50h
mov esi,OFFSET AboutText
mov al,byte ptr [esi]
.while al
.if al == 0dh
add TextOutY,10h
add esi,2h
mov TextOutX,40h
.else
invoke GetTextExtentPoint32,hMDc2,esi,1,addr TextSizeCX
invoke TextOut,hMDc2,TextOutX,TextOutY,esi,1h
mov eax,TextSizeCX
add TextOutX,eax
inc esi
.endif
mov al,byte ptr [esi]
.endw
;*******创建一个带图片的内存设备
invoke CreateCompatibleDC,hDc
mov hMDc3,eax
invoke LoadBitmap,hInst,IDB_BITMAP
mov hBitMap,eax
invoke SelectObject,hMDc3,hBitMap
;*******创建一个带图标图片的内存设备,然后释放
invoke CreateCompatibleDC,hDc
mov esi,eax
invoke LoadBitmap,hInst,IDB_BITMAP2
invoke SelectObject,esi,eax
invoke BitBlt,hMDc2,80h,120h,20h,20h,esi,0,0,0cc0020h
invoke ReleaseDC,AbouthWnd,esi
;*******
invoke BitBlt,hMDc,0h,0h,115h,50h,hMDc3,0,0,0cc0020h
invoke ReleaseDC,AbouthWnd,hDc
.elseif eax == WM_TIMER
invoke GetDC,AbouthWnd
mov hDc,eax
invoke BitBlt,hMDc,0h,55h,115h,34h,hMDc2,0,TextOutCY,0cc0020h
inc TextOutCY
.if TextOutCY == 140h
mov TextOutCY,0
.endif
invoke BitBlt,hDc,9h,8h,115h,91h,hMDc,0,0,0cc0020h
invoke ReleaseDC,AbouthWnd,hDc
.elseif eax == WM_COMMAND
mov eax,wParam
.if eax == IDC_CCGSITE ;是连接CCG站点吗?
invoke ShellExecute, SW_SHOWMAXIMIZED, NULL, ADDR CcgSiteIp, NULL, NULL,NULL
.endif
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret
ChildDlgProc3 ENDP
;*******************文件是有效的PE-EXE文件吗?*******************************
FileIsExe PROC
LOCAL ReadBuffer :DWORD
LOCAL NumberOfBytesRW :DWORD
push esi
invoke AddLine,ADDR FileName
invoke CreateFile,ADDR FileName, GENERIC_READ+GENERIC_WRITE, FILE_SHARE_READ+FILE_SHARE_WRITE,0, 3, FILE_ATTRIBUTE_NORMAL,NULL
cmp eax,INVALID_HANDLE_VALUE
jz OpenFileErr
mov hFile,eax
;**********文件头是“MZ”吗?
mov ReadBuffer,0
invoke SetFilePointer, hFile, 0h, NULL, FILE_BEGIN
invoke ReadFile, hFile, ADDR ReadBuffer, 4, ADDR NumberOfBytesRW, NULL
mov eax,ReadBuffer
cmp ax,'ZM'
jnz FileIsNotExe
;****************************
mov ReadBuffer,0
invoke SetFilePointer, hFile, 3ch, NULL, FILE_BEGIN
invoke ReadFile, hFile, ADDR ReadBuffer, 4, ADDR NumberOfBytesRW, NULL
mov eax,ReadBuffer
mov esi,eax
;*************是PE文件吗?
mov ReadBuffer,0
invoke SetFilePointer, hFile, esi, NULL, FILE_BEGIN
invoke ReadFile, hFile, ADDR ReadBuffer, 2, ADDR NumberOfBytesRW, NULL
cmp ReadBuffer,'EP'
jnz FileIsNotPe
;*************是EXE文件还是DLL文件
mov eax,esi
add eax,16h
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -