Esempio n. 1
0
int main1()
{

	//foo();
	//return 0;



	//RegSetKeySecurity(NULL,NULL,NULL);
	Persona admin(WinBuiltinAdministratorsSid);
	//HKEY hkey;
	//DWORD psdsize = 1;
	LPCTSTR keys[2];
	int num = sizeof(keys) / sizeof(*keys);

	keys[0] =  REG_SCRIPTING;
	keys[1] =  REG_WMI;

	wprintf(L"Administrators group SID: [%s]\n", admin.getSidString());
	wprintf(L"Key: [%s]  Owner: [%s]\n", REG_SCRIPTING, getOwnerString(HKEY_CLASSES_ROOT, REG_SCRIPTING));
	wprintf(L"Key: [%s]  Owner: [%s]\n", REG_WMI, getOwnerString(HKEY_CLASSES_ROOT, REG_WMI));

	TakeOwnership((LPTSTR)REG_SCRIPTING_FULL);
	TakeOwnership((LPTSTR)REG_WMI_FULL);
	TakeOwnershipNoRelection((LPTSTR)REG_WMI_FULL);

	//TakeOwnership(L"HKEY_CLASSES_ROOT\\CLSID\\{730F6CDC-2C86-11D2-8773-92E220524153}");


	TakeOwnership(L"HKEY_CLASSES_ROOT\\CLSID\\AAAAA");
	TakeOwnershipNoRelection(L"HKEY_CLASSES_ROOT\\CLSID\\AAAAA");
	TakeOwnership(L"HKEY_LOCAL_MACHINE\\SOFTWARE\\Elf");
	return 0;
}
Esempio n. 2
0
// |plugin| must not be null.  The caller takes ownership of the result, except
// when it is null (at the end of the stream).  No transfer of ownership of
// |*plugin|.  |*serializer| must be null on the first call and must be passed
// unchanged to the successive calls; its ownership is not transferred.
char const* principia__SerializePlugin(Plugin const* const plugin,
                                       PullSerializer** const serializer) {
  journal::Method<journal::SerializePlugin> m({plugin, serializer},
                                              {serializer});
  LOG(INFO) << __FUNCTION__;
  CHECK_NOTNULL(plugin);
  CHECK_NOTNULL(serializer);

  // Create and start a serializer if the caller didn't provide one.
  if (*serializer == nullptr) {
    *serializer = new PullSerializer(chunk_size, number_of_chunks);
    auto message = make_not_null_unique<serialization::Plugin>();
    plugin->WriteToMessage(message.get());
    (*serializer)->Start(std::move(message));
  }

  // Pull a chunk.
  Bytes bytes;
  bytes = (*serializer)->Pull();

  // If this is the end of the serialization, delete the serializer and return a
  // nullptr.
  if (bytes.size == 0) {
    TakeOwnership(serializer);
    return m.Return(nullptr);
  }

  // Convert to hexadecimal and return to the client.
  std::int64_t const hexadecimal_size = (bytes.size << 1) + 1;
  UniqueBytes hexadecimal(hexadecimal_size);
  HexadecimalEncode(bytes, hexadecimal.get());
  hexadecimal.data.get()[hexadecimal_size - 1] = '\0';
  return m.Return(reinterpret_cast<char const*>(hexadecimal.data.release()));
}
Esempio n. 3
0
// |navigation_frame| must not be null.  No transfer of ownership of
// |*navigation_frame|, takes ownership of |**navigation_frame|, nulls
// |*navigation_frame|.
void principia__SetPlottingFrame(Plugin* const plugin,
                                 NavigationFrame** const navigation_frame) {
  journal::Method<journal::SetPlottingFrame> m({plugin, navigation_frame},
                                               {navigation_frame});
  CHECK_NOTNULL(plugin);
  plugin->SetPlottingFrame(TakeOwnership(navigation_frame));
  return m.Return();
}
Esempio n. 4
0
void DeletePlugin(Plugin const** const plugin) {
  LOG(INFO) << "Destroying Principia plugin";
  // We want to log before and after destroying the plugin since it is a pretty
  // significant event, so we take ownership inside a block.
  {
    TakeOwnership(plugin);
  }
  LOG(INFO) << "Plugin destroyed";
}
Esempio n. 5
0
// Deletes and nulls |*plugin|.
// |plugin| must not be null.  No transfer of ownership of |*plugin|, takes
// ownership of |**plugin|.
void principia__DeletePlugin(Plugin const** const plugin) {
  CHECK_NOTNULL(plugin);
  journal::Method<journal::DeletePlugin> m({plugin}, {plugin});
  LOG(INFO) << "Destroying Principia plugin";
  // We want to log before and after destroying the plugin since it is a pretty
  // significant event, so we take ownership inside a block.
  {
    TakeOwnership(plugin);
  }
  LOG(INFO) << "Plugin destroyed";
  return m.Return();
}
Esempio n. 6
0
// The caller takes ownership of |**plugin| when it is not null.  No transfer of
// ownership of |*serialization| or |**deserializer|.  |*deserializer| and
// |*plugin| must be null on the first call and must be passed unchanged to the
// successive calls.  The caller must perform an extra call with
// |serialization_size| set to 0 to indicate the end of the input stream.  When
// this last call returns, |*plugin| is not null and may be used by the caller.
void principia__DeserializePlugin(char const* const serialization,
                                  int const serialization_size,
                                  PushDeserializer** const deserializer,
                                  Plugin const** const plugin) {
  journal::Method<journal::DeserializePlugin> m({serialization,
                                                 serialization_size,
                                                 deserializer,
                                                 plugin},
                                                {deserializer, plugin});
  LOG(INFO) << __FUNCTION__;
  CHECK_NOTNULL(serialization);
  CHECK_NOTNULL(deserializer);
  CHECK_NOTNULL(plugin);

  // Create and start a deserializer if the caller didn't provide one.
  if (*deserializer == nullptr) {
    *deserializer = new PushDeserializer(chunk_size, number_of_chunks);
    auto message = make_not_null_unique<serialization::Plugin>();
    (*deserializer)->Start(
        std::move(message),
        [plugin](google::protobuf::Message const& message) {
          *plugin = Plugin::ReadFromMessage(
              static_cast<serialization::Plugin const&>(message)).release();
        });
  }

  // Decode the hexadecimal representation.
  uint8_t const* const hexadecimal =
      reinterpret_cast<uint8_t const*>(serialization);
  int const hexadecimal_size = serialization_size;
  int const byte_size = hexadecimal_size >> 1;
  // Ownership of the following pointer is transfered to the deserializer using
  // the callback to |Push|.
  std::uint8_t* bytes = new uint8_t[byte_size];
  HexadecimalDecode({hexadecimal, hexadecimal_size}, {bytes, byte_size});

  // Push the data, taking ownership of it.
  (*deserializer)->Push(Bytes(&bytes[0], byte_size),
                        [bytes]() { delete[] bytes; });

  // If the data was empty, delete the deserializer.  This ensures that
  // |*plugin| is filled.
  if (byte_size == 0) {
    TakeOwnership(deserializer);
  }
  return m.Return();
}
Esempio n. 7
0
 TIterator3 & operator = (TIterator3 const & other)
 {
   TakeOwnership(other);
   return *this;
 }
Esempio n. 8
0
void DeleteLineAndIterator(LineAndIterator const** const line_and_iterator) {
  TakeOwnership(line_and_iterator);
}
Esempio n. 9
0
void DeleteRenderingFrame(RenderingFrame const** const frame) {
  TakeOwnership(frame);
}
Esempio n. 10
0
void
BMT_SetNormalFileAttribs (std::wstring file)
{
  SetFileAttributes (file.c_str (), FILE_ATTRIBUTE_NORMAL);
  TakeOwnership     ((LPWSTR)file.c_str ());
}
Esempio n. 11
0
void principia__IteratorDelete(Iterator** const iterator) {
  journal::Method<journal::IteratorDelete> m({iterator}, {iterator});
  TakeOwnership(iterator);
  return m.Return();
}