It has been a few years since I've worked with C++, so I'm having some difficulty with these casts.
The goal of this code is to pass lpPassword into CreateProcessWithLogonW successfully. The CreateProcessWithLogonW function takes LPCWSTR lpPassword as a parameter. However, I'm dealing with a std::string initially and need to get it to a LPCWSTR.
So far, I have :
When I printf, the all the password text comes out as it should, but when I pass the value to the Logon function, the logon fails. If I simply pass the Logon function the following then it works:
const WCHAR *lpPassword = L"password";
I think I need some way to tell the compiler that I'm dealing with a long pointer, but not sure how?
Thanks.
The goal of this code is to pass lpPassword into CreateProcessWithLogonW successfully. The CreateProcessWithLogonW function takes LPCWSTR lpPassword as a parameter. However, I'm dealing with a std::string initially and need to get it to a LPCWSTR.
So far, I have :
Code:
std::string input="encrypted_password_text.."
std::string output; // decrypted password
Encryptor * e = NULL;
e = new Encryptor();
e->DecryptString(input, output);
const char* lpPasswordTmp = output.c_str();
const WCHAR * lpPassword = (LPCWSTR) lpPasswordTmp;
printf("%s", lpPassword); // decrypted password
delete e;
e = NULL;
When I printf, the all the password text comes out as it should, but when I pass the value to the Logon function, the logon fails. If I simply pass the Logon function the following then it works:
const WCHAR *lpPassword = L"password";
I think I need some way to tell the compiler that I'm dealing with a long pointer, but not sure how?
Thanks.