Возникли проблемы в динамическом подключении библиотеки Visual studio 2005.
Объявление в *.h
Код:
#pragma comment(lib, "advapi32")
typedef BOOL (WINAPI *tConvertSidToStringSid)(PSID,LPTSTR *);
tConvertSidToStringSid pConvertSidToStringSid = 0;
typedef BOOL (__cdecl *tConvertSecurityDescriptorToStringSecurityDescriptor)(PSECURITY_DESCRIPTOR, DWORD, SECURITY_INFORMATION, LPTSTR *, PULONG *);
tConvertSecurityDescriptorToStringSecurityDescriptor pConvertSecurityDescriptorToStringSecurityDescriptor = 0;
*.cpp
Код:
int main( int argc, char *argv[] )
{
PSECURITY_DESCRIPTOR pSecurityDescriptor = NULL;
DWORD pRequestedStringSDRevision = NULL;
SECURITY_INFORMATION pSecurityInformation = NULL;
LPTSTR pStringSecurityDescriptor = NULL;
PULONG pStringSecurityDescriptorLen= NULL;
PSID userSID = {0};
LPTSTR chSID = NULL;
//Loading ConvertSidToStringSid
HINSTANCE handle1 = ::LoadLibrary((LPCSTR)("Advapi32.dll"));
if (handle1 == NULL)
{
cout << "Не удалось подгрузить handl1" << endl;
return -1;
}
pConvertSidToStringSid = (tConvertSidToStringSid) ::GetProcAddress(handle1, "ConvertSidToStringSid");
if (pConvertSidToStringSid)
{
pConvertSidToStringSid(&userSID, &chSID);
}
HINSTANCE handle2 = ::LoadLibrary((LPCSTR)("Advapi32.dll"));
if (handle2 == NULL)
{
cout << "Не удалось подгрузить handl2" << endl;
return -1;
}
// Loading ConvertSecurityDescriptorToStringSecurityDescriptor
pConvertSecurityDescriptorToStringSecurityDescriptor = (tConvertSecurityDescriptorToStringSecurityDescriptor) ::GetProcAddress(handle2, "ConvertSecurityDescriptorToStringSecurityDescriptor");
if (pConvertSecurityDescriptorToStringSecurityDescriptor)
{
pConvertSecurityDescriptorToStringSecurityDescriptor(pSecurityDescriptor,
pRequestedStringSDRevision,
pSecurityInformation,
&pStringSecurityDescriptor,
&pStringSecurityDescriptorLen);
}
setlocale(LC_ALL, "Russian");
::FreeLibrary(handle1);
::FreeLibrary(handle2);
return 0;
}
ругается на
Код:
if (pConvertSecurityDescriptorToStringSecurityDescriptor(
*pSS,
SDDL_REVISION_1, //уровень ревизии выходной строки ( 99,9% случаев SDDL_REVISION_1)
DACL_SECURITY_INFORMATION | //битовые маски тех параметров дескриптора,
SACL_SECURITY_INFORMATION | //которые мы желаем увидеть в строке
OWNER_SECURITY_INFORMATION |
GROUP_SECURITY_INFORMATION /*|
LABEL_SECURITY_INFORMATION*/,
&StringSid, //Непосредственно результирующая строка
&sizeofString) == 0) //и ее размер
output:
Код:
1>Compiling...
1>SecureDiscr.cpp
1>.\SecureDiscr.cpp(937) : error C2664: 'BOOL (PSECURITY_DESCRIPTOR,DWORD,SECURITY_INFORMATION,LPTSTR *,PULONG *)' : cannot convert parameter 5 from 'ULONG *' to 'PULONG *'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>.\SecureDiscr.cpp(937) : error C2664: 'BOOL (PSECURITY_DESCRIPTOR,DWORD,SECURITY_INFORMATION,LPTSTR *,PULONG *)' : cannot convert parameter 4 from 'int' to 'LPTSTR *'
1> Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
1>.\SecureDiscr.cpp(937) : error C2664: 'BOOL (PSECURITY_DESCRIPTOR,DWORD,SECURITY_INFORMATION,LPTSTR *,PULONG *)' : cannot convert parameter 2 from 'LPTSTR *' to 'DWORD'
1> There is no context in which this conversion is possible
1>Build log was saved at "file://c:\Users\Тутанхамон\Documents\Visual Studio 2005\Projects\SD_convertor_2\SD_convertor_2\Debug\BuildLog.htm"
1>SD_convertor_2 - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========