~ubuntu-branches/ubuntu/oneiric/likewise-open/oneiric

« back to all changes in this revision

Viewing changes to krb5/src/windows/identity/plugins/common/dynimport.c

  • Committer: Bazaar Package Importer
  • Author(s): Scott Salley
  • Date: 2010-11-22 12:06:00 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20101122120600-8lba1fpceot71wlb
Tags: 6.0.0.53010-1
Likewise Open 6.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
* Copyright (c) 2005 Massachusetts Institute of Technology
 
3
* Copyright (c) 2007 Secure Endpoints Inc.
 
4
*
 
5
* Permission is hereby granted, free of charge, to any person
 
6
* obtaining a copy of this software and associated documentation
 
7
* files (the "Software"), to deal in the Software without
 
8
* restriction, including without limitation the rights to use, copy,
 
9
* modify, merge, publish, distribute, sublicense, and/or sell copies
 
10
* of the Software, and to permit persons to whom the Software is
 
11
* furnished to do so, subject to the following conditions:
 
12
*
 
13
* The above copyright notice and this permission notice shall be
 
14
* included in all copies or substantial portions of the Software.
 
15
*
 
16
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 
17
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
18
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 
19
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 
20
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 
21
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 
22
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 
23
* SOFTWARE.
 
24
*/
 
25
 
 
26
/* $Id$ */
 
27
 
 
28
#include<windows.h>
 
29
#include<netidmgr.h>
 
30
#include<dynimport.h>
 
31
 
 
32
HINSTANCE hKrb4 = 0;
 
33
HINSTANCE hKrb5 = 0;
 
34
HINSTANCE hKrb524 = 0;
 
35
HINSTANCE hSecur32 = 0;
 
36
HINSTANCE hComErr = 0;
 
37
HINSTANCE hService = 0;
 
38
HINSTANCE hProfile = 0;
 
39
HINSTANCE hPsapi = 0; 
 
40
HINSTANCE hToolHelp32 = 0; 
 
41
HINSTANCE hCCAPI = 0;
 
42
 
 
43
DWORD     AfsAvailable = 0;
 
44
 
 
45
// CCAPI
 
46
DECL_FUNC_PTR(cc_initialize);
 
47
DECL_FUNC_PTR(cc_shutdown);
 
48
DECL_FUNC_PTR(cc_get_NC_info);
 
49
DECL_FUNC_PTR(cc_free_NC_info);
 
50
 
 
51
// krb4 functions
 
52
DECL_FUNC_PTR(get_krb_err_txt_entry);
 
53
DECL_FUNC_PTR(k_isinst);
 
54
DECL_FUNC_PTR(k_isname);
 
55
DECL_FUNC_PTR(k_isrealm);
 
56
DECL_FUNC_PTR(kadm_change_your_password);
 
57
DECL_FUNC_PTR(kname_parse);
 
58
DECL_FUNC_PTR(krb_get_cred);
 
59
DECL_FUNC_PTR(krb_get_krbhst);
 
60
DECL_FUNC_PTR(krb_get_lrealm);
 
61
DECL_FUNC_PTR(krb_get_pw_in_tkt);
 
62
DECL_FUNC_PTR(krb_get_tf_realm);
 
63
DECL_FUNC_PTR(krb_mk_req);
 
64
DECL_FUNC_PTR(krb_realmofhost);
 
65
DECL_FUNC_PTR(tf_init);
 
66
DECL_FUNC_PTR(tf_close);
 
67
DECL_FUNC_PTR(tf_get_cred);
 
68
DECL_FUNC_PTR(tf_get_pname);
 
69
DECL_FUNC_PTR(tf_get_pinst);
 
70
DECL_FUNC_PTR(LocalHostAddr);
 
71
DECL_FUNC_PTR(tkt_string);
 
72
DECL_FUNC_PTR(krb_set_tkt_string);
 
73
DECL_FUNC_PTR(initialize_krb_error_func);
 
74
DECL_FUNC_PTR(initialize_kadm_error_table);
 
75
DECL_FUNC_PTR(dest_tkt);
 
76
DECL_FUNC_PTR(krb_in_tkt);
 
77
DECL_FUNC_PTR(krb_save_credentials);
 
78
DECL_FUNC_PTR(krb_get_krbconf2);
 
79
DECL_FUNC_PTR(krb_get_krbrealm2);
 
80
DECL_FUNC_PTR(krb_life_to_time);
 
81
 
 
82
// krb5 functions
 
83
DECL_FUNC_PTR(krb5_change_password);
 
84
DECL_FUNC_PTR(krb5_get_init_creds_opt_init);
 
85
DECL_FUNC_PTR(krb5_get_init_creds_opt_set_tkt_life);
 
86
DECL_FUNC_PTR(krb5_get_init_creds_opt_set_renew_life);
 
87
DECL_FUNC_PTR(krb5_get_init_creds_opt_set_forwardable);
 
88
DECL_FUNC_PTR(krb5_get_init_creds_opt_set_proxiable);
 
89
DECL_FUNC_PTR(krb5_get_init_creds_opt_set_address_list);
 
90
DECL_FUNC_PTR(krb5_get_init_creds_opt_set_change_password_prompt);
 
91
DECL_FUNC_PTR(krb5_get_init_creds_password);
 
92
DECL_FUNC_PTR(krb5_get_prompt_types);
 
93
DECL_FUNC_PTR(krb5_build_principal_ext);
 
94
DECL_FUNC_PTR(krb5_cc_get_name);
 
95
DECL_FUNC_PTR(krb5_cc_get_type);
 
96
DECL_FUNC_PTR(krb5_cc_resolve);
 
97
DECL_FUNC_PTR(krb5_cc_default);
 
98
DECL_FUNC_PTR(krb5_cc_default_name);
 
99
DECL_FUNC_PTR(krb5_cc_set_default_name);
 
100
DECL_FUNC_PTR(krb5_cc_initialize);
 
101
DECL_FUNC_PTR(krb5_cc_destroy);
 
102
DECL_FUNC_PTR(krb5_cc_close);
 
103
DECL_FUNC_PTR(krb5_cc_store_cred);
 
104
DECL_FUNC_PTR(krb5_cc_copy_creds);
 
105
DECL_FUNC_PTR(krb5_cc_retrieve_cred);
 
106
DECL_FUNC_PTR(krb5_cc_get_principal);
 
107
DECL_FUNC_PTR(krb5_cc_start_seq_get);
 
108
DECL_FUNC_PTR(krb5_cc_next_cred);
 
109
DECL_FUNC_PTR(krb5_cc_end_seq_get);
 
110
DECL_FUNC_PTR(krb5_cc_remove_cred);
 
111
DECL_FUNC_PTR(krb5_cc_set_flags);
 
112
// DECL_FUNC_PTR(krb5_cc_get_type);
 
113
DECL_FUNC_PTR(krb5_free_context);
 
114
DECL_FUNC_PTR(krb5_free_cred_contents);
 
115
DECL_FUNC_PTR(krb5_free_principal);
 
116
DECL_FUNC_PTR(krb5_get_in_tkt_with_password);
 
117
DECL_FUNC_PTR(krb5_init_context);
 
118
DECL_FUNC_PTR(krb5_parse_name);
 
119
DECL_FUNC_PTR(krb5_timeofday);
 
120
DECL_FUNC_PTR(krb5_timestamp_to_sfstring);
 
121
DECL_FUNC_PTR(krb5_unparse_name);
 
122
DECL_FUNC_PTR(krb5_get_credentials);
 
123
DECL_FUNC_PTR(krb5_mk_req);
 
124
DECL_FUNC_PTR(krb5_sname_to_principal);
 
125
DECL_FUNC_PTR(krb5_get_credentials_renew);
 
126
DECL_FUNC_PTR(krb5_free_data);
 
127
DECL_FUNC_PTR(krb5_free_data_contents);
 
128
// DECL_FUNC_PTR(krb5_get_realm_domain);
 
129
DECL_FUNC_PTR(krb5_free_unparsed_name);
 
130
DECL_FUNC_PTR(krb5_os_localaddr);
 
131
DECL_FUNC_PTR(krb5_copy_keyblock_contents);
 
132
DECL_FUNC_PTR(krb5_copy_data);
 
133
DECL_FUNC_PTR(krb5_free_creds);
 
134
DECL_FUNC_PTR(krb5_build_principal);
 
135
DECL_FUNC_PTR(krb5_get_renewed_creds);
 
136
DECL_FUNC_PTR(krb5_get_default_config_files);
 
137
DECL_FUNC_PTR(krb5_free_config_files);
 
138
DECL_FUNC_PTR(krb5_get_default_realm);
 
139
DECL_FUNC_PTR(krb5_set_default_realm);
 
140
DECL_FUNC_PTR(krb5_free_ticket);
 
141
DECL_FUNC_PTR(krb5_decode_ticket);
 
142
DECL_FUNC_PTR(krb5_get_host_realm);
 
143
DECL_FUNC_PTR(krb5_free_host_realm);
 
144
DECL_FUNC_PTR(krb5_c_random_make_octets);
 
145
DECL_FUNC_PTR(krb5_free_addresses);
 
146
DECL_FUNC_PTR(krb5_free_default_realm);
 
147
DECL_FUNC_PTR(krb5_string_to_deltat);
 
148
DECL_FUNC_PTR(krb5_get_error_message);
 
149
DECL_FUNC_PTR(krb5_free_error_message);
 
150
DECL_FUNC_PTR(krb5_clear_error_message);
 
151
 
 
152
// Krb524 functions
 
153
DECL_FUNC_PTR(krb524_init_ets);
 
154
DECL_FUNC_PTR(krb524_convert_creds_kdc);
 
155
 
 
156
// ComErr functions
 
157
DECL_FUNC_PTR(com_err);
 
158
DECL_FUNC_PTR(error_message);
 
159
 
 
160
// Profile functions
 
161
DECL_FUNC_PTR(profile_init);    
 
162
DECL_FUNC_PTR(profile_flush);
 
163
DECL_FUNC_PTR(profile_release); 
 
164
DECL_FUNC_PTR(profile_get_subsection_names);
 
165
DECL_FUNC_PTR(profile_free_list);
 
166
DECL_FUNC_PTR(profile_get_string);
 
167
DECL_FUNC_PTR(profile_get_integer);
 
168
DECL_FUNC_PTR(profile_get_values);
 
169
DECL_FUNC_PTR(profile_get_relation_names);
 
170
DECL_FUNC_PTR(profile_clear_relation);
 
171
DECL_FUNC_PTR(profile_add_relation);
 
172
DECL_FUNC_PTR(profile_update_relation);
 
173
DECL_FUNC_PTR(profile_release_string);
 
174
DECL_FUNC_PTR(profile_rename_section);
 
175
 
 
176
// Service functions
 
177
DECL_FUNC_PTR(OpenSCManagerA);
 
178
DECL_FUNC_PTR(OpenServiceA);
 
179
DECL_FUNC_PTR(QueryServiceStatus);
 
180
DECL_FUNC_PTR(CloseServiceHandle);
 
181
DECL_FUNC_PTR(LsaNtStatusToWinError);
 
182
 
 
183
// LSA Functions
 
184
DECL_FUNC_PTR(LsaConnectUntrusted);
 
185
DECL_FUNC_PTR(LsaLookupAuthenticationPackage);
 
186
DECL_FUNC_PTR(LsaCallAuthenticationPackage);
 
187
DECL_FUNC_PTR(LsaFreeReturnBuffer);
 
188
DECL_FUNC_PTR(LsaGetLogonSessionData);
 
189
 
 
190
// CCAPI
 
191
FUNC_INFO ccapi_fi[] = {
 
192
    MAKE_FUNC_INFO(cc_initialize),
 
193
    MAKE_FUNC_INFO(cc_shutdown),
 
194
    MAKE_FUNC_INFO(cc_get_NC_info),
 
195
    MAKE_FUNC_INFO(cc_free_NC_info),
 
196
    END_FUNC_INFO
 
197
};
 
198
 
 
199
FUNC_INFO k4_fi[] = {
 
200
    MAKE_FUNC_INFO(get_krb_err_txt_entry),
 
201
    MAKE_FUNC_INFO(k_isinst),
 
202
    MAKE_FUNC_INFO(k_isname),
 
203
    MAKE_FUNC_INFO(k_isrealm),
 
204
    MAKE_FUNC_INFO(kadm_change_your_password),
 
205
    MAKE_FUNC_INFO(kname_parse),
 
206
    MAKE_FUNC_INFO(krb_get_cred),
 
207
    MAKE_FUNC_INFO(krb_get_krbhst),
 
208
    MAKE_FUNC_INFO(krb_get_lrealm),
 
209
    MAKE_FUNC_INFO(krb_get_pw_in_tkt),
 
210
    MAKE_FUNC_INFO(krb_get_tf_realm),
 
211
    MAKE_FUNC_INFO(krb_mk_req),
 
212
    MAKE_FUNC_INFO(krb_realmofhost),
 
213
    MAKE_FUNC_INFO(tf_init),
 
214
    MAKE_FUNC_INFO(tf_close),
 
215
    MAKE_FUNC_INFO(tf_get_cred),
 
216
    MAKE_FUNC_INFO(tf_get_pname),
 
217
    MAKE_FUNC_INFO(tf_get_pinst),
 
218
    MAKE_FUNC_INFO(LocalHostAddr),
 
219
    MAKE_FUNC_INFO(tkt_string),
 
220
    MAKE_FUNC_INFO(krb_set_tkt_string),
 
221
    MAKE_FUNC_INFO(initialize_krb_error_func),
 
222
    MAKE_FUNC_INFO(initialize_kadm_error_table),
 
223
    MAKE_FUNC_INFO(dest_tkt),
 
224
    /*        MAKE_FUNC_INFO(lsh_LoadKrb4LeashErrorTables), */// XXX
 
225
    MAKE_FUNC_INFO(krb_in_tkt),
 
226
    MAKE_FUNC_INFO(krb_save_credentials),
 
227
    MAKE_FUNC_INFO(krb_get_krbconf2),
 
228
    MAKE_FUNC_INFO(krb_get_krbrealm2),
 
229
    MAKE_FUNC_INFO(krb_life_to_time),
 
230
    END_FUNC_INFO
 
231
};
 
232
 
 
233
FUNC_INFO k5_fi[] = {
 
234
    MAKE_FUNC_INFO(krb5_change_password),
 
235
    MAKE_FUNC_INFO(krb5_get_init_creds_opt_init),
 
236
    MAKE_FUNC_INFO(krb5_get_init_creds_opt_set_tkt_life),
 
237
    MAKE_FUNC_INFO(krb5_get_init_creds_opt_set_renew_life),
 
238
    MAKE_FUNC_INFO(krb5_get_init_creds_opt_set_forwardable),
 
239
    MAKE_FUNC_INFO(krb5_get_init_creds_opt_set_proxiable),
 
240
    MAKE_FUNC_INFO(krb5_get_init_creds_opt_set_address_list),
 
241
    MAKE_FUNC_INFO(krb5_get_init_creds_opt_set_change_password_prompt),
 
242
    MAKE_FUNC_INFO(krb5_get_init_creds_password),
 
243
    MAKE_FUNC_INFO(krb5_get_prompt_types),
 
244
    MAKE_FUNC_INFO(krb5_build_principal_ext),
 
245
    MAKE_FUNC_INFO(krb5_cc_get_name),
 
246
    MAKE_FUNC_INFO(krb5_cc_get_type),
 
247
    MAKE_FUNC_INFO(krb5_cc_resolve),
 
248
    MAKE_FUNC_INFO(krb5_cc_default),
 
249
    MAKE_FUNC_INFO(krb5_cc_default_name),
 
250
    MAKE_FUNC_INFO(krb5_cc_set_default_name),
 
251
    MAKE_FUNC_INFO(krb5_cc_initialize),
 
252
    MAKE_FUNC_INFO(krb5_cc_destroy),
 
253
    MAKE_FUNC_INFO(krb5_cc_close),
 
254
    MAKE_FUNC_INFO(krb5_cc_copy_creds),
 
255
    MAKE_FUNC_INFO(krb5_cc_store_cred),
 
256
    MAKE_FUNC_INFO(krb5_cc_retrieve_cred),
 
257
    MAKE_FUNC_INFO(krb5_cc_get_principal),
 
258
    MAKE_FUNC_INFO(krb5_cc_start_seq_get),
 
259
    MAKE_FUNC_INFO(krb5_cc_next_cred),
 
260
    MAKE_FUNC_INFO(krb5_cc_end_seq_get),
 
261
    MAKE_FUNC_INFO(krb5_cc_remove_cred),
 
262
    MAKE_FUNC_INFO(krb5_cc_set_flags),
 
263
    // MAKE_FUNC_INFO(krb5_cc_get_type),
 
264
    MAKE_FUNC_INFO(krb5_free_context),
 
265
    MAKE_FUNC_INFO(krb5_free_cred_contents),
 
266
    MAKE_FUNC_INFO(krb5_free_principal),
 
267
    MAKE_FUNC_INFO(krb5_get_in_tkt_with_password),
 
268
    MAKE_FUNC_INFO(krb5_init_context),
 
269
    MAKE_FUNC_INFO(krb5_parse_name),
 
270
    MAKE_FUNC_INFO(krb5_timeofday),
 
271
    MAKE_FUNC_INFO(krb5_timestamp_to_sfstring),
 
272
    MAKE_FUNC_INFO(krb5_unparse_name),
 
273
    MAKE_FUNC_INFO(krb5_get_credentials),
 
274
    MAKE_FUNC_INFO(krb5_mk_req),
 
275
    MAKE_FUNC_INFO(krb5_sname_to_principal),
 
276
    MAKE_FUNC_INFO(krb5_get_credentials_renew),
 
277
    MAKE_FUNC_INFO(krb5_free_data),
 
278
    MAKE_FUNC_INFO(krb5_free_data_contents),
 
279
    //  MAKE_FUNC_INFO(krb5_get_realm_domain),
 
280
    MAKE_FUNC_INFO(krb5_free_unparsed_name),
 
281
    MAKE_FUNC_INFO(krb5_os_localaddr),
 
282
    MAKE_FUNC_INFO(krb5_copy_keyblock_contents),
 
283
    MAKE_FUNC_INFO(krb5_copy_data),
 
284
    MAKE_FUNC_INFO(krb5_free_creds),
 
285
    MAKE_FUNC_INFO(krb5_build_principal),
 
286
    MAKE_FUNC_INFO(krb5_get_renewed_creds),
 
287
    MAKE_FUNC_INFO(krb5_free_addresses),
 
288
    MAKE_FUNC_INFO(krb5_get_default_config_files),
 
289
    MAKE_FUNC_INFO(krb5_free_config_files),
 
290
    MAKE_FUNC_INFO(krb5_get_default_realm),
 
291
    MAKE_FUNC_INFO(krb5_set_default_realm),
 
292
    MAKE_FUNC_INFO(krb5_free_ticket),
 
293
    MAKE_FUNC_INFO(krb5_decode_ticket),
 
294
    MAKE_FUNC_INFO(krb5_get_host_realm),
 
295
    MAKE_FUNC_INFO(krb5_free_host_realm),
 
296
    MAKE_FUNC_INFO(krb5_c_random_make_octets),
 
297
    MAKE_FUNC_INFO(krb5_free_default_realm),
 
298
    MAKE_FUNC_INFO(krb5_string_to_deltat),
 
299
    MAKE_FUNC_INFO(krb5_get_error_message),
 
300
    MAKE_FUNC_INFO(krb5_free_error_message),
 
301
    MAKE_FUNC_INFO(krb5_clear_error_message),
 
302
    END_FUNC_INFO
 
303
};
 
304
 
 
305
FUNC_INFO k524_fi[] = {
 
306
    MAKE_FUNC_INFO(krb524_init_ets),
 
307
    MAKE_FUNC_INFO(krb524_convert_creds_kdc),
 
308
    END_FUNC_INFO
 
309
};
 
310
 
 
311
FUNC_INFO profile_fi[] = {
 
312
    MAKE_FUNC_INFO(profile_init),
 
313
    MAKE_FUNC_INFO(profile_flush),
 
314
    MAKE_FUNC_INFO(profile_release), 
 
315
    MAKE_FUNC_INFO(profile_get_subsection_names),
 
316
    MAKE_FUNC_INFO(profile_free_list),
 
317
    MAKE_FUNC_INFO(profile_get_string),
 
318
    MAKE_FUNC_INFO(profile_get_integer),
 
319
    MAKE_FUNC_INFO(profile_get_values),
 
320
    MAKE_FUNC_INFO(profile_get_relation_names),
 
321
    MAKE_FUNC_INFO(profile_clear_relation),
 
322
    MAKE_FUNC_INFO(profile_add_relation),
 
323
    MAKE_FUNC_INFO(profile_update_relation),
 
324
    MAKE_FUNC_INFO(profile_release_string),
 
325
    MAKE_FUNC_INFO(profile_rename_section),
 
326
    END_FUNC_INFO
 
327
};
 
328
 
 
329
FUNC_INFO ce_fi[] = {
 
330
    MAKE_FUNC_INFO(com_err),
 
331
    MAKE_FUNC_INFO(error_message),
 
332
    END_FUNC_INFO
 
333
};
 
334
 
 
335
FUNC_INFO service_fi[] = {
 
336
    MAKE_FUNC_INFO(OpenSCManagerA),
 
337
    MAKE_FUNC_INFO(OpenServiceA),
 
338
    MAKE_FUNC_INFO(QueryServiceStatus),
 
339
    MAKE_FUNC_INFO(CloseServiceHandle),
 
340
    MAKE_FUNC_INFO(LsaNtStatusToWinError),
 
341
    END_FUNC_INFO
 
342
};
 
343
 
 
344
FUNC_INFO lsa_fi[] = {
 
345
    MAKE_FUNC_INFO(LsaConnectUntrusted),
 
346
    MAKE_FUNC_INFO(LsaLookupAuthenticationPackage),
 
347
    MAKE_FUNC_INFO(LsaCallAuthenticationPackage),
 
348
    MAKE_FUNC_INFO(LsaFreeReturnBuffer),
 
349
    MAKE_FUNC_INFO(LsaGetLogonSessionData),
 
350
    END_FUNC_INFO
 
351
};
 
352
 
 
353
// psapi functions
 
354
DECL_FUNC_PTR(GetModuleFileNameExA);
 
355
DECL_FUNC_PTR(EnumProcessModules);
 
356
 
 
357
FUNC_INFO psapi_fi[] = {
 
358
    MAKE_FUNC_INFO(GetModuleFileNameExA),
 
359
        MAKE_FUNC_INFO(EnumProcessModules),
 
360
        END_FUNC_INFO
 
361
};
 
362
 
 
363
// toolhelp functions
 
364
DECL_FUNC_PTR(CreateToolhelp32Snapshot);
 
365
DECL_FUNC_PTR(Module32First);
 
366
DECL_FUNC_PTR(Module32Next);
 
367
 
 
368
FUNC_INFO toolhelp_fi[] = {
 
369
    MAKE_FUNC_INFO(CreateToolhelp32Snapshot),
 
370
        MAKE_FUNC_INFO(Module32First),
 
371
        MAKE_FUNC_INFO(Module32Next),
 
372
        END_FUNC_INFO
 
373
};
 
374
 
 
375
khm_int32 init_imports(void) {
 
376
    OSVERSIONINFO osvi;
 
377
    int imp_rv = 1;
 
378
 
 
379
#define CKRV(m)           \
 
380
  do {                    \
 
381
    if(!imp_rv) {         \
 
382
      _reportf(L"Can't locate all required exports from module [%S]", (m)); \
 
383
      goto _err_ret;      \
 
384
    }                     \
 
385
 } while (FALSE)
 
386
 
 
387
#ifndef _WIN64
 
388
    imp_rv = LoadFuncs(KRB4_DLL, k4_fi, &hKrb4, 0, 1, 0, 0);
 
389
    CKRV(KRB4_DLL);
 
390
#endif
 
391
 
 
392
    imp_rv = LoadFuncs(KRB5_DLL, k5_fi, &hKrb5, 0, 1, 0, 0);
 
393
    CKRV(KRB5_DLL);
 
394
 
 
395
    imp_rv = LoadFuncs(COMERR_DLL, ce_fi, &hComErr, 0, 0, 1, 0);
 
396
    CKRV(COMERR_DLL);
 
397
 
 
398
    imp_rv = LoadFuncs(SERVICE_DLL, service_fi, &hService, 0, 1, 0, 0);
 
399
    CKRV(SERVICE_DLL);
 
400
 
 
401
    imp_rv = LoadFuncs(SECUR32_DLL, lsa_fi, &hSecur32, 0, 1, 1, 1);
 
402
    CKRV(SECUR32_DLL);
 
403
 
 
404
#ifndef _WIN64
 
405
    imp_rv = LoadFuncs(KRB524_DLL, k524_fi, &hKrb524, 0, 1, 1, 1);
 
406
    CKRV(KRB524_DLL);
 
407
#endif
 
408
 
 
409
    imp_rv = LoadFuncs(PROFILE_DLL, profile_fi, &hProfile, 0, 1, 0, 0);
 
410
    CKRV(PROFILE_DLL);
 
411
 
 
412
    imp_rv = LoadFuncs(CCAPI_DLL, ccapi_fi, &hCCAPI, 0, 1, 0, 0);
 
413
    /* CCAPI_DLL is optional.  No error check. */
 
414
 
 
415
    memset(&osvi, 0, sizeof(OSVERSIONINFO));
 
416
    osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
 
417
    GetVersionEx(&osvi);
 
418
 
 
419
    // XXX: We should really use feature testing, first
 
420
    // checking for CreateToolhelp32Snapshot.  If that's
 
421
    // not around, we try the psapi stuff.
 
422
    //
 
423
    // Only load LSA functions if on NT/2000/XP
 
424
    if(osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
 
425
    {
 
426
        // Windows 9x
 
427
        imp_rv = LoadFuncs(TOOLHELPDLL, toolhelp_fi, &hToolHelp32, 0, 1, 0, 0);
 
428
        CKRV(TOOLHELPDLL);
 
429
 
 
430
        hPsapi = 0;
 
431
    }             
 
432
    else if(osvi.dwPlatformId == VER_PLATFORM_WIN32_NT)
 
433
    {
 
434
        // Windows NT
 
435
        imp_rv = LoadFuncs(PSAPIDLL, psapi_fi, &hPsapi, 0, 1, 0, 0);
 
436
        CKRV(PSAPIDLL);
 
437
 
 
438
        hToolHelp32 = 0;
 
439
    }
 
440
 
 
441
    AfsAvailable = TRUE; //afscompat_init();
 
442
 
 
443
    return KHM_ERROR_SUCCESS;
 
444
 
 
445
 _err_ret:
 
446
    return KHM_ERROR_NOT_FOUND;
 
447
}
 
448
 
 
449
khm_int32 exit_imports(void) {
 
450
    //afscompat_close();
 
451
 
 
452
    if (hKrb4)
 
453
        FreeLibrary(hKrb4);
 
454
    if (hKrb5)
 
455
        FreeLibrary(hKrb5);
 
456
    if (hProfile)
 
457
        FreeLibrary(hProfile);
 
458
    if (hComErr)
 
459
        FreeLibrary(hComErr);
 
460
    if (hService)
 
461
        FreeLibrary(hService);
 
462
    if (hSecur32)
 
463
        FreeLibrary(hSecur32);
 
464
    if (hKrb524)
 
465
        FreeLibrary(hKrb524);
 
466
    if (hPsapi)
 
467
        FreeLibrary(hPsapi);
 
468
    if (hToolHelp32)
 
469
        FreeLibrary(hToolHelp32);
 
470
 
 
471
    return KHM_ERROR_SUCCESS;
 
472
}
 
473
 
 
474
int (*Lcom_err)(LPSTR,long,LPSTR,...);
 
475
LPSTR (*Lerror_message)(long);
 
476
LPSTR (*Lerror_table_name)(long);
 
477
 
 
478
void Leash_load_com_err_callback(FARPROC ce,
 
479
                                 FARPROC em,
 
480
                                 FARPROC etn)
 
481
{
 
482
    Lcom_err = (int (*)(LPSTR,long,LPSTR,...)) ce;
 
483
    Lerror_message = (LPSTR (*)(long))         em;
 
484
    Lerror_table_name = (LPSTR (*)(long))      etn;
 
485
}