KseSetDeviceFlags

INT64 __stdcall KseSetDeviceFlags(WCHAR *DeviceId, WCHAR *DeviceClass, UINT64 DeviceFlags){
  int v4; 
  wchar_t *Buffer; 
  WCHAR v6; 
  UINT64 DataSize; 
  UNICODE_STRING TargetString; 
  struct _UNICODE_STRING DestinationString; 
  UINT64 Data; 
  HANDLE Handle; 
  Data = DeviceFlags;
  *(_QWORD *)&TargetString.Length = 0i64;
  TargetString.Buffer = 0i64;
  Handle = 0i64;
  *(_QWORD *)&DestinationString.Length = 0i64;
  DestinationString.Buffer = 0i64;
  if( dword_140C50324 != 2 || (*(_BYTE *)KseEngine & 2) != 0 )
  {
    v4 = -1073741823;
  }
  else if( DeviceId && DeviceClass )
  {
    v4 = KsepStringTransform(&TargetString, DeviceId);
    if( v4 < 0 )
      goto LABEL_15;
    Buffer = TargetString.Buffer;
    v4 = KsepRegistryCreateKey(
           (WCHAR *)L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Compatibility\\Device",
           TargetString.Buffer,
           &Handle);
    if( v4 == -1073741772 )
    {
      v4 = KsepRegistryCreateKey(
             (WCHAR *)L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Compatibility",
             (WCHAR *)L"Device",
             &Handle);
      if( v4 < 0 )
        goto LABEL_15;
      if( Handle )
      {
        ZwClose(Handle);
        _InterlockedIncrement(&dword_140C2A7FC);
        Buffer = TargetString.Buffer;
      }
      Handle = 0i64;
      v4 = KsepRegistryCreateKey(
             (WCHAR *)L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Compatibility\\Device",
             Buffer,
             &Handle);
    }
    if( v4 >= 0 )
    {
      RtlInitUnicodeString(&DestinationString, DeviceClass, v6);
      LODWORD(DataSize) = 8;
      v4 = ZwSetValueKey(Handle, &DestinationString, 0i64, 0xBui64, &Data, DataSize);
    }
  }
  else
  {
    v4 = -1073741811;
  }
LABEL_15:
  KsepStringFree(&TargetString);
  if( Handle )
  {
    ZwClose(Handle);
    _InterlockedIncrement(&dword_140C2A7FC);
  }
  return(unsigned int)v4;
}

Referenced by:

No references.