~ubuntu-branches/ubuntu/feisty/fpc/feisty

« back to all changes in this revision

Viewing changes to packages/extra/winunits/jwawinefs.pas

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2007-01-27 20:08:50 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070127200850-9mrptaqqjsx9nwa7
Tags: 2.0.4-5
* Fixed Build-Depends.
* Add myself to Uploaders in debian/control.
* Make sure that the sources are really patched before building them.
* Build unit 'libc' on powerpc too.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
{******************************************************************************}
2
 
{                                                                              }
3
 
{ Encrypting File System 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: winefs.h, released June 2000. The original Pascal      }
9
 
{ code is: WinEFS.pas, released December 2000. The initial developer of the    }
10
 
{ Pascal code is Marcel van Brakel (brakelm att chello dott 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         }
18
 
{ APILIB home page, located at http://jedi-apilib.sourceforge.net              }
19
 
{                                                                              }
20
 
{ The contents of this file are used with permission, subject to the Mozilla   }
21
 
{ Public License Version 1.1 (the "License"); you may not use this file except }
22
 
{ in compliance with the License. You may obtain a copy of the License at      }
23
 
{ http://www.mozilla.org/MPL/MPL-1.1.html                                      }
24
 
{                                                                              }
25
 
{ Software distributed under the License is distributed on an "AS IS" basis,   }
26
 
{ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
27
 
{ the specific language governing rights and limitations under the License.    }
28
 
{                                                                              }
29
 
{ Alternatively, the contents of this file may be used under the terms of the  }
30
 
{ GNU Lesser General Public License (the  "LGPL License"), in which case the   }
31
 
{ provisions of the LGPL License are applicable instead of those above.        }
32
 
{ If you wish to allow use of your version of this file only under the terms   }
33
 
{ of the LGPL License and not to allow others to use your version of this file }
34
 
{ under the MPL, indicate your decision by deleting  the provisions above and  }
35
 
{ replace  them with the notice and other provisions required by the LGPL      }
36
 
{ License.  If you do not delete the provisions above, a recipient may use     }
37
 
{ your version of this file under either the MPL or the LGPL License.          }
38
 
{                                                                              }
39
 
{ For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
40
 
{                                                                              }
41
 
{******************************************************************************}
42
 
 
43
 
// $Id: jwawinefs.pas,v 1.1 2005/04/04 07:56:11 marco Exp $
44
 
 
45
 
unit JwaWinEFS;
46
 
 
47
 
{$WEAKPACKAGEUNIT}
48
 
 
49
 
{$HPPEMIT ''}
50
 
{$HPPEMIT '#include "WinEFS.h"'}
51
 
{$HPPEMIT ''}
52
 
{$HPPEMIT 'typedef PENCRYPTION_CERTIFICATE_HASH *PPENCRYPTION_CERTIFICATE_HASH'}
53
 
{$HPPEMIT 'typedef PENCRYPTION_CERTIFICATE *PPENCRYPTION_CERTIFICATE'}
54
 
{$HPPEMIT 'typedef PENCRYPTION_CERTIFICATE_HASH_LIST *PPENCRYPTION_CERTIFICATE_HASH_LIST'}
55
 
{$HPPEMIT ''}
56
 
 
57
 
{$I jediapilib.inc}
58
 
 
59
 
interface
60
 
 
61
 
uses
62
 
  JwaWinBase, JwaWinNT, JwaWinType;
63
 
 
64
 
type
65
 
  ALG_ID = Cardinal;
66
 
  {$EXTERNALSYM ALG_ID}
67
 
 
68
 
//
69
 
//  Encoded Certificate
70
 
//
71
 
 
72
 
type
73
 
  PEFS_CERTIFICATE_BLOB = ^EFS_CERTIFICATE_BLOB;
74
 
  {$EXTERNALSYM PEFS_CERTIFICATE_BLOB}
75
 
  _CERTIFICATE_BLOB = record
76
 
    dwCertEncodingType: DWORD;
77
 
    cbData: DWORD;
78
 
    pbData: PBYTE;
79
 
  end;
80
 
  {$EXTERNALSYM _CERTIFICATE_BLOB}
81
 
  EFS_CERTIFICATE_BLOB = _CERTIFICATE_BLOB;
82
 
  {$EXTERNALSYM EFS_CERTIFICATE_BLOB}
83
 
  TEfsCertificateBlob = EFS_CERTIFICATE_BLOB;
84
 
  PEfsCertificateBlob = PEFS_CERTIFICATE_BLOB;
85
 
 
86
 
//
87
 
//  Certificate Hash
88
 
//
89
 
 
90
 
  PEFS_HASH_BLOB = ^EFS_HASH_BLOB;
91
 
  {$EXTERNALSYM PEFS_HASH_BLOB}
92
 
  _EFS_HASH_BLOB = record
93
 
    cbData: DWORD;
94
 
    pbData: PBYTE;
95
 
  end;
96
 
  {$EXTERNALSYM _EFS_HASH_BLOB}
97
 
  EFS_HASH_BLOB = _EFS_HASH_BLOB;
98
 
  {$EXTERNALSYM EFS_HASH_BLOB}
99
 
  TEfsHashBlob = EFS_HASH_BLOB;
100
 
  PEfsHashBlob = PEFS_HASH_BLOB;
101
 
 
102
 
//
103
 
//  RPC blob
104
 
//
105
 
 
106
 
  _EFS_RPC_BLOB = record
107
 
    cbData: DWORD;
108
 
    pbData: PBYTE;
109
 
  end;
110
 
  {$EXTERNALSYM _EFS_RPC_BLOB}
111
 
  EFS_RPC_BLOB = _EFS_RPC_BLOB;
112
 
  {$EXTERNALSYM EFS_RPC_BLOB}
113
 
  PEFS_RPC_BLOB = ^EFS_RPC_BLOB;
114
 
  {$EXTERNALSYM PEFS_RPC_BLOB}
115
 
  TEfsRpcBlob = EFS_RPC_BLOB;
116
 
  PEfsRpcBlob = PEFS_RPC_BLOB;
117
 
 
118
 
  _EFS_KEY_INFO = record
119
 
    dwVersion: DWORD;
120
 
    Entropy: ULONG;
121
 
    Algorithm: ALG_ID;
122
 
    KeyLength: ULONG;
123
 
  end;
124
 
  {$EXTERNALSYM _EFS_KEY_INFO}
125
 
  EFS_KEY_INFO = _EFS_KEY_INFO;
126
 
  {$EXTERNALSYM EFS_KEY_INFO}
127
 
  PEFS_KEY_INFO = ^EFS_KEY_INFO;
128
 
  {$EXTERNALSYM PEFS_KEY_INFO}
129
 
  TEfsKeyInfo = EFS_KEY_INFO;
130
 
  PEfsKeyInfo = PEFS_KEY_INFO;
131
 
 
132
 
//
133
 
// Input to add a user to an encrypted file
134
 
//
135
 
 
136
 
  PENCRYPTION_CERTIFICATE = ^ENCRYPTION_CERTIFICATE;
137
 
  {$EXTERNALSYM PENCRYPTION_CERTIFICATE}
138
 
  _ENCRYPTION_CERTIFICATE = record
139
 
    cbTotalLength: DWORD;
140
 
    pUserSid: PSID;
141
 
    pCertBlob: PEFS_CERTIFICATE_BLOB;
142
 
  end;
143
 
  {$EXTERNALSYM _ENCRYPTION_CERTIFICATE}
144
 
  ENCRYPTION_CERTIFICATE = _ENCRYPTION_CERTIFICATE;
145
 
  {$EXTERNALSYM ENCRYPTION_CERTIFICATE}
146
 
  TEncryptionCertificate = ENCRYPTION_CERTIFICATE;
147
 
  PEncryptionCertificate = PENCRYPTION_CERTIFICATE;
148
 
 
149
 
const
150
 
  MAX_SID_SIZE = 256;
151
 
  {$EXTERNALSYM MAX_SID_SIZE}
152
 
 
153
 
type
154
 
  PENCRYPTION_CERTIFICATE_HASH = ^ENCRYPTION_CERTIFICATE_HASH;
155
 
  {$EXTERNALSYM PENCRYPTION_CERTIFICATE_HASH}
156
 
  _ENCRYPTION_CERTIFICATE_HASH = record
157
 
    cbTotalLength: DWORD;
158
 
    pUserSid: PSID;
159
 
    pHash: PEFS_HASH_BLOB;
160
 
    lpDisplayInformation: LPWSTR;
161
 
  end;
162
 
  {$EXTERNALSYM _ENCRYPTION_CERTIFICATE_HASH}
163
 
  ENCRYPTION_CERTIFICATE_HASH = _ENCRYPTION_CERTIFICATE_HASH;
164
 
  {$EXTERNALSYM ENCRYPTION_CERTIFICATE_HASH}
165
 
  TEncryptionCertificateHash = ENCRYPTION_CERTIFICATE_HASH;
166
 
  PEncryptionCertificateHash = PENCRYPTION_CERTIFICATE_HASH;
167
 
 
168
 
  PPENCRYPTION_CERTIFICATE_HASH = ^PENCRYPTION_CERTIFICATE_HASH;
169
 
  {$NODEFINE PPENCRYPTION_CERTIFICATE_HASH}
170
 
 
171
 
  PENCRYPTION_CERTIFICATE_HASH_LIST = ^ENCRYPTION_CERTIFICATE_HASH_LIST;
172
 
  {$EXTERNALSYM PENCRYPTION_CERTIFICATE_HASH_LIST}
173
 
  _ENCRYPTION_CERTIFICATE_HASH_LIST = record
174
 
    nCert_Hash: DWORD;
175
 
    pUsers: PPENCRYPTION_CERTIFICATE_HASH;
176
 
  end;
177
 
  {$EXTERNALSYM _ENCRYPTION_CERTIFICATE_HASH_LIST}
178
 
  ENCRYPTION_CERTIFICATE_HASH_LIST = _ENCRYPTION_CERTIFICATE_HASH_LIST;
179
 
  {$EXTERNALSYM ENCRYPTION_CERTIFICATE_HASH_LIST}
180
 
  TEncryptionCertificateHashList = ENCRYPTION_CERTIFICATE_HASH_LIST;
181
 
  PEncryptionCertificateHashList = PENCRYPTION_CERTIFICATE_HASH_LIST;
182
 
 
183
 
  PPENCRYPTION_CERTIFICATE = ^PENCRYPTION_CERTIFICATE;
184
 
  {$NODEFINE PPENCRYPTION_CERTIFICATE}
185
 
 
186
 
  PENCRYPTION_CERTIFICATE_LIST = ^ENCRYPTION_CERTIFICATE_LIST;
187
 
  {$EXTERNALSYM PENCRYPTION_CERTIFICATE_LIST}
188
 
  _ENCRYPTION_CERTIFICATE_LIST = record
189
 
    nUsers: DWORD;
190
 
    pUsers: PPENCRYPTION_CERTIFICATE;
191
 
  end;
192
 
  {$EXTERNALSYM _ENCRYPTION_CERTIFICATE_LIST}
193
 
  ENCRYPTION_CERTIFICATE_LIST = _ENCRYPTION_CERTIFICATE_LIST;
194
 
  {$EXTERNALSYM ENCRYPTION_CERTIFICATE_LIST}
195
 
  TEncryptionCertificateList = ENCRYPTION_CERTIFICATE_LIST;
196
 
  PEncryptionCertificateList = PENCRYPTION_CERTIFICATE_LIST;
197
 
 
198
 
  PPENCRYPTION_CERTIFICATE_HASH_LIST = ^PENCRYPTION_CERTIFICATE_HASH_LIST;
199
 
  {$NODEFINE PPENCRYPTION_CERTIFICATE_HASH_LIST}
200
 
 
201
 
function QueryUsersOnEncryptedFile(lpFileName: LPCWSTR;
202
 
  var pUsers: PENCRYPTION_CERTIFICATE_HASH_LIST): DWORD; stdcall;
203
 
{$EXTERNALSYM QueryUsersOnEncryptedFile}
204
 
 
205
 
function QueryRecoveryAgentsOnEncryptedFile(lpFileName: LPCWSTR;
206
 
  var pRecoveryAgents: PENCRYPTION_CERTIFICATE_HASH_LIST): DWORD; stdcall;
207
 
{$EXTERNALSYM QueryRecoveryAgentsOnEncryptedFile}
208
 
 
209
 
function RemoveUsersFromEncryptedFile(lpFileName: LPCWSTR;
210
 
  pHashes: PENCRYPTION_CERTIFICATE_HASH_LIST): DWORD; stdcall;
211
 
{$EXTERNALSYM RemoveUsersFromEncryptedFile}
212
 
 
213
 
function AddUsersToEncryptedFile(lpFileName: LPCWSTR;
214
 
  pUsers: PENCRYPTION_CERTIFICATE_LIST): DWORD; stdcall;
215
 
{$EXTERNALSYM AddUsersToEncryptedFile}
216
 
 
217
 
function SetUserFileEncryptionKey(pEncryptionCertificate: PENCRYPTION_CERTIFICATE): DWORD; stdcall;
218
 
{$EXTERNALSYM SetUserFileEncryptionKey}
219
 
 
220
 
procedure FreeEncryptionCertificateHashList(pHashes: PENCRYPTION_CERTIFICATE_HASH_LIST); stdcall;
221
 
{$EXTERNALSYM FreeEncryptionCertificateHashList}
222
 
 
223
 
function EncryptionDisable(DirPath: LPCWSTR; Disable: BOOL): BOOL; stdcall;
224
 
{$EXTERNALSYM EncryptionDisable}
225
 
 
226
 
function DuplicateEncryptionInfoFile(SrcFileName, DstFileName: LPCWSTR; dwCreationDistribution,
227
 
  dwAttributes: DWORD; lpSecurityAttributes: LPSECURITY_ATTRIBUTES): DWORD; stdcall;
228
 
{$EXTERNALSYM DuplicateEncryptionInfoFile}
229
 
 
230
 
implementation
231
 
 
232
 
const
233
 
  advapi32 = 'advapi32.dll';
234
 
 
235
 
{$IFDEF DYNAMIC_LINK}
236
 
 
237
 
var
238
 
  _QueryUsersOnEncryptedFile: Pointer;
239
 
 
240
 
function QueryUsersOnEncryptedFile;
241
 
begin
242
 
  GetProcedureAddress(_QueryUsersOnEncryptedFile, advapi32, 'QueryUsersOnEncryptedFile');
243
 
  asm
244
 
        MOV     ESP, EBP
245
 
        POP     EBP
246
 
        JMP     [_QueryUsersOnEncryptedFile]
247
 
  end;
248
 
end;
249
 
 
250
 
var
251
 
  _QueryRecoveryAgentsOnEncrFile: Pointer;
252
 
 
253
 
function QueryRecoveryAgentsOnEncryptedFile;
254
 
begin
255
 
  GetProcedureAddress(_QueryRecoveryAgentsOnEncrFile, advapi32, 'QueryRecoveryAgentsOnEncryptedFile');
256
 
  asm
257
 
        MOV     ESP, EBP
258
 
        POP     EBP
259
 
        JMP     [_QueryRecoveryAgentsOnEncrFile]
260
 
  end;
261
 
end;
262
 
 
263
 
var
264
 
  _RemoveUsersFromEncryptedFile: Pointer;
265
 
 
266
 
function RemoveUsersFromEncryptedFile;
267
 
begin
268
 
  GetProcedureAddress(_RemoveUsersFromEncryptedFile, advapi32, 'RemoveUsersFromEncryptedFile');
269
 
  asm
270
 
        MOV     ESP, EBP
271
 
        POP     EBP
272
 
        JMP     [_RemoveUsersFromEncryptedFile]
273
 
  end;
274
 
end;
275
 
 
276
 
var
277
 
  _AddUsersToEncryptedFile: Pointer;
278
 
 
279
 
function AddUsersToEncryptedFile;
280
 
begin
281
 
  GetProcedureAddress(_AddUsersToEncryptedFile, advapi32, 'AddUsersToEncryptedFile');
282
 
  asm
283
 
        MOV     ESP, EBP
284
 
        POP     EBP
285
 
        JMP     [_AddUsersToEncryptedFile]
286
 
  end;
287
 
end;
288
 
 
289
 
var
290
 
  _SetUserFileEncryptionKey: Pointer;
291
 
 
292
 
function SetUserFileEncryptionKey;
293
 
begin
294
 
  GetProcedureAddress(_SetUserFileEncryptionKey, advapi32, 'SetUserFileEncryptionKey');
295
 
  asm
296
 
        MOV     ESP, EBP
297
 
        POP     EBP
298
 
        JMP     [_SetUserFileEncryptionKey]
299
 
  end;
300
 
end;
301
 
 
302
 
var
303
 
  _FreeEncrCertificateHashList: Pointer;
304
 
 
305
 
procedure FreeEncryptionCertificateHashList;
306
 
begin
307
 
  GetProcedureAddress(_FreeEncrCertificateHashList, advapi32, 'FreeEncryptionCertificateHashList');
308
 
  asm
309
 
        MOV     ESP, EBP
310
 
        POP     EBP
311
 
        JMP     [_FreeEncrCertificateHashList]
312
 
  end;
313
 
end;
314
 
 
315
 
var
316
 
  _EncryptionDisable: Pointer;
317
 
 
318
 
function EncryptionDisable;
319
 
begin
320
 
  GetProcedureAddress(_EncryptionDisable, advapi32, 'EncryptionDisable');
321
 
  asm
322
 
        MOV     ESP, EBP
323
 
        POP     EBP
324
 
        JMP     [_EncryptionDisable]
325
 
  end;
326
 
end;
327
 
 
328
 
var
329
 
  _DuplicateEncryptionInfoFile: Pointer;
330
 
 
331
 
function DuplicateEncryptionInfoFile;
332
 
begin
333
 
  GetProcedureAddress(_DuplicateEncryptionInfoFile, advapi32, 'DuplicateEncryptionInfoFile');
334
 
  asm
335
 
        MOV     ESP, EBP
336
 
        POP     EBP
337
 
        JMP     [_DuplicateEncryptionInfoFile]
338
 
  end;
339
 
end;
340
 
 
341
 
{$ELSE}
342
 
 
343
 
function QueryUsersOnEncryptedFile; external advapi32 name 'QueryUsersOnEncryptedFile';
344
 
function QueryRecoveryAgentsOnEncryptedFile; external advapi32 name 'QueryRecoveryAgentsOnEncryptedFile';
345
 
function RemoveUsersFromEncryptedFile; external advapi32 name 'RemoveUsersFromEncryptedFile';
346
 
function AddUsersToEncryptedFile; external advapi32 name 'AddUsersToEncryptedFile';
347
 
function SetUserFileEncryptionKey; external advapi32 name 'SetUserFileEncryptionKey';
348
 
procedure FreeEncryptionCertificateHashList; external advapi32 name 'FreeEncryptionCertificateHashList';
349
 
function EncryptionDisable; external advapi32 name 'EncryptionDisable';
350
 
function DuplicateEncryptionInfoFile; external advapi32 name 'DuplicateEncryptionInfoFile';
351
 
 
352
 
{$ENDIF DYNAMIC_LINK}
353
 
 
354
 
end.
 
1
{******************************************************************************}
 
2
{                                                                              }
 
3
{ Encrypting File System 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: winefs.h, released June 2000. The original Pascal      }
 
9
{ code is: WinEFS.pas, released December 2000. The initial developer of the    }
 
10
{ Pascal code is Marcel van Brakel (brakelm att chello dott 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         }
 
18
{ APILIB home page, located at http://jedi-apilib.sourceforge.net              }
 
19
{                                                                              }
 
20
{ The contents of this file are used with permission, subject to the Mozilla   }
 
21
{ Public License Version 1.1 (the "License"); you may not use this file except }
 
22
{ in compliance with the License. You may obtain a copy of the License at      }
 
23
{ http://www.mozilla.org/MPL/MPL-1.1.html                                      }
 
24
{                                                                              }
 
25
{ Software distributed under the License is distributed on an "AS IS" basis,   }
 
26
{ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
 
27
{ the specific language governing rights and limitations under the License.    }
 
28
{                                                                              }
 
29
{ Alternatively, the contents of this file may be used under the terms of the  }
 
30
{ GNU Lesser General Public License (the  "LGPL License"), in which case the   }
 
31
{ provisions of the LGPL License are applicable instead of those above.        }
 
32
{ If you wish to allow use of your version of this file only under the terms   }
 
33
{ of the LGPL License and not to allow others to use your version of this file }
 
34
{ under the MPL, indicate your decision by deleting  the provisions above and  }
 
35
{ replace  them with the notice and other provisions required by the LGPL      }
 
36
{ License.  If you do not delete the provisions above, a recipient may use     }
 
37
{ your version of this file under either the MPL or the LGPL License.          }
 
38
{                                                                              }
 
39
{ For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
 
40
{                                                                              }
 
41
{******************************************************************************}
 
42
 
 
43
 
 
44
unit JwaWinEFS;
 
45
 
 
46
{$WEAKPACKAGEUNIT}
 
47
 
 
48
{$HPPEMIT ''}
 
49
{$HPPEMIT '#include "WinEFS.h"'}
 
50
{$HPPEMIT ''}
 
51
{$HPPEMIT 'typedef PENCRYPTION_CERTIFICATE_HASH *PPENCRYPTION_CERTIFICATE_HASH'}
 
52
{$HPPEMIT 'typedef PENCRYPTION_CERTIFICATE *PPENCRYPTION_CERTIFICATE'}
 
53
{$HPPEMIT 'typedef PENCRYPTION_CERTIFICATE_HASH_LIST *PPENCRYPTION_CERTIFICATE_HASH_LIST'}
 
54
{$HPPEMIT ''}
 
55
 
 
56
{$I jediapilib.inc}
 
57
 
 
58
interface
 
59
 
 
60
uses
 
61
  JwaWinBase, JwaWinNT, JwaWinType;
 
62
 
 
63
type
 
64
  ALG_ID = Cardinal;
 
65
  {$EXTERNALSYM ALG_ID}
 
66
 
 
67
//
 
68
//  Encoded Certificate
 
69
//
 
70
 
 
71
type
 
72
  PEFS_CERTIFICATE_BLOB = ^EFS_CERTIFICATE_BLOB;
 
73
  {$EXTERNALSYM PEFS_CERTIFICATE_BLOB}
 
74
  _CERTIFICATE_BLOB = record
 
75
    dwCertEncodingType: DWORD;
 
76
    cbData: DWORD;
 
77
    pbData: PBYTE;
 
78
  end;
 
79
  {$EXTERNALSYM _CERTIFICATE_BLOB}
 
80
  EFS_CERTIFICATE_BLOB = _CERTIFICATE_BLOB;
 
81
  {$EXTERNALSYM EFS_CERTIFICATE_BLOB}
 
82
  TEfsCertificateBlob = EFS_CERTIFICATE_BLOB;
 
83
  PEfsCertificateBlob = PEFS_CERTIFICATE_BLOB;
 
84
 
 
85
//
 
86
//  Certificate Hash
 
87
//
 
88
 
 
89
  PEFS_HASH_BLOB = ^EFS_HASH_BLOB;
 
90
  {$EXTERNALSYM PEFS_HASH_BLOB}
 
91
  _EFS_HASH_BLOB = record
 
92
    cbData: DWORD;
 
93
    pbData: PBYTE;
 
94
  end;
 
95
  {$EXTERNALSYM _EFS_HASH_BLOB}
 
96
  EFS_HASH_BLOB = _EFS_HASH_BLOB;
 
97
  {$EXTERNALSYM EFS_HASH_BLOB}
 
98
  TEfsHashBlob = EFS_HASH_BLOB;
 
99
  PEfsHashBlob = PEFS_HASH_BLOB;
 
100
 
 
101
//
 
102
//  RPC blob
 
103
//
 
104
 
 
105
  _EFS_RPC_BLOB = record
 
106
    cbData: DWORD;
 
107
    pbData: PBYTE;
 
108
  end;
 
109
  {$EXTERNALSYM _EFS_RPC_BLOB}
 
110
  EFS_RPC_BLOB = _EFS_RPC_BLOB;
 
111
  {$EXTERNALSYM EFS_RPC_BLOB}
 
112
  PEFS_RPC_BLOB = ^EFS_RPC_BLOB;
 
113
  {$EXTERNALSYM PEFS_RPC_BLOB}
 
114
  TEfsRpcBlob = EFS_RPC_BLOB;
 
115
  PEfsRpcBlob = PEFS_RPC_BLOB;
 
116
 
 
117
  _EFS_KEY_INFO = record
 
118
    dwVersion: DWORD;
 
119
    Entropy: ULONG;
 
120
    Algorithm: ALG_ID;
 
121
    KeyLength: ULONG;
 
122
  end;
 
123
  {$EXTERNALSYM _EFS_KEY_INFO}
 
124
  EFS_KEY_INFO = _EFS_KEY_INFO;
 
125
  {$EXTERNALSYM EFS_KEY_INFO}
 
126
  PEFS_KEY_INFO = ^EFS_KEY_INFO;
 
127
  {$EXTERNALSYM PEFS_KEY_INFO}
 
128
  TEfsKeyInfo = EFS_KEY_INFO;
 
129
  PEfsKeyInfo = PEFS_KEY_INFO;
 
130
 
 
131
//
 
132
// Input to add a user to an encrypted file
 
133
//
 
134
 
 
135
  PENCRYPTION_CERTIFICATE = ^ENCRYPTION_CERTIFICATE;
 
136
  {$EXTERNALSYM PENCRYPTION_CERTIFICATE}
 
137
  _ENCRYPTION_CERTIFICATE = record
 
138
    cbTotalLength: DWORD;
 
139
    pUserSid: PSID;
 
140
    pCertBlob: PEFS_CERTIFICATE_BLOB;
 
141
  end;
 
142
  {$EXTERNALSYM _ENCRYPTION_CERTIFICATE}
 
143
  ENCRYPTION_CERTIFICATE = _ENCRYPTION_CERTIFICATE;
 
144
  {$EXTERNALSYM ENCRYPTION_CERTIFICATE}
 
145
  TEncryptionCertificate = ENCRYPTION_CERTIFICATE;
 
146
  PEncryptionCertificate = PENCRYPTION_CERTIFICATE;
 
147
 
 
148
const
 
149
  MAX_SID_SIZE = 256;
 
150
  {$EXTERNALSYM MAX_SID_SIZE}
 
151
 
 
152
type
 
153
  PENCRYPTION_CERTIFICATE_HASH = ^ENCRYPTION_CERTIFICATE_HASH;
 
154
  {$EXTERNALSYM PENCRYPTION_CERTIFICATE_HASH}
 
155
  _ENCRYPTION_CERTIFICATE_HASH = record
 
156
    cbTotalLength: DWORD;
 
157
    pUserSid: PSID;
 
158
    pHash: PEFS_HASH_BLOB;
 
159
    lpDisplayInformation: LPWSTR;
 
160
  end;
 
161
  {$EXTERNALSYM _ENCRYPTION_CERTIFICATE_HASH}
 
162
  ENCRYPTION_CERTIFICATE_HASH = _ENCRYPTION_CERTIFICATE_HASH;
 
163
  {$EXTERNALSYM ENCRYPTION_CERTIFICATE_HASH}
 
164
  TEncryptionCertificateHash = ENCRYPTION_CERTIFICATE_HASH;
 
165
  PEncryptionCertificateHash = PENCRYPTION_CERTIFICATE_HASH;
 
166
 
 
167
  PPENCRYPTION_CERTIFICATE_HASH = ^PENCRYPTION_CERTIFICATE_HASH;
 
168
  {$NODEFINE PPENCRYPTION_CERTIFICATE_HASH}
 
169
 
 
170
  PENCRYPTION_CERTIFICATE_HASH_LIST = ^ENCRYPTION_CERTIFICATE_HASH_LIST;
 
171
  {$EXTERNALSYM PENCRYPTION_CERTIFICATE_HASH_LIST}
 
172
  _ENCRYPTION_CERTIFICATE_HASH_LIST = record
 
173
    nCert_Hash: DWORD;
 
174
    pUsers: PPENCRYPTION_CERTIFICATE_HASH;
 
175
  end;
 
176
  {$EXTERNALSYM _ENCRYPTION_CERTIFICATE_HASH_LIST}
 
177
  ENCRYPTION_CERTIFICATE_HASH_LIST = _ENCRYPTION_CERTIFICATE_HASH_LIST;
 
178
  {$EXTERNALSYM ENCRYPTION_CERTIFICATE_HASH_LIST}
 
179
  TEncryptionCertificateHashList = ENCRYPTION_CERTIFICATE_HASH_LIST;
 
180
  PEncryptionCertificateHashList = PENCRYPTION_CERTIFICATE_HASH_LIST;
 
181
 
 
182
  PPENCRYPTION_CERTIFICATE = ^PENCRYPTION_CERTIFICATE;
 
183
  {$NODEFINE PPENCRYPTION_CERTIFICATE}
 
184
 
 
185
  PENCRYPTION_CERTIFICATE_LIST = ^ENCRYPTION_CERTIFICATE_LIST;
 
186
  {$EXTERNALSYM PENCRYPTION_CERTIFICATE_LIST}
 
187
  _ENCRYPTION_CERTIFICATE_LIST = record
 
188
    nUsers: DWORD;
 
189
    pUsers: PPENCRYPTION_CERTIFICATE;
 
190
  end;
 
191
  {$EXTERNALSYM _ENCRYPTION_CERTIFICATE_LIST}
 
192
  ENCRYPTION_CERTIFICATE_LIST = _ENCRYPTION_CERTIFICATE_LIST;
 
193
  {$EXTERNALSYM ENCRYPTION_CERTIFICATE_LIST}
 
194
  TEncryptionCertificateList = ENCRYPTION_CERTIFICATE_LIST;
 
195
  PEncryptionCertificateList = PENCRYPTION_CERTIFICATE_LIST;
 
196
 
 
197
  PPENCRYPTION_CERTIFICATE_HASH_LIST = ^PENCRYPTION_CERTIFICATE_HASH_LIST;
 
198
  {$NODEFINE PPENCRYPTION_CERTIFICATE_HASH_LIST}
 
199
 
 
200
function QueryUsersOnEncryptedFile(lpFileName: LPCWSTR;
 
201
  var pUsers: PENCRYPTION_CERTIFICATE_HASH_LIST): DWORD; stdcall;
 
202
{$EXTERNALSYM QueryUsersOnEncryptedFile}
 
203
 
 
204
function QueryRecoveryAgentsOnEncryptedFile(lpFileName: LPCWSTR;
 
205
  var pRecoveryAgents: PENCRYPTION_CERTIFICATE_HASH_LIST): DWORD; stdcall;
 
206
{$EXTERNALSYM QueryRecoveryAgentsOnEncryptedFile}
 
207
 
 
208
function RemoveUsersFromEncryptedFile(lpFileName: LPCWSTR;
 
209
  pHashes: PENCRYPTION_CERTIFICATE_HASH_LIST): DWORD; stdcall;
 
210
{$EXTERNALSYM RemoveUsersFromEncryptedFile}
 
211
 
 
212
function AddUsersToEncryptedFile(lpFileName: LPCWSTR;
 
213
  pUsers: PENCRYPTION_CERTIFICATE_LIST): DWORD; stdcall;
 
214
{$EXTERNALSYM AddUsersToEncryptedFile}
 
215
 
 
216
function SetUserFileEncryptionKey(pEncryptionCertificate: PENCRYPTION_CERTIFICATE): DWORD; stdcall;
 
217
{$EXTERNALSYM SetUserFileEncryptionKey}
 
218
 
 
219
procedure FreeEncryptionCertificateHashList(pHashes: PENCRYPTION_CERTIFICATE_HASH_LIST); stdcall;
 
220
{$EXTERNALSYM FreeEncryptionCertificateHashList}
 
221
 
 
222
function EncryptionDisable(DirPath: LPCWSTR; Disable: BOOL): BOOL; stdcall;
 
223
{$EXTERNALSYM EncryptionDisable}
 
224
 
 
225
function DuplicateEncryptionInfoFile(SrcFileName, DstFileName: LPCWSTR; dwCreationDistribution,
 
226
  dwAttributes: DWORD; lpSecurityAttributes: LPSECURITY_ATTRIBUTES): DWORD; stdcall;
 
227
{$EXTERNALSYM DuplicateEncryptionInfoFile}
 
228
 
 
229
implementation
 
230
 
 
231
const
 
232
  advapi32 = 'advapi32.dll';
 
233
 
 
234
{$IFDEF DYNAMIC_LINK}
 
235
 
 
236
var
 
237
  _QueryUsersOnEncryptedFile: Pointer;
 
238
 
 
239
function QueryUsersOnEncryptedFile;
 
240
begin
 
241
  GetProcedureAddress(_QueryUsersOnEncryptedFile, advapi32, 'QueryUsersOnEncryptedFile');
 
242
  asm
 
243
        MOV     ESP, EBP
 
244
        POP     EBP
 
245
        JMP     [_QueryUsersOnEncryptedFile]
 
246
  end;
 
247
end;
 
248
 
 
249
var
 
250
  _QueryRecoveryAgentsOnEncrFile: Pointer;
 
251
 
 
252
function QueryRecoveryAgentsOnEncryptedFile;
 
253
begin
 
254
  GetProcedureAddress(_QueryRecoveryAgentsOnEncrFile, advapi32, 'QueryRecoveryAgentsOnEncryptedFile');
 
255
  asm
 
256
        MOV     ESP, EBP
 
257
        POP     EBP
 
258
        JMP     [_QueryRecoveryAgentsOnEncrFile]
 
259
  end;
 
260
end;
 
261
 
 
262
var
 
263
  _RemoveUsersFromEncryptedFile: Pointer;
 
264
 
 
265
function RemoveUsersFromEncryptedFile;
 
266
begin
 
267
  GetProcedureAddress(_RemoveUsersFromEncryptedFile, advapi32, 'RemoveUsersFromEncryptedFile');
 
268
  asm
 
269
        MOV     ESP, EBP
 
270
        POP     EBP
 
271
        JMP     [_RemoveUsersFromEncryptedFile]
 
272
  end;
 
273
end;
 
274
 
 
275
var
 
276
  _AddUsersToEncryptedFile: Pointer;
 
277
 
 
278
function AddUsersToEncryptedFile;
 
279
begin
 
280
  GetProcedureAddress(_AddUsersToEncryptedFile, advapi32, 'AddUsersToEncryptedFile');
 
281
  asm
 
282
        MOV     ESP, EBP
 
283
        POP     EBP
 
284
        JMP     [_AddUsersToEncryptedFile]
 
285
  end;
 
286
end;
 
287
 
 
288
var
 
289
  _SetUserFileEncryptionKey: Pointer;
 
290
 
 
291
function SetUserFileEncryptionKey;
 
292
begin
 
293
  GetProcedureAddress(_SetUserFileEncryptionKey, advapi32, 'SetUserFileEncryptionKey');
 
294
  asm
 
295
        MOV     ESP, EBP
 
296
        POP     EBP
 
297
        JMP     [_SetUserFileEncryptionKey]
 
298
  end;
 
299
end;
 
300
 
 
301
var
 
302
  _FreeEncrCertificateHashList: Pointer;
 
303
 
 
304
procedure FreeEncryptionCertificateHashList;
 
305
begin
 
306
  GetProcedureAddress(_FreeEncrCertificateHashList, advapi32, 'FreeEncryptionCertificateHashList');
 
307
  asm
 
308
        MOV     ESP, EBP
 
309
        POP     EBP
 
310
        JMP     [_FreeEncrCertificateHashList]
 
311
  end;
 
312
end;
 
313
 
 
314
var
 
315
  _EncryptionDisable: Pointer;
 
316
 
 
317
function EncryptionDisable;
 
318
begin
 
319
  GetProcedureAddress(_EncryptionDisable, advapi32, 'EncryptionDisable');
 
320
  asm
 
321
        MOV     ESP, EBP
 
322
        POP     EBP
 
323
        JMP     [_EncryptionDisable]
 
324
  end;
 
325
end;
 
326
 
 
327
var
 
328
  _DuplicateEncryptionInfoFile: Pointer;
 
329
 
 
330
function DuplicateEncryptionInfoFile;
 
331
begin
 
332
  GetProcedureAddress(_DuplicateEncryptionInfoFile, advapi32, 'DuplicateEncryptionInfoFile');
 
333
  asm
 
334
        MOV     ESP, EBP
 
335
        POP     EBP
 
336
        JMP     [_DuplicateEncryptionInfoFile]
 
337
  end;
 
338
end;
 
339
 
 
340
{$ELSE}
 
341
 
 
342
function QueryUsersOnEncryptedFile; external advapi32 name 'QueryUsersOnEncryptedFile';
 
343
function QueryRecoveryAgentsOnEncryptedFile; external advapi32 name 'QueryRecoveryAgentsOnEncryptedFile';
 
344
function RemoveUsersFromEncryptedFile; external advapi32 name 'RemoveUsersFromEncryptedFile';
 
345
function AddUsersToEncryptedFile; external advapi32 name 'AddUsersToEncryptedFile';
 
346
function SetUserFileEncryptionKey; external advapi32 name 'SetUserFileEncryptionKey';
 
347
procedure FreeEncryptionCertificateHashList; external advapi32 name 'FreeEncryptionCertificateHashList';
 
348
function EncryptionDisable; external advapi32 name 'EncryptionDisable';
 
349
function DuplicateEncryptionInfoFile; external advapi32 name 'DuplicateEncryptionInfoFile';
 
350
 
 
351
{$ENDIF DYNAMIC_LINK}
 
352
 
 
353
end.