Changeset 35581 in vbox
- Timestamp:
- Jan 17, 2011 12:21:28 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 69471
- Location:
- trunk/src/VBox/Additions/WINNT/VBoxCredProv
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxCredProv/VBoxCredential.cpp
r33595 r35581 696 696 UNREFERENCED_PARAMETER(pcpsiOptionalStatusIcon); 697 697 698 KERB_INTERACTIVE_LOGON kil; 699 ZeroMemory(&kil, sizeof(kil)); 698 KERB_INTERACTIVE_UNLOCK_LOGON kiul; 699 ZeroMemory(&kiul, sizeof(kiul)); 700 701 /* Save a pointer to the interactive logon struct. */ 702 KERB_INTERACTIVE_LOGON* pkil = &kiul.Logon; 703 AssertPtr(pkil); 700 704 701 705 HRESULT hr; … … 707 711 /* Is a domain name missing? Then use the name of the local computer. */ 708 712 if (NULL == m_rgFieldStrings [SFI_DOMAINNAME]) 709 hr = UnicodeStringInitWithString(wszComputerName, & kil.LogonDomainName);713 hr = UnicodeStringInitWithString(wszComputerName, &pkil->LogonDomainName); 710 714 else 711 715 hr = UnicodeStringInitWithString(m_rgFieldStrings [SFI_DOMAINNAME], 712 & kil.LogonDomainName);716 &pkil->LogonDomainName); 713 717 714 718 /* Fill in the username and password. */ 715 719 if (SUCCEEDED(hr)) 716 720 { 717 hr = UnicodeStringInitWithString(m_rgFieldStrings[SFI_USERNAME], & kil.UserName);721 hr = UnicodeStringInitWithString(m_rgFieldStrings[SFI_USERNAME], &pkil->UserName); 718 722 if (SUCCEEDED(hr)) 719 723 { 720 hr = UnicodeStringInitWithString(m_rgFieldStrings[SFI_PASSWORD], & kil.Password);724 hr = UnicodeStringInitWithString(m_rgFieldStrings[SFI_PASSWORD], &pkil->Password); 721 725 if (SUCCEEDED(hr)) 722 726 { 723 /* Allocate copies of, and package, the strings in a binary blob. */ 724 kil.MessageType = KerbInteractiveLogon; 725 hr = KerbInteractiveLogonPack(kil, 726 &pcpCredentialSerialization->rgbSerialization, 727 &pcpCredentialSerialization->cbSerialization); 727 /* Set credential type according to current usage scenario. */ 728 AssertPtr(pkil); 729 switch (m_cpUS) 730 { 731 case CPUS_UNLOCK_WORKSTATION: 732 pkil->MessageType = KerbWorkstationUnlockLogon; 733 break; 734 735 case CPUS_LOGON: 736 pkil->MessageType = KerbInteractiveLogon; 737 break; 738 739 case CPUS_CREDUI: 740 pkil->MessageType = (KERB_LOGON_SUBMIT_TYPE)0; /* No message type required here. */ 741 break; 742 743 default: 744 hr = E_FAIL; 745 break; 746 } 747 748 if (SUCCEEDED(hr)) 749 { 750 /* Allocate copies of, and package, the strings in a binary blob. */ 751 hr = KerbInteractiveUnlockLogonPack(kiul, 752 &pcpCredentialSerialization->rgbSerialization, 753 &pcpCredentialSerialization->cbSerialization); 754 } 728 755 if (SUCCEEDED(hr)) 729 756 { -
trunk/src/VBox/Additions/WINNT/VBoxCredProv/helpers.cpp
r33540 r35581 170 170 171 171 // 172 // WinLogon and LSA consume "packed" KERB_INTERACTIVE_ LOGONs. In these, the PWSTR members of each172 // WinLogon and LSA consume "packed" KERB_INTERACTIVE_UNLOCK_LOGONs. In these, the PWSTR members of each 173 173 // UNICODE_STRING are not actually pointers but byte offsets into the overall buffer represented 174 // by the packed KERB_INTERACTIVE_ LOGON. For example:175 // 176 // kil.LogonDomainName.Length = 14-> Length is in bytes, not characters177 // kil.LogonDomainName.Buffer = sizeof(KERB_INTERACTIVE_LOGON) -> LogonDomainName begins immediately178 // after the KERB_... struct in the buffer179 // kil.UserName.Length = 10180 // kil.UserName.Buffer = sizeof(KERB_INTERACTIVE_LOGON) + 14 -> UNICODE_STRINGS are NOT null-terminated181 // 182 // kil.Password.Length = 16183 // kil.Password.Buffer = sizeof(KERB_INTERACTIVE_LOGON) + 14 + 10174 // by the packed KERB_INTERACTIVE_UNLOCK_LOGON. For example: 175 // 176 // rkiulIn.Logon.LogonDomainName.Length = 14 -> Length is in bytes, not characters 177 // rkiulIn.Logon.LogonDomainName.Buffer = sizeof(KERB_INTERACTIVE_UNLOCK_LOGON) -> LogonDomainName begins immediately 178 // after the KERB_... struct in the buffer 179 // rkiulIn.Logon.UserName.Length = 10 180 // rkiulIn.Logon.UserName.Buffer = sizeof(KERB_INTERACTIVE_UNLOCK_LOGON) + 14 -> UNICODE_STRINGS are NOT null-terminated 181 // 182 // rkiulIn.Logon.Password.Length = 16 183 // rkiulIn.Logon.Password.Buffer = sizeof(KERB_INTERACTIVE_UNLOCK_LOGON) + 14 + 10 184 184 // 185 185 // There's more information on this at: 186 186 // http://msdn.microsoft.com/msdnmag/issues/05/06/SecurityBriefs/#void 187 187 // 188 189 HRESULT KerbInteractiveLogonPack( 190 const KERB_INTERACTIVE_LOGON& rkil, 191 BYTE** prgb, 192 DWORD* pcb 193 ) 194 { 195 HRESULT hr; 188 HRESULT KerbInteractiveUnlockLogonPack( 189 const KERB_INTERACTIVE_UNLOCK_LOGON& rkiulIn, 190 BYTE** prgb, 191 DWORD* pcb 192 ) 193 { 194 HRESULT hr; 195 196 const KERB_INTERACTIVE_LOGON* pkilIn = &rkiulIn.Logon; 196 197 197 198 // alloc space for struct plus extra for the three strings 198 DWORD cb = sizeof(rki l) +199 rkil.LogonDomainName.Length +200 rkil.UserName.Length +201 rkil.Password.Length;202 203 KERB_INTERACTIVE_ LOGON* pkil = (KERB_INTERACTIVE_LOGON*)CoTaskMemAlloc(cb);204 205 if (pki l)206 { 207 pkil->MessageType = rkil.MessageType;199 DWORD cb = sizeof(rkiulIn) + 200 pkilIn->LogonDomainName.Length + 201 pkilIn->UserName.Length + 202 pkilIn->Password.Length; 203 204 KERB_INTERACTIVE_UNLOCK_LOGON* pkiulOut = (KERB_INTERACTIVE_UNLOCK_LOGON*)CoTaskMemAlloc(cb); 205 206 if (pkiulOut) 207 { 208 ZeroMemory(&pkiulOut->LogonId, sizeof(LUID)); 208 209 209 210 // 210 211 // point pbBuffer at the beginning of the extra space 211 212 // 212 BYTE* pbBuffer = (BYTE*)pkil + sizeof(KERB_INTERACTIVE_LOGON); 213 BYTE* pbBuffer = (BYTE*)pkiulOut + sizeof(*pkiulOut); 214 215 // 216 // set up the Logon structure within the KERB_INTERACTIVE_UNLOCK_LOGON 217 // 218 KERB_INTERACTIVE_LOGON* pkilOut = &pkiulOut->Logon; 219 220 pkilOut->MessageType = pkilIn->MessageType; 213 221 214 222 // … … 217 225 // advance buffer pointer over copied characters in extra space 218 226 // 219 _UnicodeStringPackedUnicodeStringCopy( rkil.LogonDomainName, (PWSTR)pbBuffer, &pkil->LogonDomainName);220 pkil ->LogonDomainName.Buffer = (PWSTR)(pbBuffer - (BYTE*)pkil);221 pbBuffer += pkil ->LogonDomainName.Length;222 223 _UnicodeStringPackedUnicodeStringCopy( rkil.UserName, (PWSTR)pbBuffer, &pkil->UserName);224 pkil ->UserName.Buffer = (PWSTR)(pbBuffer - (BYTE*)pkil);225 pbBuffer += pkil ->UserName.Length;226 227 _UnicodeStringPackedUnicodeStringCopy( rkil.Password, (PWSTR)pbBuffer, &pkil->Password);228 pkil ->Password.Buffer = (PWSTR)(pbBuffer - (BYTE*)pkil);229 230 *prgb = (BYTE*)pki l;227 _UnicodeStringPackedUnicodeStringCopy(pkilIn->LogonDomainName, (PWSTR)pbBuffer, &pkilOut->LogonDomainName); 228 pkilOut->LogonDomainName.Buffer = (PWSTR)(pbBuffer - (BYTE*)pkiulOut); 229 pbBuffer += pkilOut->LogonDomainName.Length; 230 231 _UnicodeStringPackedUnicodeStringCopy(pkilIn->UserName, (PWSTR)pbBuffer, &pkilOut->UserName); 232 pkilOut->UserName.Buffer = (PWSTR)(pbBuffer - (BYTE*)pkiulOut); 233 pbBuffer += pkilOut->UserName.Length; 234 235 _UnicodeStringPackedUnicodeStringCopy(pkilIn->Password, (PWSTR)pbBuffer, &pkilOut->Password); 236 pkilOut->Password.Buffer = (PWSTR)(pbBuffer - (BYTE*)pkiulOut); 237 238 *prgb = (BYTE*)pkiulOut; 231 239 *pcb = cb; 232 240 … … 246 254 // memory space boundary is not going to work -- repack it if necessary! 247 255 // 248 // 249 // Unpack a KERB_INTERACTIVE_UNLOCK_LOGON *in place*. That is, reset the Buffers from being offsets to 250 // being real pointers. This means, of course, that passing the resultant struct across any sort of 251 // memory space boundary is not going to work -- repack it if necessary! 252 // 253 void KerbInteractiveLogonUnpackInPlace( 256 void KerbInteractiveUnlockLogonUnpackInPlace( 254 257 __inout_bcount(cb) KERB_INTERACTIVE_UNLOCK_LOGON* pkiul 255 258 ) -
trunk/src/VBox/Additions/WINNT/VBoxCredProv/helpers.h
r33540 r35581 44 44 45 45 //packages the credentials into the buffer that the system expects 46 HRESULT KerbInteractive LogonPack(47 const KERB_INTERACTIVE_ LOGON& rkil,46 HRESULT KerbInteractiveUnlockLogonPack( 47 const KERB_INTERACTIVE_UNLOCK_LOGON& rkiulIn, 48 48 BYTE** prgb, 49 49 DWORD* pcb … … 51 51 52 52 //unpacks the "packed" version of the creds in-place into the "unpacked" version 53 void KerbInteractive LogonUnpackInPlace(53 void KerbInteractiveUnlockLogonUnpackInPlace( 54 54 KERB_INTERACTIVE_UNLOCK_LOGON* pkiul 55 55 ); 56 57 56 58 57 //get the authentication package that will be used for our logon attempt … … 60 59 ULONG * pulAuthPackage 61 60 ); 61
Note:
See TracChangeset
for help on using the changeset viewer.