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

📄 system.pas

📁 delphi源代码分析源码
💻 PAS
字号:
unit System;

interface

procedure _InitLib;
procedure _HandleFinally;
procedure _halt0;

const
  Kernel32 = 'kernel32.dll';
  User32 = 'user32.dll';

type
  TGUID = record
    D1: LongWord;
    D2: Word;
    D3: Word;
    D4: array[0..7] of Byte;
  end;

type
  PInitContext = ^TInitContext;
  TInitContext = record
    OuterContext:   PInitContext;     { saved InitContext   }
{$IFNDEF PC_MAPPED_EXCEPTIONS}
    ExcFrame:       Pointer;          { bottom exc handler  }
{$ENDIF}
    InitTable:      Pointer;          { unit init info      }
    InitCount:      Integer;          { how far we got      }
    Module:         Pointer;          { ptr to module desc  }
    DLLSaveEBP:     Pointer;          { saved regs for DLLs }
    DLLSaveEBX:     Pointer;          { saved regs for DLLs }
    DLLSaveESI:     Pointer;          { saved regs for DLLs }
    DLLSaveEDI:     Pointer;          { saved regs for DLLs }
{$IFDEF MSWINDOWS}
    ExitProcessTLS: procedure;        { Shutdown for TLS    }
{$ENDIF}
    DLLInitState:   Byte;             { 0 = package, 1 = DLL shutdown, 2 = DLL startup }
  end platform;

type
  TDLLProc = procedure (Reason: Integer);
  // TDLLProcEx provides the reserved param returned by WinNT
  TDLLProcEx = procedure (Reason: Integer; Reserved: Integer);

var
  DllProc: TDLLProc;            { Called whenever DLL entry point is called }
  HInstance: LongWord;          { Handle of this instance }
  ExitCode: Integer;

implementation

procedure _InitLib;
asm
        { ->    EAX Inittable   }
        {       [EBP+8] Hinst   }
        {       [EBP+12] Reason }
        {       [EBP+16] Resvd  }

        MOV     EAX,[EBP+8]
        MOV     HInstance,EAX

        MOV     ECX,DllProc
        TEST    ECX,ECX
        JE      @@noDllProc
        PUSHA
        MOV     EAX,[EBP+12]
        MOV     EDX,[EBP+16]
        CALL    ECX
        POPA

@@noDllProc:
        CMP     [EBP+12],1
        JNE     _Halt0
        RET     4
end;

procedure _HandleFinally;
asm
end;

// same ExitDll()
procedure _halt0;
asm
        XOR     EAX,EAX
        XCHG    EAX, ExitCode
        NEG     EAX
        SBB     EAX,EAX
        INC     EAX

        LEAVE
        RET     12
end;

end.

⌨️ 快捷键说明

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