Skip to content

Commit f8e2eb5

Browse files
committed
Use _dpctl_load_win_dynamic_lib()
1 parent 4e9c685 commit f8e2eb5

File tree

2 files changed

+40
-33
lines changed

2 files changed

+40
-33
lines changed

dpctl-capi/helper/include/dpctl_dynamic_lib_helper.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,13 @@
3333

3434
#elif defined(_WIN32) || defined(_WIN64)
3535

36+
#include "Support/DllExport.h"
37+
3638
#define NOMINMAX
3739
#include <windows.h>
3840

41+
DPCTL_API HMODULE _dpctl_load_win_dynamic_lib(LPCTSTR filename);
42+
3943
#endif // __linux__
4044

4145
#include <cstdint>
@@ -55,7 +59,7 @@ class DynamicLibHelper final
5559
#ifdef __linux__
5660
_handle = dlopen(libName, flag);
5761
#elif defined(_WIN32) || defined(_WIN64)
58-
_handle = LoadLibraryA(libName);
62+
_handle = _dpctl_load_win_dynamic_lib(libName);
5963
#endif
6064
}
6165

dpctl-capi/helper/source/dpctl_dynamic_lib_helper.cpp

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
1-
/* file: service_daal_load_win_dynamic_lib.cpp */
2-
/*******************************************************************************
3-
* Copyright 2021 Intel Corporation
4-
*
5-
* Licensed under the Apache License, Version 2.0 (the "License");
6-
* you may not use this file except in compliance with the License.
7-
* You may obtain a copy of the License at
8-
*
9-
* http://www.apache.org/licenses/LICENSE-2.0
10-
*
11-
* Unless required by applicable law or agreed to in writing, software
12-
* distributed under the License is distributed on an "AS IS" BASIS,
13-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
* See the License for the specific language governing permissions and
15-
* limitations under the License.
16-
*******************************************************************************/
1+
//===-- dpctl_dynamic_lib_helper.cpp - Dynamic library helper -*-C++-*- ===//
2+
//
3+
// Data Parallel Control (dpctl)
4+
//
5+
// Copyright 2020-2021 Intel Corporation
6+
//
7+
// Licensed under the Apache License, Version 2.0 (the "License");
8+
// you may not use this file except in compliance with the License.
9+
// You may obtain a copy of the License at
10+
//
11+
// http://www.apache.org/licenses/LICENSE-2.0
12+
//
13+
// Unless required by applicable law or agreed to in writing, software
14+
// distributed under the License is distributed on an "AS IS" BASIS,
15+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
// See the License for the specific language governing permissions and
17+
// limitations under the License.
18+
//
19+
//===----------------------------------------------------------------------===//
1720

1821
/*
1922
//++
@@ -23,13 +26,13 @@
2326

2427
#if defined(_WIN32) || defined(_WIN64)
2528

26-
#include "services/daal_defines.h"
29+
#include "Support/DllExport.h"
2730
#include <windows.h>
2831

29-
#if !defined(DAAL_CHECK_DLL_SIG)
30-
#define DAAL_LOAD_DLL(name) LoadLibrary(name)
32+
#if !defined(DPCTL_CHECK_DLL_SIG)
33+
#define DPCTL_LOAD_DLL(name) LoadLibrary(name)
3134
#else
32-
#define DAAL_LOAD_DLL(name) _DAALLoadLibrary(name)
35+
#define DPCTL_LOAD_DLL(name) _DPCTLLoadLibrary(name)
3336

3437
#include <stdio.h>
3538
#include <Softpub.h>
@@ -38,7 +41,7 @@
3841

3942
#pragma comment(lib, "Wintrust.lib")
4043

41-
static HMODULE WINAPI _DAALLoadLibrary(LPCTSTR filename)
44+
static HMODULE WINAPI _DPCTLLoadLibrary(LPCTSTR filename)
4245
{
4346
TCHAR PathBuf[MAX_PATH];
4447
DWORD rv;
@@ -57,21 +60,21 @@ static HMODULE WINAPI _DAALLoadLibrary(LPCTSTR filename)
5760
rv1 = SetDllDirectoryA("");
5861
if (0 == rv1)
5962
{
60-
printf("Intel oneDAL FATAL ERROR: Cannot exclude current directory from serch path.\n");
63+
printf("Intel dpctl FATAL ERROR: Cannot exclude current directory from serch path.\n");
6164
return NULL;
6265
}
6366

6467
rv2 = LoadLibraryExA(filename, NULL, DONT_RESOLVE_DLL_REFERENCES);
6568
if (NULL == rv2)
6669
{
67-
printf("Intel oneDAL FATAL ERROR: Cannot find/load library %s.\n", filename);
70+
printf("Intel dpctl FATAL ERROR: Cannot find/load library %s.\n", filename);
6871
return NULL;
6972
}
7073

7174
rv = GetModuleFileNameA(rv2, PathBuf, MAX_PATH);
7275
if (0 == rv)
7376
{
74-
printf("Intel oneDAL FATAL ERROR: Cannot find module %s in memory.\n", filename);
77+
printf("Intel dpctl FATAL ERROR: Cannot find module %s in memory.\n", filename);
7578
return NULL;
7679
}
7780

@@ -118,27 +121,27 @@ static HMODULE WINAPI _DAALLoadLibrary(LPCTSTR filename)
118121
lerr = GetLastError();
119122
if (TRUST_E_NOSIGNATURE == lerr || TRUST_E_SUBJECT_FORM_UNKNOWN == lerr || TRUST_E_PROVIDER_UNKNOWN == lerr)
120123
{
121-
printf("Intel oneDAL FATAL ERROR: %s is not signed.\n", filename);
124+
printf("Intel dpctl FATAL ERROR: %s is not signed.\n", filename);
122125
}
123126
else
124127
{
125-
printf("Intel oneDAL FATAL ERROR: An unknown error occurred trying to verify the signature of the %s.\n", filename);
128+
printf("Intel dpctl FATAL ERROR: An unknown error occurred trying to verify the signature of the %s.\n", filename);
126129
}
127130
break;
128131

129-
case TRUST_E_EXPLICIT_DISTRUST: printf("Intel oneDAL FATAL ERROR: The signature/publisher of %s is disallowed.\n", filename); break;
132+
case TRUST_E_EXPLICIT_DISTRUST: printf("Intel dpctl FATAL ERROR: The signature/publisher of %s is disallowed.\n", filename); break;
130133

131134
case ERROR_SUCCESS: break;
132135

133-
case TRUST_E_SUBJECT_NOT_TRUSTED: printf("Intel oneDAL FATAL ERROR: The signature of %s in not trusted.\n", filename); break;
136+
case TRUST_E_SUBJECT_NOT_TRUSTED: printf("Intel dpctl FATAL ERROR: The signature of %s in not trusted.\n", filename); break;
134137

135138
case CRYPT_E_SECURITY_SETTINGS:
136-
printf("Intel oneDAL FATAL ERROR: %s. The subject hash or publisher was not explicitly trusted and user trust was not allowed "
139+
printf("Intel dpctl FATAL ERROR: %s. The subject hash or publisher was not explicitly trusted and user trust was not allowed "
137140
"(CRYPT_E_SECURITY_SETTINGS).\n",
138141
filename);
139142
break;
140143

141-
default: printf("Intel oneDAL FATAL ERROR: %s. Error code is 0x%x.\n", filename, (unsigned int)sverif); break;
144+
default: printf("Intel dpctl FATAL ERROR: %s. Error code is 0x%x.\n", filename, (unsigned int)sverif); break;
142145
}
143146

144147
pWVTData.dwStateAction = WTD_STATEACTION_CLOSE;
@@ -159,9 +162,9 @@ static HMODULE WINAPI _DAALLoadLibrary(LPCTSTR filename)
159162
}
160163
#endif
161164

162-
DAAL_EXPORT HMODULE _daal_load_win_dynamic_lib(LPCTSTR filename)
165+
DPCTL_API HMODULE _dpctl_load_win_dynamic_lib(LPCTSTR filename)
163166
{
164-
return DAAL_LOAD_DLL(filename);
167+
return DPCTL_LOAD_DLL(filename);
165168
}
166169

167170
#endif // defined(_WIN32) || defined(_WIN64)

0 commit comments

Comments
 (0)