public OSVERSIONINFOEX CreateOsVersionInfoEx( uint majorVersion, uint minorVersion, uint buildNumber, RprnProcessorArchitecture platformId, string csdVersion, ushort servicePackMajor, ushort servicePackMinor, RprnProductSuiteFlags suiteMask, OS_TYPE productType ) { OSVERSIONINFOEX osVersionInfoEx = new OSVERSIONINFOEX(); osVersionInfoEx.OSVersionInfo = new OSVERSIONINFO(); osVersionInfoEx.OSVersionInfo.dwMajorVersion = majorVersion; osVersionInfoEx.OSVersionInfo.dwMinorVersion = minorVersion; osVersionInfoEx.OSVersionInfo.dwBuildNumber = buildNumber; osVersionInfoEx.OSVersionInfo.dwPlatformId = (uint)platformId; //szCSDVersion (256 bytes): A maintenance string for Microsoft Product //Support Services (PSS) use. osVersionInfoEx.OSVersionInfo.szCSDVersion = new ushort[128]; if (csdVersion != null) { Buffer.BlockCopy( Encoding.Unicode.GetBytes(csdVersion), 0, osVersionInfoEx.OSVersionInfo.szCSDVersion, 0, sizeof(ushort) * Math.Min( osVersionInfoEx.OSVersionInfo.szCSDVersion.Length, csdVersion.Length)); } osVersionInfoEx.OSVersionInfo.dwOSVersionInfoSize = (uint)TypeMarshal.GetBlockMemorySize(osVersionInfoEx.OSVersionInfo); osVersionInfoEx.wServicePackMajor = servicePackMajor; osVersionInfoEx.wServicePackMinor = servicePackMinor; osVersionInfoEx.wSuiteMask = (ushort)suiteMask; osVersionInfoEx.wProductType = (byte)productType; osVersionInfoEx.wReserved = 0; return osVersionInfoEx; }
public _NETLOGON_WORKSTATION_INFORMATION CreateNetlogonWorkstationInformation( Level_Values level, string dnsHostName, string siteName, OSVERSIONINFOEX? osVersion, string osName, NrpcWorkstationFlags workstationFlags, uint kerberosSupportedEncryptionTypes) { _NETLOGON_WORKSTATION_INFORMATION netlogonWorkstationInfo = new _NETLOGON_WORKSTATION_INFORMATION(); //TODO: TDI 48704: 3.5.5.3.9 said: //The WkstaBuffer parameter contains one of the following structures, //based on the value of level field. Value Meaning //0x00000001: The WkstaBuffer contains a NETLOGON_DOMAIN_INFO structure. //0x00000002: The WkstaBuffer contains a NETLOGON_LSA_POLICY_INFO structure. // //But in 2.2.1.3.9, //union _NETLOGON_WORKSTATION_INFORMATION { // [case(1)] // PNETLOGON_WORKSTATION_INFO WorkstationInfo; // [case(2)] // PNETLOGON_WORKSTATION_INFO LsaPolicyInfo; //} switch (level) { case Level_Values.NetlogonDomainInfo: netlogonWorkstationInfo.WorkstationInfo = new _NETLOGON_WORKSTATION_INFO[1]; netlogonWorkstationInfo.WorkstationInfo[0] = new _NETLOGON_WORKSTATION_INFO(); netlogonWorkstationInfo.WorkstationInfo[0].DnsHostName = dnsHostName; netlogonWorkstationInfo.WorkstationInfo[0].SiteName = siteName; netlogonWorkstationInfo.WorkstationInfo[0].Dummy1 = null; netlogonWorkstationInfo.WorkstationInfo[0].Dummy2 = null; netlogonWorkstationInfo.WorkstationInfo[0].Dummy3 = null; netlogonWorkstationInfo.WorkstationInfo[0].Dummy4 = null; if (osVersion != null) { const int CSD_VERSION_LENGTH = 256; if (osVersion.Value.OSVersionInfo.szCSDVersion == null) { throw new ArgumentException("szCSDVersion of osVersion cannot be null.", "osVersion"); } if (osVersion.Value.OSVersionInfo.szCSDVersion.Length != CSD_VERSION_LENGTH / sizeof(ushort)) { throw new ArgumentException("Length of szCSDVersion should be 256 bytes.", "osVersion"); } netlogonWorkstationInfo.WorkstationInfo[0].OsVersion = DtypUtility.ToRpcUnicodeString( Encoding.Unicode.GetString(TypeMarshal.ToBytes(osVersion.Value))); } else { netlogonWorkstationInfo.WorkstationInfo[0].OsVersion = DtypUtility.ToRpcUnicodeString(null); } netlogonWorkstationInfo.WorkstationInfo[0].OsName = DtypUtility.ToRpcUnicodeString(osName); netlogonWorkstationInfo.WorkstationInfo[0].DummyString3 = DtypUtility.ToRpcUnicodeString((string)null); netlogonWorkstationInfo.WorkstationInfo[0].DummyString4 = DtypUtility.ToRpcUnicodeString((string)null); netlogonWorkstationInfo.WorkstationInfo[0].WorkstationFlags = (uint)workstationFlags; netlogonWorkstationInfo.WorkstationInfo[0].KerberosSupportedEncryptionTypes = kerberosSupportedEncryptionTypes; netlogonWorkstationInfo.WorkstationInfo[0].DummyLong3 = 0; netlogonWorkstationInfo.WorkstationInfo[0].DummyLong4 = 0; break; case Level_Values.NetlogonLsaPolicyInfo: netlogonWorkstationInfo.LsaPolicyInfo = new _NETLOGON_WORKSTATION_INFO[1]; netlogonWorkstationInfo.LsaPolicyInfo[0] = new _NETLOGON_WORKSTATION_INFO(); netlogonWorkstationInfo.LsaPolicyInfo[0].LsaPolicy = new _NETLOGON_LSA_POLICY_INFO(); netlogonWorkstationInfo.LsaPolicyInfo[0].LsaPolicy.LsaPolicy = new byte[0]; netlogonWorkstationInfo.LsaPolicyInfo[0].LsaPolicy.LsaPolicySize = 0; break; default: throw new ArgumentException("level is invalid.", "level"); } return netlogonWorkstationInfo; }
public NL_IN_CHAIN_SET_CLIENT_ATTRIBUTES CreateNlInChainSetClientAttributes( string clientDnsHostName, OSVERSIONINFOEX? osVersionInfo, string osName) { NL_IN_CHAIN_SET_CLIENT_ATTRIBUTES nlInChainSetClientAttributes = new NL_IN_CHAIN_SET_CLIENT_ATTRIBUTES(); nlInChainSetClientAttributes.V1 = new _NL_IN_CHAIN_SET_CLIENT_ATTRIBUTES_V1(); nlInChainSetClientAttributes.V1.ClientDnsHostName = clientDnsHostName; nlInChainSetClientAttributes.V1.OsName = osName; if (osVersionInfo != null) { nlInChainSetClientAttributes.V1.OsVersionInfo = new _NL_OSVERSIONINFO_V1[1]; nlInChainSetClientAttributes.V1.OsVersionInfo[0].dwBuildNumber = osVersionInfo.Value.OSVersionInfo.dwBuildNumber; nlInChainSetClientAttributes.V1.OsVersionInfo[0].dwMajorVersion = (dwMajorVersion_Values)osVersionInfo.Value.OSVersionInfo.dwMajorVersion; nlInChainSetClientAttributes.V1.OsVersionInfo[0].dwMinorVersion = (dwMinorVersion_Values)osVersionInfo.Value.OSVersionInfo.dwMinorVersion; nlInChainSetClientAttributes.V1.OsVersionInfo[0].dwPlatformId = osVersionInfo.Value.OSVersionInfo.dwPlatformId; nlInChainSetClientAttributes.V1.OsVersionInfo[0].szCSDVersion = osVersionInfo.Value.OSVersionInfo.szCSDVersion; nlInChainSetClientAttributes.V1.OsVersionInfo[0].wProductType = (wProductType_Values)osVersionInfo.Value.wProductType; nlInChainSetClientAttributes.V1.OsVersionInfo[0].wReserved = 0; nlInChainSetClientAttributes.V1.OsVersionInfo[0].wServicePackMajor = osVersionInfo.Value.wServicePackMajor; nlInChainSetClientAttributes.V1.OsVersionInfo[0].wServicePackMinor = osVersionInfo.Value.wServicePackMinor; nlInChainSetClientAttributes.V1.OsVersionInfo[0].wSuiteMask = (wSuiteMask_Values)osVersionInfo.Value.wSuiteMask; nlInChainSetClientAttributes.V1.OsVersionInfo[0].dwOSVersionInfoSize = (uint)TypeMarshal.GetBlockMemorySize(nlInChainSetClientAttributes.V1.OsVersionInfo[0]); } return nlInChainSetClientAttributes; }