<?xml version="1.0" encoding="utf-8"?> 
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
 <title type="text">XGQT's blog: Posts tagged 'windows'</title>
 <link rel="self" href="https://xgqt.gitlab.io/blog/feeds/windows.atom.xml" />
 <link href="https://xgqt.gitlab.io/blog/tags/windows.html" />
 <id>urn:https-xgqt-gitlab-io:-blog-tags-windows-html</id>
 <updated>2023-07-07T22:39:44Z</updated>
 <entry>
  <title type="text">Time hackery in VirtualBox</title>
  <link rel="alternate" href="https://xgqt.gitlab.io/blog/posts/2023/07/08/time-hackery-in-virtualbox/?utm_source=windows&amp;utm_medium=Atom" />
  <id>urn:https-xgqt-gitlab-io:-blog-posts-2023-07-08-time-hackery-in-virtualbox</id>
  <published>2023-07-07T22:39:44Z</published>
  <updated>2023-07-07T22:39:44Z</updated>
  <author>
   <name>Maciej Barć</name></author>
  <content type="html">
&lt;h1 id="unwanted-vdi-present"&gt;Unwanted (VDI) present&lt;/h1&gt;

&lt;p&gt;Recently I was given a task to run a outdated piece of commercial software on a very outdated (in)famous operating system. Unlucky for me on the given VDI (VirtualBox disk image) the so-called &amp;ldquo;Guests Additions&amp;rdquo; that enabled &amp;ldquo;better&amp;rdquo; time synchronization were already installed.&lt;/p&gt;

&lt;h1 id="fighting-vbox-time"&gt;Fighting VBox time&lt;/h1&gt;

&lt;p&gt;So, this is what I had to do to keep the old clock:&lt;/p&gt;

&lt;ul&gt;
 &lt;li&gt;turn off networking card in the virtual machine configuration, because we do not want the system to use NTP or other newt service to get the &amp;ldquo;new&amp;rdquo; time,&lt;/li&gt;
 &lt;li&gt;disable getting the host&amp;rsquo;s clock time: &lt;code&gt;VBoxManage setextradata "WinXP" "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 1&lt;/code&gt;,&lt;/li&gt;
 &lt;li&gt;and&amp;hellip; this magic: &lt;code&gt;VBoxManage modifyvm "WinXP" --biossystemtimeoffset "-341597644449"&lt;/code&gt;, this thing does the very weird thing of telling the virtual machine BIOS how much to set it back in time, the &lt;code&gt;offset&lt;/code&gt; here is total milliseconds between some old date and current date.&lt;/li&gt;&lt;/ul&gt;

&lt;h1 id="getting-the-old-date"&gt;Getting the old date&lt;/h1&gt;

&lt;p&gt;With the Python script snippet below you will get the milliseconds to set back the VirtualBox clock to &lt;code&gt;01.01.2012 01:00&lt;/code&gt;.&lt;/p&gt;

&lt;div class="brush: python"&gt;
 &lt;div class="source"&gt;
  &lt;table class="sourcetable"&gt;
   &lt;tbody&gt;
    &lt;tr&gt;
     &lt;td class="linenos"&gt;
      &lt;div class="linenodiv"&gt;
       &lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;
&lt;span class="normal"&gt;2&lt;/span&gt;
&lt;span class="normal"&gt;3&lt;/span&gt;
&lt;span class="normal"&gt;4&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;
     &lt;td class="code"&gt;
      &lt;div&gt;
       &lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;datetime&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;

&lt;span class="nb"&gt;round&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;strptime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"01.01.2012 01:00"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;%d&lt;/span&gt;&lt;span class="s2"&gt;.%m.%Y %H:%M"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;total_seconds&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;

&lt;/div&gt;</content></entry></feed>