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

Windows编程

开发平台:

Delphi

  1. {******************************************************************************}
  2. {                                                                       }
  3. { Security Service Attachements 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: scesvc.h, released June 2000. The original Pascal      }
  9. { code is: SceSvc.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 JwaSceSvc;
  44. {$WEAKPACKAGEUNIT}
  45. {$HPPEMIT ''}
  46. {$HPPEMIT '#include "scesvc.h"'}
  47. {$HPPEMIT ''}
  48. {$HPPEMIT 'typedef SCESVC_HANDLE *PSCESVC_HANDLE'}
  49. {$HPPEMIT ''}
  50. {$I WINDEFINES.INC}
  51. interface
  52. uses
  53.   JwaWinType;
  54. type
  55.   SCESTATUS = DWORD;
  56.   {$EXTERNALSYM SCESTATUS}
  57. const
  58.   SCESTATUS_SUCCESS             = 0;
  59.   {$EXTERNALSYM SCESTATUS_SUCCESS}
  60.   SCESTATUS_INVALID_PARAMETER   = 1;
  61.   {$EXTERNALSYM SCESTATUS_INVALID_PARAMETER}
  62.   SCESTATUS_RECORD_NOT_FOUND    = 2;
  63.   {$EXTERNALSYM SCESTATUS_RECORD_NOT_FOUND}
  64.   SCESTATUS_INVALID_DATA        = 3;
  65.   {$EXTERNALSYM SCESTATUS_INVALID_DATA}
  66.   SCESTATUS_OBJECT_EXIST        = 4;
  67.   {$EXTERNALSYM SCESTATUS_OBJECT_EXIST}
  68.   SCESTATUS_BUFFER_TOO_SMALL    = 5;
  69.   {$EXTERNALSYM SCESTATUS_BUFFER_TOO_SMALL}
  70.   SCESTATUS_PROFILE_NOT_FOUND   = 6;
  71.   {$EXTERNALSYM SCESTATUS_PROFILE_NOT_FOUND}
  72.   SCESTATUS_BAD_FORMAT          = 7;
  73.   {$EXTERNALSYM SCESTATUS_BAD_FORMAT}
  74.   SCESTATUS_NOT_ENOUGH_RESOURCE = 8;
  75.   {$EXTERNALSYM SCESTATUS_NOT_ENOUGH_RESOURCE}
  76.   SCESTATUS_ACCESS_DENIED       = 9;
  77.   {$EXTERNALSYM SCESTATUS_ACCESS_DENIED}
  78.   SCESTATUS_CANT_DELETE         = 10;
  79.   {$EXTERNALSYM SCESTATUS_CANT_DELETE}
  80.   SCESTATUS_PREFIX_OVERFLOW     = 11;
  81.   {$EXTERNALSYM SCESTATUS_PREFIX_OVERFLOW}
  82.   SCESTATUS_OTHER_ERROR         = 12;
  83.   {$EXTERNALSYM SCESTATUS_OTHER_ERROR}
  84.   SCESTATUS_ALREADY_RUNNING     = 13;
  85.   {$EXTERNALSYM SCESTATUS_ALREADY_RUNNING}
  86.   SCESTATUS_SERVICE_NOT_SUPPORT = 14;
  87.   {$EXTERNALSYM SCESTATUS_SERVICE_NOT_SUPPORT}
  88.   SCESTATUS_MOD_NOT_FOUND       = 15;
  89.   {$EXTERNALSYM SCESTATUS_MOD_NOT_FOUND}
  90.   SCESTATUS_EXCEPTION_IN_SERVER = 16;
  91.   {$EXTERNALSYM SCESTATUS_EXCEPTION_IN_SERVER}
  92.   SCESTATUS_NO_TEMPLATE_GIVEN   = 17;
  93.   {$EXTERNALSYM SCESTATUS_NO_TEMPLATE_GIVEN}
  94.   SCESTATUS_NO_MAPPING          = 18;
  95.   {$EXTERNALSYM SCESTATUS_NO_MAPPING}
  96.   SCESTATUS_TRUST_FAIL          = 19;
  97.   {$EXTERNALSYM SCESTATUS_TRUST_FAIL}
  98. type
  99.   PSCESVC_CONFIGURATION_LINE = ^SCESVC_CONFIGURATION_LINE;
  100.   {$EXTERNALSYM PSCESVC_CONFIGURATION_LINE}
  101.   _SCESVC_CONFIGURATION_LINE_ = record
  102.     Key: LPTSTR;
  103.     Value: LPTSTR;
  104.     ValueLen: DWORD; // number of bytes
  105.   end;
  106.   {$EXTERNALSYM _SCESVC_CONFIGURATION_LINE_}
  107.   SCESVC_CONFIGURATION_LINE = _SCESVC_CONFIGURATION_LINE_;
  108.   {$EXTERNALSYM SCESVC_CONFIGURATION_LINE}
  109.   TScesvcConfigurationLine = SCESVC_CONFIGURATION_LINE;
  110.   PScesvcConfigurationLine = PSCESVC_CONFIGURATION_LINE;
  111.   PSCESVC_CONFIGURATION_INFO = ^SCESVC_CONFIGURATION_INFO;
  112.   {$EXTERNALSYM PSCESVC_CONFIGURATION_INFO}
  113.   _SCESVC_CONFIGURATION_INFO_ = record
  114.     Count: DWORD;
  115.     Lines: PSCESVC_CONFIGURATION_INFO;
  116.   end;
  117.   {$EXTERNALSYM _SCESVC_CONFIGURATION_INFO_}
  118.   SCESVC_CONFIGURATION_INFO = _SCESVC_CONFIGURATION_INFO_;
  119.   {$EXTERNALSYM SCESVC_CONFIGURATION_INFO}
  120.   TScesvcConfigurationInfo = SCESVC_CONFIGURATION_INFO;
  121.   PScesvcConfigurationInfo = PSCESVC_CONFIGURATION_INFO;
  122.   SCE_HANDLE = PVOID;
  123.   {$EXTERNALSYM SCE_HANDLE}
  124.   SCE_ENUMERATION_CONTEXT = ULONG;
  125.   {$EXTERNALSYM SCE_ENUMERATION_CONTEXT}
  126.   PSCE_ENUMERATION_CONTEXT = ^SCE_ENUMERATION_CONTEXT;
  127.   {$EXTERNALSYM PSCE_ENUMERATION_CONTEXT}
  128.   _SCESVC_INFO_TYPE = (
  129.     SceSvcConfigurationInfo,
  130.     SceSvcMergedPolicyInfo,
  131.     SceSvcAnalysisInfo,
  132.     SceSvcInternalUse); // !!!do not use this type!!!
  133.   {$EXTERNALSYM _SCESVC_INFO_TYPE}
  134.   SCESVC_INFO_TYPE = _SCESVC_INFO_TYPE;
  135.   {$EXTERNALSYM SCESVC_INFO_TYPE}
  136.   TScesvcInfoType = _SCESVC_INFO_TYPE;
  137. const
  138.   SCE_ROOT_PATH = 'SoftwareMicrosoftWindows NTCurrentVersionSeCEdit';
  139.   {$EXTERNALSYM SCE_ROOT_PATH}
  140.   SCE_ROOT_SERVICE_PATH = SCE_ROOT_PATH + 'SvcEngs';
  141.   {$EXTERNALSYM SCE_ROOT_SERVICE_PATH}
  142. type
  143.   SCESVC_HANDLE = PVOID;
  144.   {$EXTERNALSYM SCESVC_HANDLE}
  145.   PSCESVC_HANDLE = ^SCESVC_HANDLE;
  146.   {$NODEFINE PSCESVC_HANDLE}
  147.   PSCESVC_ANALYSIS_LINE = ^SCESVC_ANALYSIS_LINE;
  148.   {$EXTERNALSYM PSCESVC_ANALYSIS_LINE}
  149.   _SCESVC_ANALYSIS_LINE_ = record
  150.     Key: LPTSTR;
  151.     Value: PBYTE;
  152.     ValueLen: DWORD; // number of bytes
  153.   end;
  154.   {$EXTERNALSYM _SCESVC_ANALYSIS_LINE_}
  155.   SCESVC_ANALYSIS_LINE = _SCESVC_ANALYSIS_LINE_;
  156.   {$EXTERNALSYM SCESVC_ANALYSIS_LINE}
  157.   TScesvcAnalysisLine = SCESVC_ANALYSIS_LINE;
  158.   PScesvcAnalysisLine = PSCESVC_ANALYSIS_LINE;
  159.   PSCESVC_ANALYSIS_INFO = ^SCESVC_ANALYSIS_INFO;
  160.   {$EXTERNALSYM PSCESVC_ANALYSIS_INFO}
  161.   _SCESVC_ANALYSIS_INFO_ = record
  162.     Count: DWORD;
  163.     Lines: PSCESVC_ANALYSIS_LINE;
  164.   end;
  165.   {$EXTERNALSYM _SCESVC_ANALYSIS_INFO_}
  166.   SCESVC_ANALYSIS_INFO = _SCESVC_ANALYSIS_INFO_;
  167.   {$EXTERNALSYM SCESVC_ANALYSIS_INFO}
  168.   TScesvcAnalysisInfo = SCESVC_ANALYSIS_INFO;
  169.   PScesvcAnalysisInfo = PSCESVC_ANALYSIS_INFO;
  170. const
  171.   SCESVC_ENUMERATION_MAX = 100;
  172.   {$EXTERNALSYM SCESVC_ENUMERATION_MAX}
  173. type
  174.   PFSCE_QUERY_INFO = function (sceHandle: SCE_HANDLE; sceType: SCESVC_INFO_TYPE;
  175.     lpPrefix: LPTSTR; bExact: BOOL; ppvInfo: PPVOID;
  176.     var psceEnumHandle: SCE_ENUMERATION_CONTEXT): SCESTATUS; stdcall;
  177.   {$EXTERNALSYM PFSCE_QUERY_INFO}
  178.   PFSCE_SET_INFO = function (sceHandle: SCE_HANDLE; sceType: SCESVC_INFO_TYPE;
  179.     lpPrefix: LPTSTR; bExact: BOOL; pvInfo: PVOID): SCESTATUS; stdcall;
  180.   {$EXTERNALSYM PFSCE_SET_INFO}
  181.   PFSCE_FREE_INFO = function (pvServiceInfo: PVOID): SCESTATUS; stdcall;
  182.   {$EXTERNALSYM PFSCE_FREE_INFO}
  183. const
  184.   SCE_LOG_LEVEL_ALWAYS = 0;
  185.   {$EXTERNALSYM SCE_LOG_LEVEL_ALWAYS}
  186.   SCE_LOG_LEVEL_ERROR  = 1;
  187.   {$EXTERNALSYM SCE_LOG_LEVEL_ERROR}
  188.   SCE_LOG_LEVEL_DETAIL = 2;
  189.   {$EXTERNALSYM SCE_LOG_LEVEL_DETAIL}
  190.   SCE_LOG_LEVEL_DEBUG  = 3;
  191.   {$EXTERNALSYM SCE_LOG_LEVEL_DEBUG}
  192. type
  193.   PFSCE_LOG_INFO = function (ErrLevel: Integer; Win32rc: DWORD; pErrFmt: LPTSTR {...}): SCESTATUS; stdcall;
  194.   {$EXTERNALSYM PFSCE_LOG_INFO}
  195.   PSCESVC_CALLBACK_INFO = ^SCESVC_CALLBACK_INFO;
  196.   {$EXTERNALSYM PSCESVC_CALLBACK_INFO}
  197.   _SCESVC_CALLBACK_INFO_ = record
  198.     sceHandle: SCE_HANDLE;
  199.     pfQueryInfo: PFSCE_QUERY_INFO;
  200.     pfSetInfo: PFSCE_SET_INFO;
  201.     pfFreeInfo: PFSCE_FREE_INFO;
  202.     pfLogInfo: PFSCE_LOG_INFO;
  203.   end;
  204.   {$EXTERNALSYM _SCESVC_CALLBACK_INFO_}
  205.   SCESVC_CALLBACK_INFO = _SCESVC_CALLBACK_INFO_;
  206.   {$EXTERNALSYM SCESVC_CALLBACK_INFO}
  207.   TScesvcCallbackInfo = SCESVC_CALLBACK_INFO;
  208.   PScesvcCallbackInfo = PSCESVC_CALLBACK_INFO;
  209.   PF_ConfigAnalyzeService = function (pSceCbInfo: PSCESVC_CALLBACK_INFO): SCESTATUS; stdcall;
  210.   {$EXTERNALSYM PF_ConfigAnalyzeService}
  211.   PF_UpdateService = function (pSceCbInfo: PSCESVC_CALLBACK_INFO;
  212.     ServiceInfo: PSCESVC_CONFIGURATION_INFO): SCESTATUS; stdcall;
  213.   {$EXTERNALSYM PF_UpdateService}
  214. //
  215. // headers for extension snap-ins
  216. // only define this for NT5
  217. //
  218. const
  219.   struuidNodetypeSceTemplateServices = '{24a7f717-1f0c-11d1-affb-00c04fb984f9}';
  220.   {$EXTERNALSYM struuidNodetypeSceTemplateServices}
  221.   lstruuidNodetypeSceTemplateServices = '{24a7f717-1f0c-11d1-affb-00c04fb984f9}';
  222.   {$EXTERNALSYM lstruuidNodetypeSceTemplateServices}
  223.   cNodetypeSceTemplateServices: GUID = (
  224.     D1:$24a7f717; D2:$1f0c; D3:$11d1; D4:($af, $fb, $0, $c0, $4f, $b9, $84, $f9));
  225.   {$EXTERNALSYM cNodetypeSceTemplateServices}
  226.   struuidNodetypeSceAnalysisServices = '{678050c7-1ff8-11d1-affb-00c04fb984f9}';
  227.   {$EXTERNALSYM struuidNodetypeSceAnalysisServices}
  228.   lstruuidNodetypeSceAnalysisServices = '{678050c7-1ff8-11d1-affb-00c04fb984f9}';
  229.   {$EXTERNALSYM lstruuidNodetypeSceAnalysisServices}
  230.   cNodetypeSceAnalysisServices: GUID = (
  231.     D1:$678050c7; D2:$1ff8; D3:$11d1; D4:($af, $fb, $0, $c0, $4f, $b9, $84, $f9));
  232.   {$EXTERNALSYM cNodetypeSceAnalysisServices}
  233.   struuidNodetypeSceEventLog = '{2ce06698-4bf3-11d1-8c30-00c04fb984f9}';
  234.   {$EXTERNALSYM struuidNodetypeSceEventLog}
  235.   lstruuidNodetypeSceEventLog = '{2ce06698-4bf3-11d1-8c30-00c04fb984f9}';
  236.   {$EXTERNALSYM lstruuidNodetypeSceEventLog}
  237.   cNodetypeSceEventLog: GUID = (
  238.     D1:$2ce06698; D2:$4bf3; D3:$11d1; D4:($8c, $30, $0, $c0, $4f, $b9, $84, $f9));
  239.   {$EXTERNALSYM cNodetypeSceEventLog}
  240. type
  241.   LPSCESVC_CONFIGURATION_INFO = ^PSCESVC_CONFIGURATION_INFO;
  242.   {$EXTERNALSYM LPSCESVC_CONFIGURATION_INFO}
  243.   LPSCESVC_ANALYSIS_INFO = ^PSCESVC_ANALYSIS_INFO;
  244.   {$EXTERNALSYM LPSCESVC_ANALYSIS_INFO}
  245. const
  246.   CCF_SCESVC_ATTACHMENT       = 'CCF_SCESVC_ATTACHMENT';
  247.   {$EXTERNALSYM CCF_SCESVC_ATTACHMENT}
  248.   CCF_SCESVC_ATTACHMENT_DATA  = 'CCF_SCESVC_ATTACHMENT_DATA';
  249.   {$EXTERNALSYM CCF_SCESVC_ATTACHMENT_DATA}
  250. //
  251. // implemented by service attachment
  252. //
  253. const
  254.   IID_ISceSvcAttachmentPersistInfo: GUID = (
  255.     D1:$6d90e0d0; D2:$200d; D3:$11d1; D4:($af, $fb, $0, $c0, $4f, $b9, $84, $f9));
  256.   {$EXTERNALSYM IID_ISceSvcAttachmentPersistInfo}
  257.   SID_ISceSvcAttachmentPersistInfo = '{6d90e0d0-200d-11d1-affb-00c04fb984f9}';
  258. type
  259.   ISceSvcAttachmentPersistInfo = interface (IUnknown)
  260.     [SID_ISceSvcAttachmentPersistInfo]
  261.     function Save(lpTemplateName: LPTSTR; scesvcHandle: PSCESVC_HANDLE;
  262.       ppvData: PPVOID; pbOverwriteAll: PBOOL): HRESULT; stdcall;
  263.     function IsDirty(lpTemplateName: LPTSTR): HRESULT; stdcall;
  264.     function FreeBuffer(pvData: PVOID): HRESULT; stdcall;
  265.   end;
  266.   {$EXTERNALSYM ISceSvcAttachmentPersistInfo}
  267.   LPSCESVCATTACHMENTPERSISTINFO = ISceSvcAttachmentPersistInfo;
  268.   {$EXTERNALSYM LPSCESVCATTACHMENTPERSISTINFO}
  269. //
  270. // implemented by SecEdit
  271. //
  272. const
  273.   IID_ISceSvcAttachmentData: GUID = (
  274.     D1:$17c35fde; D2:$200d; D3:$11d1; D4:($af, $fb, $0, $c0, $4f, $b9, $84, $f9));
  275.   {$EXTERNALSYM IID_ISceSvcAttachmentData}
  276.   SID_ISceSvcAttachmentData = '{17c35fde-200d-11d1-affb-00c04fb984f9}';
  277. type
  278.   ISceSvcAttachmentData = interface (IUnknown)
  279.     [SID_ISceSvcAttachmentData]
  280.     function GetData(scesvcHandle: SCESVC_HANDLE; sceType: SCESVC_INFO_TYPE;
  281.       ppvData: PPVOID; psceEnumHandle: PSCE_ENUMERATION_CONTEXT): HRESULT; stdcall;
  282.     function Initialize(lpServiceName, lpTemplateName: LPCTSTR;
  283.       lpSceSvcPersistInfo: LPSCESVCATTACHMENTPERSISTINFO;
  284.       pscesvcHandle: PSCESVC_HANDLE): HRESULT; stdcall;
  285.     function FreeBuffer(pvData: PVOID): HRESULT; stdcall;
  286.     function CloseHandle(scesvcHandle: SCESVC_HANDLE): HRESULT; stdcall;
  287.   end;
  288.   {$EXTERNALSYM ISceSvcAttachmentData}
  289.   LPSCESVCATTACHMENTDATA = ISceSvcAttachmentData;
  290.   {$EXTERNALSYM LPSCESVCATTACHMENTDATA}
  291. implementation
  292. end.