Возможно, более эффективный маршрут должен был бы сериализировать использование BinaryFormatter
, Как скопировано от http://blog.paranoidferret.com/index.php/2007/04/27/csharp-tutorial-serialize-objects-to-a-file/
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
public class Serializer
{
public Serializer()
{
}
public void SerializeObject(string filename,
ObjectToSerialize objectToSerialize)
{
Stream stream = File.Open(filename, FileMode.Create);
BinaryFormatter bFormatter = new BinaryFormatter();
bFormatter.Serialize(stream, objectToSerialize);
stream.Close();
}
public ObjectToSerialize DeSerializeObject(string filename)
{
ObjectToSerialize objectToSerialize;
Stream stream = File.Open(filename, FileMode.Open);
BinaryFormatter bFormatter = new BinaryFormatter();
objectToSerialize =
(ObjectToSerialize)bFormatter.Deserialize(stream);
stream.Close();
return objectToSerialize;
}
}
It is flushing the TLBs (Translation Lookaside Buffers) by loading cr3 with itself.
Intel even mentions the code in their "Intel 64 and IA-32 Architectures Software Develoment Manual Volume 3A - System Programming Guide".
mov EAX,CR3 ; invalidate the TLB
mov CR3,EAX ; by copying CR3 to itself
You can find that and many more handy manuals at: