JwaSspi.pas
上传用户:davidchvip
上传日期:2009-07-28
资源大小:1749k
文件大小:120k
源码类别:

Windows编程

开发平台:

Delphi

  1. {******************************************************************************}
  2. {                                                                       }
  3. { Security Service Provider API interface Unit for Object Pascal               }
  4. {                                                                       }
  5. { Portions created by Microsoft are Copyright (C) 1995-2001 Microsoft          }
  6. { Corporation. All Rights Reserved.                                            }
  7. {                 }
  8. { The original file is: sspi.h, released June 2000. The original Pascal        }
  9. { code is: Sspi.pas, released December 2000. The initial developer of the      }
  10. { Pascal code is Marcel van Brakel (brakelm@chello.nl).                        }
  11. {                                                                              }
  12. { Portions created by Marcel van Brakel are Copyright (C) 1999-2001            }
  13. { Marcel van Brakel. All Rights Reserved.                                      }
  14. {                 }
  15. { Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI)        }
  16. {                }
  17. { You may retrieve the latest version of this file at the Project JEDI home    }
  18. { page, located at http://delphi-jedi.org or my personal homepage located at   }
  19. { http://members.chello.nl/m.vanbrakel2                                        }
  20. {                }
  21. { The contents of this file are used with permission, subject to the Mozilla   }
  22. { Public License Version 1.1 (the "License"); you may not use this file except }
  23. { in compliance with the License. You may obtain a copy of the License at      }
  24. { http://www.mozilla.org/MPL/MPL-1.1.html                                      }
  25. {                                                                              }
  26. { Software distributed under the License is distributed on an "AS IS" basis,   }
  27. { WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
  28. { the specific language governing rights and limitations under the License.    }
  29. {                                                                              }
  30. { Alternatively, the contents of this file may be used under the terms of the  }
  31. { GNU Lesser General Public License (the  "LGPL License"), in which case the   }
  32. { provisions of the LGPL License are applicable instead of those above.        }
  33. { If you wish to allow use of your version of this file only under the terms   }
  34. { of the LGPL License and not to allow others to use your version of this file }
  35. { under the MPL, indicate your decision by deleting  the provisions above and  }
  36. { replace  them with the notice and other provisions required by the LGPL      }
  37. { License.  If you do not delete the provisions above, a recipient may use     }
  38. { your version of this file under either the MPL or the LGPL License.          }
  39. {                 }
  40. { For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
  41. {                 }
  42. {******************************************************************************}
  43. unit JwaSspi;
  44. {$WEAKPACKAGEUNIT}
  45. {$HPPEMIT ''}
  46. {$HPPEMIT '#include "sspi.h"'}
  47. {$HPPEMIT ''}
  48. {$HPPEMIT '#typedef SEC_CHAR *PSEC_CHAR'}
  49. {$HPPEMIT '#typedef SEC_WCHAR *PSEC_WCHAR'}
  50. {$HPPEMIT ''}
  51. {$I WINDEFINES.INC}
  52. interface
  53. uses
  54.   JwaWinType;
  55. //
  56. // Determine environment:
  57. //
  58. const
  59.   ISSP_LEVEL = 32;
  60.   {$EXTERNALSYM ISSP_LEVEL}
  61.   ISSP_MODE  = 1;
  62.   {$EXTERNALSYM ISSP_MODE}
  63. //
  64. // Now, define platform specific mappings:
  65. //
  66. //
  67. // For NT-2 and up, wtypes will define HRESULT to be long.
  68. //
  69. type
  70.   SEC_WCHAR = WCHAR;
  71.   {$EXTERNALSYM SEC_WCHAR}
  72.   PSEC_WCHAR = ^SEC_CHAR;
  73.   {$NODEFINE PSEC_WCHAR}
  74.   PSecWChar = ^TSecWChar;
  75.   TSecWChar = SEC_WCHAR;
  76.   SEC_CHAR = CHAR;
  77.   {$EXTERNALSYM SEC_CHAR}
  78.   PSEC_CHAR = ^SEC_CHAR;
  79.   {$NODEFINE PSEC_CHAR}
  80.   PSecChar = ^TSecChar;
  81.   TSecChar = SEC_CHAR;
  82.   SECURITY_STATUS = LONG;
  83.   {$EXTERNALSYM SECURITY_STATUS}
  84.   PSecurityStatus = ^TSecurityStatus;
  85.   TSecurityStatus = SECURITY_STATUS;
  86. //
  87. // Decide what a string - 32 bits only since for 16 bits it is clear.
  88. //
  89. {$IFDEF UNICODE}
  90.   SECURITY_PSTR = ^SEC_WCHAR;
  91.   {$EXTERNALSYM SECURITY_PSTR}
  92.   SECURITY_PCSTR = ^SEC_WCHAR;
  93.   {$EXTERNALSYM SECURITY_PCSTR}
  94. {$ELSE}
  95.   SECURITY_PSTR = ^SEC_CHAR;
  96.   {$EXTERNALSYM SECURITY_PSTR}
  97.   SECURITY_PCSTR = ^SEC_CHAR;
  98.   {$EXTERNALSYM SECURITY_PCSTR}
  99. {$ENDIF}
  100. //
  101. // Okay, security specific types:
  102. //
  103.   PSecHandle = ^SecHandle;
  104.   {$EXTERNALSYM PSecHandle}
  105.   _SecHandle = record
  106.     dwLower: ULONG_PTR;
  107.     dwUpper: ULONG_PTR;
  108.   end;
  109.   {$EXTERNALSYM _SecHandle}
  110.   SecHandle = _SecHandle;
  111.   {$EXTERNALSYM SecHandle}
  112.   TSecHandle = SecHandle;
  113. procedure SecInvalidateHandle(var x: SecHandle);
  114. {$EXTERNALSYM SecInvalidateHandle}
  115. function SecIsValidHandle(x: SecHandle): Boolean;
  116. {$EXTERNALSYM SecIsValidHandle}
  117. type
  118.   CredHandle = SecHandle;
  119.   {$EXTERNALSYM CredHandle}
  120.   PCredHandle = ^CredHandle;
  121.   {$EXTERNALSYM PCredHandle}
  122.   TCredHandle = CredHandle;
  123.   CtxtHandle = SecHandle;
  124.   {$EXTERNALSYM CtxtHandle}
  125.   PCtxtHandle = ^CtxtHandle;
  126.   {$EXTERNALSYM PCtxthandle}
  127.   TCtxthandle = CtxtHandle;
  128.   _SECURITY_INTEGER = LARGE_INTEGER;
  129.   {$EXTERNALSYM _SECURITY_INTEGER}
  130.   SECURITY_INTEGER = _SECURITY_INTEGER;
  131.   {$EXTERNALSYM SECURITY_INTEGER}
  132.   PSECURITY_INTEGER = ^SECURITY_INTEGER;
  133.   {$EXTERNALSYM PSECURITY_INTEGER}
  134. // todo Timestamp was removed from SSPI in August 2001 PSDK, where is it now?!
  135.   TimeStamp = SECURITY_INTEGER;
  136.   {$EXTERNALSYM TimeStamp}
  137.   PTimeStamp = ^SECURITY_INTEGER;
  138.   {$EXTERNALSYM PTimeStamp}
  139.   TTimeStamp = TimeStamp;
  140. //
  141. // If we are in 32 bit mode, define the SECURITY_STRING structure,
  142. // as a clone of the base UNICODE_STRING structure.  This is used
  143. // internally in security components, an as the string interface
  144. // for kernel components (e.g. FSPs)
  145. //
  146.   SECURITY_STRING = UNICODE_STRING;
  147.   {$EXTERNALSYM SECURITY_STRING}
  148.   PSECURITY_STRING = ^SECURITY_STRING;
  149.   {$EXTERNALSYM PSECURITY_STRING}
  150.   TSecurityString = SECURITY_STRING;
  151.   PSecurityString = PSECURITY_STRING;
  152. //
  153. // SecPkgInfo structure
  154. //
  155. //  Provides general information about a security provider
  156. //
  157.   PSecPkgInfoW = ^SecPkgInfoW;
  158.   {$EXTERNALSYM PSecPkgInfoW}
  159.   _SecPkgInfoW = record
  160.     fCapabilities: Cardinal; // Capability bitmask
  161.     wVersion: Word; // Version of driver
  162.     wRPCID: Word; // ID for RPC Runtime
  163.     cbMaxToken: Cardinal; // Size of authentication token (max)
  164.     Name: PSecWChar; // Text name
  165.     Comment: PSecWChar; // Comment
  166.   end;
  167.   {$EXTERNALSYM _SecPkgInfoW}
  168.   SecPkgInfoW = _SecPkgInfoW;
  169.   {$EXTERNALSYM SecPkgInfoW}
  170.   TSecPkgInfoW = SecPkgInfoW;
  171.   PSecPkgInfoA = ^SecPkgInfoA;
  172.   {$EXTERNALSYM PSecPkgInfoA}
  173.   _SecPkgInfoA = record
  174.     fCapabilities: Cardinal; // Capability bitmask
  175.     wVersion: Word; // Version of driver
  176.     wRPCID: Word; // ID for RPC Runtime
  177.     cbMaxToken: Cardinal; // Size of authentication token (max)
  178.     Name: PSecChar; // Text name
  179.     Comment: PSecChar; // Comment
  180.   end;
  181.   {$EXTERNALSYM _SecPkgInfoA}
  182.   SecPkgInfoA = _SecPkgInfoA;
  183.   {$EXTERNALSYM SecPkgInfoA}
  184.   TSecPkgInfoA = SecPkgInfoA;
  185. {$IFDEF UNICODE}
  186.   SecPkgInfo = SecPkgInfoW;
  187.   {$EXTERNALSYM SecPkgInfo}
  188.   PSecPkgInfo = PSecPkgInfoW;
  189.   {$EXTERNALSYM PSecPkgInfo}
  190.   TSecPkgInfo = TSecPkgInfoW;
  191. {$ELSE}
  192.   SecPkgInfo = SecPkgInfoA;
  193.   {$EXTERNALSYM SecPkgInfo}
  194.   PSecPkgInfo = PSecPkgInfoA;
  195.   {$EXTERNALSYM PSecPkgInfo}
  196.   TSecPkgInfo = TSecPkgInfoA;
  197. {$ENDIF}
  198. //
  199. //  Security Package Capabilities
  200. //
  201. const
  202.   SECPKG_FLAG_INTEGRITY         = $00000001; // Supports integrity on messages
  203.   {$EXTERNALSYM SECPKG_FLAG_INTEGRITY}
  204.   SECPKG_FLAG_PRIVACY           = $00000002; // Supports privacy (confidentiality)
  205.   {$EXTERNALSYM SECPKG_FLAG_PRIVACY}
  206.   SECPKG_FLAG_TOKEN_ONLY        = $00000004; // Only security token needed
  207.   {$EXTERNALSYM SECPKG_FLAG_TOKEN_ONLY}
  208.   SECPKG_FLAG_DATAGRAM          = $00000008; // Datagram RPC support
  209.   {$EXTERNALSYM SECPKG_FLAG_DATAGRAM}
  210.   SECPKG_FLAG_CONNECTION        = $00000010; // Connection oriented RPC support
  211.   {$EXTERNALSYM SECPKG_FLAG_CONNECTION}
  212.   SECPKG_FLAG_MULTI_REQUIRED    = $00000020; // Full 3-leg required for re-auth.
  213.   {$EXTERNALSYM SECPKG_FLAG_MULTI_REQUIRED}
  214.   SECPKG_FLAG_CLIENT_ONLY       = $00000040; // Server side functionality not available
  215.   {$EXTERNALSYM SECPKG_FLAG_CLIENT_ONLY}
  216.   SECPKG_FLAG_EXTENDED_ERROR    = $00000080; // Supports extended error msgs
  217.   {$EXTERNALSYM SECPKG_FLAG_EXTENDED_ERROR}
  218.   SECPKG_FLAG_IMPERSONATION     = $00000100; // Supports impersonation
  219.   {$EXTERNALSYM SECPKG_FLAG_IMPERSONATION}
  220.   SECPKG_FLAG_ACCEPT_WIN32_NAME = $00000200; // Accepts Win32 names
  221.   {$EXTERNALSYM SECPKG_FLAG_ACCEPT_WIN32_NAME}
  222.   SECPKG_FLAG_STREAM            = $00000400; // Supports stream semantics
  223.   {$EXTERNALSYM SECPKG_FLAG_STREAM}
  224.   SECPKG_FLAG_NEGOTIABLE        = $00000800; // Can be used by the negotiate package
  225.   {$EXTERNALSYM SECPKG_FLAG_NEGOTIABLE}
  226.   SECPKG_FLAG_GSS_COMPATIBLE    = $00001000; // GSS Compatibility Available
  227.   {$EXTERNALSYM SECPKG_FLAG_GSS_COMPATIBLE}
  228.   SECPKG_FLAG_LOGON             = $00002000; // Supports common LsaLogonUser
  229.   {$EXTERNALSYM SECPKG_FLAG_LOGON}
  230.   SECPKG_FLAG_ASCII_BUFFERS     = $00004000; // Token Buffers are in ASCII
  231.   {$EXTERNALSYM SECPKG_FLAG_ASCII_BUFFERS}
  232.   SECPKG_FLAG_FRAGMENT          = $00008000; // Package can fragment to fit
  233.   {$EXTERNALSYM SECPKG_FLAG_FRAGMENT}
  234.   SECPKG_FLAG_MUTUAL_AUTH       = $00010000; // Package can perform mutual authentication
  235.   {$EXTERNALSYM SECPKG_FLAG_MUTUAL_AUTH}
  236.   SECPKG_FLAG_DELEGATION        = $00020000; // Package can delegate
  237.   {$EXTERNALSYM SECPKG_FLAG_DELEGATION}
  238.   SECPKG_ID_NONE = $FFFF;
  239.   {$EXTERNALSYM SECPKG_ID_NONE}
  240. //
  241. // SecBuffer
  242. //
  243. //  Generic memory descriptors for buffers passed in to the security
  244. //  API
  245. //
  246. type
  247.   PSecBuffer = ^SecBuffer;
  248.   {$EXTERNALSYM PSecBuffer}
  249.   _SecBuffer = record
  250.     cbBuffer: Cardinal;   // Size of the buffer, in bytes
  251.     BufferType: Cardinal; // Type of the buffer (below)
  252.     pvBuffer: Pointer;    // Pointer to the buffer
  253.   end;
  254.   {$EXTERNALSYM _SecBuffer}
  255.   SecBuffer = _SecBuffer;
  256.   {$EXTERNALSYM SecBuffer}
  257.   TSecBuffer = SecBuffer;
  258.   PSecBufferDesc = ^SecBufferDesc;
  259.   {$EXTERNALSYM PSecBufferDesc}
  260.   _SecBufferDesc = record
  261.     ulVersion: Cardinal;  // Version number
  262.     cBuffers: Cardinal;   // Number of buffers
  263.     pBuffers: PSecBuffer; // Pointer to array of buffers
  264.   end;
  265.   {$EXTERNALSYM _SecBufferDesc}
  266.   SecBufferDesc = _SecBufferDesc;
  267.   {$EXTERNALSYM SecBufferDesc}
  268.   TSecBufferDesc = SecBufferDesc;
  269. const
  270.   SECBUFFER_VERSION = 0;
  271.   {$EXTERNALSYM SECBUFFER_VERSION}
  272.   SECBUFFER_EMPTY              = 0; // Undefined, replaced by provider
  273.   {$EXTERNALSYM SECBUFFER_EMPTY}
  274.   SECBUFFER_DATA               = 1; // Packet data
  275.   {$EXTERNALSYM SECBUFFER_DATA}
  276.   SECBUFFER_TOKEN              = 2; // Security token
  277.   {$EXTERNALSYM SECBUFFER_TOKEN}
  278.   SECBUFFER_PKG_PARAMS         = 3; // Package specific parameters
  279.   {$EXTERNALSYM SECBUFFER_PKG_PARAMS}
  280.   SECBUFFER_MISSING            = 4; // Missing Data indicator
  281.   {$EXTERNALSYM SECBUFFER_MISSING}
  282.   SECBUFFER_EXTRA              = 5; // Extra data
  283.   {$EXTERNALSYM SECBUFFER_EXTRA}
  284.   SECBUFFER_STREAM_TRAILER     = 6; // Security Trailer
  285.   {$EXTERNALSYM SECBUFFER_STREAM_TRAILER}
  286.   SECBUFFER_STREAM_HEADER      = 7; // Security Header
  287.   {$EXTERNALSYM SECBUFFER_STREAM_HEADER}
  288.   SECBUFFER_NEGOTIATION_INFO   = 8; // Hints from the negotiation pkg
  289.   {$EXTERNALSYM SECBUFFER_NEGOTIATION_INFO}
  290.   SECBUFFER_PADDING            = 9; // non-data padding
  291.   {$EXTERNALSYM SECBUFFER_PADDING}
  292.   SECBUFFER_STREAM             = 10; // whole encrypted message
  293.   {$EXTERNALSYM SECBUFFER_STREAM}
  294.   SECBUFFER_MECHLIST           = 11;
  295.   {$EXTERNALSYM SECBUFFER_MECHLIST}
  296.   SECBUFFER_MECHLIST_SIGNATURE = 12;
  297.   {$EXTERNALSYM SECBUFFER_MECHLIST_SIGNATURE}
  298.   SECBUFFER_TARGET             = 13;
  299.   {$EXTERNALSYM SECBUFFER_TARGET}
  300.   SECBUFFER_CHANNEL_BINDINGS   = 14;
  301.   {$EXTERNALSYM SECBUFFER_CHANNEL_BINDINGS}
  302.   SECBUFFER_ATTRMASK = DWORD($F0000000);
  303.   {$EXTERNALSYM SECBUFFER_ATTRMASK}
  304.   SECBUFFER_READONLY = DWORD($80000000); // Buffer is read-only
  305.   {$EXTERNALSYM SECBUFFER_READONLY}
  306.   SECBUFFER_READONLY_WITH_CHECKSUM = $10000000;  // Buffer is read-only, and checksummed
  307.   {$EXTERNALSYM SECBUFFER_READONLY_WITH_CHECKSUM}
  308.   SECBUFFER_RESERVED = DWORD($60000000); // Flags reserved to security system
  309.   {$EXTERNALSYM SECBUFFER_RESERVED}
  310. type
  311.   PSEC_NEGOTIATION_INFO = ^SEC_NEGOTIATION_INFO;
  312.   {$EXTERNALSYM PSEC_NEGOTIATION_INFO}
  313.   _SEC_NEGOTIATION_INFO = record
  314.     Size: Cardinal;       // Size of this structure
  315.     NameLength: Cardinal; // Length of name hint
  316.     Name: PSecWChar;     // Name hint
  317.     Reserved: Pointer;    // Reserved
  318.   end;
  319.   {$EXTERNALSYM _SEC_NEGOTIATION_INFO}
  320.   SEC_NEGOTIATION_INFO = _SEC_NEGOTIATION_INFO;
  321.   {$EXTERNALSYM SEC_NEGOTIATION_INFO}
  322.   TSecNegotiationInfo = SEC_NEGOTIATION_INFO;
  323.   PSecNegotiationInfo = PSEC_NEGOTIATION_INFO;
  324.   _SEC_CHANNEL_BINDINGS = record
  325.     dwInitiatorAddrType: Cardinal;
  326.     cbInitiatorLength: Cardinal;
  327.     dwInitiatorOffset: Cardinal;
  328.     dwAcceptorAddrType: Cardinal;
  329.     cbAcceptorLength: Cardinal;
  330.     dwAcceptorOffset: Cardinal;
  331.     cbApplicationDataLength: Cardinal;
  332.     dwApplicationDataOffset: Cardinal;
  333.   end;
  334.   {$EXTERNALSYM _SEC_CHANNEL_BINDINGS}
  335.   SEC_CHANNEL_BINDINGS = _SEC_CHANNEL_BINDINGS;
  336.   {$EXTERNALSYM SEC_CHANNEL_BINDINGS}
  337.   PSEC_CHANNEL_BINDINGS = ^SEC_CHANNEL_BINDINGS;
  338.   {$EXTERNALSYM PSEC_CHANNEL_BINDINGS}
  339.   TSecChannelBindings = SEC_CHANNEL_BINDINGS;
  340.   PSecChannelBindings = PSEC_CHANNEL_BINDINGS;  
  341. //
  342. //  Data Representation Constant:
  343. //
  344. const
  345.   SECURITY_NATIVE_DREP  = $00000010;
  346.   {$EXTERNALSYM SECURITY_NATIVE_DREP}
  347.   SECURITY_NETWORK_DREP = $00000000;
  348.   {$EXTERNALSYM SECURITY_NETWORK_DREP}
  349. //
  350. //  Credential Use Flags
  351. //
  352.   SECPKG_CRED_INBOUND  = $00000001;
  353.   {$EXTERNALSYM SECPKG_CRED_INBOUND}
  354.   SECPKG_CRED_OUTBOUND = $00000002;
  355.   {$EXTERNALSYM SECPKG_CRED_OUTBOUND}
  356.   SECPKG_CRED_BOTH     = $00000003;
  357.   {$EXTERNALSYM SECPKG_CRED_BOTH}
  358.   SECPKG_CRED_DEFAULT  = $00000004;
  359.   {$EXTERNALSYM SECPKG_CRED_DEFAULT}
  360.   SECPKG_CRED_RESERVED = DWORD($F0000000);
  361.   {$EXTERNALSYM SECPKG_CRED_RESERVED}
  362. //
  363. //  InitializeSecurityContext Requirement and return flags:
  364. //
  365.   ISC_REQ_DELEGATE               = $00000001;
  366.   {$EXTERNALSYM ISC_REQ_DELEGATE}
  367.   ISC_REQ_MUTUAL_AUTH            = $00000002;
  368.   {$EXTERNALSYM ISC_REQ_MUTUAL_AUTH}
  369.   ISC_REQ_REPLAY_DETECT          = $00000004;
  370.   {$EXTERNALSYM ISC_REQ_REPLAY_DETECT}
  371.   ISC_REQ_SEQUENCE_DETECT        = $00000008;
  372.   {$EXTERNALSYM ISC_REQ_SEQUENCE_DETECT}
  373.   ISC_REQ_CONFIDENTIALITY        = $00000010;
  374.   {$EXTERNALSYM ISC_REQ_CONFIDENTIALITY}
  375.   ISC_REQ_USE_SESSION_KEY        = $00000020;
  376.   {$EXTERNALSYM ISC_REQ_USE_SESSION_KEY}
  377.   ISC_REQ_PROMPT_FOR_CREDS       = $00000040;
  378.   {$EXTERNALSYM ISC_REQ_PROMPT_FOR_CREDS}
  379.   ISC_REQ_USE_SUPPLIED_CREDS     = $00000080;
  380.   {$EXTERNALSYM ISC_REQ_USE_SUPPLIED_CREDS}
  381.   ISC_REQ_ALLOCATE_MEMORY        = $00000100;
  382.   {$EXTERNALSYM ISC_REQ_ALLOCATE_MEMORY}
  383.   ISC_REQ_USE_DCE_STYLE          = $00000200;
  384.   {$EXTERNALSYM ISC_REQ_USE_DCE_STYLE}
  385.   ISC_REQ_DATAGRAM               = $00000400;
  386.   {$EXTERNALSYM ISC_REQ_DATAGRAM}
  387.   ISC_REQ_CONNECTION             = $00000800;
  388.   {$EXTERNALSYM ISC_REQ_CONNECTION}
  389.   ISC_REQ_CALL_LEVEL             = $00001000;
  390.   {$EXTERNALSYM ISC_REQ_CALL_LEVEL}
  391.   ISC_REQ_FRAGMENT_SUPPLIED      = $00002000;
  392.   {$EXTERNALSYM ISC_REQ_FRAGMENT_SUPPLIED}
  393.   ISC_REQ_EXTENDED_ERROR         = $00004000;
  394.   {$EXTERNALSYM ISC_REQ_EXTENDED_ERROR}
  395.   ISC_REQ_STREAM                 = $00008000;
  396.   {$EXTERNALSYM ISC_REQ_STREAM}
  397.   ISC_REQ_INTEGRITY              = $00010000;
  398.   {$EXTERNALSYM ISC_REQ_INTEGRITY}
  399.   ISC_REQ_IDENTIFY               = $00020000;
  400.   {$EXTERNALSYM ISC_REQ_IDENTIFY}
  401.   ISC_REQ_NULL_SESSION           = $00040000;
  402.   {$EXTERNALSYM ISC_REQ_NULL_SESSION}
  403.   ISC_REQ_MANUAL_CRED_VALIDATION = $00080000;
  404.   {$EXTERNALSYM ISC_REQ_MANUAL_CRED_VALIDATION}
  405.   ISC_REQ_RESERVED1              = $00100000;
  406.   {$EXTERNALSYM ISC_REQ_RESERVED1}
  407.   ISC_REQ_FRAGMENT_TO_FIT        = $00200000;
  408.   {$EXTERNALSYM ISC_REQ_FRAGMENT_TO_FIT}
  409.   ISC_RET_DELEGATE               = $00000001;
  410.   {$EXTERNALSYM ISC_RET_DELEGATE}
  411.   ISC_RET_MUTUAL_AUTH            = $00000002;
  412.   {$EXTERNALSYM ISC_RET_MUTUAL_AUTH}
  413.   ISC_RET_REPLAY_DETECT          = $00000004;
  414.   {$EXTERNALSYM ISC_RET_REPLAY_DETECT}
  415.   ISC_RET_SEQUENCE_DETECT        = $00000008;
  416.   {$EXTERNALSYM ISC_RET_SEQUENCE_DETECT}
  417.   ISC_RET_CONFIDENTIALITY        = $00000010;
  418.   {$EXTERNALSYM ISC_RET_CONFIDENTIALITY}
  419.   ISC_RET_USE_SESSION_KEY        = $00000020;
  420.   {$EXTERNALSYM ISC_RET_USE_SESSION_KEY}
  421.   ISC_RET_USED_COLLECTED_CREDS   = $00000040;
  422.   {$EXTERNALSYM ISC_RET_USED_COLLECTED_CREDS}
  423.   ISC_RET_USED_SUPPLIED_CREDS    = $00000080;
  424.   {$EXTERNALSYM ISC_RET_USED_SUPPLIED_CREDS}
  425.   ISC_RET_ALLOCATED_MEMORY       = $00000100;
  426.   {$EXTERNALSYM ISC_RET_ALLOCATED_MEMORY}
  427.   ISC_RET_USED_DCE_STYLE         = $00000200;
  428.   {$EXTERNALSYM ISC_RET_USED_DCE_STYLE}
  429.   ISC_RET_DATAGRAM               = $00000400;
  430.   {$EXTERNALSYM ISC_RET_DATAGRAM}
  431.   ISC_RET_CONNECTION             = $00000800;
  432.   {$EXTERNALSYM ISC_RET_CONNECTION}
  433.   ISC_RET_INTERMEDIATE_RETURN    = $00001000;
  434.   {$EXTERNALSYM ISC_RET_INTERMEDIATE_RETURN}
  435.   ISC_RET_CALL_LEVEL             = $00002000;
  436.   {$EXTERNALSYM ISC_RET_CALL_LEVEL}
  437.   ISC_RET_EXTENDED_ERROR         = $00004000;
  438.   {$EXTERNALSYM ISC_RET_EXTENDED_ERROR}
  439.   ISC_RET_STREAM                 = $00008000;
  440.   {$EXTERNALSYM ISC_RET_STREAM}
  441.   ISC_RET_INTEGRITY              = $00010000;
  442.   {$EXTERNALSYM ISC_RET_INTEGRITY}
  443.   ISC_RET_IDENTIFY               = $00020000;
  444.   {$EXTERNALSYM ISC_RET_IDENTIFY}
  445.   ISC_RET_NULL_SESSION           = $00040000;
  446.   {$EXTERNALSYM ISC_RET_NULL_SESSION}
  447.   ISC_RET_MANUAL_CRED_VALIDATION = $00080000;
  448.   {$EXTERNALSYM ISC_RET_MANUAL_CRED_VALIDATION}
  449.   ISC_RET_RESERVED1              = $00100000;
  450.   {$EXTERNALSYM ISC_RET_RESERVED1}
  451.   ISC_RET_FRAGMENT_ONLY          = $00200000;
  452.   {$EXTERNALSYM ISC_RET_FRAGMENT_ONLY}
  453.   ASC_REQ_DELEGATE              = $00000001;
  454.   {$EXTERNALSYM ASC_REQ_DELEGATE}
  455.   ASC_REQ_MUTUAL_AUTH           = $00000002;
  456.   {$EXTERNALSYM ASC_REQ_MUTUAL_AUTH}
  457.   ASC_REQ_REPLAY_DETECT         = $00000004;
  458.   {$EXTERNALSYM ASC_REQ_REPLAY_DETECT}
  459.   ASC_REQ_SEQUENCE_DETECT       = $00000008;
  460.   {$EXTERNALSYM ASC_REQ_SEQUENCE_DETECT}
  461.   ASC_REQ_CONFIDENTIALITY       = $00000010;
  462.   {$EXTERNALSYM ASC_REQ_CONFIDENTIALITY}
  463.   ASC_REQ_USE_SESSION_KEY       = $00000020;
  464.   {$EXTERNALSYM ASC_REQ_USE_SESSION_KEY}
  465.   ASC_REQ_ALLOCATE_MEMORY       = $00000100;
  466.   {$EXTERNALSYM ASC_REQ_ALLOCATE_MEMORY}
  467.   ASC_REQ_USE_DCE_STYLE         = $00000200;
  468.   {$EXTERNALSYM ASC_REQ_USE_DCE_STYLE}
  469.   ASC_REQ_DATAGRAM              = $00000400;
  470.   {$EXTERNALSYM ASC_REQ_DATAGRAM}
  471.   ASC_REQ_CONNECTION            = $00000800;
  472.   {$EXTERNALSYM ASC_REQ_CONNECTION}
  473.   ASC_REQ_CALL_LEVEL            = $00001000;
  474.   {$EXTERNALSYM ASC_REQ_CALL_LEVEL}
  475.   ASC_REQ_EXTENDED_ERROR        = $00008000;
  476.   {$EXTERNALSYM ASC_REQ_EXTENDED_ERROR}
  477.   ASC_REQ_STREAM                = $00010000;
  478.   {$EXTERNALSYM ASC_REQ_STREAM}
  479.   ASC_REQ_INTEGRITY             = $00020000;
  480.   {$EXTERNALSYM ASC_REQ_INTEGRITY}
  481.   ASC_REQ_LICENSING             = $00040000;
  482.   {$EXTERNALSYM ASC_REQ_LICENSING}
  483.   ASC_REQ_IDENTIFY              = $00080000;
  484.   {$EXTERNALSYM ASC_REQ_IDENTIFY}
  485.   ASC_REQ_ALLOW_NULL_SESSION    = $00100000;
  486.   {$EXTERNALSYM ASC_REQ_ALLOW_NULL_SESSION}
  487.   ASC_REQ_ALLOW_NON_USER_LOGONS = $00200000;
  488.   {$EXTERNALSYM ASC_REQ_ALLOW_NON_USER_LOGONS}
  489.   ASC_REQ_ALLOW_CONTEXT_REPLAY  = $00400000;
  490.   {$EXTERNALSYM ASC_REQ_ALLOW_CONTEXT_REPLAY}
  491.   ASC_REQ_FRAGMENT_TO_FIT       = $00800000;
  492.   {$EXTERNALSYM ASC_REQ_FRAGMENT_TO_FIT}
  493.   ASC_REQ_FRAGMENT_SUPPLIED     = $00002000;
  494.   {$EXTERNALSYM ASC_REQ_FRAGMENT_SUPPLIED}
  495.   ASC_REQ_NO_TOKEN              = $01000000;
  496.   {$EXTERNALSYM ASC_REQ_NO_TOKEN}
  497.   ASC_RET_DELEGATE              = $00000001;
  498.   {$EXTERNALSYM ASC_RET_DELEGATE}
  499.   ASC_RET_MUTUAL_AUTH           = $00000002;
  500.   {$EXTERNALSYM ASC_RET_MUTUAL_AUTH}
  501.   ASC_RET_REPLAY_DETECT         = $00000004;
  502.   {$EXTERNALSYM ASC_RET_REPLAY_DETECT}
  503.   ASC_RET_SEQUENCE_DETECT       = $00000008;
  504.   {$EXTERNALSYM ASC_RET_SEQUENCE_DETECT}
  505.   ASC_RET_CONFIDENTIALITY       = $00000010;
  506.   {$EXTERNALSYM ASC_RET_CONFIDENTIALITY}
  507.   ASC_RET_USE_SESSION_KEY       = $00000020;
  508.   {$EXTERNALSYM ASC_RET_USE_SESSION_KEY}
  509.   ASC_RET_ALLOCATED_MEMORY      = $00000100;
  510.   {$EXTERNALSYM ASC_RET_ALLOCATED_MEMORY}
  511.   ASC_RET_USED_DCE_STYLE        = $00000200;
  512.   {$EXTERNALSYM ASC_RET_USED_DCE_STYLE}
  513.   ASC_RET_DATAGRAM              = $00000400;
  514.   {$EXTERNALSYM ASC_RET_DATAGRAM}
  515.   ASC_RET_CONNECTION            = $00000800;
  516.   {$EXTERNALSYM ASC_RET_CONNECTION}
  517.   ASC_RET_CALL_LEVEL            = $00002000; // skipped 1000 to be like ISC_
  518.   {$EXTERNALSYM ASC_RET_CALL_LEVEL}
  519.   ASC_RET_THIRD_LEG_FAILED      = $00004000;
  520.   {$EXTERNALSYM ASC_RET_THIRD_LEG_FAILED}
  521.   ASC_RET_EXTENDED_ERROR        = $00008000;
  522.   {$EXTERNALSYM ASC_RET_EXTENDED_ERROR}
  523.   ASC_RET_STREAM                = $00010000;
  524.   {$EXTERNALSYM ASC_RET_STREAM}
  525.   ASC_RET_INTEGRITY             = $00020000;
  526.   {$EXTERNALSYM ASC_RET_INTEGRITY}
  527.   ASC_RET_LICENSING             = $00040000;
  528.   {$EXTERNALSYM ASC_RET_LICENSING}
  529.   ASC_RET_IDENTIFY              = $00080000;
  530.   {$EXTERNALSYM ASC_RET_IDENTIFY}
  531.   ASC_RET_NULL_SESSION          = $00100000;
  532.   {$EXTERNALSYM ASC_RET_NULL_SESSION}
  533.   ASC_RET_ALLOW_NON_USER_LOGONS = $00200000;
  534.   {$EXTERNALSYM ASC_RET_ALLOW_NON_USER_LOGONS}
  535.   ASC_RET_ALLOW_CONTEXT_REPLAY  = $00400000;
  536.   {$EXTERNALSYM ASC_RET_ALLOW_CONTEXT_REPLAY}
  537.   ASC_RET_FRAGMENT_ONLY         = $00800000;
  538.   {$EXTERNALSYM ASC_RET_FRAGMENT_ONLY}
  539.   ASC_RET_NO_TOKEN              = $01000000;
  540.   {$EXTERNALSYM ASC_RET_NO_TOKEN}
  541. //
  542. //  Security Credentials Attributes:
  543. //
  544.   SECPKG_CRED_ATTR_NAMES = 1;
  545.   {$EXTERNALSYM SECPKG_CRED_ATTR_NAMES}
  546. type
  547.   PSecPkgCredentials_NamesW = ^SecPkgCredentials_NamesW;
  548.   {$EXTERNALSYM PSecPkgCredentials_NamesW}
  549.   _SecPkgCredentials_NamesW = record
  550.     sUserName: PSecWChar;
  551.   end;
  552.   {$EXTERNALSYM _SecPkgCredentials_NamesW}
  553.   SecPkgCredentials_NamesW = _SecPkgCredentials_NamesW;
  554.   {$EXTERNALSYM SecPkgCredentials_NamesW}
  555.   TSecPkgCredentialsNamesW = SecPkgCredentials_NamesW;
  556.   PSecPkgCredentialsNamesW = PSecPkgCredentials_NamesW;
  557.   PSecPkgCredentials_NamesA = ^SecPkgCredentials_NamesA;
  558.   {$EXTERNALSYM PSecPkgCredentials_NamesA}
  559.   _SecPkgCredentials_NamesA = record
  560.     sUserName: PSecChar;
  561.   end;
  562.   {$EXTERNALSYM _SecPkgCredentials_NamesA}
  563.   SecPkgCredentials_NamesA = _SecPkgCredentials_NamesA;
  564.   {$EXTERNALSYM SecPkgCredentials_NamesA}
  565.   TSecPkgCredentialsNamesA = SecPkgCredentials_NamesA;
  566.   PSecPkgCredentialsNamesA = PSecPkgCredentials_NamesA;
  567. {$IFDEF UNICODE}
  568.   SecPkgCredentials_Names = SecPkgCredentials_NamesW;
  569.   {$EXTERNALSYM SecPkgCredentials_Names}
  570.   PSecPkgCredentials_Names = PSecPkgCredentials_NamesW;
  571.   {$EXTERNALSYM PSecPkgCredentials_Names}
  572.   TSecPkgCredentialsNames = TSecPkgCredentialsNamesW;
  573.   PSecPkgCredentialsNames = PSecPkgCredentialsNamesW;
  574. {$ELSE}
  575.   SecPkgCredentials_Names = SecPkgCredentials_NamesA;
  576.   {$EXTERNALSYM SecPkgCredentials_Names}
  577.   PSecPkgCredentials_Names = PSecPkgCredentials_NamesA;
  578.   {$EXTERNALSYM PSecPkgCredentials_Names}
  579.   TSecPkgCredentialsNames = TSecPkgCredentialsNamesA;
  580.   PSecPkgCredentialsNames = PSecPkgCredentialsNamesA;
  581. {$ENDIF}
  582. //
  583. //  Security Context Attributes:
  584. //
  585. const
  586.   SECPKG_ATTR_SIZES            = 0;
  587.   {$EXTERNALSYM SECPKG_ATTR_SIZES}
  588.   SECPKG_ATTR_NAMES            = 1;
  589.   {$EXTERNALSYM SECPKG_ATTR_NAMES}
  590.   SECPKG_ATTR_LIFESPAN         = 2;
  591.   {$EXTERNALSYM SECPKG_ATTR_LIFESPAN}
  592.   SECPKG_ATTR_DCE_INFO         = 3;
  593.   {$EXTERNALSYM SECPKG_ATTR_DCE_INFO}
  594.   SECPKG_ATTR_STREAM_SIZES     = 4;
  595.   {$EXTERNALSYM SECPKG_ATTR_STREAM_SIZES}
  596.   SECPKG_ATTR_KEY_INFO         = 5;
  597.   {$EXTERNALSYM SECPKG_ATTR_KEY_INFO}
  598.   SECPKG_ATTR_AUTHORITY        = 6;
  599.   {$EXTERNALSYM SECPKG_ATTR_AUTHORITY}
  600.   SECPKG_ATTR_PROTO_INFO       = 7;
  601.   {$EXTERNALSYM SECPKG_ATTR_PROTO_INFO}
  602.   SECPKG_ATTR_PASSWORD_EXPIRY  = 8;
  603.   {$EXTERNALSYM SECPKG_ATTR_PASSWORD_EXPIRY}
  604.   SECPKG_ATTR_SESSION_KEY      = 9;
  605.   {$EXTERNALSYM SECPKG_ATTR_SESSION_KEY}
  606.   SECPKG_ATTR_PACKAGE_INFO     = 10;
  607.   {$EXTERNALSYM SECPKG_ATTR_PACKAGE_INFO}
  608.   SECPKG_ATTR_USER_FLAGS       = 11;
  609.   {$EXTERNALSYM SECPKG_ATTR_USER_FLAGS}
  610.   SECPKG_ATTR_NEGOTIATION_INFO = 12;
  611.   {$EXTERNALSYM SECPKG_ATTR_NEGOTIATION_INFO}
  612.   SECPKG_ATTR_NATIVE_NAMES     = 13;
  613.   {$EXTERNALSYM SECPKG_ATTR_NATIVE_NAMES}
  614.   SECPKG_ATTR_FLAGS            = 14;
  615.   {$EXTERNALSYM SECPKG_ATTR_FLAGS}
  616.   SECPKG_ATTR_USE_VALIDATED    = 15;
  617.   {$EXTERNALSYM SECPKG_ATTR_USE_VALIDATED}
  618.   SECPKG_ATTR_CREDENTIAL_NAME  = 16;
  619.   {$EXTERNALSYM SECPKG_ATTR_CREDENTIAL_NAME}
  620.   SECPKG_ATTR_TARGET_INFORMATION = 17;
  621.   {$EXTERNALSYM SECPKG_ATTR_TARGET_INFORMATION}
  622.   SECPKG_ATTR_ACCESS_TOKEN     = 18;
  623.   {$EXTERNALSYM SECPKG_ATTR_ACCESS_TOKEN}
  624.   SECPKG_ATTR_TARGET           = 19;
  625.   {$EXTERNALSYM SECPKG_ATTR_TARGET}
  626.   SECPKG_ATTR_AUTHENTICATION_ID = 20;
  627.   {$EXTERNALSYM SECPKG_ATTR_AUTHENTICATION_ID}
  628. type
  629.   PSecPkgContext_Sizes = ^SecPkgContext_Sizes;
  630.   {$EXTERNALSYM PSecPkgContext_Sizes}
  631.   _SecPkgContext_Sizes = record
  632.     cbMaxToken: Cardinal;
  633.     cbMaxSignature: Cardinal;
  634.     cbBlockSize: Cardinal;
  635.     cbSecurityTrailer: Cardinal;
  636.   end;
  637.   {$EXTERNALSYM _SecPkgContext_Sizes}
  638.   SecPkgContext_Sizes = _SecPkgContext_Sizes;
  639.   {$EXTERNALSYM SecPkgContext_Sizes}
  640.   TSecPkgContextSizes = SecPkgContext_Sizes;
  641.   PSecPkgContextSizes = PSecPkgContext_Sizes;
  642.   PSecPkgContext_StreamSizes = ^SecPkgContext_StreamSizes;
  643.   {$EXTERNALSYM PSecPkgContext_StreamSizes}
  644.   _SecPkgContext_StreamSizes = record
  645.     cbHeader: Cardinal;
  646.     cbTrailer: Cardinal;
  647.     cbMaximumMessage: Cardinal;
  648.     cBuffers: Cardinal;
  649.     cbBlockSize: Cardinal;
  650.   end;
  651.   {$EXTERNALSYM _SecPkgContext_StreamSizes}
  652.   SecPkgContext_StreamSizes = _SecPkgContext_StreamSizes;
  653.   {$EXTERNALSYM SecPkgContext_StreamSizes}
  654.   TSecPkgContextStreamSizes = SecPkgContext_StreamSizes;
  655.   PSecPkgContextStreamSizes = PSecPkgContext_StreamSizes;
  656.   PSecPkgContext_NamesW = ^SecPkgContext_NamesW;
  657.   {$EXTERNALSYM PSecPkgContext_NamesW}
  658.   _SecPkgContext_NamesW = record
  659.     sUserName: PSecWChar;
  660.   end;
  661.   {$EXTERNALSYM _SecPkgContext_NamesW}
  662.   SecPkgContext_NamesW = _SecPkgContext_NamesW;
  663.   {$EXTERNALSYM SecPkgContext_NamesW}
  664.   TSecPkgContextNamesW = SecPkgContext_NamesW;
  665.   PSecPkgContextNamesW = PSecPkgContext_NamesW;
  666.   PSecPkgContext_NamesA = ^SecPkgContext_NamesA;
  667.   {$EXTERNALSYM PSecPkgContext_NamesA}
  668.   _SecPkgContext_NamesA = record
  669.     sUserName: PSecChar;
  670.   end;
  671.   {$EXTERNALSYM _SecPkgContext_NamesA}
  672.   SecPkgContext_NamesA = _SecPkgContext_NamesA;
  673.   {$EXTERNALSYM SecPkgContext_NamesA}
  674.   TSecPkgContextNamesA = SecPkgContext_NamesA;
  675.   PSecPkgContextNamesA = PSecPkgContext_NamesA;
  676. {$IFDEF UNICODE}
  677.   SecPkgContext_Names = SecPkgContext_NamesW;
  678.   {$EXTERNALSYM SecPkgContext_Names}
  679.   PSecPkgContext_Names = PSecPkgContext_NamesW;
  680.   {$EXTERNALSYM PSecPkgContext_Names}
  681.   TSecPkgContextNames = TSecPkgContextNamesW;
  682.   PSecPkgContextNames = PSecPkgContextNamesW;
  683. {$ELSE}
  684.   SecPkgContext_Names = SecPkgContext_NamesA;
  685.   {$EXTERNALSYM SecPkgContext_Names}
  686.   PSecPkgContext_Names = PSecPkgContext_NamesA;
  687.   {$EXTERNALSYM PSecPkgContext_Names}
  688.   TSecPkgContextNames = TSecPkgContextNamesA;
  689.   PSecPkgContextNames = PSecPkgContextNamesA;
  690. {$ENDIF}
  691.   PSecPkgContext_LifeSpan = ^SecPkgContext_LifeSpan;
  692.   {$EXTERNALSYM PSecPkgContext_LifeSpan}
  693.   _SecPkgContext_Lifespan = record
  694.     tsStart: TimeStamp;
  695.     tsExpiry: TimeStamp;
  696.   end;
  697.   {$EXTERNALSYM _SecPkgContext_Lifespan}
  698.   SecPkgContext_Lifespan = _SecPkgContext_Lifespan;
  699.   {$EXTERNALSYM SecPkgContext_Lifespan}
  700.   TSecPkgContextLifeSpan = SecPkgContext_Lifespan;
  701.   PSecPkgContextLifeSpan = PSecPkgContext_LifeSpan;
  702.   PSecPkgContext_DceInfo = ^SecPkgContext_DceInfo;
  703.   {$EXTERNALSYM PSecPkgContext_DceInfo}
  704.   _SecPkgContext_DceInfo = record
  705.     AuthzSvc: Cardinal;
  706.     pPac: Pointer;
  707.   end;
  708.   {$EXTERNALSYM _SecPkgContext_DceInfo}
  709.   SecPkgContext_DceInfo = _SecPkgContext_DceInfo;
  710.   {$EXTERNALSYM SecPkgContext_DceInfo}
  711.   TSecPkgContextDceInfo = SecPkgContext_DceInfo;
  712.   PSecPkgContextDceInfo = PSecPkgContext_DceInfo;
  713.   PSecPkgContext_KeyInfoA = ^SecPkgContext_KeyInfoA;
  714.   {$EXTERNALSYM PSecPkgContext_KeyInfoA}
  715.   _SecPkgContext_KeyInfoA = record
  716.     sSignatureAlgorithmName: PSecChar;
  717.     sEncryptAlgorithmName: PSecChar;
  718.     KeySize: Cardinal;
  719.     SignatureAlgorithm: Cardinal;
  720.     EncryptAlgorithm: Cardinal;
  721.   end;
  722.   {$EXTERNALSYM _SecPkgContext_KeyInfoA}
  723.   SecPkgContext_KeyInfoA = _SecPkgContext_KeyInfoA;
  724.   {$EXTERNALSYM SecPkgContext_KeyInfoA}
  725.   TSecPkgContextKeyInfoA = SecPkgContext_KeyInfoA;
  726.   PSecPkgContextKeyInfoA = PSecPkgContext_KeyInfoA;
  727.   PSecPkgContext_KeyInfoW = ^SecPkgContext_KeyInfoW;
  728.   {$EXTERNALSYM PSecPkgContext_KeyInfoW}
  729.   _SecPkgContext_KeyInfoW = record
  730.     sSignatureAlgorithmName: PSecWChar;
  731.     sEncryptAlgorithmName: PSecWChar;
  732.     KeySize: Cardinal;
  733.     SignatureAlgorithm: Cardinal;
  734.     EncryptAlgorithm: Cardinal;
  735.   end;
  736.   {$EXTERNALSYM _SecPkgContext_KeyInfoW}
  737.   SecPkgContext_KeyInfoW = _SecPkgContext_KeyInfoW;
  738.   {$EXTERNALSYM SecPkgContext_KeyInfoW}
  739.   TSecPkgContextKeyInfoW = SecPkgContext_KeyInfoW;
  740.   PSecPkgContextKeyInfoW = PSecPkgContext_KeyInfoW;
  741. {$IFDEF UNICODE}
  742.   SecPkgContext_KeyInfo  = SecPkgContext_KeyInfoW;
  743.   {$EXTERNALSYM SecPkgContext_KeyInfo}
  744.   PSecPkgContext_KeyInfo = PSecPkgContext_KeyInfoW;
  745.   {$EXTERNALSYM PSecPkgContext_KeyInfo}
  746.   TSecPkgContextKeyInfo = TSecPkgContextKeyInfoW;
  747.   PSecPkgContextKeyInfo = PSecPkgContextKeyInfoW;
  748. {$ELSE}
  749.   SecPkgContext_KeyInfo  = SecPkgContext_KeyInfoA;
  750.   {$EXTERNALSYM SecPkgContext_KeyInfo}
  751.   PSecPkgContext_KeyInfo = PSecPkgContext_KeyInfoA;
  752.   {$EXTERNALSYM PSecPkgContext_KeyInfo}
  753.   TSecPkgContextKeyInfo = TSecPkgContextKeyInfoA;
  754.   PSecPkgContextKeyInfo = PSecPkgContextKeyInfoA;
  755. {$ENDIF}
  756.   PSecPkgContext_AuthorityA = ^SecPkgContext_AuthorityA;
  757.   {$EXTERNALSYM PSecPkgContext_AuthorityA}
  758.   _SecPkgContext_AuthorityA = record
  759.     sAuthorityName: PSecChar;
  760.   end;
  761.   {$EXTERNALSYM _SecPkgContext_AuthorityA}
  762.   SecPkgContext_AuthorityA = _SecPkgContext_AuthorityA;
  763.   {$EXTERNALSYM SecPkgContext_AuthorityA}
  764.   TSecPkgContextAuthorityA = SecPkgContext_AuthorityA;
  765.   PSecPkgContextAuthorityA = PSecPkgContext_AuthorityA;
  766.   PSecPkgContext_AuthorityW = ^SecPkgContext_AuthorityW;
  767.   {$EXTERNALSYM PSecPkgContext_AuthorityW}
  768.   _SecPkgContext_AuthorityW = record
  769.     sAuthorityName: PSecWChar;
  770.   end;
  771.   {$EXTERNALSYM _SecPkgContext_AuthorityW}
  772.   SecPkgContext_AuthorityW = _SecPkgContext_AuthorityW;
  773.   {$EXTERNALSYM SecPkgContext_AuthorityW}
  774.   TSecPkgContextAuthorityW = SecPkgContext_AuthorityW;
  775.   PSecPkgContextAuthorityW = PSecPkgContext_AuthorityW;
  776. {$IFDEF UNICODE}
  777.   SecPkgContext_Authority  = SecPkgContext_AuthorityW;
  778.   {$EXTERNALSYM SecPkgContext_Authority}
  779.   PSecPkgContext_Authority = PSecPkgContext_AuthorityW;
  780.   {$EXTERNALSYM PSecPkgContext_Authority}
  781.   TSecPkgContextAuthority = TSecPkgContextAuthorityW;
  782.   PSecPkgContextAuthority = PSecPkgContextAuthorityW;
  783. {$ELSE}
  784.   SecPkgContext_Authority  = SecPkgContext_AuthorityA;
  785.   {$EXTERNALSYM SecPkgContext_Authority}
  786.   PSecPkgContext_Authority = PSecPkgContext_AuthorityA;
  787.   {$EXTERNALSYM PSecPkgContext_Authority}
  788.   TSecPkgContextAuthority = SecPkgContext_AuthorityA;
  789.   PSecPkgContextAuthority = PSecPkgContext_AuthorityA;
  790. {$ENDIF}
  791.   PSecPkgContext_ProtoInfoA = ^SecPkgContext_ProtoInfoA;
  792.   {$EXTERNALSYM PSecPkgContext_ProtoInfoA}
  793.   _SecPkgContext_ProtoInfoA = record
  794.     sProtocolName: PSecChar;
  795.     majorVersion: Cardinal;
  796.     minorVersion: Cardinal;
  797.   end;
  798.   {$EXTERNALSYM _SecPkgContext_ProtoInfoA}
  799.   SecPkgContext_ProtoInfoA = _SecPkgContext_ProtoInfoA;
  800.   {$EXTERNALSYM SecPkgContext_ProtoInfoA}
  801.   TSecPkgContextProtoInfoA = SecPkgContext_ProtoInfoA;
  802.   PSecPkgContextProtoInfoA = PSecPkgContext_ProtoInfoA;
  803.   PSecPkgContext_ProtoInfoW = ^SecPkgContext_ProtoInfoW;
  804.   {$EXTERNALSYM PSecPkgContext_ProtoInfoW}
  805.   _SecPkgContext_ProtoInfoW = record
  806.     sProtocolName: PSecWChar;
  807.     majorVersion: Cardinal;
  808.     minorVersion: Cardinal;
  809.   end;
  810.   {$EXTERNALSYM _SecPkgContext_ProtoInfoW}
  811.   SecPkgContext_ProtoInfoW = _SecPkgContext_ProtoInfoW;
  812.   {$EXTERNALSYM SecPkgContext_ProtoInfoW}
  813.   TSecPkgContextProtoInfoW = SecPkgContext_ProtoInfoW;
  814.   PSecPkgContextProtoInfoW = PSecPkgContext_ProtoInfoW;
  815. {$IFDEF UNICODE}
  816.   SecPkgContext_ProtoInfo  = SecPkgContext_ProtoInfoW;
  817.   {$EXTERNALSYM SecPkgContext_ProtoInfo}
  818.   PSecPkgContext_ProtoInfo = PSecPkgContext_ProtoInfoW;
  819.   {$EXTERNALSYM PSecPkgContext_ProtoInfo}
  820.   TSecPkgContextProtoInfo = TSecPkgContextProtoInfoW;
  821.   PSecPkgContextProtoInfo = PSecPkgContextProtoInfoW;
  822. {$ELSE}
  823.   SecPkgContext_ProtoInfo  = SecPkgContext_ProtoInfoA;
  824.   {$EXTERNALSYM SecPkgContext_ProtoInfo}
  825.   PSecPkgContext_ProtoInfo = PSecPkgContext_ProtoInfoA;
  826.   {$EXTERNALSYM PSecPkgContext_ProtoInfo}
  827.   TSecPkgContextProtoInfo = TSecPkgContextProtoInfoA;
  828.   PSecPkgContextProtoInfo = PSecPkgContextProtoInfoA;
  829. {$ENDIF}
  830.   PSecPkgContext_PasswordExpiry = ^SecPkgContext_PasswordExpiry;
  831.   {$EXTERNALSYM PSecPkgContext_PasswordExpiry}
  832.   _SecPkgContext_PasswordExpiry = record
  833.     tsPasswordExpires: TimeStamp;
  834.   end;
  835.   {$EXTERNALSYM _SecPkgContext_PasswordExpiry}
  836.   SecPkgContext_PasswordExpiry = _SecPkgContext_PasswordExpiry;
  837.   {$EXTERNALSYM SecPkgContext_PasswordExpiry}
  838.   TSecPkgContextPasswordExpiry = SecPkgContext_PasswordExpiry;
  839.   PSecPkgContextPasswordExpiry = PSecPkgContext_PasswordExpiry;
  840.   PSecPkgContext_SessionKey = ^SecPkgContext_SessionKey;
  841.   {$EXTERNALSYM PSecPkgContext_SessionKey}
  842.   _SecPkgContext_SessionKey = record
  843.     SessionKeyLength: Cardinal;
  844.     SessionKey: PByte;
  845.   end;
  846.   {$EXTERNALSYM _SecPkgContext_SessionKey}
  847.   SecPkgContext_SessionKey = _SecPkgContext_SessionKey;
  848.   {$EXTERNALSYM SecPkgContext_SessionKey}
  849.   TSecPkgContextSessionKey = SecPkgContext_SessionKey;
  850.   PSecPkgContextSessionKey = PSecPkgContext_SessionKey;
  851.   PSecPkgContext_PackageInfoW = ^SecPkgContext_PackageInfoW;
  852.   {$EXTERNALSYM PSecPkgContext_PackageInfoW}
  853.   _SecPkgContext_PackageInfoW = record
  854.     PackageInfo: PSecPkgInfoW;
  855.   end;
  856.   {$EXTERNALSYM _SecPkgContext_PackageInfoW}
  857.   SecPkgContext_PackageInfoW = _SecPkgContext_PackageInfoW;
  858.   {$EXTERNALSYM SecPkgContext_PackageInfoW}
  859.   TSecPkgContextPackageInfoW = SecPkgContext_PackageInfoW;
  860.   PSecPkgContextPackageInfoW = PSecPkgContext_PackageInfoW;
  861.   PSecPkgContext_PackageInfoA = ^SecPkgContext_PackageInfoA;
  862.   {$EXTERNALSYM PSecPkgContext_PackageInfoA}
  863.   _SecPkgContext_PackageInfoA = record
  864.     PackageInfo: PSecPkgInfoA;
  865.   end;
  866.   {$EXTERNALSYM _SecPkgContext_PackageInfoA}
  867.   SecPkgContext_PackageInfoA = _SecPkgContext_PackageInfoA;
  868.   {$EXTERNALSYM SecPkgContext_PackageInfoA}
  869.   TSecPkgContextPackageInfoA = SecPkgContext_PackageInfoA;
  870.   PSecPkgContextPackageInfoA = PSecPkgContext_PackageInfoA;
  871.   PSecPkgContext_UserFlags = ^SecPkgContext_UserFlags;
  872.   {$EXTERNALSYM PSecPkgContext_UserFlags}
  873.   _SecPkgContext_UserFlags = record
  874.     UserFlags: Cardinal;
  875.   end;
  876.   {$EXTERNALSYM _SecPkgContext_UserFlags}
  877.   SecPkgContext_UserFlags = _SecPkgContext_UserFlags;
  878.   {$EXTERNALSYM SecPkgContext_UserFlags}
  879.   TSecPkgContextUserFlags = SecPkgContext_UserFlags;
  880.   PSecPkgContextUserFlags = PSecPkgContext_UserFlags;
  881.   PSecPkgContext_Flags = ^SecPkgContext_Flags;
  882.   {$EXTERNALSYM PSecPkgContext_Flags}
  883.   _SecPkgContext_Flags = record
  884.     Flags: Cardinal;
  885.   end;
  886.   {$EXTERNALSYM _SecPkgContext_Flags}
  887.   SecPkgContext_Flags = _SecPkgContext_Flags;
  888.   {$EXTERNALSYM SecPkgContext_Flags}
  889.   TSecPkgContextFlags = SecPkgContext_Flags;
  890.   PSecPkgContextFlags = PSecPkgContext_Flags;
  891. {$IFDEF UNICODE}
  892.   SecPkgContext_PackageInfo  = SecPkgContext_PackageInfoW;
  893.   {$EXTERNALSYM SecPkgContext_PackageInfo}
  894.   PSecPkgContext_PackageInfo = PSecPkgContext_PackageInfoW;
  895.   {$EXTERNALSYM PSecPkgContext_PackageInfo}
  896.   TSecPkgContextPackageInfo = TSecPkgContextPackageInfoW;
  897.   PSecPkgContextPackageInfo = PSecPkgContextPackageInfoW;
  898. {$ELSE}
  899.   SecPkgContext_PackageInfo  = SecPkgContext_PackageInfoA;
  900.   {$EXTERNALSYM SecPkgContext_PackageInfo}
  901.   PSecPkgContext_PackageInfo = PSecPkgContext_PackageInfoA;
  902.   {$EXTERNALSYM PSecPkgContext_PackageInfo}
  903.   TSecPkgContextPackageInfo = TSecPkgContextPackageInfoA;
  904.   PSecPkgContextPackageInfo = PSecPkgContextPackageInfoA;
  905. {$ENDIF}
  906.   PSecPkgContext_NegotiationInfoA = ^SecPkgContext_NegotiationInfoA;
  907.   {$EXTERNALSYM PSecPkgContext_NegotiationInfoA}
  908.   _SecPkgContext_NegotiationInfoA = record
  909.     PackageInfo: PSecPkgInfoA;
  910.     NegotiationState: Cardinal;
  911.   end;
  912.   {$EXTERNALSYM _SecPkgContext_NegotiationInfoA}
  913.   SecPkgContext_NegotiationInfoA = _SecPkgContext_NegotiationInfoA;
  914.   {$EXTERNALSYM SecPkgContext_NegotiationInfoA}
  915.   TSecPkgContextNegotiationInfoA = SecPkgContext_NegotiationInfoA;
  916.   PSecPkgContextNegotiationInfoA = PSecPkgContext_NegotiationInfoA;
  917.   PSecPkgContext_NegotiationInfoW = ^SecPkgContext_NegotiationInfoW;
  918.   {$EXTERNALSYM PSecPkgContext_NegotiationInfoW}
  919.   _SecPkgContext_NegotiationInfoW = record
  920.     PackageInfo: PSecPkgInfoW;
  921.     NegotiationState: Cardinal;
  922.   end;
  923.   {$EXTERNALSYM _SecPkgContext_NegotiationInfoW}
  924.   SecPkgContext_NegotiationInfoW = _SecPkgContext_NegotiationInfoW;
  925.   {$EXTERNALSYM SecPkgContext_NegotiationInfoW}
  926.   TSecPkgContextNegotiationInfoW = SecPkgContext_NegotiationInfoW;
  927.   PSecPkgContextNegotiationInfoW = PSecPkgContext_NegotiationInfoW ;
  928. {$IFDEF UNICODE}
  929.   SecPkgContext_NegotiationInfo  = SecPkgContext_NegotiationInfoW;
  930.   {$EXTERNALSYM SecPkgContext_NegotiationInfo}
  931.   PSecPkgContext_NegotiationInfo = PSecPkgContext_NegotiationInfoW;
  932.   {$EXTERNALSYM PSecPkgContext_NegotiationInfo}
  933.   TSecPkgContextNegotiationInfo = TSecPkgContextNegotiationInfoW;
  934.   PSecPkgContextNegotiationInfo = PSecPkgContextNegotiationInfoW;
  935. {$ELSE}
  936.   SecPkgContext_NegotiationInfo  = SecPkgContext_NegotiationInfoA;
  937.   {$EXTERNALSYM SecPkgContext_NegotiationInfo}
  938.   PSecPkgContext_NegotiationInfo = PSecPkgContext_NegotiationInfoA;
  939.   {$EXTERNALSYM PSecPkgContext_NegotiationInfo}
  940.   TSecPkgContextNegotiationInfo = TSecPkgContextNegotiationInfoA;
  941.   PSecPkgContextNegotiationInfo = PSecPkgContextNegotiationInfoA;
  942. {$ENDIF}
  943. const
  944.   SECPKG_NEGOTIATION_COMPLETE    = 0;
  945.   {$EXTERNALSYM SECPKG_NEGOTIATION_COMPLETE}
  946.   SECPKG_NEGOTIATION_OPTIMISTIC  = 1;
  947.   {$EXTERNALSYM SECPKG_NEGOTIATION_OPTIMISTIC}
  948.   SECPKG_NEGOTIATION_IN_PROGRESS = 2;
  949.   {$EXTERNALSYM SECPKG_NEGOTIATION_IN_PROGRESS}
  950.   SECPKG_NEGOTIATION_DIRECT      = 3;
  951.   {$EXTERNALSYM SECPKG_NEGOTIATION_DIRECT}
  952.   SECPKG_NEGOTIATION_TRY_MULTICRED = 4;
  953.   {$EXTERNALSYM SECPKG_NEGOTIATION_TRY_MULTICRED}
  954. type
  955.   PSecPkgContext_NativeNamesW = ^SecPkgContext_NativeNamesW;
  956.   {$EXTERNALSYM PSecPkgContext_NativeNamesW}
  957.   _SecPkgContext_NativeNamesW = record
  958.     sClientName: PSecWChar;
  959.     sServerName: PSecWChar;
  960.   end;
  961.   {$EXTERNALSYM _SecPkgContext_NativeNamesW}
  962.   SecPkgContext_NativeNamesW = _SecPkgContext_NativeNamesW;
  963.   {$EXTERNALSYM SecPkgContext_NativeNamesW}
  964.   TSecPkgContextNativeNamesW = SecPkgContext_NativeNamesW;
  965.   PSecPkgContextNativeNamesW = PSecPkgContext_NativeNamesW;
  966.   PSecPkgContext_NativeNamesA = ^SecPkgContext_NativeNamesA;
  967.   {$EXTERNALSYM PSecPkgContext_NativeNamesA}
  968.   _SecPkgContext_NativeNamesA = record
  969.     sClientName: PSecChar;
  970.     sServerName: PSecChar;
  971.   end;
  972.   {$EXTERNALSYM _SecPkgContext_NativeNamesA}
  973.   SecPkgContext_NativeNamesA = _SecPkgContext_NativeNamesA;
  974.   {$EXTERNALSYM SecPkgContext_NativeNamesA}
  975.   TSecPkgContextNativeNamesA = SecPkgContext_NativeNamesA;
  976.   PSecPkgContextNativeNamesA = PSecPkgContext_NativeNamesA;
  977. {$IFDEF UNICODE}
  978.   SecPkgContext_NativeNames  = SecPkgContext_NativeNamesW;
  979.   {$EXTERNALSYM SecPkgContext_NativeNames}
  980.   PSecPkgContext_NativeNames = PSecPkgContext_NativeNamesW;
  981.   {$EXTERNALSYM PSecPkgContext_NativeNames}
  982.   TSecPkgContextNativeNames = TSecPkgContextNativeNamesW;
  983.   PSecPkgContextNativeNames = PSecPkgContextNativeNamesW;
  984. {$ELSE}
  985.   SecPkgContext_NativeNames  = SecPkgContext_NativeNamesA;
  986.   {$EXTERNALSYM SecPkgContext_NativeNames}
  987.   PSecPkgContext_NativeNames = PSecPkgContext_NativeNamesA;
  988.   {$EXTERNALSYM PSecPkgContext_NativeNames}
  989.   TSecPkgContextNativeNames = TSecPkgContextNativeNamesA;
  990.   PSecPkgContextNativeNames = PSecPkgContextNativeNamesA;
  991. {$ENDIF}
  992.   _SecPkgContext_CredentialNameW = record
  993.     CredentialType: Cardinal;
  994.     sCredentialName: PSEC_WCHAR;
  995.   end;
  996.   {$EXTERNALSYM _SecPkgContext_CredentialNameW}
  997.   SecPkgContext_CredentialNameW = _SecPkgContext_CredentialNameW;
  998.   {$EXTERNALSYM SecPkgContext_CredentialNameW}
  999.   PSecPkgContext_CredentialNameW = ^SecPkgContext_CredentialNameW;
  1000.   {$EXTERNALSYM PSecPkgContext_CredentialNameW}
  1001.   TSecPkgContextCredentialNameW = SecPkgContext_CredentialNameW;
  1002.   PSecPkgContextCredentialNameW = PSecPkgContext_CredentialNameW;
  1003.   _SecPkgContext_CredentialNameA = record
  1004.     CredentialType: Cardinal;
  1005.     sCredentialName: PSEC_CHAR;
  1006.   end;
  1007.   {$EXTERNALSYM _SecPkgContext_CredentialNameA}
  1008.   SecPkgContext_CredentialNameA = _SecPkgContext_CredentialNameA;
  1009.   {$EXTERNALSYM SecPkgContext_CredentialNameA}
  1010.   PSecPkgContext_CredentialNameA = ^SecPkgContext_CredentialNameA;
  1011.   {$EXTERNALSYM PSecPkgContext_CredentialNameA}
  1012.   TSecPkgContextCredentialNameA = SecPkgContext_CredentialNameA;
  1013.   PSecPkgContextCredentialNameA = PSecPkgContext_CredentialNameA;
  1014. {$IFDEF UNICODE}
  1015.   SecPkgContext_CredentialName = SecPkgContext_CredentialNameW;
  1016.   {$EXTERNALSYM SecPkgContext_CredentialName}
  1017.   PSecPkgContext_CredentialName = PSecPkgContext_CredentialNameW;
  1018.   {$EXTERNALSYM PSecPkgContext_CredentialName}
  1019.   TSecPkgContextCredentialName = TSecPkgContextCredentialNameW;
  1020.   PSecPkgContextCredentialName = PSecPkgContextCredentialNameW;
  1021. {$ELSE}
  1022.   SecPkgContext_CredentialName = SecPkgContext_CredentialNameA;
  1023.   {$EXTERNALSYM SecPkgContext_CredentialName}
  1024.   PSecPkgContext_CredentialName = PSecPkgContext_CredentialNameA;
  1025.   {$EXTERNALSYM PSecPkgContext_CredentialName}
  1026.   TSecPkgContextCredentialName = TSecPkgContextCredentialNameA;
  1027.   PSecPkgContextCredentialName = PSecPkgContextCredentialNameA;
  1028. {$ENDIF}
  1029.   _SecPkgContext_AccessToken = record
  1030.     AccessToken: Pointer;
  1031.   end;
  1032.   {$EXTERNALSYM _SecPkgContext_AccessToken}
  1033.   SecPkgContext_AccessToken = _SecPkgContext_AccessToken;
  1034.   {$EXTERNALSYM SecPkgContext_AccessToken}
  1035.   PSecPkgContext_AccessToken = ^SecPkgContext_AccessToken;
  1036.   {$EXTERNALSYM PSecPkgContext_AccessToken}
  1037.   TSecPkgContextAccessToken = SecPkgContext_AccessToken;
  1038.   PSecPkgContextAccessToken = PSecPkgContext_AccessToken;
  1039.   _SecPkgContext_TargetInformation = record
  1040.     MarshalledTargetInfoLength: Cardinal;
  1041.     MarshalledTargetInfo: PWideChar;
  1042.   end;
  1043.   {$EXTERNALSYM _SecPkgContext_TargetInformation}
  1044.   SecPkgContext_TargetInformation = _SecPkgContext_TargetInformation;
  1045.   {$EXTERNALSYM SecPkgContext_TargetInformation}
  1046.   PSecPkgContext_TargetInformation = ^SecPkgContext_TargetInformation;
  1047.   {$EXTERNALSYM PSecPkgContext_TargetInformation}
  1048.   TSecPkgContextTargetInformation = SecPkgContext_TargetInformation;
  1049.   PSecPkgContextTargetInformation = PSecPkgContext_TargetInformation;
  1050.   _SecPkgContext_AuthzID = record
  1051.     AuthzIDLength: Cardinal;
  1052.     AuthzID: PChar;
  1053.   end;
  1054.   {$EXTERNALSYM _SecPkgContext_AuthzID}
  1055.   SecPkgContext_AuthzID = _SecPkgContext_AuthzID;
  1056.   {$EXTERNALSYM SecPkgContext_AuthzID}
  1057.   PSecPkgContext_AuthzID = ^SecPkgContext_AuthzID;
  1058.   {$EXTERNALSYM PSecPkgContext_AuthzID}
  1059.   TSecPkgContextAuthzID = SecPkgContext_AuthzID;
  1060.   PSecPkgContextAuthzID = PSecPkgContext_AuthzID;  
  1061.   _SecPkgContext_Target = record
  1062.     TargetLength: Cardinal;
  1063.     Target: PChar;
  1064.   end;
  1065.   {$EXTERNALSYM _SecPkgContext_Target}
  1066.   SecPkgContext_Target = _SecPkgContext_Target;
  1067.   {$EXTERNALSYM SecPkgContext_Target}
  1068.   PSecPkgContext_Target = ^SecPkgContext_Target;
  1069.   {$EXTERNALSYM PSecPkgContext_Target}
  1070.   TSecPkgContextTarget = SecPkgContext_Target;
  1071.   PSecPkgContextTarget = PSecPkgContext_Target;  
  1072.   SEC_GET_KEY_FN = procedure (
  1073.     Arg: Pointer;                           // Argument passed in
  1074.     Principal: Pointer;                     // Principal ID
  1075.     KeyVer: Cardinal;                       // Key Version
  1076.     var Key: Pointer;                       // Returned ptr to key
  1077.     var Status: SECURITY_STATUS); stdcall;  // returned status
  1078.   {$EXTERNALSYM SEC_GET_KEY_FN}
  1079.   TSecGetKeyFn = SEC_GET_KEY_FN;
  1080. //
  1081. // Flags for ExportSecurityContext
  1082. //
  1083. const
  1084.   SECPKG_CONTEXT_EXPORT_RESET_NEW  = $00000001; // New context is reset to initial state
  1085.   {$EXTERNALSYM SECPKG_CONTEXT_EXPORT_RESET_NEW}
  1086.   SECPKG_CONTEXT_EXPORT_DELETE_OLD = $00000002; // Old context is deleted during export
  1087.   {$EXTERNALSYM SECPKG_CONTEXT_EXPORT_DELETE_OLD}
  1088. function AcquireCredentialsHandleW(pszPrincipal, pszPackage: PSecWChar;
  1089.   fCredentialUse: Cardinal; pvLogonId, pAuthData: Pointer;
  1090.   pGetKeyFn: SEC_GET_KEY_FN; pvGetKeyArgument: Pointer; phCredential: PCredHandle;
  1091.   var ptsExpiry: TTimeStamp): SECURITY_STATUS; stdcall;
  1092. {$EXTERNALSYM AcquireCredentialsHandleW}
  1093. type
  1094.   ACQUIRE_CREDENTIALS_HANDLE_FN_W = function (
  1095.     pszPrincipal: PSecWChar;
  1096.     pszPackage: PSecWChar;
  1097.     fCredentialsUse: Cardinal;
  1098.     pvLogonId: Pointer;
  1099.     pAuthData: Pointer;
  1100.     pGetKeyFn: SEC_GET_KEY_FN;
  1101.     pvGetKeyArgument: Pointer;
  1102.     phCredential: PCredHandle;
  1103.     ptsExpiry: PTimeStamp): SECURITY_STATUS; stdcall;
  1104.   {$EXTERNALSYM ACQUIRE_CREDENTIALS_HANDLE_FN_W}
  1105.   TAcquireCredentialsHandleFnW = ACQUIRE_CREDENTIALS_HANDLE_FN_W;
  1106. function AcquireCredentialsHandleA(pszPrincipal, pszPackage: PSecChar;
  1107.   fCredentialUse: Cardinal; pvLogonId, pAuthData: Pointer;
  1108.   pGetKeyFn: SEC_GET_KEY_FN; pvGetKeyArgument: Pointer; phCredential: PCredHandle;
  1109.   var ptsExpiry: TTimeStamp): SECURITY_STATUS; stdcall;
  1110. {$EXTERNALSYM AcquireCredentialsHandleA}
  1111. type
  1112.   ACQUIRE_CREDENTIALS_HANDLE_FN_A = function (
  1113.     pszPrincipal: PSecChar;
  1114.     pszPackage: PSecChar;
  1115.     fCredentialsUse: Cardinal;
  1116.     pvLogonId: Pointer;
  1117.     pAuthData: Pointer;
  1118.     pGetKeyFn: SEC_GET_KEY_FN;
  1119.     pvGetKeyArgument: Pointer;
  1120.     phCredential: PCredHandle;
  1121.     ptsExpiry: PTimeStamp): SECURITY_STATUS; stdcall;
  1122.   {$EXTERNALSYM ACQUIRE_CREDENTIALS_HANDLE_FN_A}
  1123.   TAcquireCredentialsHandleFnA = ACQUIRE_CREDENTIALS_HANDLE_FN_A;
  1124. {$IFDEF UNICODE}
  1125. function AcquireCredentialsHandle(pszPrincipal, pszPackage: PSecWChar;
  1126.   fCredentialUse: Cardinal; pvLogonId, pAuthData: Pointer;
  1127.   pGetKeyFn: SEC_GET_KEY_FN; pvGetKeyArgument: Pointer; phCredential: PCredHandle;
  1128.   var ptsExpiry: TTimeStamp): SECURITY_STATUS; stdcall;
  1129. {$EXTERNALSYM AcquireCredentialsHandle}
  1130. type
  1131.   ACQUIRE_CREDENTIALS_HANDLE_FN = ACQUIRE_CREDENTIALS_HANDLE_FN_W;
  1132.   {$EXTERNALSYM ACQUIRE_CREDENTIALS_HANDLE_FN}
  1133.   TAcquireCredentialsHandleFn = TAcquireCredentialsHandleFnW;
  1134. {$ELSE}
  1135. function AcquireCredentialsHandle(pszPrincipal, pszPackage: PSecChar;
  1136.   fCredentialUse: Cardinal; pvLogonId, pAuthData: Pointer;
  1137.   pGetKeyFn: SEC_GET_KEY_FN; pvGetKeyArgument: Pointer; phCredential: PCredHandle;
  1138.   var ptsExpiry: TTimeStamp): SECURITY_STATUS; stdcall;
  1139. {$EXTERNALSYM AcquireCredentialsHandle}
  1140. type
  1141.   ACQUIRE_CREDENTIALS_HANDLE_FN = ACQUIRE_CREDENTIALS_HANDLE_FN_A;
  1142.   {$EXTERNALSYM ACQUIRE_CREDENTIALS_HANDLE_FN}
  1143.   TAcquireCredentialsHandleFn = TAcquireCredentialsHandleFnA;
  1144. {$ENDIF}
  1145. function FreeCredentialsHandle(phCredential: PCredHandle): SECURITY_STATUS; stdcall;
  1146. {$EXTERNALSYM FreeCredentialsHandle}
  1147. type
  1148.   FREE_CREDENTIALS_HANDLE_FN = function (phCredential: PCredHandle): SECURITY_STATUS; stdcall;
  1149.   {$EXTERNALSYM FREE_CREDENTIALS_HANDLE_FN}
  1150. function AddCredentialsW(hCredentials: PCredHandle; pszPrincipal: PSecWChar;
  1151.   pszPackage: PSecWChar; fCredentialUse: Cardinal; pAuthData: Pointer;
  1152.   pGetKeyFn: SEC_GET_KEY_FN; pvGetKeyArgument: Pointer;
  1153.   ptsExpiry: PTimeStamp): SECURITY_STATUS; stdcall;
  1154. {$EXTERNALSYM AddCredentialsW}
  1155. type
  1156.   ADD_CREDENTIALS_FN_W = function (hCredentials: PCredHandle; pszPrincipal: PSecWChar;
  1157.     pszPackage: PSecWChar; fCredentialUse: Cardinal; pAuthData: Pointer;
  1158.     pGetKeyFn: SEC_GET_KEY_FN; pvGetKeyArgument: Pointer;
  1159.     ptsExpiry: PTimeStamp): SECURITY_STATUS; stdcall;
  1160.   {$EXTERNALSYM ADD_CREDENTIALS_FN_W}
  1161. function AddCredentialsA(hCredentials: PCredHandle; pszPrincipal: PSecChar;
  1162.   pszPackage: PSecChar; fCredentialUse: Cardinal; pAuthData: Pointer;
  1163.   pGetKeyFn: SEC_GET_KEY_FN; pvGetKeyArgument: Pointer; ptsExpiry: PTimeStamp): SECURITY_STATUS; stdcall;
  1164. {$EXTERNALSYM AddCredentialsA}
  1165. type
  1166.   ADD_CREDENTIALS_FN_A = function (hCredentials: PCredHandle; pszPrincipal: PSecChar;
  1167.     pszPackage: PSecChar; fCredentialUse: Cardinal; pAuthData: Pointer;
  1168.     pGetKeyFn: SEC_GET_KEY_FN; pvGetKeyArgument: Pointer; ptsExpiry: PTimeStamp): SECURITY_STATUS; stdcall;
  1169.   {$EXTERNALSYM ADD_CREDENTIALS_FN_A}
  1170. {$IFDEF UNICODE}
  1171. function AddCredentials(hCredentials: PCredHandle; pszPrincipal: PSecWChar;
  1172.   pszPackage: PSecWChar; fCredentialUse: Cardinal; pAuthData: Pointer;
  1173.   pGetKeyFn: SEC_GET_KEY_FN; pvGetKeyArgument: Pointer;
  1174.   ptsExpiry: PTimeStamp): SECURITY_STATUS; stdcall;
  1175. {$EXTERNALSYM AddCredentials}
  1176. type
  1177.   ADD_CREDENTIALS_FN = function (hCredentials: PCredHandle; pszPrincipal: PSecWChar;
  1178.     pszPackage: PSecWChar; fCredentialUse: Cardinal; pAuthData: Pointer;
  1179.     pGetKeyFn: SEC_GET_KEY_FN; pvGetKeyArgument: Pointer;
  1180.     ptsExpiry: PTimeStamp): SECURITY_STATUS; stdcall;
  1181.   {$EXTERNALSYM ADD_CREDENTIALS_FN}
  1182. {$ELSE}
  1183. function AddCredentials(hCredentials: PCredHandle; pszPrincipal: PSecChar;
  1184.   pszPackage: PSecChar; fCredentialUse: Cardinal; pAuthData: Pointer;
  1185.   pGetKeyFn: SEC_GET_KEY_FN; pvGetKeyArgument: Pointer; ptsExpiry: PTimeStamp): SECURITY_STATUS; stdcall;
  1186. {$EXTERNALSYM AddCredentials}
  1187. type
  1188.   ADD_CREDENTIALS_FN = function (hCredentials: PCredHandle; pszPrincipal: PSecChar;
  1189.     pszPackage: PSecChar; fCredentialUse: Cardinal; pAuthData: Pointer;
  1190.     pGetKeyFn: SEC_GET_KEY_FN; pvGetKeyArgument: Pointer; ptsExpiry: PTimeStamp): SECURITY_STATUS; stdcall;
  1191.   {$EXTERNALSYM ADD_CREDENTIALS_FN}
  1192. {$ENDIF}
  1193. ////////////////////////////////////////////////////////////////////////
  1194. ///
  1195. /// Context Management Functions
  1196. ///
  1197. ////////////////////////////////////////////////////////////////////////
  1198. function InitializeSecurityContextW(phCredential: PCredHandle; phContext: PCtxtHandle;
  1199.   pszTargetName: PSecWChar; fContextReq, Reserved1, TargetDataRep: Cardinal;
  1200.   pInput: PSecBufferDesc; Reserved2: Cardinal; phNewContext: PCtxtHandle;
  1201.   pOutput: PSecBufferDesc; var pfContextAttr: Cardinal; ptsExpiry: PTimeStamp): SECURITY_STATUS; stdcall;
  1202. {$EXTERNALSYM InitializeSecurityContextW}
  1203. type
  1204.   INITIALIZE_SECURITY_CONTEXT_FN_W = function (phCredential: PCredHandle; phContext: PCtxtHandle;
  1205.     pszTargetName: PSecWChar; fContextReq, Reserved1, TargetDataRep: Cardinal;
  1206.     pInput: PSecBufferDesc; Reserved2: Cardinal; phNewContext: PCtxtHandle;
  1207.     pOutput: PSecBufferDesc; var pfContextAttr: Cardinal; ptsExpiry: PTimeStamp): SECURITY_STATUS; stdcall;
  1208.   {$EXTERNALSYM INITIALIZE_SECURITY_CONTEXT_FN_W}
  1209. function InitializeSecurityContextA(phCredential: PCredHandle; phContext: PCtxtHandle;
  1210.   pszTargetName: PSecChar; fContextReq, Reserved1, TargetDataRep: Cardinal;
  1211.   pInput: PSecBufferDesc; Reserved2: Cardinal; phNewContext: PCtxtHandle;
  1212.   pOutput: PSecBufferDesc; var pfContextAttr: Cardinal; ptsExpiry: PTimeStamp): SECURITY_STATUS; stdcall;
  1213. {$EXTERNALSYM InitializeSecurityContextA}
  1214. type
  1215.   INITIALIZE_SECURITY_CONTEXT_FN_A = function (phCredential: PCredHandle; phContext: PCtxtHandle;
  1216.     pszTargetName: PSecChar; fContextReq, Reserved1, TargetDataRep: Cardinal;
  1217.     pInput: PSecBufferDesc; Reserved2: Cardinal; phNewContext: PCtxtHandle;
  1218.     pOutput: PSecBufferDesc; var pfContextAttr: Cardinal; ptsExpiry: PTimeStamp): SECURITY_STATUS; stdcall;
  1219.   {$EXTERNALSYM INITIALIZE_SECURITY_CONTEXT_FN_A}
  1220. {$IFDEF UNICODE}
  1221. function InitializeSecurityContext(phCredential: PCredHandle; phContext: PCtxtHandle;
  1222.   pszTargetName: PSecWChar; fContextReq, Reserved1, TargetDataRep: Cardinal;
  1223.   pInput: PSecBufferDesc; Reserved2: Cardinal; phNewContext: PCtxtHandle;
  1224.   pOutput: PSecBufferDesc; var pfContextAttr: Cardinal; ptsExpiry: PTimeStamp): SECURITY_STATUS; stdcall;
  1225. {$EXTERNALSYM InitializeSecurityContext}
  1226. type
  1227.   INITIALIZE_SECURITY_CONTEXT_FN = function (phCredential: PCredHandle; phContext: PCtxtHandle;
  1228.     pszTargetName: PSecWChar; fContextReq, Reserved1, TargetDataRep: Cardinal;
  1229.     pInput: PSecBufferDesc; Reserved2: Cardinal; phNewContext: PCtxtHandle;
  1230.     pOutput: PSecBufferDesc; var pfContextAttr: Cardinal; ptsExpiry: PTimeStamp): SECURITY_STATUS; stdcall;
  1231.   {$EXTERNALSYM INITIALIZE_SECURITY_CONTEXT_FN}
  1232. {$ELSE}
  1233. function InitializeSecurityContext(phCredential: PCredHandle; phContext: PCtxtHandle;
  1234.   pszTargetName: PSecChar; fContextReq, Reserved1, TargetDataRep: Cardinal;
  1235.   pInput: PSecBufferDesc; Reserved2: Cardinal; phNewContext: PCtxtHandle;
  1236.   pOutput: PSecBufferDesc; var pfContextAttr: Cardinal; ptsExpiry: PTimeStamp): SECURITY_STATUS; stdcall;
  1237. {$EXTERNALSYM InitializeSecurityContext}
  1238. type
  1239.   INITIALIZE_SECURITY_CONTEXT_FN = function (phCredential: PCredHandle; phContext: PCtxtHandle;
  1240.     pszTargetName: PSecChar; fContextReq, Reserved1, TargetDataRep: Cardinal;
  1241.     pInput: PSecBufferDesc; Reserved2: Cardinal; phNewContext: PCtxtHandle;
  1242.     pOutput: PSecBufferDesc; var pfContextAttr: Cardinal; ptsExpiry: PTimeStamp): SECURITY_STATUS; stdcall;
  1243.   {$EXTERNALSYM INITIALIZE_SECURITY_CONTEXT_FN}
  1244. {$ENDIF}
  1245. function AcceptSecurityContext(phCredential: PCredHandle; phContext: PCtxtHandle;
  1246.   pInput: PSecBufferDesc; fContextReq, TargetDataRep: Cardinal;
  1247.   phNewContext: PCtxtHandle; pOutput: PSecBufferDesc; var pfContextAttr: Cardinal;
  1248.   ptsExpiry: PTimeStamp): SECURITY_STATUS; stdcall;
  1249. {$EXTERNALSYM AcceptSecurityContext}
  1250. type
  1251.   ACCEPT_SECURITY_CONTEXT_FN = function (phCredential: PCredHandle; phContext: PCtxtHandle;
  1252.     pInput: PSecBufferDesc; fContextReq, TargetDataRep: Cardinal;
  1253.     phNewContext: PCtxtHandle; pOutput: PSecBufferDesc; var pfContextAttr: Cardinal;
  1254.     ptsExpiry: PTimeStamp): SECURITY_STATUS; stdcall;
  1255.   {$EXTERNALSYM ACCEPT_SECURITY_CONTEXT_FN}
  1256. function CompleteAuthToken(phContext: PCtxtHandle; pToken: PSecBufferDesc): SECURITY_STATUS; stdcall;
  1257. {$EXTERNALSYM CompleteAuthToken}
  1258. type
  1259.   COMPLETE_AUTH_TOKEN_FN = function (phContext: PCtxtHandle; pToken: PSecBufferDesc): SECURITY_STATUS; stdcall;
  1260.   {$EXTERNALSYM COMPLETE_AUTH_TOKEN_FN}
  1261. function ImpersonateSecurityContext(phContext: PCtxtHandle): SECURITY_STATUS; stdcall;
  1262. {$EXTERNALSYM ImpersonateSecurityContext}
  1263. type
  1264.   IMPERSONATE_SECURITY_CONTEXT_FN = function (phContext: PCtxtHandle): SECURITY_STATUS; stdcall;
  1265.   {$EXTERNALSYM IMPERSONATE_SECURITY_CONTEXT_FN}
  1266. function RevertSecurityContext(phContext: PCtxtHandle): SECURITY_STATUS; stdcall;
  1267. {$EXTERNALSYM RevertSecurityContext}
  1268. type
  1269.   REVERT_SECURITY_CONTEXT_FN = function (phContext: PCtxtHandle): SECURITY_STATUS; stdcall;
  1270.   {$EXTERNALSYM REVERT_SECURITY_CONTEXT_FN}
  1271. function QuerySecurityContextToken(phContext: PCtxtHandle; var Token: Pointer): SECURITY_STATUS; stdcall;
  1272. {$EXTERNALSYM QuerySecurityContextToken}
  1273. type
  1274.   QUERY_SECURITY_CONTEXT_TOKEN_FN = function (phContext: PCtxtHandle;
  1275.     var Token: Pointer): SECURITY_STATUS; stdcall;
  1276.   {$EXTERNALSYM QUERY_SECURITY_CONTEXT_TOKEN_FN}
  1277. function DeleteSecurityContext(phContext: PCtxtHandle): SECURITY_STATUS; stdcall;
  1278. {$EXTERNALSYM DeleteSecurityContext}
  1279. type
  1280.   DELETE_SECURITY_CONTEXT_FN = function (phContext: PCtxtHandle): SECURITY_STATUS; stdcall;
  1281.   {$EXTERNALSYM DELETE_SECURITY_CONTEXT_FN}
  1282. function ApplyControlToken(phContext: PCtxtHandle; pInput: PSecBufferDesc): SECURITY_STATUS; stdcall;
  1283. {$EXTERNALSYM ApplyControlToken}
  1284. type
  1285.   APPLY_CONTROL_TOKEN_FN = function (phContext: PCtxtHandle; pInput: PSecBufferDesc): SECURITY_STATUS; stdcall;
  1286.   {$EXTERNALSYM APPLY_CONTROL_TOKEN_FN}
  1287. function QueryContextAttributesW(phContext: PCtxtHandle; ulAttribute: Cardinal;
  1288.   pBuffer: Pointer): SECURITY_STATUS; stdcall;
  1289. {$EXTERNALSYM QueryContextAttributesW}
  1290. type
  1291.   QUERY_CONTEXT_ATTRIBUTES_FN_W = function (phContext: PCtxtHandle;
  1292.     ulAttribute: Cardinal; pBuffer: Pointer): SECURITY_STATUS; stdcall;
  1293.   {$EXTERNALSYM QUERY_CONTEXT_ATTRIBUTES_FN_W}
  1294. function QueryContextAttributesA(phContext: PCtxtHandle; ulAttribute: Cardinal;
  1295.   pBuffer: Pointer): SECURITY_STATUS; stdcall;
  1296. {$EXTERNALSYM QueryContextAttributesA}
  1297. type
  1298.   QUERY_CONTEXT_ATTRIBUTES_FN_A = function (phContext: PCtxtHandle;
  1299.     ulAttribute: Cardinal; pBuffer: Pointer): SECURITY_STATUS; stdcall;
  1300.   {$EXTERNALSYM QUERY_CONTEXT_ATTRIBUTES_FN_A}
  1301. {$IFDEF UNICODE}
  1302. function QueryContextAttributes(phContext: PCtxtHandle; ulAttribute: Cardinal;
  1303.   pBuffer: Pointer): SECURITY_STATUS; stdcall;
  1304. {$EXTERNALSYM QueryContextAttributes}
  1305. type
  1306.   QUERY_CONTEXT_ATTRIBUTES_FN = function (phContext: PCtxtHandle;
  1307.     ulAttribute: Cardinal; pBuffer: Pointer): SECURITY_STATUS; stdcall;
  1308.   {$EXTERNALSYM QUERY_CONTEXT_ATTRIBUTES_FN}
  1309. {$ELSE}
  1310. function QueryContextAttributes(phContext: PCtxtHandle; ulAttribute: Cardinal;
  1311.   pBuffer: Pointer): SECURITY_STATUS; stdcall;
  1312. {$EXTERNALSYM QueryContextAttributes}
  1313. type
  1314.   QUERY_CONTEXT_ATTRIBUTES_FN = function (phContext: PCtxtHandle;
  1315.     ulAttribute: Cardinal; pBuffer: Pointer): SECURITY_STATUS; stdcall;
  1316.   {$EXTERNALSYM QUERY_CONTEXT_ATTRIBUTES_FN}
  1317. {$ENDIF}
  1318. function SetContextAttributesW(phContext: PCtxtHandle; ulAttribute: Cardinal;
  1319.   pBuffer: Pointer; cbBuffer: Cardinal): SECURITY_STATUS; stdcall;
  1320. {$EXTERNALSYM SetContextAttributesW}
  1321. type
  1322.   SET_CONTEXT_ATTRIBUTES_FN_W = function (phContext: PCtxtHandle; ulAttribute: Cardinal;
  1323.     pBuffer: Pointer; cbBuffer: Cardinal): SECURITY_STATUS; stdcall;
  1324.   {$EXTERNALSYM SET_CONTEXT_ATTRIBUTES_FN_W}
  1325. function SetContextAttributesA(phContext: PCtxtHandle; ulAttribute: Cardinal;
  1326.   pBuffer: Pointer; cbBuffer: Cardinal): SECURITY_STATUS; stdcall;
  1327. {$EXTERNALSYM SetContextAttributesA}
  1328. type
  1329.   SET_CONTEXT_ATTRIBUTES_FN_A = function (phContext: PCtxtHandle; ulAttribute: Cardinal;
  1330.     pBuffer: Pointer; cbBuffer: Cardinal): SECURITY_STATUS; stdcall;
  1331.   {$EXTERNALSYM SET_CONTEXT_ATTRIBUTES_FN_A}
  1332. {$IFDEF UNICODE}
  1333. function SetContextAttributes(phContext: PCtxtHandle; ulAttribute: Cardinal;
  1334.   pBuffer: Pointer; cbBuffer: Cardinal): SECURITY_STATUS; stdcall;
  1335. {$EXTERNALSYM SetContextAttributes}
  1336. type
  1337.   SET_CONTEXT_ATTRIBUTES_FN = SET_CONTEXT_ATTRIBUTES_FN_W;
  1338.   {$EXTERNALSYM SET_CONTEXT_ATTRIBUTES_FN}
  1339. {$ELSE}
  1340. function SetContextAttributes(phContext: PCtxtHandle; ulAttribute: Cardinal;
  1341.   pBuffer: Pointer; cbBuffer: Cardinal): SECURITY_STATUS; stdcall;
  1342. {$EXTERNALSYM SetContextAttributes}
  1343. type
  1344.   SET_CONTEXT_ATTRIBUTES_FN = SET_CONTEXT_ATTRIBUTES_FN_A;
  1345.   {$EXTERNALSYM SET_CONTEXT_ATTRIBUTES_FN}
  1346. {$ENDIF}
  1347. function QueryCredentialsAttributesW(phCredential: PCredHandle;
  1348.   ulAttribute: Cardinal; pBuffer: Pointer): SECURITY_STATUS; stdcall;
  1349. {$EXTERNALSYM QueryCredentialsAttributesW}
  1350. type
  1351.   QUERY_CREDENTIALS_ATTRIBUTES_FN_W = function (phCredential: PCredHandle;
  1352.     ulAttribute: Cardinal; pBuffer: Pointer): SECURITY_STATUS; stdcall;
  1353.   {$EXTERNALSYM QUERY_CREDENTIALS_ATTRIBUTES_FN_W}
  1354. function QueryCredentialsAttributesA(phCredential: PCredHandle;
  1355.   ulAttribute: Cardinal; pBuffer: Pointer): SECURITY_STATUS; stdcall;
  1356. {$EXTERNALSYM QueryCredentialsAttributesA}
  1357. type
  1358.   QUERY_CREDENTIALS_ATTRIBUTES_FN_A = function (phCredential: PCredHandle;
  1359.     ulAttribute: Cardinal; pBuffer: Pointer): SECURITY_STATUS; stdcall;
  1360.   {$EXTERNALSYM QUERY_CREDENTIALS_ATTRIBUTES_FN_A}
  1361. {$IFDEF UNICODE}
  1362. function QueryCredentialsAttributes(phCredential: PCredHandle;
  1363.   ulAttribute: Cardinal; pBuffer: Pointer): SECURITY_STATUS; stdcall;
  1364. {$EXTERNALSYM QueryCredentialsAttributes}
  1365. type
  1366.   QUERY_CREDENTIALS_ATTRIBUTES_FN = function (phCredential: PCredHandle;
  1367.     ulAttribute: Cardinal; pBuffer: Pointer): SECURITY_STATUS; stdcall;
  1368.   {$EXTERNALSYM QUERY_CREDENTIALS_ATTRIBUTES_FN}
  1369. {$ELSE}
  1370. function QueryCredentialsAttributes(phCredential: PCredHandle;
  1371.   ulAttribute: Cardinal; pBuffer: Pointer): SECURITY_STATUS; stdcall;
  1372. {$EXTERNALSYM QueryCredentialsAttributes}
  1373. type
  1374.   QUERY_CREDENTIALS_ATTRIBUTES_FN = function (phCredential: PCredHandle;
  1375.     ulAttribute: Cardinal; pBuffer: Pointer): SECURITY_STATUS; stdcall;
  1376.   {$EXTERNALSYM QUERY_CREDENTIALS_ATTRIBUTES_FN}
  1377. {$ENDIF}
  1378. function FreeContextBuffer(pvContextBuffer: Pointer): SECURITY_STATUS; stdcall;
  1379. {$EXTERNALSYM FreeContextBuffer}
  1380. type
  1381.   FREE_CONTEXT_BUFFER_FN = function (pvContextBuffer: Pointer): SECURITY_STATUS; stdcall;
  1382.   {$EXTERNALSYM FREE_CONTEXT_BUFFER_FN}
  1383. ///////////////////////////////////////////////////////////////////
  1384. ////
  1385. ////    Message Support API
  1386. ////
  1387. //////////////////////////////////////////////////////////////////
  1388. function MakeSignature(phContext: PCtxtHandle; fQOP: Cardinal;
  1389.   pMessage: PSecBufferDesc; MessageSeqNo: Cardinal): SECURITY_STATUS; stdcall;
  1390. {$EXTERNALSYM MakeSignature}
  1391. type
  1392.   MAKE_SIGNATURE_FN = function (phContext: PCtxtHandle; fQOP: Cardinal;
  1393.     pMessage: PSecBufferDesc; MessageSeqNo: Cardinal): SECURITY_STATUS; stdcall;
  1394.   {$EXTERNALSYM MAKE_SIGNATURE_FN}
  1395. function VerifySignature(phContext: PCtxtHandle; pMessage: PSecBufferDesc;
  1396.   MessageSeqNo: Cardinal; var pfQOP: Cardinal): SECURITY_STATUS; stdcall;
  1397. {$EXTERNALSYM VerifySignature}
  1398. type
  1399.   VERIFY_SIGNATURE_FN = function (phContext: PCtxtHandle; pMessage: PSecBufferDesc;
  1400.     MessageSeqNo: Cardinal; var pfQOP: Cardinal): SECURITY_STATUS; stdcall;
  1401.   {$EXTERNALSYM VERIFY_SIGNATURE_FN}
  1402. const
  1403.   SECQOP_WRAP_NO_ENCRYPT = DWORD($80000001);
  1404.   {$EXTERNALSYM SECQOP_WRAP_NO_ENCRYPT}
  1405. function EncryptMessage(phContext: PCtxtHandle; fQOP: Cardinal;
  1406.   pMessage: PSecBufferDesc; MessageSeqNo: Cardinal): SECURITY_STATUS; stdcall;
  1407. {$EXTERNALSYM EncryptMessage}
  1408. type
  1409.   ENCRYPT_MESSAGE_FN = function (phContext: PCtxtHandle; fQOP: Cardinal;
  1410.     pMessage: PSecBufferDesc; MessageSeqNo: Cardinal): SECURITY_STATUS; stdcall;
  1411.   {$EXTERNALSYM ENCRYPT_MESSAGE_FN}
  1412. function DecryptMessage(phContext: PCtxtHandle; pMessage: PSecBufferDesc;
  1413.   MessageSeqNo: Cardinal; var pfQOP: Cardinal): SECURITY_STATUS; stdcall;
  1414. {$EXTERNALSYM DecryptMessage}
  1415. type
  1416.   DECRYPT_MESSAGE_FN = function (phContext: PCtxtHandle; pMessage: PSecBufferDesc;
  1417.     MessageSeqNo: Cardinal; var pfQOP: Cardinal): SECURITY_STATUS; stdcall;
  1418.   {$EXTERNALSYM DECRYPT_MESSAGE_FN}
  1419. ///////////////////////////////////////////////////////////////////////////
  1420. ////
  1421. ////    Misc.
  1422. ////
  1423. ///////////////////////////////////////////////////////////////////////////
  1424. function EnumerateSecurityPackagesW(var pcPackages: Cardinal;
  1425.   var ppPackageInfo: PSecPkgInfoW): SECURITY_STATUS; stdcall;
  1426. {$EXTERNALSYM EnumerateSecurityPackagesW}
  1427. type
  1428.   ENUMERATE_SECURITY_PACKAGES_FN_W = function (var pcPackages: Cardinal;
  1429.     var ppPackageInfo: PSecPkgInfoW): SECURITY_STATUS; stdcall;
  1430.   {$EXTERNALSYM ENUMERATE_SECURITY_PACKAGES_FN_W}
  1431. function EnumerateSecurityPackagesA(var pcPackages: Cardinal;
  1432.   var ppPackageInfo: PSecPkgInfoA): SECURITY_STATUS; stdcall;
  1433. {$EXTERNALSYM EnumerateSecurityPackagesA}
  1434. type
  1435.   ENUMERATE_SECURITY_PACKAGES_FN_A = function (var pcPackages: Cardinal;
  1436.     var ppPackageInfo: PSecPkgInfoA): SECURITY_STATUS; stdcall;
  1437.   {$EXTERNALSYM ENUMERATE_SECURITY_PACKAGES_FN_A}
  1438. {$IFDEF UNICODE}
  1439. function EnumerateSecurityPackages(var pcPackages: Cardinal;
  1440.   var ppPackageInfo: PSecPkgInfoW): SECURITY_STATUS; stdcall;
  1441. {$EXTERNALSYM EnumerateSecurityPackages}
  1442. type
  1443.   ENUMERATE_SECURITY_PACKAGES_FN = function (var pcPackages: Cardinal;
  1444.     var ppPackageInfo: PSecPkgInfoW): SECURITY_STATUS; stdcall;
  1445.   {$EXTERNALSYM ENUMERATE_SECURITY_PACKAGES_FN}
  1446. {$ELSE}
  1447. function EnumerateSecurityPackages(var pcPackages: Cardinal;
  1448.   var ppPackageInfo: PSecPkgInfoA): SECURITY_STATUS; stdcall;
  1449. {$EXTERNALSYM EnumerateSecurityPackages}
  1450. type
  1451.   ENUMERATE_SECURITY_PACKAGES_FN = function (var pcPackages: Cardinal;
  1452.     var ppPackageInfo: PSecPkgInfoA): SECURITY_STATUS; stdcall;
  1453.   {$EXTERNALSYM ENUMERATE_SECURITY_PACKAGES_FN}
  1454. {$ENDIF}
  1455. function QuerySecurityPackageInfoW(pszPackageName: PSecWChar;
  1456.   var ppPackageInfo: PSecPkgInfoW): SECURITY_STATUS; stdcall;
  1457. {$EXTERNALSYM QuerySecurityPackageInfoW}
  1458. type
  1459.   QUERY_SECURITY_PACKAGE_INFO_FN_W = function (pszPackageName: PSecWChar;
  1460.     var ppPackageInfo: PSecPkgInfoW): SECURITY_STATUS; stdcall;
  1461.   {$EXTERNALSYM QUERY_SECURITY_PACKAGE_INFO_FN_W}
  1462. function QuerySecurityPackageInfoA(pszPackageName: PSecChar;
  1463.   var ppPackageInfo: PSecPkgInfoA): SECURITY_STATUS; stdcall;
  1464. {$EXTERNALSYM QuerySecurityPackageInfoA}
  1465. type
  1466.   QUERY_SECURITY_PACKAGE_INFO_FN_A = function (pszPackageName: PSecChar;
  1467.     var ppPackageInfo: PSecPkgInfoA): SECURITY_STATUS; stdcall;
  1468.   {$EXTERNALSYM QUERY_SECURITY_PACKAGE_INFO_FN_A}
  1469. {$IFDEF UNICODE}
  1470. function QuerySecurityPackageInfo(pszPackageName: PSecWChar;
  1471.   var ppPackageInfo: PSecPkgInfoW): SECURITY_STATUS; stdcall;
  1472. {$EXTERNALSYM QuerySecurityPackageInfo}
  1473. type
  1474.   QUERY_SECURITY_PACKAGE_INFO_FN = function (pszPackageName: PSecWChar;
  1475.     var ppPackageInfo: PSecPkgInfoW): SECURITY_STATUS; stdcall;
  1476.   {$EXTERNALSYM QUERY_SECURITY_PACKAGE_INFO_FN}
  1477. {$ELSE}
  1478. function QuerySecurityPackageInfo(pszPackageName: PSecChar;
  1479.   var ppPackageInfo: PSecPkgInfoA): SECURITY_STATUS; stdcall;
  1480. {$EXTERNALSYM QuerySecurityPackageInfo}
  1481. type
  1482.   QUERY_SECURITY_PACKAGE_INFO_FN = function (pszPackageName: PSecChar;
  1483.     var ppPackageInfo: PSecPkgInfoA): SECURITY_STATUS; stdcall;
  1484.   {$EXTERNALSYM QUERY_SECURITY_PACKAGE_INFO_FN}
  1485. {$ENDIF}
  1486. type
  1487.   _SecDelegationType = (
  1488.     SecFull,
  1489.     SecService,
  1490.     SecTree,
  1491.     SecDirectory,
  1492.     SecObject);
  1493.   {$EXTERNALSYM _SecDelegationType}
  1494.   SecDelegationType = _SecDelegationType;
  1495.   {$EXTERNALSYM SecDelegationType}
  1496.   PSecDelegationType = ^SecDelegationType;
  1497.   {$EXTERNALSYM PSecDelegationType}
  1498.   TSecDelegationType = SecDelegationType;
  1499. //function DelegateSecurityContext(phContext: PCtxtHandle; pszTarget: PSecChar;
  1500. //  DelegationType: SecDelegationType; pExpiry: PTimeStamp;
  1501. //  pPackageParameters: PSecBuffer; pOutput: PSecBufferDesc): SECURITY_STATUS; stdcall;
  1502. //{$EXTERNALSYM DelegateSecurityContext}
  1503. ///////////////////////////////////////////////////////////////////////////
  1504. ////
  1505. ////    Proxies
  1506. ////
  1507. ///////////////////////////////////////////////////////////////////////////
  1508. //
  1509. // Proxies are only available on NT platforms
  1510. //
  1511. ///////////////////////////////////////////////////////////////////////////
  1512. ////
  1513. ////    Context export/import
  1514. ////
  1515. ///////////////////////////////////////////////////////////////////////////
  1516. function ExportSecurityContext(phContext: PCtxtHandle; fFlags: ULONG;
  1517.   pPackedContext: PSecBuffer; var pToken: Pointer): SECURITY_STATUS; stdcall;
  1518. {$EXTERNALSYM ExportSecurityContext}
  1519. type
  1520.   EXPORT_SECURITY_CONTEXT_FN = function (phContext: PCtxtHandle; fFlags: ULONG;
  1521.     pPackedContext: PSecBuffer; var pToken: Pointer): SECURITY_STATUS; stdcall;
  1522.   {$EXTERNALSYM EXPORT_SECURITY_CONTEXT_FN}
  1523. function ImportSecurityContextW(pszPackage: PSecWChar; pPackedContext: PSecBuffer;
  1524.   Token: Pointer; phContext: PCtxtHandle): SECURITY_STATUS; stdcall;
  1525. {$EXTERNALSYM ImportSecurityContextW}
  1526. type
  1527.   IMPORT_SECURITY_CONTEXT_FN_W = function (pszPackage: PSecWChar; pPackedContext: PSecBuffer;
  1528.     Token: Pointer; phContext: PCtxtHandle): SECURITY_STATUS; stdcall;
  1529.   {$EXTERNALSYM IMPORT_SECURITY_CONTEXT_FN_W}
  1530. function ImportSecurityContextA(pszPackage: PSecChar; pPackedContext: PSecBuffer;
  1531.   Token: Pointer; phContext: PCtxtHandle): SECURITY_STATUS; stdcall;
  1532. {$EXTERNALSYM ImportSecurityContextA}
  1533. type
  1534.   IMPORT_SECURITY_CONTEXT_FN_A = function (pszPackage: PSecChar; pPackedContext: PSecBuffer;
  1535.     Token: Pointer; phContext: PCtxtHandle): SECURITY_STATUS; stdcall;
  1536.   {$EXTERNALSYM IMPORT_SECURITY_CONTEXT_FN_A}
  1537. {$IFDEF UNICODE}
  1538. function ImportSecurityContext(pszPackage: PSecWChar; pPackedContext: PSecBuffer;
  1539.   Token: Pointer; phContext: PCtxtHandle): SECURITY_STATUS; stdcall;
  1540. {$EXTERNALSYM ImportSecurityContext}
  1541. type
  1542.   IMPORT_SECURITY_CONTEXT_FN = function (pszPackage: PSecWChar; pPackedContext: PSecBuffer;
  1543.     Token: Pointer; phContext: PCtxtHandle): SECURITY_STATUS; stdcall;
  1544.   {$EXTERNALSYM IMPORT_SECURITY_CONTEXT_FN}
  1545. {$ELSE}
  1546. function ImportSecurityContext(pszPackage: PSecChar; pPackedContext: PSecBuffer;
  1547.   Token: Pointer; phContext: PCtxtHandle): SECURITY_STATUS; stdcall;
  1548. {$EXTERNALSYM ImportSecurityContext}
  1549. type
  1550.   IMPORT_SECURITY_CONTEXT_FN = function (pszPackage: PSecChar; pPackedContext: PSecBuffer;
  1551.     Token: Pointer; phContext: PCtxtHandle): SECURITY_STATUS; stdcall;
  1552.   {$EXTERNALSYM IMPORT_SECURITY_CONTEXT_FN}
  1553. {$ENDIF}
  1554. (*
  1555. #if ISSP_MODE == 0
  1556. NTSTATUS
  1557. NTAPI
  1558. SecMakeSPN(
  1559.     IN PUNICODE_STRING ServiceClass,
  1560.     IN PUNICODE_STRING ServiceName,
  1561.     IN PUNICODE_STRING InstanceName OPTIONAL,
  1562.     IN USHORT InstancePort OPTIONAL,
  1563.     IN PUNICODE_STRING Referrer OPTIONAL,
  1564.     IN OUT PUNICODE_STRING Spn,
  1565.     OUT PULONG Length OPTIONAL,
  1566.     IN BOOLEAN Allocate
  1567.     );
  1568. NTSTATUS
  1569. NTAPI
  1570. SecMakeSPNEx(
  1571.     IN PUNICODE_STRING ServiceClass,
  1572.     IN PUNICODE_STRING ServiceName,
  1573.     IN PUNICODE_STRING InstanceName OPTIONAL,
  1574.     IN USHORT InstancePort OPTIONAL,
  1575.     IN PUNICODE_STRING Referrer OPTIONAL,
  1576.     IN PUNICODE_STRING TargetInfo OPTIONAL,
  1577.     IN OUT PUNICODE_STRING Spn,
  1578.     OUT PULONG Length OPTIONAL,
  1579.     IN BOOLEAN Allocate
  1580.     );
  1581. NTSTATUS
  1582. SEC_ENTRY
  1583. SecLookupAccountSid(
  1584.     IN PSID Sid,
  1585.     IN OUT PULONG NameSize,
  1586.     OUT PUNICODE_STRING NameBuffer,
  1587.     IN OUT PULONG DomainSize OPTIONAL,
  1588.     OUT PUNICODE_STRING DomainBuffer OPTIONAL,
  1589.     OUT PSID_NAME_USE NameUse
  1590.     );
  1591. NTSTATUS
  1592. SEC_ENTRY
  1593. SecLookupAccountName(
  1594.     IN PUNICODE_STRING Name,
  1595.     IN OUT PULONG SidSize,
  1596.     OUT PSID Sid,
  1597.     OUT PSID_NAME_USE NameUse,
  1598.     IN OUT PULONG DomainSize OPTIONAL,
  1599.     OUT PUNICODE_STRING ReferencedDomain OPTIONAL
  1600.     );
  1601. NTSTATUS
  1602. SEC_ENTRY
  1603. SecLookupWellKnownSid(
  1604.     IN WELL_KNOWN_SID_TYPE SidType,
  1605.     OUT PSID Sid,
  1606.     ULONG SidBufferSize,
  1607.     OUT PULONG SidSize OPTIONAL
  1608.     );
  1609. #endif
  1610. *)
  1611. ///////////////////////////////////////////////////////////////////////////////
  1612. ////
  1613. ////  Fast access for RPC:
  1614. ////
  1615. ///////////////////////////////////////////////////////////////////////////////
  1616. const
  1617.   SECURITY_ENTRYPOINT_ANSIW = 'InitSecurityInterfaceW';
  1618.   {$EXTERNALSYM SECURITY_ENTRYPOINT_ANSIW}
  1619.   SECURITY_ENTRYPOINT_ANSIA = 'InitSecurityInterfaceA';
  1620.   {$EXTERNALSYM SECURITY_ENTRYPOINT_ANSIA}
  1621.   SECURITY_ENTRYPOINTW      = 'InitSecurityInterfaceW';
  1622.   {$EXTERNALSYM SECURITY_ENTRYPOINTW}
  1623.   SECURITY_ENTRYPOINTA      = 'InitSecurityInterfaceA';
  1624.   {$EXTERNALSYM SECURITY_ENTRYPOINTA}
  1625.   SECURITY_ENTRYPOINT16     = 'INITSECURITYINTERFACEA';
  1626.   {$EXTERNALSYM SECURITY_ENTRYPOINT16}
  1627. {$IFDEF UNICODE}
  1628.   SECURITY_ENTRYPOINT = SECURITY_ENTRYPOINTW;
  1629.   {$EXTERNALSYM SECURITY_ENTRYPOINT}
  1630.   SECURITY_ENTRYPOINT_ANSI = SECURITY_ENTRYPOINT_ANSIW;
  1631.   {$EXTERNALSYM SECURITY_ENTRYPOINT_ANSI}
  1632. {$ELSE}
  1633.   SECURITY_ENTRYPOINT = SECURITY_ENTRYPOINTA;
  1634.   {$EXTERNALSYM SECURITY_ENTRYPOINT}
  1635.   SECURITY_ENTRYPOINT_ANSI = SECURITY_ENTRYPOINT_ANSIA;
  1636.   {$EXTERNALSYM SECURITY_ENTRYPOINT_ANSI}
  1637. {$ENDIF}
  1638. function FreeCredentialHandle(phCredential: PCredHandle): SECURITY_STATUS;
  1639. {$EXTERNALSYM FreeCredentialHandle}
  1640. type
  1641.   PSecurityFunctionTableW = ^SecurityFunctionTableW;
  1642.   {$EXTERNALSYM PSecurityFunctionTableW}
  1643.   _SECURITY_FUNCTION_TABLE_W = record
  1644.     dwVersion: Cardinal;
  1645.     EnumerateSecurityPackagesW: ENUMERATE_SECURITY_PACKAGES_FN_W;
  1646.     QueryCredentialsAttributesW: QUERY_CREDENTIALS_ATTRIBUTES_FN_W;
  1647.     AcquireCredentialsHandleW: ACQUIRE_CREDENTIALS_HANDLE_FN_W;
  1648.     FreeCredentialsHandle: FREE_CREDENTIALS_HANDLE_FN;
  1649.     Reserved2: Pointer;
  1650.     InitializeSecurityContextW: INITIALIZE_SECURITY_CONTEXT_FN_W;
  1651.     AcceptSecurityContext: ACCEPT_SECURITY_CONTEXT_FN;
  1652.     CompleteAuthToken: COMPLETE_AUTH_TOKEN_FN;
  1653.     DeleteSecurityContext: DELETE_SECURITY_CONTEXT_FN;
  1654.     ApplyControlToken: APPLY_CONTROL_TOKEN_FN;
  1655.     QueryContextAttributesW: QUERY_CONTEXT_ATTRIBUTES_FN_W;
  1656.     ImpersonateSecurityContext: IMPERSONATE_SECURITY_CONTEXT_FN;
  1657.     RevertSecurityContext: REVERT_SECURITY_CONTEXT_FN;
  1658.     MakeSignature: MAKE_SIGNATURE_FN;
  1659.     VerifySignature: VERIFY_SIGNATURE_FN;
  1660.     FreeContextBuffer: FREE_CONTEXT_BUFFER_FN;
  1661.     QuerySecurityPackageInfoW: QUERY_SECURITY_PACKAGE_INFO_FN_W;
  1662.     Reserved3: Pointer;
  1663.     Reserved4: Pointer;
  1664.     ExportSecurityContext: EXPORT_SECURITY_CONTEXT_FN;
  1665.     ImportSecurityContextW: IMPORT_SECURITY_CONTEXT_FN_W;
  1666.     AddCredentialsW: ADD_CREDENTIALS_FN_W;
  1667.     Reserved8: Pointer;
  1668.     QuerySecurityContextToken: QUERY_SECURITY_CONTEXT_TOKEN_FN;
  1669.     EncryptMessage: ENCRYPT_MESSAGE_FN;
  1670.     DecryptMessage: DECRYPT_MESSAGE_FN;
  1671.     SetContextAttributesW: SET_CONTEXT_ATTRIBUTES_FN_W;
  1672.   end;
  1673.   {$EXTERNALSYM _SECURITY_FUNCTION_TABLE_W}
  1674.   SecurityFunctionTableW = _SECURITY_FUNCTION_TABLE_W;
  1675.   {$EXTERNALSYM SecurityFunctionTableW}
  1676.   TSecurityFunctionTableW = SecurityFunctionTableW;
  1677.   PSecurityFunctionTableA = ^SecurityFunctionTableA;
  1678.   {$EXTERNALSYM PSecurityFunctionTableA}
  1679.   _SECURITY_FUNCTION_TABLE_A = record
  1680.     dwVersion: Cardinal;
  1681.     EnumerateSecurityPackagesA: ENUMERATE_SECURITY_PACKAGES_FN_A;
  1682.     QueryCredentialsAttributesA: QUERY_CREDENTIALS_ATTRIBUTES_FN_A;
  1683.     AcquireCredentialsHandleA: ACQUIRE_CREDENTIALS_HANDLE_FN_A;
  1684.     FreeCredentialHandle: FREE_CREDENTIALS_HANDLE_FN;
  1685.     Reserved2: Pointer;
  1686.     InitializeSecurityContextA: INITIALIZE_SECURITY_CONTEXT_FN_A;
  1687.     AcceptSecurityContext: ACCEPT_SECURITY_CONTEXT_FN;
  1688.     CompleteAuthToken: COMPLETE_AUTH_TOKEN_FN;
  1689.     DeleteSecurityContext: DELETE_SECURITY_CONTEXT_FN;
  1690.     ApplyControlToken: APPLY_CONTROL_TOKEN_FN;
  1691.     QueryContextAttributesA: QUERY_CONTEXT_ATTRIBUTES_FN_A;
  1692.     ImpersonateSecurityContext: IMPERSONATE_SECURITY_CONTEXT_FN;
  1693.     RevertSecurityContext: REVERT_SECURITY_CONTEXT_FN;
  1694.     MakeSignature: MAKE_SIGNATURE_FN;
  1695.     VerifySignature: VERIFY_SIGNATURE_FN;
  1696.     FreeContextBuffer: FREE_CONTEXT_BUFFER_FN;
  1697.     QuerySecurityPackageInfoA: QUERY_SECURITY_PACKAGE_INFO_FN_A;
  1698.     Reserved3: Pointer;
  1699.     Reserved4: Pointer;
  1700.     ExportSecurityContext: EXPORT_SECURITY_CONTEXT_FN;
  1701.     ImportSecurityContextA: IMPORT_SECURITY_CONTEXT_FN_A;
  1702.     AddCredentialsA : ADD_CREDENTIALS_FN_A;
  1703.     Reserved8: Pointer;
  1704.     QuerySecurityContextToken: QUERY_SECURITY_CONTEXT_TOKEN_FN;
  1705.     EncryptMessage: ENCRYPT_MESSAGE_FN;
  1706.     DecryptMessage: DECRYPT_MESSAGE_FN;
  1707.     SetContextAttributesA: SET_CONTEXT_ATTRIBUTES_FN_A;
  1708.   end;
  1709.   {$EXTERNALSYM _SECURITY_FUNCTION_TABLE_A}
  1710.   SecurityFunctionTableA = _SECURITY_FUNCTION_TABLE_A;
  1711.   {$EXTERNALSYM SecurityFunctionTableA}
  1712.   TSecurityFunctionTableA = SecurityFunctionTableA;
  1713. {$IFDEF UNICODE}
  1714.   SecurityFunctionTable  = SecurityFunctionTableW;
  1715.   {$EXTERNALSYM SecurityFunctionTable}
  1716.   PSecurityFunctionTable = PSecurityFunctionTableW;
  1717.   {$EXTERNALSYM PSecurityFunctionTable}
  1718.   TSecurityFunctionTable = TSecurityFunctionTableW;
  1719. {$ELSE}
  1720.   SecurityFunctionTable  = SecurityFunctionTableA;
  1721.   {$EXTERNALSYM SecurityFunctionTable}
  1722.   PSecurityFunctionTable = PSecurityFunctionTableA;
  1723.   {$EXTERNALSYM PSecurityFunctionTable}
  1724.   TSecurityFunctionTable = TSecurityFunctionTableA;
  1725. {$ENDIF}
  1726. const
  1727.   // Function table has all routines through DecryptMessage
  1728.   SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION = 1;
  1729.   {$EXTERNALSYM SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION}
  1730.   // Function table has all routines through SetContextAttributes
  1731.   SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION_2 = 2;
  1732.   {$EXTERNALSYM SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION_2}
  1733. function InitSecurityInterfaceA: PSecurityFunctionTableA; stdcall;
  1734. {$EXTERNALSYM InitSecurityInterfaceA}
  1735. type
  1736.   INIT_SECURITY_INTERFACE_A = function : PSecurityFunctionTableA; stdcall;
  1737.   {$EXTERNALSYM INIT_SECURITY_INTERFACE_A}
  1738. function InitSecurityInterfaceW: PSecurityFunctionTableW; stdcall;
  1739. {$EXTERNALSYM InitSecurityInterfaceW}
  1740. type
  1741.   INIT_SECURITY_INTERFACE_W = function : PSecurityFunctionTableW; stdcall;
  1742.   {$EXTERNALSYM INIT_SECURITY_INTERFACE_W}
  1743. {$IFDEF UNICODE}
  1744. function InitSecurityInterface: PSecurityFunctionTableW; stdcall;
  1745. {$EXTERNALSYM InitSecurityInterface}
  1746. type
  1747.   INIT_SECURITY_INTERFACE = function : PSecurityFunctionTableW; stdcall;
  1748.   {$EXTERNALSYM INIT_SECURITY_INTERFACE}
  1749. {$ELSE}
  1750. function InitSecurityInterface: PSecurityFunctionTableA; stdcall;
  1751. {$EXTERNALSYM InitSecurityInterface}
  1752. type
  1753.   INIT_SECURITY_INTERFACE = function : PSecurityFunctionTableA; stdcall;
  1754.   {$EXTERNALSYM INIT_SECURITY_INTERFACE}
  1755. {$ENDIF}
  1756. //
  1757. // SASL Profile Support
  1758. //
  1759. function SaslEnumerateProfilesA(var ProfileList: LPSTR;
  1760.   var ProfileCount: ULONG): SECURITY_STATUS; stdcall;
  1761. {$EXTERNALSYM SaslEnumerateProfilesA}
  1762. function SaslEnumerateProfilesW(var ProfileList: LPWSTR;
  1763.   var ProfileCount: ULONG): SECURITY_STATUS; stdcall;
  1764. {$EXTERNALSYM SaslEnumerateProfilesW}
  1765. {$IFDEF UNICODE}
  1766. function SaslEnumerateProfiles(var ProfileList: LPWSTR;
  1767.   var ProfileCount: ULONG): SECURITY_STATUS; stdcall;
  1768. {$EXTERNALSYM SaslEnumerateProfiles}
  1769. {$ELSE}
  1770. function SaslEnumerateProfiles(var ProfileList: LPSTR;
  1771.   var ProfileCount: ULONG): SECURITY_STATUS; stdcall;
  1772. {$EXTERNALSYM SaslEnumerateProfiles}
  1773. {$ENDIF}
  1774. function SaslGetProfilePackageA(ProfileName: LPSTR;
  1775.   var PackageInfo: PSecPkgInfoA): SECURITY_STATUS; stdcall;
  1776. {$EXTERNALSYM SaslGetProfilePackageA}
  1777. function SaslGetProfilePackageW(ProfileName: LPWSTR;
  1778.   var PackageInfo: PSecPkgInfoW): SECURITY_STATUS; stdcall;
  1779. {$EXTERNALSYM SaslGetProfilePackageW}
  1780. {$IFDEF UNICODE}
  1781. function SaslGetProfilePackage(ProfileName: LPWSTR;
  1782.   var PackageInfo: PSecPkgInfoW): SECURITY_STATUS; stdcall;
  1783. {$EXTERNALSYM SaslGetProfilePackage}
  1784. {$ELSE}
  1785. function SaslGetProfilePackage(ProfileName: LPSTR;
  1786.   var PackageInfo: PSecPkgInfoA): SECURITY_STATUS; stdcall;
  1787. {$EXTERNALSYM SaslGetProfilePackage}
  1788. {$ENDIF}
  1789. function SaslIdentifyPackageA(pInput: PSecBufferDesc;
  1790.   var PackageInfo: PSecPkgInfoA): SECURITY_STATUS; stdcall;
  1791. {$EXTERNALSYM SaslIdentifyPackageA}
  1792. function SaslIdentifyPackageW(pInput: PSecBufferDesc;
  1793.   var PackageInfo: PSecPkgInfoW): SECURITY_STATUS; stdcall;
  1794. {$EXTERNALSYM SaslIdentifyPackageW}
  1795. {$IFDEF UNICODE}
  1796. function SaslIdentifyPackage(pInput: PSecBufferDesc;
  1797.   var PackageInfo: PSecPkgInfoW): SECURITY_STATUS; stdcall;
  1798. {$EXTERNALSYM SaslIdentifyPackage}
  1799. {$ELSE}
  1800. function SaslIdentifyPackage(pInput: PSecBufferDesc;
  1801.   var PackageInfo: PSecPkgInfoA): SECURITY_STATUS; stdcall;
  1802. {$EXTERNALSYM SaslIdentifyPackage}
  1803. {$ENDIF}
  1804. function SaslInitializeSecurityContextW(phCredential: PCredHandle;
  1805.   phContext: PCtxtHandle; pszTargetName: LPWSTR; fContextReq, Reserved1: Cardinal;
  1806.   TargetDataRep: Cardinal; pInput: PSecBufferDesc; Reserved2: Cardinal;
  1807.   phNewContext: PCtxtHandle; pOutput: PSecBufferDesc; var pfContextAttr: Cardinal;
  1808.   ptsExpiry: PTimeStamp): SECURITY_STATUS; stdcall;
  1809. {$EXTERNALSYM SaslInitializeSecurityContextW}
  1810. function SaslInitializeSecurityContextA(phCredential: PCredHandle;
  1811.   phContext: PCtxtHandle; pszTargetName: LPSTR; fContextReq, Reserved1: Cardinal;
  1812.   TargetDataRep: Cardinal; pInput: PSecBufferDesc; Reserved2: Cardinal;
  1813.   phNewContext: PCtxtHandle; pOutput: PSecBufferDesc; var pfContextAttr: Cardinal;
  1814.   ptsExpiry: PTimeStamp): SECURITY_STATUS; stdcall;
  1815. {$EXTERNALSYM SaslInitializeSecurityContextA}
  1816. {$IFDEF UNICODE}
  1817. function SaslInitializeSecurityContext(phCredential: PCredHandle;
  1818.   phContext: PCtxtHandle; pszTargetName: LPWSTR; fContextReq, Reserved1: Cardinal;
  1819.   TargetDataRep: Cardinal; pInput: PSecBufferDesc; Reserved2: Cardinal;
  1820.   phNewContext: PCtxtHandle; pOutput: PSecBufferDesc; var pfContextAttr: Cardinal;
  1821.   ptsExpiry: PTimeStamp): SECURITY_STATUS; stdcall;
  1822. {$EXTERNALSYM SaslInitializeSecurityContext}
  1823. {$ELSE}
  1824. function SaslInitializeSecurityContext(phCredential: PCredHandle;
  1825.   phContext: PCtxtHandle; pszTargetName: LPSTR; fContextReq, Reserved1: Cardinal;
  1826.   TargetDataRep: Cardinal; pInput: PSecBufferDesc; Reserved2: Cardinal;
  1827.   phNewContext: PCtxtHandle; pOutput: PSecBufferDesc; var pfContextAttr: Cardinal;
  1828.   ptsExpiry: PTimeStamp): SECURITY_STATUS; stdcall;
  1829. {$EXTERNALSYM SaslInitializeSecurityContext}
  1830. {$ENDIF}
  1831. function SaslAcceptSecurityContext(phCredential: PCredHandle;
  1832.   phContext: PCtxtHandle; pInput: PSecBufferDesc; fContextReq: Cardinal;
  1833.   TargetDataRep: Cardinal; phNewContext: PCtxtHandle; pOutput: PSecBufferDesc;
  1834.   var pfContextAttr: Cardinal; ptsExpiry: PTimeStamp): SECURITY_STATUS; stdcall;
  1835. {$EXTERNALSYM SaslAcceptSecurityContext}
  1836. const
  1837.   SASL_OPTION_SEND_SIZE        = 1;       // Maximum size to send to peer
  1838.   {$EXTERNALSYM SASL_OPTION_SEND_SIZE}
  1839.   SASL_OPTION_RECV_SIZE        = 2;       // Maximum size willing to receive
  1840.   {$EXTERNALSYM SASL_OPTION_RECV_SIZE}
  1841.   SASL_OPTION_AUTHZ_STRING     = 3;       // Authorization string
  1842.   {$EXTERNALSYM SASL_OPTION_AUTHZ_STRING}
  1843.   SASL_OPTION_AUTHZ_PROCESSING = 4;       // Authorization string processing
  1844.   {$EXTERNALSYM SASL_OPTION_AUTHZ_PROCESSING}
  1845. type
  1846.   _SASL_AUTHZID_STATE = (
  1847.     Sasl_AuthZIDForbidden,             // allow no AuthZID strings to be specified - error out (default)
  1848.     Sasl_AuthZIDProcessed);           // AuthZID Strings processed by Application or SSP
  1849.   {$EXTERNALSYM _SASL_AUTHZID_STATE}
  1850.   SASL_AUTHZID_STATE = _SASL_AUTHZID_STATE;
  1851.   {$EXTERNALSYM SASL_AUTHZID_STATE}
  1852.   TSaslAuthzIDState = SASL_AUTHZID_STATE;
  1853. function SaslSetContextOption(ContextHandle: PCtxtHandle; Option: ULONG; Value: PVOID; Size: ULONG): SECURITY_STATUS; stdcall;
  1854. {$EXTERNALSYM SaslSetContextOption}
  1855. function SaslGetContextOption(ContextHandle: PCtxtHandle; Option: ULONG; Value: PVOID;
  1856.   Size: ULONG; Needed: PULONG): SECURITY_STATUS; stdcall;
  1857. {$EXTERNALSYM SaslGetContextOption}
  1858. //
  1859. // This is the legacy credentials structure.
  1860. // The EX version below is preferred.
  1861. const
  1862.   SEC_WINNT_AUTH_IDENTITY_ANSI    = $1;
  1863.   {$EXTERNALSYM SEC_WINNT_AUTH_IDENTITY_ANSI}
  1864.   SEC_WINNT_AUTH_IDENTITY_UNICODE = $2;
  1865.   {$EXTERNALSYM SEC_WINNT_AUTH_IDENTITY_UNICODE}
  1866. type
  1867.   _SEC_WINNT_AUTH_IDENTITY_W = record
  1868.     User: PWideChar;
  1869.     UserLength: Cardinal;
  1870.     Domain: PWideChar;
  1871.     DomainLength: Cardinal;
  1872.     Password: PWideChar;
  1873.     PasswordLength: Cardinal;
  1874.     Flags: Cardinal;
  1875.   end;
  1876.   {$EXTERNALSYM _SEC_WINNT_AUTH_IDENTITY_W}
  1877.   SEC_WINNT_AUTH_IDENTITY_W = _SEC_WINNT_AUTH_IDENTITY_W;
  1878.   {$EXTERNALSYM SEC_WINNT_AUTH_IDENTITY_W}
  1879.   PSEC_WINNT_AUTH_IDENTITY_W = ^SEC_WINNT_AUTH_IDENTITY_W;
  1880.   {$EXTERNALSYM PSEC_WINNT_AUTH_IDENTITY_W}
  1881.   TSecWinNTAuthIdentityW = SEC_WINNT_AUTH_IDENTITY_W;
  1882.   PSecWinNTAuthIdentityW = PSEC_WINNT_AUTH_IDENTITY_W;
  1883.   _SEC_WINNT_AUTH_IDENTITY_A = record
  1884.     User: PChar;
  1885.     UserLength: Cardinal;
  1886.     Domain: PChar;
  1887.     DomainLength: Cardinal;
  1888.     Password: PChar;
  1889.     PasswordLength: Cardinal;
  1890.     Flags: Cardinal;
  1891.   end;
  1892.   {$EXTERNALSYM _SEC_WINNT_AUTH_IDENTITY_A}
  1893.   SEC_WINNT_AUTH_IDENTITY_A = _SEC_WINNT_AUTH_IDENTITY_A;
  1894.   {$EXTERNALSYM SEC_WINNT_AUTH_IDENTITY_A}
  1895.   PSEC_WINNT_AUTH_IDENTITY_A = ^SEC_WINNT_AUTH_IDENTITY_A;
  1896.   {$EXTERNALSYM PSEC_WINNT_AUTH_IDENTITY_A}
  1897.   TSecWinNTAuthIdentityA = SEC_WINNT_AUTH_IDENTITY_A;
  1898.   PSecWinNTAuthIdentityA = PSEC_WINNT_AUTH_IDENTITY_A;
  1899. {$IFDEF UNICODE}
  1900.   SEC_WINNT_AUTH_IDENTITY = SEC_WINNT_AUTH_IDENTITY_W;
  1901.   {$EXTERNALSYM SEC_WINNT_AUTH_IDENTITY}
  1902.   PSEC_WINNT_AUTH_IDENTITY = PSEC_WINNT_AUTH_IDENTITY_W;
  1903.   {$EXTERNALSYM PSEC_WINNT_AUTH_IDENTITY}
  1904.   _SEC_WINNT_AUTH_IDENTITY = _SEC_WINNT_AUTH_IDENTITY_W;
  1905.   {$EXTERNALSYM _SEC_WINNT_AUTH_IDENTITY}
  1906.   TSecWinNTAuthIdentity = TSecWinNTAuthIdentityW;
  1907.   PSecWinNTAuthIdentity = PSecWinNTAuthIdentityW;
  1908. {$ELSE}
  1909.   SEC_WINNT_AUTH_IDENTITY = SEC_WINNT_AUTH_IDENTITY_A;
  1910.   {$EXTERNALSYM SEC_WINNT_AUTH_IDENTITY}
  1911.   PSEC_WINNT_AUTH_IDENTITY = PSEC_WINNT_AUTH_IDENTITY_A;
  1912.   {$EXTERNALSYM PSEC_WINNT_AUTH_IDENTITY}
  1913.   _SEC_WINNT_AUTH_IDENTITY = _SEC_WINNT_AUTH_IDENTITY_A;
  1914.   {$EXTERNALSYM _SEC_WINNT_AUTH_IDENTITY}
  1915.   TSecWinNTAuthIdentity = TSecWinNTAuthIdentityA;
  1916.   PSecWinNTAuthIdentity = PSecWinNTAuthIdentityA;
  1917. {$ENDIF}
  1918. //
  1919. // This is the combined authentication identity structure that may be
  1920. // used with the negotiate package, NTLM, Kerberos, or SCHANNEL
  1921. //
  1922. const
  1923.   SEC_WINNT_AUTH_IDENTITY_VERSION = $200;
  1924. type
  1925.   _SEC_WINNT_AUTH_IDENTITY_EXW = record
  1926.     Version: Cardinal;
  1927.     Length: Cardinal;
  1928.     User: PWideChar;
  1929.     UserLength: Cardinal;
  1930.     Domain: PWideChar;
  1931.     DomainLength: Cardinal;
  1932.     Password: PWideChar;
  1933.     PasswordLength: Cardinal;
  1934.     Flags: Cardinal;
  1935.     PackageList: PWideChar;
  1936.     PackageListLength: Cardinal;
  1937.   end;
  1938.   {$EXTERNALSYM _SEC_WINNT_AUTH_IDENTITY_EXW}
  1939.   SEC_WINNT_AUTH_IDENTITY_EXW = _SEC_WINNT_AUTH_IDENTITY_EXW;
  1940.   {$EXTERNALSYM SEC_WINNT_AUTH_IDENTITY_EXW}
  1941.   PSEC_WINNT_AUTH_IDENTITY_EXW = ^SEC_WINNT_AUTH_IDENTITY_EXW;
  1942.   {$EXTERNALSYM PSEC_WINNT_AUTH_IDENTITY_EXW}
  1943.   TSecWinNTAuthIdentityExW = SEC_WINNT_AUTH_IDENTITY_EXW;
  1944.   PSecWinNTAuthIdentityExW = PSEC_WINNT_AUTH_IDENTITY_EXW;
  1945.   _SEC_WINNT_AUTH_IDENTITY_EXA = record
  1946.     Version: Cardinal;
  1947.     Length: Cardinal;
  1948.     User: PChar;
  1949.     UserLength: Cardinal;
  1950.     Domain: PChar;
  1951.     DomainLength: Cardinal;
  1952.     Password: PChar;
  1953.     PasswordLength: Cardinal;
  1954.     Flags: Cardinal;
  1955.     PackageList: PChar;
  1956.     PackageListLength: Cardinal;
  1957.   end;
  1958.   {$EXTERNALSYM _SEC_WINNT_AUTH_IDENTITY_EXA}
  1959.   SEC_WINNT_AUTH_IDENTITY_EXA = _SEC_WINNT_AUTH_IDENTITY_EXA;
  1960.   {$EXTERNALSYM SEC_WINNT_AUTH_IDENTITY_EXA}
  1961.   PSEC_WINNT_AUTH_IDENTITY_EXA = ^SEC_WINNT_AUTH_IDENTITY_EXA;
  1962.   {$EXTERNALSYM PSEC_WINNT_AUTH_IDENTITY_EXA}
  1963.   TSecWinNTAuthIdentityExA = SEC_WINNT_AUTH_IDENTITY_EXA;
  1964.   PSecWinNTAuthIdentityExA = PSEC_WINNT_AUTH_IDENTITY_EXA;
  1965. {$IFDEF UNICODE}
  1966.   SEC_WINNT_AUTH_IDENTITY_EX = SEC_WINNT_AUTH_IDENTITY_EXW;
  1967.   {$EXTERNALSYM SEC_WINNT_AUTH_IDENTITY_EX}
  1968.   PSEC_WINNT_AUTH_IDENTITY_EX = PSEC_WINNT_AUTH_IDENTITY_EXW;
  1969.   {$EXTERNALSYM PSEC_WINNT_AUTH_IDENTITY_EX}
  1970.   TSecWinNTAuthIdentityEx = TSecWinNTAuthIdentityExW;
  1971.   PSecWinNTAuthIdentityEx = PSecWinNTAuthIdentityExW;
  1972. {$ELSE}
  1973.   SEC_WINNT_AUTH_IDENTITY_EX = SEC_WINNT_AUTH_IDENTITY_EXA;
  1974.   {$EXTERNALSYM SEC_WINNT_AUTH_IDENTITY_EX}
  1975.   PSEC_WINNT_AUTH_IDENTITY_EX = PSEC_WINNT_AUTH_IDENTITY_EXA;
  1976.   {$EXTERNALSYM PSEC_WINNT_AUTH_IDENTITY_EX}
  1977.   TSecWinNTAuthIdentityEx = TSecWinNTAuthIdentityExA;
  1978.   PSecWinNTAuthIdentityEx = PSecWinNTAuthIdentityExA;
  1979. {$ENDIF}
  1980. //
  1981. // Common types used by negotiable security packages
  1982. //
  1983. const
  1984.   SEC_WINNT_AUTH_IDENTITY_MARSHALLED     = $4;     // all data is in one buffer
  1985.   {$EXTERNALSYM SEC_WINNT_AUTH_IDENTITY_MARSHALLED}
  1986.   SEC_WINNT_AUTH_IDENTITY_ONLY           = $8;     // these credentials are for identity only - no PAC needed
  1987.   {$EXTERNALSYM SEC_WINNT_AUTH_IDENTITY_ONLY}
  1988. //
  1989. // Routines for manipulating packages
  1990. //
  1991. type
  1992.   _SECURITY_PACKAGE_OPTIONS = record
  1993.     Size: Cardinal;
  1994.     Type_: Cardinal;
  1995.     Flags: Cardinal;
  1996.     SignatureSize: Cardinal;
  1997.     Signature: Pointer;
  1998.   end;
  1999.   {$EXTERNALSYM _SECURITY_PACKAGE_OPTIONS}
  2000.   SECURITY_PACKAGE_OPTIONS = _SECURITY_PACKAGE_OPTIONS;
  2001.   {$EXTERNALSYM SECURITY_PACKAGE_OPTIONS}
  2002.   PSECURITY_PACKAGE_OPTIONS = ^SECURITY_PACKAGE_OPTIONS;
  2003.   TSecurityPackageOptions = SECURITY_PACKAGE_OPTIONS;
  2004.   PSecurityPackageOptions = PSECURITY_PACKAGE_OPTIONS;
  2005. const
  2006.   SECPKG_OPTIONS_TYPE_UNKNOWN = 0;
  2007.   {$EXTERNALSYM SECPKG_OPTIONS_TYPE_UNKNOWN}
  2008.   SECPKG_OPTIONS_TYPE_LSA     = 1;
  2009.   {$EXTERNALSYM SECPKG_OPTIONS_TYPE_LSA}
  2010.   SECPKG_OPTIONS_TYPE_SSPI    = 2;
  2011.   {$EXTERNALSYM SECPKG_OPTIONS_TYPE_SSPI}
  2012.   SECPKG_OPTIONS_PERMANENT    = $00000001;
  2013.   {$EXTERNALSYM SECPKG_OPTIONS_PERMANENT}
  2014. function AddSecurityPackageA(pszPackageName: PSEC_CHAR; Options: PSECURITY_PACKAGE_OPTIONS): SECURITY_STATUS; stdcall;
  2015. {$EXTERNALSYM AddSecurityPackageA}
  2016. function AddSecurityPackageW(pszPackageName: PSEC_WCHAR; Options: PSECURITY_PACKAGE_OPTIONS): SECURITY_STATUS; stdcall;
  2017. {$EXTERNALSYM AddSecurityPackageW}
  2018. {$IFDEF UNICODE}
  2019. function AddSecurityPackage(pszPackageName: PSEC_WCHAR; Options: PSECURITY_PACKAGE_OPTIONS): SECURITY_STATUS; stdcall;
  2020. {$EXTERNALSYM AddSecurityPackage}
  2021. {$ELSE}
  2022. function AddSecurityPackage(pszPackageName: PSEC_CHAR; Options: PSECURITY_PACKAGE_OPTIONS): SECURITY_STATUS; stdcall;
  2023. {$EXTERNALSYM AddSecurityPackage}
  2024. {$ENDIF}
  2025. function DeleteSecurityPackageA(pszPackageName: PSEC_CHAR): SECURITY_STATUS; stdcall;
  2026. {$EXTERNALSYM DeleteSecurityPackageA}
  2027. function DeleteSecurityPackageW(pszPackageName: PSEC_WCHAR): SECURITY_STATUS; stdcall;
  2028. {$EXTERNALSYM DeleteSecurityPackageW}
  2029. {$IFDEF UNICODE}
  2030. function DeleteSecurityPackage(pszPackageName: PSEC_WCHAR): SECURITY_STATUS; stdcall;
  2031. {$EXTERNALSYM DeleteSecurityPackage}
  2032. {$ELSE}
  2033. function DeleteSecurityPackage(pszPackageName: PSEC_CHAR): SECURITY_STATUS; stdcall;
  2034. {$EXTERNALSYM DeleteSecurityPackage}
  2035. {$ENDIF}
  2036. implementation
  2037. procedure SecInvalidateHandle(var x: SecHandle);
  2038. begin
  2039.   x.dwLower := ULONG_PTR(-1);
  2040.   x.dwUpper := ULONG_PTR(-1);
  2041. end;
  2042. function SecIsValidHandle(x: SecHandle): Boolean;
  2043. begin
  2044.   Result := (x.dwLower <> ULONG_PTR(-1)) and (x.dwUpper <> ULONG_PTR(-1));
  2045. end;
  2046. function FreeCredentialHandle(phCredential: PCredHandle): SECURITY_STATUS;
  2047. begin
  2048.   Result := FreeCredentialsHandle(phCredential);
  2049. end;
  2050. const
  2051.   secur32 = 'secur32.dll';
  2052. {$IFDEF DYNAMIC_LINK}
  2053. var
  2054.   _AcquireCredentialsHandleW: Pointer;
  2055. function AcquireCredentialsHandleW;
  2056. begin
  2057.   GetProcedureAddress(_AcquireCredentialsHandleW, secur32, 'AcquireCredentialsHandleW');
  2058.   asm
  2059.     mov esp, ebp
  2060.     pop ebp
  2061.     jmp [_AcquireCredentialsHandleW]
  2062.   end;
  2063. end;
  2064. {$ELSE}
  2065. function AcquireCredentialsHandleW; external secur32 name 'AcquireCredentialsHandleW';
  2066. {$ENDIF DYNAMIC_LINK}
  2067. {$IFDEF DYNAMIC_LINK}
  2068. var
  2069.   _AcquireCredentialsHandleA: Pointer;
  2070. function AcquireCredentialsHandleA;
  2071. begin
  2072.   GetProcedureAddress(_AcquireCredentialsHandleA, secur32, 'AcquireCredentialsHandleA');
  2073.   asm
  2074.     mov esp, ebp
  2075.     pop ebp
  2076.     jmp [_AcquireCredentialsHandleA]
  2077.   end;
  2078. end;
  2079. {$ELSE}
  2080. function AcquireCredentialsHandleA; external secur32 name 'AcquireCredentialsHandleA';
  2081. {$ENDIF DYNAMIC_LINK}
  2082. {$IFDEF UNICODE}
  2083. {$IFDEF DYNAMIC_LINK}
  2084. var
  2085.   _AcquireCredentialsHandle: Pointer;
  2086. function AcquireCredentialsHandle;
  2087. begin
  2088.   GetProcedureAddress(_AcquireCredentialsHandle, secur32, 'AcquireCredentialsHandleW');
  2089.   asm
  2090.     mov esp, ebp
  2091.     pop ebp
  2092.     jmp [_AcquireCredentialsHandle]
  2093.   end;
  2094. end;
  2095. {$ELSE}
  2096. function AcquireCredentialsHandle; external secur32 name 'AcquireCredentialsHandleW';
  2097. {$ENDIF DYNAMIC_LINK}
  2098. {$ELSE}
  2099. {$IFDEF DYNAMIC_LINK}
  2100. var
  2101.   _AcquireCredentialsHandle: Pointer;
  2102. function AcquireCredentialsHandle;
  2103. begin
  2104.   GetProcedureAddress(_AcquireCredentialsHandle, secur32, 'AcquireCredentialsHandleA');
  2105.   asm
  2106.     mov esp, ebp
  2107.     pop ebp
  2108.     jmp [_AcquireCredentialsHandle]
  2109.   end;
  2110. end;
  2111. {$ELSE}
  2112. function AcquireCredentialsHandle; external secur32 name 'AcquireCredentialsHandleA';
  2113. {$ENDIF DYNAMIC_LINK}
  2114. {$ENDIF}
  2115. {$IFDEF DYNAMIC_LINK}
  2116. var
  2117.   _FreeCredentialsHandle: Pointer;
  2118. function FreeCredentialsHandle;
  2119. begin
  2120.   GetProcedureAddress(_FreeCredentialsHandle, secur32, 'FreeCredentialsHandle');
  2121.   asm
  2122.     mov esp, ebp
  2123.     pop ebp
  2124.     jmp [_FreeCredentialsHandle]
  2125.   end;
  2126. end;
  2127. {$ELSE}
  2128. function FreeCredentialsHandle; external secur32 name 'FreeCredentialsHandle';
  2129. {$ENDIF DYNAMIC_LINK}
  2130. {$IFDEF DYNAMIC_LINK}
  2131. var
  2132.   _AddCredentialsW: Pointer;
  2133. function AddCredentialsW;
  2134. begin
  2135.   GetProcedureAddress(_AddCredentialsW, secur32, 'AddCredentialsW');
  2136.   asm
  2137.     mov esp, ebp
  2138.     pop ebp
  2139.     jmp [_AddCredentialsW]
  2140.   end;
  2141. end;
  2142. {$ELSE}
  2143. function AddCredentialsW; external secur32 name 'AddCredentialsW';
  2144. {$ENDIF DYNAMIC_LINK}
  2145. {$IFDEF DYNAMIC_LINK}
  2146. var
  2147.   _AddCredentialsA: Pointer;
  2148. function AddCredentialsA;
  2149. begin
  2150.   GetProcedureAddress(_AddCredentialsA, secur32, 'AddCredentialsA');
  2151.   asm
  2152.     mov esp, ebp
  2153.     pop ebp
  2154.     jmp [_AddCredentialsA]
  2155.   end;
  2156. end;
  2157. {$ELSE}
  2158. function AddCredentialsA; external secur32 name 'AddCredentialsA';
  2159. {$ENDIF DYNAMIC_LINK}
  2160. {$IFDEF UNICODE}
  2161. {$IFDEF DYNAMIC_LINK}
  2162. var
  2163.   _AddCredentials: Pointer;
  2164. function AddCredentials;
  2165. begin
  2166.   GetProcedureAddress(_AddCredentials, secur32, 'AddCredentialsW');
  2167.   asm
  2168.     mov esp, ebp
  2169.     pop ebp
  2170.     jmp [_AddCredentials]
  2171.   end;
  2172. end;
  2173. {$ELSE}
  2174. function AddCredentials; external secur32 name 'AddCredentialsW';
  2175. {$ENDIF DYNAMIC_LINK}
  2176. {$ELSE}
  2177. {$IFDEF DYNAMIC_LINK}
  2178. var
  2179.   _AddCredentials: Pointer;
  2180. function AddCredentials;
  2181. begin
  2182.   GetProcedureAddress(_AddCredentials, secur32, 'AddCredentialsA');
  2183.   asm
  2184.     mov esp, ebp
  2185.     pop ebp
  2186.     jmp [_AddCredentials]
  2187.   end;
  2188. end;
  2189. {$ELSE}
  2190. function AddCredentials; external secur32 name 'AddCredentialsA';
  2191. {$ENDIF DYNAMIC_LINK}
  2192. {$ENDIF}
  2193. //function SspiLogonUserW; external secur32 name 'SspiLogonUserW';
  2194. //function SspiLogonUserA; external secur32 name 'SspiLogonUserA';
  2195. //{$IFDEF UNICODE}
  2196. //function SspiLogonUser; external secur32 name 'SspiLogonUserW';
  2197. //{$ELSE}
  2198. //function SspiLogonUser; external secur32 name 'SspiLogonUserA';
  2199. //{$ENDIF}
  2200. {$IFDEF DYNAMIC_LINK}
  2201. var
  2202.   _InitializeSecurityContextW: Pointer;
  2203. function InitializeSecurityContextW;
  2204. begin
  2205.   GetProcedureAddress(_InitializeSecurityContextW, secur32, 'InitializeSecurityContextW');
  2206.   asm
  2207.     mov esp, ebp
  2208.     pop ebp
  2209.     jmp [_InitializeSecurityContextW]
  2210.   end;
  2211. end;
  2212. {$ELSE}
  2213. function InitializeSecurityContextW; external secur32 name 'InitializeSecurityContextW';
  2214. {$ENDIF DYNAMIC_LINK}
  2215. {$IFDEF DYNAMIC_LINK}
  2216. var
  2217.   _InitializeSecurityContextA: Pointer;
  2218. function InitializeSecurityContextA;
  2219. begin
  2220.   GetProcedureAddress(_InitializeSecurityContextA, secur32, 'InitializeSecurityContextA');
  2221.   asm
  2222.     mov esp, ebp
  2223.     pop ebp
  2224.     jmp [_InitializeSecurityContextA]
  2225.   end;
  2226. end;
  2227. {$ELSE}
  2228. function InitializeSecurityContextA; external secur32 name 'InitializeSecurityContextA';
  2229. {$ENDIF DYNAMIC_LINK}
  2230. {$IFDEF UNICODE}
  2231. {$IFDEF DYNAMIC_LINK}
  2232. var
  2233.   _InitializeSecurityContext: Pointer;
  2234. function InitializeSecurityContext;
  2235. begin
  2236.   GetProcedureAddress(_InitializeSecurityContext, secur32, 'InitializeSecurityContextW');
  2237.   asm
  2238.     mov esp, ebp
  2239.     pop ebp
  2240.     jmp [_InitializeSecurityContext]
  2241.   end;
  2242. end;
  2243. {$ELSE}
  2244. function InitializeSecurityContext; external secur32 name 'InitializeSecurityContextW';
  2245. {$ENDIF DYNAMIC_LINK}
  2246. {$ELSE}
  2247. {$IFDEF DYNAMIC_LINK}
  2248. var
  2249.   _InitializeSecurityContext: Pointer;
  2250. function InitializeSecurityContext;
  2251. begin
  2252.   GetProcedureAddress(_InitializeSecurityContext, secur32, 'InitializeSecurityContextA');
  2253.   asm
  2254.     mov esp, ebp
  2255.     pop ebp
  2256.     jmp [_InitializeSecurityContext]
  2257.   end;
  2258. end;
  2259. {$ELSE}
  2260. function InitializeSecurityContext; external secur32 name 'InitializeSecurityContextA';
  2261. {$ENDIF DYNAMIC_LINK}
  2262. {$ENDIF}
  2263. {$IFDEF DYNAMIC_LINK}
  2264. var
  2265.   _AcceptSecurityContext: Pointer;
  2266. function AcceptSecurityContext;
  2267. begin
  2268.   GetProcedureAddress(_AcceptSecurityContext, secur32, 'AcceptSecurityContext');
  2269.   asm
  2270.     mov esp, ebp
  2271.     pop ebp
  2272.     jmp [_AcceptSecurityContext]
  2273.   end;
  2274. end;
  2275. {$ELSE}
  2276. function AcceptSecurityContext; external secur32 name 'AcceptSecurityContext';
  2277. {$ENDIF DYNAMIC_LINK}
  2278. {$IFDEF DYNAMIC_LINK}
  2279. var
  2280.   _CompleteAuthToken: Pointer;
  2281. function CompleteAuthToken;
  2282. begin
  2283.   GetProcedureAddress(_CompleteAuthToken, secur32, 'CompleteAuthToken');
  2284.   asm
  2285.     mov esp, ebp
  2286.     pop ebp
  2287.     jmp [_CompleteAuthToken]
  2288.   end;
  2289. end;
  2290. {$ELSE}
  2291. function CompleteAuthToken; external secur32 name 'CompleteAuthToken';
  2292. {$ENDIF DYNAMIC_LINK}
  2293. {$IFDEF DYNAMIC_LINK}
  2294. var
  2295.   _ImpersonateSecurityContext: Pointer;
  2296. function ImpersonateSecurityContext;
  2297. begin
  2298.   GetProcedureAddress(_ImpersonateSecurityContext, secur32, 'ImpersonateSecurityContext');
  2299.   asm
  2300.     mov esp, ebp
  2301.     pop ebp
  2302.     jmp [_ImpersonateSecurityContext]
  2303.   end;
  2304. end;
  2305. {$ELSE}
  2306. function ImpersonateSecurityContext; external secur32 name 'ImpersonateSecurityContext';
  2307. {$ENDIF DYNAMIC_LINK}
  2308. {$IFDEF DYNAMIC_LINK}
  2309. var
  2310.   _RevertSecurityContext: Pointer;
  2311. function RevertSecurityContext;
  2312. begin
  2313.   GetProcedureAddress(_RevertSecurityContext, secur32, 'RevertSecurityContext');
  2314.   asm
  2315.     mov esp, ebp
  2316.     pop ebp
  2317.     jmp [_RevertSecurityContext]
  2318.   end;
  2319. end;
  2320. {$ELSE}
  2321. function RevertSecurityContext; external secur32 name 'RevertSecurityContext';
  2322. {$ENDIF DYNAMIC_LINK}
  2323. {$IFDEF DYNAMIC_LINK}
  2324. var
  2325.   _QuerySecurityContextToken: Pointer;
  2326. function QuerySecurityContextToken;
  2327. begin
  2328.   GetProcedureAddress(_QuerySecurityContextToken, secur32, 'QuerySecurityContextToken');
  2329.   asm
  2330.     mov esp, ebp
  2331.     pop ebp
  2332.     jmp [_QuerySecurityContextToken]
  2333.   end;
  2334. end;
  2335. {$ELSE}
  2336. function QuerySecurityContextToken; external secur32 name 'QuerySecurityContextToken';
  2337. {$ENDIF DYNAMIC_LINK}
  2338. {$IFDEF DYNAMIC_LINK}
  2339. var
  2340.   _DeleteSecurityContext: Pointer;
  2341. function DeleteSecurityContext;
  2342. begin
  2343.   GetProcedureAddress(_DeleteSecurityContext, secur32, 'DeleteSecurityContext');
  2344.   asm
  2345.     mov esp, ebp
  2346.     pop ebp
  2347.     jmp [_DeleteSecurityContext]
  2348.   end;
  2349. end;
  2350. {$ELSE}
  2351. function DeleteSecurityContext; external secur32 name 'DeleteSecurityContext';
  2352. {$ENDIF DYNAMIC_LINK}
  2353. {$IFDEF DYNAMIC_LINK}
  2354. var
  2355.   _ApplyControlToken: Pointer;
  2356. function ApplyControlToken;
  2357. begin
  2358.   GetProcedureAddress(_ApplyControlToken, secur32, 'ApplyControlToken');
  2359.   asm
  2360.     mov esp, ebp
  2361.     pop ebp
  2362.     jmp [_ApplyControlToken]
  2363.   end;
  2364. end;
  2365. {$ELSE}
  2366. function ApplyControlToken; external secur32 name 'ApplyControlToken';
  2367. {$ENDIF DYNAMIC_LINK}
  2368. {$IFDEF DYNAMIC_LINK}
  2369. var
  2370.   _QueryContextAttributesW: Pointer;
  2371. function QueryContextAttributesW;
  2372. begin
  2373.   GetProcedureAddress(_QueryContextAttributesW, secur32, 'QueryContextAttributesW');
  2374.   asm
  2375.     mov esp, ebp
  2376.     pop ebp
  2377.     jmp [_QueryContextAttributesW]
  2378.   end;
  2379. end;
  2380. {$ELSE}
  2381. function QueryContextAttributesW; external secur32 name 'QueryContextAttributesW';
  2382. {$ENDIF DYNAMIC_LINK}
  2383. {$IFDEF DYNAMIC_LINK}
  2384. var
  2385.   _QueryContextAttributesA: Pointer;
  2386. function QueryContextAttributesA;
  2387. begin
  2388.   GetProcedureAddress(_QueryContextAttributesA, secur32, 'QueryContextAttributesA');
  2389.   asm
  2390.     mov esp, ebp
  2391.     pop ebp
  2392.     jmp [_QueryContextAttributesA]
  2393.   end;
  2394. end;
  2395. {$ELSE}
  2396. function QueryContextAttributesA; external secur32 name 'QueryContextAttributesA';
  2397. {$ENDIF DYNAMIC_LINK}
  2398. {$IFDEF UNICODE}
  2399. {$IFDEF DYNAMIC_LINK}
  2400. var
  2401.   _QueryContextAttributes: Pointer;
  2402. function QueryContextAttributes;
  2403. begin
  2404.   GetProcedureAddress(_QueryContextAttributes, secur32, 'QueryContextAttributesW');
  2405.   asm
  2406.     mov esp, ebp
  2407.     pop ebp
  2408.     jmp [_QueryContextAttributes]
  2409.   end;
  2410. end;
  2411. {$ELSE}
  2412. function QueryContextAttributes; external secur32 name 'QueryContextAttributesW';
  2413. {$ENDIF DYNAMIC_LINK}
  2414. {$ELSE}
  2415. {$IFDEF DYNAMIC_LINK}
  2416. var
  2417.   _QueryContextAttributes: Pointer;
  2418. function QueryContextAttributes;
  2419. begin
  2420.   GetProcedureAddress(_QueryContextAttributes, secur32, 'QueryContextAttributesA');
  2421.   asm
  2422.     mov esp, ebp
  2423.     pop ebp
  2424.     jmp [_QueryContextAttributes]
  2425.   end;
  2426. end;
  2427. {$ELSE}
  2428. function QueryContextAttributes; external secur32 name 'QueryContextAttributesA';
  2429. {$ENDIF DYNAMIC_LINK}
  2430. {$ENDIF}
  2431. {$IFDEF DYNAMIC_LINK}
  2432. var
  2433.   _SetContextAttributesW: Pointer;
  2434. function SetContextAttributesW;
  2435. begin
  2436.   GetProcedureAddress(_SetContextAttributesW, secur32, 'SetContextAttributesW');
  2437.   asm
  2438.     mov esp, ebp
  2439.     pop ebp
  2440.     jmp [_SetContextAttributesW]
  2441.   end;
  2442. end;
  2443. {$ELSE}
  2444. function SetContextAttributesW; external secur32 name 'SetContextAttributesW';
  2445. {$ENDIF DYNAMIC_LINK}
  2446. {$IFDEF DYNAMIC_LINK}
  2447. var
  2448.   _SetContextAttributesA: Pointer;
  2449. function SetContextAttributesA;
  2450. begin
  2451.   GetProcedureAddress(_SetContextAttributesA, secur32, 'SetContextAttributesA');
  2452.   asm
  2453.     mov esp, ebp
  2454.     pop ebp
  2455.     jmp [_SetContextAttributesA]
  2456.   end;
  2457. end;
  2458. {$ELSE}
  2459. function SetContextAttributesA; external secur32 name 'SetContextAttributesA';
  2460. {$ENDIF DYNAMIC_LINK}
  2461. {$IFDEF UNICODE}
  2462. {$IFDEF DYNAMIC_LINK}
  2463. var
  2464.   _SetContextAttributes: Pointer;
  2465. function SetContextAttributes;
  2466. begin
  2467.   GetProcedureAddress(_SetContextAttributes, secur32, 'SetContextAttributesW');
  2468.   asm
  2469.     mov esp, ebp
  2470.     pop ebp
  2471.     jmp [_SetContextAttributes]
  2472.   end;
  2473. end;
  2474. {$ELSE}
  2475. function SetContextAttributes; external secur32 name 'SetContextAttributesW';
  2476. {$ENDIF DYNAMIC_LINK}
  2477. {$ELSE}
  2478. {$IFDEF DYNAMIC_LINK}
  2479. var
  2480.   _SetContextAttributes: Pointer;
  2481. function SetContextAttributes;
  2482. begin
  2483.   GetProcedureAddress(_SetContextAttributes, secur32, 'SetContextAttributesA');
  2484.   asm
  2485.     mov esp, ebp
  2486.     pop ebp
  2487.     jmp [_SetContextAttributes]
  2488.   end;
  2489. end;
  2490. {$ELSE}
  2491. function SetContextAttributes; external secur32 name 'SetContextAttributesA';
  2492. {$ENDIF DYNAMIC_LINK}
  2493. {$ENDIF}
  2494. {$IFDEF DYNAMIC_LINK}
  2495. var
  2496.   _QueryCredentialsAttributesW: Pointer;
  2497. function QueryCredentialsAttributesW;
  2498. begin
  2499.   GetProcedureAddress(_QueryCredentialsAttributesW, secur32, 'QueryCredentialsAttributesW');
  2500.   asm
  2501.     mov esp, ebp
  2502.     pop ebp
  2503.     jmp [_QueryCredentialsAttributesW]
  2504.   end;
  2505. end;
  2506. {$ELSE}
  2507. function QueryCredentialsAttributesW; external secur32 name 'QueryCredentialsAttributesW';
  2508. {$ENDIF DYNAMIC_LINK}
  2509. {$IFDEF DYNAMIC_LINK}
  2510. var
  2511.   _QueryCredentialsAttributesA: Pointer;
  2512. function QueryCredentialsAttributesA;
  2513. begin
  2514.   GetProcedureAddress(_QueryCredentialsAttributesA, secur32, 'QueryCredentialsAttributesA');
  2515.   asm
  2516.     mov esp, ebp
  2517.     pop ebp
  2518.     jmp [_QueryCredentialsAttributesA]
  2519.   end;
  2520. end;
  2521. {$ELSE}
  2522. function QueryCredentialsAttributesA; external secur32 name 'QueryCredentialsAttributesA';
  2523. {$ENDIF DYNAMIC_LINK}
  2524. {$IFDEF UNICODE}
  2525. {$IFDEF DYNAMIC_LINK}
  2526. var
  2527.   _QueryCredentialsAttributes: Pointer;
  2528. function QueryCredentialsAttributes;
  2529. begin
  2530.   GetProcedureAddress(_QueryCredentialsAttributes, secur32, 'QueryCredentialsAttributesW');
  2531.   asm
  2532.     mov esp, ebp
  2533.     pop ebp
  2534.     jmp [_QueryCredentialsAttributes]
  2535.   end;
  2536. end;
  2537. {$ELSE}
  2538. function QueryCredentialsAttributes; external secur32 name 'QueryCredentialsAttributesW';
  2539. {$ENDIF DYNAMIC_LINK}
  2540. {$ELSE}
  2541. {$IFDEF DYNAMIC_LINK}
  2542. var
  2543.   _QueryCredentialsAttributes: Pointer;
  2544. function QueryCredentialsAttributes;
  2545. begin
  2546.   GetProcedureAddress(_QueryCredentialsAttributes, secur32, 'QueryCredentialsAttributesA');
  2547.   asm
  2548.     mov esp, ebp
  2549.     pop ebp
  2550.     jmp [_QueryCredentialsAttributes]
  2551.   end;
  2552. end;
  2553. {$ELSE}
  2554. function QueryCredentialsAttributes; external secur32 name 'QueryCredentialsAttributesA';
  2555. {$ENDIF DYNAMIC_LINK}
  2556. {$ENDIF}
  2557. {$IFDEF DYNAMIC_LINK}
  2558. var
  2559.   _FreeContextBuffer: Pointer;
  2560. function FreeContextBuffer;
  2561. begin
  2562.   GetProcedureAddress(_FreeContextBuffer, secur32, 'FreeContextBuffer');
  2563.   asm
  2564.     mov esp, ebp
  2565.     pop ebp
  2566.     jmp [_FreeContextBuffer]
  2567.   end;
  2568. end;
  2569. {$ELSE}
  2570. function FreeContextBuffer; external secur32 name 'FreeContextBuffer';
  2571. {$ENDIF DYNAMIC_LINK}
  2572. {$IFDEF DYNAMIC_LINK}
  2573. var
  2574.   _MakeSignature: Pointer;
  2575. function MakeSignature;
  2576. begin
  2577.   GetProcedureAddress(_MakeSignature, secur32, 'MakeSignature');
  2578.   asm
  2579.     mov esp, ebp
  2580.     pop ebp
  2581.     jmp [_MakeSignature]
  2582.   end;
  2583. end;
  2584. {$ELSE}
  2585. function MakeSignature; external secur32 name 'MakeSignature';
  2586. {$ENDIF DYNAMIC_LINK}
  2587. {$IFDEF DYNAMIC_LINK}
  2588. var
  2589.   _VerifySignature: Pointer;
  2590. function VerifySignature;
  2591. begin
  2592.   GetProcedureAddress(_VerifySignature, secur32, 'VerifySignature');
  2593.   asm
  2594.     mov esp, ebp
  2595.     pop ebp
  2596.     jmp [_VerifySignature]
  2597.   end;
  2598. end;
  2599. {$ELSE}
  2600. function VerifySignature; external secur32 name 'VerifySignature';
  2601. {$ENDIF DYNAMIC_LINK}
  2602. {$IFDEF DYNAMIC_LINK}
  2603. var
  2604.   _EncryptMessage: Pointer;
  2605. function EncryptMessage;
  2606. begin
  2607.   GetProcedureAddress(_EncryptMessage, secur32, 'EncryptMessage');
  2608.   asm
  2609.     mov esp, ebp
  2610.     pop ebp
  2611.     jmp [_EncryptMessage]
  2612.   end;
  2613. end;
  2614. {$ELSE}
  2615. function EncryptMessage; external secur32 name 'EncryptMessage';
  2616. {$ENDIF DYNAMIC_LINK}
  2617. {$IFDEF DYNAMIC_LINK}
  2618. var
  2619.   _DecryptMessage: Pointer;
  2620. function DecryptMessage;
  2621. begin
  2622.   GetProcedureAddress(_DecryptMessage, secur32, 'DecryptMessage');
  2623.   asm
  2624.     mov esp, ebp
  2625.     pop ebp
  2626.     jmp [_DecryptMessage]
  2627.   end;
  2628. end;
  2629. {$ELSE}
  2630. function DecryptMessage; external secur32 name 'DecryptMessage';
  2631. {$ENDIF DYNAMIC_LINK}
  2632. {$IFDEF DYNAMIC_LINK}
  2633. var
  2634.   _EnumerateSecurityPackagesW: Pointer;
  2635. function EnumerateSecurityPackagesW;
  2636. begin
  2637.   GetProcedureAddress(_EnumerateSecurityPackagesW, secur32, 'EnumerateSecurityPackagesW');
  2638.   asm
  2639.     mov esp, ebp
  2640.     pop ebp
  2641.     jmp [_EnumerateSecurityPackagesW]
  2642.   end;
  2643. end;
  2644. {$ELSE}
  2645. function EnumerateSecurityPackagesW; external secur32 name 'EnumerateSecurityPackagesW';
  2646. {$ENDIF DYNAMIC_LINK}
  2647. {$IFDEF DYNAMIC_LINK}
  2648. var
  2649.   _EnumerateSecurityPackagesA: Pointer;
  2650. function EnumerateSecurityPackagesA;
  2651. begin
  2652.   GetProcedureAddress(_EnumerateSecurityPackagesA, secur32, 'EnumerateSecurityPackagesA');
  2653.   asm
  2654.     mov esp, ebp
  2655.     pop ebp
  2656.     jmp [_EnumerateSecurityPackagesA]
  2657.   end;
  2658. end;
  2659. {$ELSE}
  2660. function EnumerateSecurityPackagesA; external secur32 name 'EnumerateSecurityPackagesA';
  2661. {$ENDIF DYNAMIC_LINK}
  2662. {$IFDEF UNICODE}
  2663. {$IFDEF DYNAMIC_LINK}
  2664. var
  2665.   _EnumerateSecurityPackages: Pointer;
  2666. function EnumerateSecurityPackages;
  2667. begin
  2668.   GetProcedureAddress(_EnumerateSecurityPackages, secur32, 'EnumerateSecurityPackagesW');
  2669.   asm
  2670.     mov esp, ebp
  2671.     pop ebp
  2672.     jmp [_EnumerateSecurityPackages]
  2673.   end;
  2674. end;
  2675. {$ELSE}
  2676. function EnumerateSecurityPackages; external secur32 name 'EnumerateSecurityPackagesW';
  2677. {$ENDIF DYNAMIC_LINK}
  2678. {$ELSE}
  2679. {$IFDEF DYNAMIC_LINK}
  2680. var
  2681.   _EnumerateSecurityPackages: Pointer;
  2682. function EnumerateSecurityPackages;
  2683. begin
  2684.   GetProcedureAddress(_EnumerateSecurityPackages, secur32, 'EnumerateSecurityPackagesA');
  2685.   asm
  2686.     mov esp, ebp
  2687.     pop ebp
  2688.     jmp [_EnumerateSecurityPackages]
  2689.   end;
  2690. end;
  2691. {$ELSE}
  2692. function EnumerateSecurityPackages; external secur32 name 'EnumerateSecurityPackagesA';
  2693. {$ENDIF DYNAMIC_LINK}
  2694. {$ENDIF}
  2695. {$IFDEF DYNAMIC_LINK}
  2696. var
  2697.   _QuerySecurityPackageInfoW: Pointer;
  2698. function QuerySecurityPackageInfoW;
  2699. begin
  2700.   GetProcedureAddress(_QuerySecurityPackageInfoW, secur32, 'QuerySecurityPackageInfoW');
  2701.   asm
  2702.     mov esp, ebp
  2703.     pop ebp
  2704.     jmp [_QuerySecurityPackageInfoW]
  2705.   end;
  2706. end;
  2707. {$ELSE}
  2708. function QuerySecurityPackageInfoW; external secur32 name 'QuerySecurityPackageInfoW';
  2709. {$ENDIF DYNAMIC_LINK}
  2710. {$IFDEF DYNAMIC_LINK}
  2711. var
  2712.   _QuerySecurityPackageInfoA: Pointer;
  2713. function QuerySecurityPackageInfoA;
  2714. begin
  2715.   GetProcedureAddress(_QuerySecurityPackageInfoA, secur32, 'QuerySecurityPackageInfoA');
  2716.   asm
  2717.     mov esp, ebp
  2718.     pop ebp
  2719.     jmp [_QuerySecurityPackageInfoA]
  2720.   end;
  2721. end;
  2722. {$ELSE}
  2723. function QuerySecurityPackageInfoA; external secur32 name 'QuerySecurityPackageInfoA';
  2724. {$ENDIF DYNAMIC_LINK}
  2725. {$IFDEF UNICODE}
  2726. {$IFDEF DYNAMIC_LINK}
  2727. var
  2728.   _QuerySecurityPackageInfo: Pointer;
  2729. function QuerySecurityPackageInfo;
  2730. begin
  2731.   GetProcedureAddress(_QuerySecurityPackageInfo, secur32, 'QuerySecurityPackageInfoW');
  2732.   asm
  2733.     mov esp, ebp
  2734.     pop ebp
  2735.     jmp [_QuerySecurityPackageInfo]
  2736.   end;
  2737. end;
  2738. {$ELSE}
  2739. function QuerySecurityPackageInfo; external secur32 name 'QuerySecurityPackageInfoW';
  2740. {$ENDIF DYNAMIC_LINK}
  2741. {$ELSE}
  2742. {$IFDEF DYNAMIC_LINK}
  2743. var
  2744.   _QuerySecurityPackageInfo: Pointer;
  2745. function QuerySecurityPackageInfo;
  2746. begin
  2747.   GetProcedureAddress(_QuerySecurityPackageInfo, secur32, 'QuerySecurityPackageInfoA');
  2748.   asm
  2749.     mov esp, ebp
  2750.     pop ebp
  2751.     jmp [_QuerySecurityPackageInfo]
  2752.   end;
  2753. end;
  2754. {$ELSE}
  2755. function QuerySecurityPackageInfo; external secur32 name 'QuerySecurityPackageInfoA';
  2756. {$ENDIF DYNAMIC_LINK}
  2757. {$ENDIF}
  2758. //function DelegateSecurityContext; external secur32 name 'DelegateSecurityContext';
  2759. {$IFDEF DYNAMIC_LINK}
  2760. var
  2761.   _ExportSecurityContext: Pointer;
  2762. function ExportSecurityContext;
  2763. begin
  2764.   GetProcedureAddress(_ExportSecurityContext, secur32, 'ExportSecurityContext');
  2765.   asm
  2766.     mov esp, ebp
  2767.     pop ebp
  2768.     jmp [_ExportSecurityContext]
  2769.   end;
  2770. end;
  2771. {$ELSE}
  2772. function ExportSecurityContext; external secur32 name 'ExportSecurityContext';
  2773. {$ENDIF DYNAMIC_LINK}
  2774. {$IFDEF DYNAMIC_LINK}
  2775. var
  2776.   _ImportSecurityContextW: Pointer;
  2777. function ImportSecurityContextW;
  2778. begin
  2779.   GetProcedureAddress(_ImportSecurityContextW, secur32, 'ImportSecurityContextW');
  2780.   asm
  2781.     mov esp, ebp
  2782.     pop ebp
  2783.     jmp [_ImportSecurityContextW]
  2784.   end;
  2785. end;
  2786. {$ELSE}
  2787. function ImportSecurityContextW; external secur32 name 'ImportSecurityContextW';
  2788. {$ENDIF DYNAMIC_LINK}
  2789. {$IFDEF DYNAMIC_LINK}
  2790. var
  2791.   _ImportSecurityContextA: Pointer;
  2792. function ImportSecurityContextA;
  2793. begin
  2794.   GetProcedureAddress(_ImportSecurityContextA, secur32, 'ImportSecurityContextA');
  2795.   asm
  2796.     mov esp, ebp
  2797.     pop ebp
  2798.     jmp [_ImportSecurityContextA]
  2799.   end;
  2800. end;
  2801. {$ELSE}
  2802. function ImportSecurityContextA; external secur32 name 'ImportSecurityContextA';
  2803. {$ENDIF DYNAMIC_LINK}
  2804. {$IFDEF UNICODE}
  2805. {$IFDEF DYNAMIC_LINK}
  2806. var
  2807.   _ImportSecurityContext: Pointer;
  2808. function ImportSecurityContext;
  2809. begin
  2810.   GetProcedureAddress(_ImportSecurityContext, secur32, 'ImportSecurityContextW');
  2811.   asm
  2812.     mov esp, ebp
  2813.     pop ebp
  2814.     jmp [_ImportSecurityContext]
  2815.   end;
  2816. end;
  2817. {$ELSE}
  2818. function ImportSecurityContext; external secur32 name 'ImportSecurityContextW';
  2819. {$ENDIF DYNAMIC_LINK}
  2820. {$ELSE}
  2821. {$IFDEF DYNAMIC_LINK}
  2822. var
  2823.   _ImportSecurityContext: Pointer;
  2824. function ImportSecurityContext;
  2825. begin
  2826.   GetProcedureAddress(_ImportSecurityContext, secur32, 'ImportSecurityContextA');
  2827.   asm
  2828.     mov esp, ebp
  2829.     pop ebp
  2830.     jmp [_ImportSecurityContext]
  2831.   end;
  2832. end;
  2833. {$ELSE}
  2834. function ImportSecurityContext; external secur32 name 'ImportSecurityContextA';
  2835. {$ENDIF DYNAMIC_LINK}
  2836. {$ENDIF}
  2837. {$IFDEF DYNAMIC_LINK}
  2838. var
  2839.   _InitSecurityInterfaceA: Pointer;
  2840. function InitSecurityInterfaceA;
  2841. begin
  2842.   GetProcedureAddress(_InitSecurityInterfaceA, secur32, 'InitSecurityInterfaceA');
  2843.   asm
  2844.     mov esp, ebp
  2845.     pop ebp
  2846.     jmp [_InitSecurityInterfaceA]
  2847.   end;
  2848. end;
  2849. {$ELSE}
  2850. function InitSecurityInterfaceA; external secur32 name 'InitSecurityInterfaceA';
  2851. {$ENDIF DYNAMIC_LINK}
  2852. {$IFDEF DYNAMIC_LINK}
  2853. var
  2854.   _InitSecurityInterfaceW: Pointer;
  2855. function InitSecurityInterfaceW;
  2856. begin
  2857.   GetProcedureAddress(_InitSecurityInterfaceW, secur32, 'InitSecurityInterfaceW');
  2858.   asm
  2859.     mov esp, ebp
  2860.     pop ebp
  2861.     jmp [_InitSecurityInterfaceW]
  2862.   end;
  2863. end;
  2864. {$ELSE}
  2865. function InitSecurityInterfaceW; external secur32 name 'InitSecurityInterfaceW';
  2866. {$ENDIF DYNAMIC_LINK}
  2867. {$IFDEF UNICODE}
  2868. {$IFDEF DYNAMIC_LINK}
  2869. var
  2870.   _InitSecurityInterface: Pointer;
  2871. function InitSecurityInterface;
  2872. begin
  2873.   GetProcedureAddress(_InitSecurityInterface, secur32, 'InitSecurityInterfaceW');
  2874.   asm
  2875.     mov esp, ebp
  2876.     pop ebp
  2877.     jmp [_InitSecurityInterface]
  2878.   end;
  2879. end;
  2880. {$ELSE}
  2881. function InitSecurityInterface; external secur32 name 'InitSecurityInterfaceW';
  2882. {$ENDIF DYNAMIC_LINK}
  2883. {$ELSE}
  2884. {$IFDEF DYNAMIC_LINK}
  2885. var
  2886.   _InitSecurityInterface: Pointer;
  2887. function InitSecurityInterface;
  2888. begin
  2889.   GetProcedureAddress(_InitSecurityInterface, secur32, 'InitSecurityInterfaceA');
  2890.   asm
  2891.     mov esp, ebp
  2892.     pop ebp
  2893.     jmp [_InitSecurityInterface]
  2894.   end;
  2895. end;
  2896. {$ELSE}
  2897. function InitSecurityInterface; external secur32 name 'InitSecurityInterfaceA';
  2898. {$ENDIF DYNAMIC_LINK}
  2899. {$ENDIF}
  2900. {$IFDEF DYNAMIC_LINK}
  2901. var
  2902.   _SaslEnumerateProfilesA: Pointer;
  2903. function SaslEnumerateProfilesA;
  2904. begin
  2905.   GetProcedureAddress(_SaslEnumerateProfilesA, secur32, 'SaslEnumerateProfilesA');
  2906.   asm
  2907.     mov esp, ebp
  2908.     pop ebp
  2909.     jmp [_SaslEnumerateProfilesA]
  2910.   end;
  2911. end;
  2912. {$ELSE}
  2913. function SaslEnumerateProfilesA; external secur32 name 'SaslEnumerateProfilesA';
  2914. {$ENDIF DYNAMIC_LINK}
  2915. {$IFDEF DYNAMIC_LINK}
  2916. var
  2917.   _SaslEnumerateProfilesW: Pointer;
  2918. function SaslEnumerateProfilesW;
  2919. begin
  2920.   GetProcedureAddress(_SaslEnumerateProfilesW, secur32, 'SaslEnumerateProfilesW');
  2921.   asm
  2922.     mov esp, ebp
  2923.     pop ebp
  2924.     jmp [_SaslEnumerateProfilesW]
  2925.   end;
  2926. end;
  2927. {$ELSE}
  2928. function SaslEnumerateProfilesW; external secur32 name 'SaslEnumerateProfilesW';
  2929. {$ENDIF DYNAMIC_LINK}
  2930. {$IFDEF UNICODE}
  2931. {$IFDEF DYNAMIC_LINK}
  2932. var
  2933.   _SaslEnumerateProfiles: Pointer;
  2934. function SaslEnumerateProfiles;
  2935. begin
  2936.   GetProcedureAddress(_SaslEnumerateProfiles, secur32, 'SaslEnumerateProfilesW');
  2937.   asm
  2938.     mov esp, ebp
  2939.     pop ebp
  2940.     jmp [_SaslEnumerateProfiles]
  2941.   end;
  2942. end;
  2943. {$ELSE}
  2944. function SaslEnumerateProfiles; external secur32 name 'SaslEnumerateProfilesW';
  2945. {$ENDIF DYNAMIC_LINK}
  2946. {$ELSE}
  2947. {$IFDEF DYNAMIC_LINK}
  2948. var
  2949.   _SaslEnumerateProfiles: Pointer;
  2950. function SaslEnumerateProfiles;
  2951. begin
  2952.   GetProcedureAddress(_SaslEnumerateProfiles, secur32, 'SaslEnumerateProfilesA');
  2953.   asm
  2954.     mov esp, ebp
  2955.     pop ebp
  2956.     jmp [_SaslEnumerateProfiles]
  2957.   end;
  2958. end;
  2959. {$ELSE}
  2960. function SaslEnumerateProfiles; external secur32 name 'SaslEnumerateProfilesA';
  2961. {$ENDIF DYNAMIC_LINK}
  2962. {$ENDIF}
  2963. {$IFDEF DYNAMIC_LINK}
  2964. var
  2965.   _SaslGetProfilePackageA: Pointer;
  2966. function SaslGetProfilePackageA;
  2967. begin
  2968.   GetProcedureAddress(_SaslGetProfilePackageA, secur32, 'SaslGetProfilePackageA');
  2969.   asm
  2970.     mov esp, ebp
  2971.     pop ebp
  2972.     jmp [_SaslGetProfilePackageA]
  2973.   end;
  2974. end;
  2975. {$ELSE}
  2976. function SaslGetProfilePackageA; external secur32 name 'SaslGetProfilePackageA';
  2977. {$ENDIF DYNAMIC_LINK}
  2978. {$IFDEF DYNAMIC_LINK}
  2979. var
  2980.   _SaslGetProfilePackageW: Pointer;
  2981. function SaslGetProfilePackageW;
  2982. begin
  2983.   GetProcedureAddress(_SaslGetProfilePackageW, secur32, 'SaslGetProfilePackageW');
  2984.   asm
  2985.     mov esp, ebp
  2986.     pop ebp
  2987.     jmp [_SaslGetProfilePackageW]
  2988.   end;
  2989. end;
  2990. {$ELSE}
  2991. function SaslGetProfilePackageW; external secur32 name 'SaslGetProfilePackageW';
  2992. {$ENDIF DYNAMIC_LINK}
  2993. {$IFDEF UNICODE}
  2994. {$IFDEF DYNAMIC_LINK}
  2995. var
  2996.   _SaslGetProfilePackage: Pointer;
  2997. function SaslGetProfilePackage;
  2998. begin
  2999.   GetProcedureAddress(_SaslGetProfilePackage, secur32, 'SaslGetProfilePackageW');
  3000.   asm
  3001.     mov esp, ebp
  3002.     pop ebp
  3003.     jmp [_SaslGetProfilePackage]
  3004.   end;
  3005. end;
  3006. {$ELSE}
  3007. function SaslGetProfilePackage; external secur32 name 'SaslGetProfilePackageW';
  3008. {$ENDIF DYNAMIC_LINK}
  3009. {$ELSE}
  3010. {$IFDEF DYNAMIC_LINK}
  3011. var
  3012.   _SaslGetProfilePackage: Pointer;
  3013. function SaslGetProfilePackage;
  3014. begin
  3015.   GetProcedureAddress(_SaslGetProfilePackage, secur32, 'SaslGetProfilePackageA');
  3016.   asm
  3017.     mov esp, ebp
  3018.     pop ebp
  3019.     jmp [_SaslGetProfilePackage]
  3020.   end;
  3021. end;
  3022. {$ELSE}
  3023. function SaslGetProfilePackage; external secur32 name 'SaslGetProfilePackageA';
  3024. {$ENDIF DYNAMIC_LINK}
  3025. {$ENDIF}
  3026. {$IFDEF DYNAMIC_LINK}
  3027. var
  3028.   _SaslIdentifyPackageA: Pointer;
  3029. function SaslIdentifyPackageA;
  3030. begin
  3031.   GetProcedureAddress(_SaslIdentifyPackageA, secur32, 'SaslIdentifyPackageA');
  3032.   asm
  3033.     mov esp, ebp
  3034.     pop ebp
  3035.     jmp [_SaslIdentifyPackageA]
  3036.   end;
  3037. end;
  3038. {$ELSE}
  3039. function SaslIdentifyPackageA; external secur32 name 'SaslIdentifyPackageA';
  3040. {$ENDIF DYNAMIC_LINK}
  3041. {$IFDEF DYNAMIC_LINK}
  3042. var
  3043.   _SaslIdentifyPackageW: Pointer;
  3044. function SaslIdentifyPackageW;
  3045. begin
  3046.   GetProcedureAddress(_SaslIdentifyPackageW, secur32, 'SaslIdentifyPackageW');
  3047.   asm
  3048.     mov esp, ebp
  3049.     pop ebp
  3050.     jmp [_SaslIdentifyPackageW]
  3051.   end;
  3052. end;
  3053. {$ELSE}
  3054. function SaslIdentifyPackageW; external secur32 name 'SaslIdentifyPackageW';
  3055. {$ENDIF DYNAMIC_LINK}
  3056. {$IFDEF UNICODE}
  3057. {$IFDEF DYNAMIC_LINK}
  3058. var
  3059.   _SaslIdentifyPackage: Pointer;
  3060. function SaslIdentifyPackage;
  3061. begin
  3062.   GetProcedureAddress(_SaslIdentifyPackage, secur32, 'SaslIdentifyPackageW');
  3063.   asm
  3064.     mov esp, ebp
  3065.     pop ebp
  3066.     jmp [_SaslIdentifyPackage]
  3067.   end;
  3068. end;
  3069. {$ELSE}
  3070. function SaslIdentifyPackage; external secur32 name 'SaslIdentifyPackageW';
  3071. {$ENDIF DYNAMIC_LINK}
  3072. {$ELSE}
  3073. {$IFDEF DYNAMIC_LINK}
  3074. var
  3075.   _SaslIdentifyPackage: Pointer;
  3076. function SaslIdentifyPackage;
  3077. begin
  3078.   GetProcedureAddress(_SaslIdentifyPackage, secur32, 'SaslIdentifyPackageA');
  3079.   asm
  3080.     mov esp, ebp
  3081.     pop ebp
  3082.     jmp [_SaslIdentifyPackage]
  3083.   end;
  3084. end;
  3085. {$ELSE}
  3086. function SaslIdentifyPackage; external secur32 name 'SaslIdentifyPackageA';
  3087. {$ENDIF DYNAMIC_LINK}
  3088. {$ENDIF}
  3089. {$IFDEF DYNAMIC_LINK}
  3090. var
  3091.   _SaslInitializeSecurityContextW: Pointer;
  3092. function SaslInitializeSecurityContextW;
  3093. begin
  3094.   GetProcedureAddress(_SaslInitializeSecurityContextW, secur32, 'SaslInitializeSecurityContextW');
  3095.   asm
  3096.     mov esp, ebp
  3097.     pop ebp
  3098.     jmp [_SaslInitializeSecurityContextW]
  3099.   end;
  3100. end;
  3101. {$ELSE}
  3102. function SaslInitializeSecurityContextW; external secur32 name 'SaslInitializeSecurityContextW';
  3103. {$ENDIF DYNAMIC_LINK}
  3104. {$IFDEF DYNAMIC_LINK}
  3105. var
  3106.   _SaslInitializeSecurityContextA: Pointer;
  3107. function SaslInitializeSecurityContextA;
  3108. begin
  3109.   GetProcedureAddress(_SaslInitializeSecurityContextA, secur32, 'SaslInitializeSecurityContextA');
  3110.   asm
  3111.     mov esp, ebp
  3112.     pop ebp
  3113.     jmp [_SaslInitializeSecurityContextA]
  3114.   end;
  3115. end;
  3116. {$ELSE}
  3117. function SaslInitializeSecurityContextA; external secur32 name 'SaslInitializeSecurityContextA';
  3118. {$ENDIF DYNAMIC_LINK}
  3119. {$IFDEF UNICODE}
  3120. {$IFDEF DYNAMIC_LINK}
  3121. var
  3122.   _SaslInitializeSecurityContext: Pointer;
  3123. function SaslInitializeSecurityContext;
  3124. begin
  3125.   GetProcedureAddress(_SaslInitializeSecurityContext, secur32, 'SaslInitializeSecurityContextW');
  3126.   asm
  3127.     mov esp, ebp
  3128.     pop ebp
  3129.     jmp [_SaslInitializeSecurityContext]
  3130.   end;
  3131. end;
  3132. {$ELSE}
  3133. function SaslInitializeSecurityContext; external secur32 name 'SaslInitializeSecurityContextW';
  3134. {$ENDIF DYNAMIC_LINK}
  3135. {$ELSE}
  3136. {$IFDEF DYNAMIC_LINK}
  3137. var
  3138.   _SaslInitializeSecurityContext: Pointer;
  3139. function SaslInitializeSecurityContext;
  3140. begin
  3141.   GetProcedureAddress(_SaslInitializeSecurityContext, secur32, 'SaslInitializeSecurityContextA');
  3142.   asm
  3143.     mov esp, ebp
  3144.     pop ebp
  3145.     jmp [_SaslInitializeSecurityContext]
  3146.   end;
  3147. end;
  3148. {$ELSE}
  3149. function SaslInitializeSecurityContext; external secur32 name 'SaslInitializeSecurityContextA';
  3150. {$ENDIF DYNAMIC_LINK}
  3151. {$ENDIF}
  3152. {$IFDEF DYNAMIC_LINK}
  3153. var
  3154.   _SaslAcceptSecurityContext: Pointer;
  3155. function SaslAcceptSecurityContext;
  3156. begin
  3157.   GetProcedureAddress(_SaslAcceptSecurityContext, secur32, 'SaslAcceptSecurityContext');
  3158.   asm
  3159.     mov esp, ebp
  3160.     pop ebp
  3161.     jmp [_SaslAcceptSecurityContext]
  3162.   end;
  3163. end;
  3164. {$ELSE}
  3165. function SaslAcceptSecurityContext; external secur32 name 'SaslAcceptSecurityContext';
  3166. {$ENDIF DYNAMIC_LINK}
  3167. {$IFDEF DYNAMIC_LINK}
  3168. var
  3169.   _SaslSetContextOption: Pointer;
  3170. function SaslSetContextOption;
  3171. begin
  3172.   GetProcedureAddress(_SaslSetContextOption, secur32, 'SaslSetContextOption');
  3173.   asm
  3174.     mov esp, ebp
  3175.     pop ebp
  3176.     jmp [_SaslSetContextOption]
  3177.   end;
  3178. end;
  3179. {$ELSE}
  3180. function SaslSetContextOption; external secur32 name 'SaslSetContextOption';
  3181. {$ENDIF DYNAMIC_LINK}
  3182. {$IFDEF DYNAMIC_LINK}
  3183. var
  3184.   _SaslGetContextOption: Pointer;
  3185. function SaslGetContextOption;
  3186. begin
  3187.   GetProcedureAddress(_SaslGetContextOption, secur32, 'SaslGetContextOption');
  3188.   asm
  3189.     mov esp, ebp
  3190.     pop ebp
  3191.     jmp [_SaslGetContextOption]
  3192.   end;
  3193. end;
  3194. {$ELSE}
  3195. function SaslGetContextOption; external secur32 name 'SaslGetContextOption';
  3196. {$ENDIF DYNAMIC_LINK}
  3197. {$IFDEF DYNAMIC_LINK}
  3198. var
  3199.   _AddSecurityPackageA: Pointer;
  3200. function AddSecurityPackageA;
  3201. begin
  3202.   GetProcedureAddress(_AddSecurityPackageA, secur32, 'AddSecurityPackageA');
  3203.   asm
  3204.     mov esp, ebp
  3205.     pop ebp
  3206.     jmp [_AddSecurityPackageA]
  3207.   end;
  3208. end;
  3209. {$ELSE}
  3210. function AddSecurityPackageA; external secur32 name 'AddSecurityPackageA';
  3211. {$ENDIF DYNAMIC_LINK}
  3212. {$IFDEF DYNAMIC_LINK}
  3213. var
  3214.   _AddSecurityPackageW: Pointer;
  3215. function AddSecurityPackageW;
  3216. begin
  3217.   GetProcedureAddress(_AddSecurityPackageW, secur32, 'AddSecurityPackageW');
  3218.   asm
  3219.     mov esp, ebp
  3220.     pop ebp
  3221.     jmp [_AddSecurityPackageW]
  3222.   end;
  3223. end;
  3224. {$ELSE}
  3225. function AddSecurityPackageW; external secur32 name 'AddSecurityPackageW';
  3226. {$ENDIF DYNAMIC_LINK}
  3227. {$IFDEF UNICODE}
  3228. {$IFDEF DYNAMIC_LINK}
  3229. var
  3230.   _AddSecurityPackage: Pointer;
  3231. function AddSecurityPackage;
  3232. begin
  3233.   GetProcedureAddress(_AddSecurityPackage, secur32, 'AddSecurityPackageW');
  3234.   asm
  3235.     mov esp, ebp
  3236.     pop ebp
  3237.     jmp [_AddSecurityPackage]
  3238.   end;
  3239. end;
  3240. {$ELSE}
  3241. function AddSecurityPackage; external secur32 name 'AddSecurityPackageW';
  3242. {$ENDIF DYNAMIC_LINK}
  3243. {$ELSE}
  3244. {$IFDEF DYNAMIC_LINK}
  3245. var
  3246.   _AddSecurityPackage: Pointer;
  3247. function AddSecurityPackage;
  3248. begin
  3249.   GetProcedureAddress(_AddSecurityPackage, secur32, 'AddSecurityPackageA');
  3250.   asm
  3251.     mov esp, ebp
  3252.     pop ebp
  3253.     jmp [_AddSecurityPackage]
  3254.   end;
  3255. end;
  3256. {$ELSE}
  3257. function AddSecurityPackage; external secur32 name 'AddSecurityPackageA';
  3258. {$ENDIF DYNAMIC_LINK}
  3259. {$ENDIF}
  3260. {$IFDEF DYNAMIC_LINK}
  3261. var
  3262.   _DeleteSecurityPackageA: Pointer;
  3263. function DeleteSecurityPackageA;
  3264. begin
  3265.   GetProcedureAddress(_DeleteSecurityPackageA, secur32, 'DeleteSecurityPackageA');
  3266.   asm
  3267.     mov esp, ebp
  3268.     pop ebp
  3269.     jmp [_DeleteSecurityPackageA]
  3270.   end;
  3271. end;
  3272. {$ELSE}
  3273. function DeleteSecurityPackageA; external secur32 name 'DeleteSecurityPackageA';
  3274. {$ENDIF DYNAMIC_LINK}
  3275. {$IFDEF DYNAMIC_LINK}
  3276. var
  3277.   _DeleteSecurityPackageW: Pointer;
  3278. function DeleteSecurityPackageW;
  3279. begin
  3280.   GetProcedureAddress(_DeleteSecurityPackageW, secur32, 'DeleteSecurityPackageW');
  3281.   asm
  3282.     mov esp, ebp
  3283.     pop ebp
  3284.     jmp [_DeleteSecurityPackageW]
  3285.   end;
  3286. end;
  3287. {$ELSE}
  3288. function DeleteSecurityPackageW; external secur32 name 'DeleteSecurityPackageW';
  3289. {$ENDIF DYNAMIC_LINK}
  3290. {$IFDEF UNICODE}
  3291. {$IFDEF DYNAMIC_LINK}
  3292. var
  3293.   _DeleteSecurityPackage: Pointer;
  3294. function DeleteSecurityPackage;
  3295. begin
  3296.   GetProcedureAddress(_DeleteSecurityPackage, secur32, 'DeleteSecurityPackageW');
  3297.   asm
  3298.     mov esp, ebp
  3299.     pop ebp
  3300.     jmp [_DeleteSecurityPackage]
  3301.   end;
  3302. end;
  3303. {$ELSE}
  3304. function DeleteSecurityPackage; external secur32 name 'DeleteSecurityPackageW';
  3305. {$ENDIF DYNAMIC_LINK}
  3306. {$ELSE}
  3307. {$IFDEF DYNAMIC_LINK}
  3308. var
  3309.   _DeleteSecurityPackage: Pointer;
  3310. function DeleteSecurityPackage;
  3311. begin
  3312.   GetProcedureAddress(_DeleteSecurityPackage, secur32, 'DeleteSecurityPackageA');
  3313.   asm
  3314.     mov esp, ebp
  3315.     pop ebp
  3316.     jmp [_DeleteSecurityPackage]
  3317.   end;
  3318. end;
  3319. {$ELSE}
  3320. function DeleteSecurityPackage; external secur32 name 'DeleteSecurityPackageA';
  3321. {$ENDIF DYNAMIC_LINK}
  3322. {$ENDIF}
  3323. end.