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

📄 uencrypt.pas

📁 这个小软件通过在可执行文件(.exe)的尾部添加一个新节(Section)
💻 PAS
字号:
{******************************************************************************}
{ Author:    Liwuyue                                                           }
{ Email:     smokingroom@sina.com                                              }
{ Home page: http://www.programmerlife.com                                     }
{ built:     2005-03-08                                                        }
{******************************************************************************}
unit uEncrypt;

interface

uses
  Windows, SysUtils, Messages;


procedure Encrypt(Handle:HWND; LFileName:string;LPassword:string;LBackup:Boolean);

function AttachStart:DWORD;stdcall;
procedure AttachProc;stdcall;
function AttachWindowProc(hwnd:HWND;uMsg:UINT;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;
function CalcCrc32(lpSource:PChar;nLength:Integer):DWORD;stdcall;
procedure AttachEnd;stdcall;

implementation

const
  hWndAttachExStyle      = 0;
  hWndAttachStyle        = WS_MINIMIZEBOX or WS_SYSMENU or WS_CAPTION or WS_OVERLAPPED;    //WS_SIZEBOX
  dwWndAttachWidth       = 320;
  dwWndAttachHeight      = 120;
  IDC_EDIT_PASSWORD      = 100;
  IDC_BUTTON_OK	         = 101;
  IDC_BUTTON_CANCEL      = 102;
  IDM_ATTACH_MENU_ABOUT	 = 103;
  MAX_PASSWORD_LENGTH    = 16;

type
  TGetProcAddress        = function(hModule:HMODULE;lpProcName:LPCSTR):Pointer;stdcall;
  TLoadLibrary           = function(lpLibFileName:PChar):HMODULE;stdcall;
  TFreeLibrary           = function(hLibModule:HMODULE):BOOL;stdcall;
  TExitProcess           = procedure(uExitCode:UINT);stdcall;
  TGetModuleHandle       = function(lpModuleName:PChar):HMODULE;stdcall;
  TGetMessage            = function(var lpMsg:TMsg;hWnd:HWND;wMsgFilterMin,wMsgFilterMax:UINT):BOOL;stdcall;
  TTranslateMessage      = function(const lpMsg:TMsg):BOOL; stdcall;
  TDispatchMessage       = function(const lpMsg:TMsg):Longint; stdcall;
  TGetSystemMetrics      = function(nIndex:Integer): Integer; stdcall;
  TPostMessage           = function(hWnd:HWND;Msg:UINT;wParam:WPARAM;lParam:LPARAM):BOOL;stdcall;
  TSendMessage           = function(hWnd:HWND;Msg:UINT;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;
  TShowWindow            = function(hWnd:HWND;nCmdShow:Integer):BOOL;stdcall;
  TUpdateWindow          = function(hWnd:HWND):BOOL;stdcall;
  TLoadCursor            = function(hInstance:HINST;lpCursorName:PAnsiChar):HCURSOR;stdcall;
  TLoadIcon              = function(hInstance:HINST;lpIconName:PAnsiChar):HICON; stdcall;
  TPostQuitMessage       = procedure(nExitCode:Integer);stdcall;
  TMessageBox            = function(hWnd:HWND;lpText,lpCaption:PChar;uType:UINT):Integer;stdcall;
  TRegisterClassEx       = function(const WndClass:TWndClassEx):ATOM;stdcall;
  TCreateWindowEx        = function(dwExStyle:DWORD;lpClassName:PChar;
                                    lpWindowName:PChar;dwStyle:DWORD;X,Y,nWidth,nHeight:Integer;
                                    hWndParent:HWND;hMenu:HMENU;hInstance:HINST;lpParam:Pointer):HWND;stdcall;
  TDefWindowProc         = function(hWnd:HWND;Msg:UINT;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;
  TSetFocus              = function(hWnd:HWND):HWND;stdcall;
  TGetWindowLong         = function(hWnd:HWND;nIndex:Integer):Longint;stdcall;
  TSetWindowLong         = function(hWnd:HWND;nIndex:Integer;dwNewLong:Longint):Longint; stdcall;
  TGetDlgItemText        = function(hDlg:HWND;nIDDlgItem:Integer;lpString:PChar;nMaxCount:Integer):UINT;stdcall;
  TGetSystemMenu         = function(hWnd:HWND;bRevert:BOOL):HMENU;stdcall;
  TAppendMenu            = function(hMenu:HMENU;uFlags,uIDNewItem:UINT;lpNewItem:PChar):BOOL;stdcall;
  TCreateFontIndirect    = function(const p1:TLogFont):HFONT;stdcall;
  TDeleteObject          = function(p1:HGDIOBJ):BOOL;stdcall;
  TIsDialogMessage       = function(hDlg:HWND;var lpMsg:TMsg):BOOL;stdcall;
  TGetDlgItem            = function(hDlg:HWND;nIDDlgItem:Integer):HWND;stdcall;
  Twsprintf              = function(Output:PChar;Format:PChar;arglist:va_list):Integer;stdcall;
  TSetWindowText         = function(hWnd:HWND;lpString:PChar):BOOL;stdcall;
  Tlstrlen               = function(lpString:PChar):Integer;stdcall;


type
  PAttachData=^TAttachData;
  TAttachData=packed record
    hLibUser32:                HMODULE;
    hLibGDI32:                 HMODULE;
    _GetProcAddress:           TGetProcAddress;
    _LoadLibrary:              TLoadLibrary;
    _FreeLibrary:              TFreeLibrary;
    _ExitProcess:	       TExitProcess;
    _GetModuleHandle:	       TGetModuleHandle;
    _lstrlen:                  Tlstrlen;
    _GetMessage:	       TGetMessage;
    _TranslateMessage:	       TTranslateMessage;
    _DispatchMessage:	       TDispatchMessage;
    _GetSystemMetrics:	       TGetSystemMetrics;
    _PostMessage:	       TPostMessage;
    _SendMessage:	       TSendMessage;
    _ShowWindow:  	       TShowWindow;
    _UpdateWindow:	       TUpdateWindow;
    _LoadCursor:  	       TLoadCursor;
    _LoadIcon:                 TLoadIcon;
    _PostQuitMessage:	       TPostQuitMessage;
    _MessageBox: 	       TMessageBox;
    _RegisterClassEx:	       TRegisterClassEx;
    _CreateWindowEx:	       TCreateWindowEx;
    _DefWindowProc:	       TDefWindowProc;
    _SetFocus:		       TSetFocus;
    _GetWindowLong:	       TGetWindowLong;
    _SetWindowLong:	       TSetWindowLong;
    _GetDlgItemText:	       TGetDlgItemText;
    _GetSystemMenu:	       TGetSystemMenu;
    _AppendMenu: 	       TAppendMenu;
    _CreateFontIndirect:       TCreateFontIndirect;
    _DeleteObject:	       TDeleteObject;
    _IsDialogMessage:	       TIsDialogMessage;
    _GetDlgItem:	       TGetDlgItem;
    _wsprintf:		       Twsprintf;
    _SetWindowText:	       TSetWindowText;

    szLibUser32:	       array[0..6]  of Char; //	"user32"
    szLibGDI32:		       array[0..5]  of Char; //	"gdi32"

    szLoadLibrary:	       array[0..12] of Char; //	"LoadLibraryA"
    szFreeLibrary:	       array[0..11] of Char; //	"FreeLibrary"
    szExitProcess:	       array[0..11] of Char; //	"ExitProcess"
    szGetModuleHandle:         array[0..16] of Char; //	"GetModuleHandleA"
    szlstrlen:                 array[0..8]  of Char; // "lstrlenA"

    szGetMessage:	       array[0..11] of Char; //	"GetMessageA"
    szTranslateMessage:        array[0..16] of Char; //	"TranslateMessage"
    szDispatchMessage:         array[0..16] of Char; //	"DispatchMessageA"
    szGetSystemMetrics:        array[0..16] of Char; //	"GetSystemMetrics"
    szPostMessage:	       array[0..12] of Char; //	"PostMessageA"
    szSendMessage:	       array[0..12] of Char; //	"SendMessageA"
    szShowWindow:	       array[0..10] of Char; //	"ShowWindow"
    szUpdateWindow:	       array[0..12] of Char; //	"UpdateWindow"
    szLoadCursor:	       array[0..11] of Char; //	"LoadCursorA"
    szLoadIcon:                array[0..9]  of Char; // "LoadIconA"
    szPostQuitMessage:         array[0..15] of Char; //	"PostQuitMessage"
    szMessageBox:	       array[0..11] of Char; //	"MessageBoxA"
    szRegisterClassEx:         array[0..16] of Char; //	"RegisterClassExA"
    szCreateWindowEx:          array[0..15] of Char; //	"CreateWindowExA"
    szDefWindowProc:           array[0..14] of Char; //	"DefWindowProcA"
    szSetFocus:	               array[0..8]  of Char; //	"SetFocus"
    szGetWindowLong:           array[0..14] of Char; //	"GetWindowLongA"
    szSetWindowLong:           array[0..14] of Char; //	"SetWindowLongA"
    szGetDlgItemText:          array[0..15] of Char; //	"GetDlgItemTextA"
    szGetSystemMenu:           array[0..13] of Char; //	"GetSystemMenu"
    szAppendMenu:              array[0..11] of Char; //	"AppendMenuA"
    szIsDialogMessage:	       array[0..15] of Char; //	"IsDialogMessage"
    szGetDlgItem:	       array[0..10] of Char; //	"GetDlgItem"
    szwsprintf:	               array[0..10] of Char; //	"wvsprintfA"
    szSetWindowText:	       array[0..14] of Char; //	"SetWindowTextA"

    szCreateFontIndirect:      array[0..19] of Char; //	"CreateFontIndirectA"
    szDeleteObject:	       array[0..12] of Char; //	"DeleteObject"

    _szAppClass:	       array[0..10]  of Char; // "PE Encrypt"
    _szAppTitle:	       array[0..20]  of Char; // "PE Encrypt :: v1.0"
    _szMenuAbout:	       array[0..20]  of Char; // "&About PE Encrypt..."
    _szMsgAbout:	       array[0..150] of Char; //

    _szClassEdit:	       array[0..4]   of Char; // "Edit"
    _szClassStatic:	       array[0..6]   of Char; // "Static"
    _szClassButton:	       array[0..6]   of Char; // "Button"
    _szTitlePassword:	       array[0..11]  of Char; // "叫块

⌨️ 快捷键说明

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