Reputation: 1
I am developing a custom authentication package for Windows and encountering an issue where the logon screen displays the error message: "The remote procedure call failed." and the machine shutdown after a short period of time. This happens when I attempt to call a function from another DLL within the LsaApLogonUserEx2 function.
std::this_thread::sleep_for(std::chrono::seconds(10)))
, the logon process works without errors, and I can log into Windows successfully.The purpose of the DLL is to retrieve the user's password from an external resource. I want to perform this operation in the authentication package rather than the credential provider because of my application 's requirement. Can someone explain why does windows display the error message? And is there anyway to achieve my goal?
Here is my code implement the LsaApLogonUserEx2 function:
typedef int(__stdcall* ExportHelperFnType)();
int ExportHelperFunc() {
HMODULE helperDll = LoadLibraryW(L"path to dll.dll");
if (helperDll) {
TRACE("function loaded");
ExportHelperFnType ExportHelperFn = (ExportHelperFnType)GetProcAddress(helperDll, "ExportHelperFn");
TRACE("function loaded: %d", ExportHelperFn);
//function loaded successfully, I'm able to log the function 's address
//but the log just end here, futhermore, no exeption was logged.
try
{
int rs = ExportHelperFn();
return rs;
}
catch (...)
{
TRACE("error");
}
TRACE("done ExportHelperFn with error");
}
return STATUS_SUCCESS;
}
extern "C" NTSTATUS
NTAPI
LsaApLogonUserEx2_Custom(IN PLSA_CLIENT_REQUEST ClientRequest,
IN SECURITY_LOGON_TYPE LogonType,
IN PVOID ProtocolSubmitBuffer,
IN PVOID ClientBufferBase,
IN ULONG SubmitBufferSize,
OUT PVOID* ProfileBuffer,
OUT PULONG ProfileBufferSize,
OUT PLUID LogonId,
OUT PNTSTATUS SubStatus,
OUT PLSA_TOKEN_INFORMATION_TYPE TokenInformationType,
OUT PVOID* TokenInformation,
OUT PUNICODE_STRING* AccountName,
OUT PUNICODE_STRING* AuthenticatingAuthority,
OUT PUNICODE_STRING* MachineName,
OUT PSECPKG_PRIMARY_CRED PrimaryCredentials, /* Not supported yet */
OUT PSECPKG_SUPPLEMENTAL_CRED_ARRAY* SupplementalCredentials)
{
NTSTATUS result = STATUS_SUCCESS;
try
{
//somehow this is not working
result = ExportHelperFunc();
}
catch (...)
{
TRACE("Error ExportHelperFunc: %d", result);
}
//simply call to MSV1_0 logon user function
result = MSV1_0LsaApLogonUserEx2(ClientRequest, LogonType, ProtocolSubmitBuffer, ClientBufferBase, SubmitBufferSize, ProfileBuffer, ProfileBufferSize, LogonId, SubStatus, TokenInformationType, TokenInformation, AccountName, AuthenticatingAuthority, MachineName, PrimaryCredentials, SupplementalCredentials);
return result;
}
I 'm using windows 10 hyper-V machine to test these stubs.
Upvotes: 0
Views: 65