I want to use LsaLookupAuthenticationPackage() to get the Authentication Package for kerberos. he Windows docs tell me that it takes a PHandle which i called lsaHandle, a PLSA_STRING which i called packageNamePointer, and PULONG which I called auth package. I wrote it like this:
LSA_STRING packageName;
LPSTR tempPkgName = const_cast<LPSTR>("ker-beros");
packageName.Length = static_cast<USHORT>(strlen(tempPkgName));
packageName.MaximumLength = packageName.Length+1;
packageName.Buffer = tempPkgName;
PLSA_STRING packageNamePointer = &packageName;
PULONG authPackage;
errorCode = LsaLookupAuthenticationPackage(lsaHandle, packageNamePointer, authPackage);
if(errorCode != SCESTATUS_SUCCESS){
std::cout << LsaNtStatusToWinError(errorCode) << std::endl;
return 1;
}
However I always get a SegFault when calling LsaLookupAuthenticationPackage. I belive it has to do with the PLSA_STRING, as I had a similar problem when, calling LsaRegisterLogonProcess.
A gdb backtrace only gives me this:
#0 0x00007fff641f28f4 in SspiCli!LsaLookupAuthenticationPackage () from C:\Windows\SYSTEM32\sspicli.dll
#1 0x00007ff774f514fe in main () at C:/Users/user/Documents/folder/folder/folder/temp.cpp:38
I tried finding a sspicli.lib to link to, in order to get a better backtrace (if that would even help), but sadly couldn't find anything.
So what I am asking is: Why this code throws a segfault when calling LsaLookup and how would I prevent it?
So what caused the problem, was the
PULONG authPackage;
This is a Pointer to an ULONG, so when I gave it to the method it had an unitialized pointer which caused the segfault. After changing the code to
ULONG authPackage;
errorCode = LsaLookupAuthenticationPackage(lsaHandle, packageNamePointer, &authPackage);
It all worked fine