Pages

Friday, December 9, 2016

PowerShell v2 Convert Hex encoded String to DateTime


In the process of researching an article I stumbled onto a challenge I had not faced yet. The specific information I was working with involved registry values for Micrsoft Excel MRU (Most Recently Used) items. In Windows 7/Office 2010 files opened by Excel get cached in MRU keys as a form of persistence. Without getting too far into the details, I had some values I wanted to know more about, so, I cracked open PowerShell and drilled into the key with this command:
PS H:> cd HKCU:SoftwareMicrosoftOffice14.0ExcelFile MRU
PS HKCU:SoftwareMicrosoftOffice14.0ExcelFile MRU> Get-ItemProperty . | select item 1

Item 1
------
[F00000000][T01CD552EBC494F30][O00000000]*C:UsersWillDocumentsPowershellProjectsEncodingFormat Table.xlsx
Having already researched what these fields are with this document:
Microsoft Office 2007, 2010 – Registry Artifacts
Within Hurlbuts analysis is this tidbit regarding the values located in this key,
In Office 2008, Microsoft added a new feature to MRUs for Excel, PowerPoint, and Word. There is now a header that precedes the path statement in the value.
The header is defined by a bracketed [F00000000]. Following this is a second bracketed data set starting with a "T". The numbers following the T appear to be a date/time stamp of when the document was last opened by the user.
...
This information is saved in a non-standard 64-bit Windows date and time stamp. The typical format in the registry is to store the data in hexadecimal little endian format.
Hmm, I thought, this could be of value, but, I have to port the value to a [DateTime] for it to be of use in PowerShell. In the data listed above, I knew I was interested in the timestamp field: [T01CD552EBC494F30]. I assumed T was meaningless, so, my focus was this: 01CD552EBC494F30.
Checking it out with some simple properties
"01CD552EBC494F30".length
verified it was Hex encoded for starters since it must have at least an even number of characters. The fact that it was 16 characters long (8-bytes) was good as well. So, I began digging around. One particular search result:
Convert Hex value to Int64
suggested the conversion was mindlessly easy:
Dim str As String
Dim resultint64 As Int64
str = TextBox1.Text
resultint64 =Convert.ToInt64(str, 16)
TextBox2.Text = resultint64
Of key interest was the line
resultint64 = Convert.ToInt64(str, 16)
Going with the theory that I could just use PowerShells static method was confirmed when I ran this:
[Convert]::ToInt64("01CD552EBC494F30", 16)
and it returned this:
129853623479390000
Well, that looks right, but, the only way to be sure is to see if I can get a [DateTime] from this somehow. Wondering, on a sheer hunch, if a conversion would handle it via .NET also proved to be a stroke of luck:

[DateTime][Convert]::ToInt64("01CD552EBC494F30", 16)
 Thursday, June 28, 0412 1:05:47 PM

The only weird this is that the year is off. Way off and the hours were not right. I knew the 1600 thing was a Microsoft specific issue, but, could not put my finger on it. A little more digging led me to find this Connect case pointing out it was not only known, but, by design:
datetime 1600 year bug
As noted in the case comments:
This is by design.
You should use the static FromFileTime method to get back your datetime object.
PS C:WindowsSystem32> [datetime]::FromFileTime($ntDate)
Wednesday, May 14, 2008 7:12:30 PM
Casting with [DateTime] will interpret the int64 as ticks.
When I rewrote my command it worked as expected to the second:
[DateTime]::FromFileTime([Convert]::ToInt64("01CD552EBC494F30", 16))
To be more exhaustive on how you can do this from an array, a simple join command can take an 8-character byte array and turn it into a string:
$hexarray = "01","CD","55","2E","BC","49","4F","30"[DateTime]::FromFileTime([Convert]::ToInt64(($hexarray -join ),16)
returns the same value:
Thursday, June 28, 2012 8:05:47 AM
So, as is outlined above, a little understanding can help transform seemingly useless data into useful information.
Read More..

RPi Videolooper Not booting blinking cursor bug fix

VideoLooper 4 (bug fix)!!

Wanted to apologize to everyone for the blinking cursor bug with the newest videolooper. I introduced it without realizing it by over-aggressively shrinking the partition to ease the download. If you have that bug you can download the newest version below, which fixes that. 

Alternatively, you can do the following (Thanks to Anthony Calvano for this) :
SSH in or press Windows key + R at the blinking menu, then you can extend the partition using the directions at "Manually resizing the SD card on Raspberry Pi" located at http://elinux.org/RPi_Resize_Flash_Partitions.



This image is compatible with the A,B,B+, and B 2 versions. 

I have a brand new version of the Raspberry Pi Videolooper that is compatible with the new B V2 and has a bunch of new features that streamline it for easy use.
It can now loop one video seamlessly (without audio though) thanks to a solution from the talented individual over at Curioustechnologist.com (link here). And again thanks to Tim Schwartz as well (link here).

You can download the new image here:

https://onedrive.live.com/redir?resid=e0f17bd2b1ffe81!411&authkey=!AGW37ozZuaeyjDw&ithint=file%2czip

MIRROR: https://mega.co.nz/#!JBcDxLhQ!z41lixcpCS0-zvF2X9SkX-T98Gj5I4m3QIFjXKiZ5p4


For help you can post on the Raspberry Pi subreddit (probably the best way to get fast help) or email me (be forewarned, I respond intermittently and sporadically)

How to set up the looper

  1. Copy this image to an SD card following these directions
  2. If you want to use USB, change usb=0 to usb=1 in looperconfig.txt on the SD card (It is in the boot partition which can be read by Windows and Mac).
  3. If you want to disable the looping autostart to make copying files easier, change autostart=1 to autostart=0 in looperconfig.txt
  4. If you want to change the audio source to 3.5 mm, change audio_source=hdmi to audio_source=local in looperconfig.txt.
  5. If you want to play a seamless video (supports only one for now), convert it according to these directions, put it in the videos folder, and then change seamless=0 to seamless=name-of-your-video.h264 in looperconfig.txt. (NOTE: This video wont have audio so take that into account).
  6. You may also want to expand your filesystem to it your SD card by using sudo raspi-config as detailed here: http://elinux.org/RPi_Resize_Flash_Partitions.
  7. If you arent using a USB (NTFS) put your video files in the /home/pi/videos directory with SFTP or by turning autostart off. Otherwise, put your video files in a directory named videos on the root directory of your USB.
  8. Set your config options and plug it in!

Features

  • NEW: Has an audio_source flag in the config file (audio_source=hdmi,audio_source=local)
  • NEW: Has a seamless flag in the config file (seamless=0,seamless=some-file.h264)
  • NEW: Has a new boot up splash screen
  • NEW: Compatible with the RPi B2 (1 GB RAM version)
  • NEW: Updated all packages (no heartbleed vulnerability, new omxplayer version)
  • Has a config file in the boot directory (looperconfig.txt)
  • Has a autostart flag in the config file (autostart=0,autostart=1)
  • Has a USB flag in the config file (usb=0,usb=1), just set usb=1, then plug a USB (NTFS) with a videos folder on it and boot
  • Only requires 4GB SD card and has a smaller zipped download file
  • Supports all raspberry pi video types (mp4,avi,mkv,mp3,mov,mpg,flv,m4v)
  • Supports subtitles (just put the srt file in the same directory as the videos)
  • Reduces time between videos
  • Allows spaces and special characters in the filename
  • Full screen with a black background and no flicker
  • SSH automatically enabled with user:pi and password:raspberry
  • Allows easy video conversion using ffmpeg (ffmpeg INFILE -sameq OUTFILE)
  • Has a default of HDMI audio output with one quick file change (replace -o hdmi with -o local in startvideos.sh).
  • Can support external HDDs and other directories easily with one quick file change (Change FILES=/home/pi/videos/ to FILES=/YOUR DIRECTORY/ in startvideos.sh)

Source code

The source code can be found on github here. 

This is perfect if you are working on a museum or school exhibit. Dont spend a lot of money and energy on a PC running windows and have problems like below (courtesy of the Atlanta Aquarium)!

If you are a museum or other educationally based program and need help, you can post on the Raspberry Pi subreddit (probably the best way to get fast help) or contact me by e-mail at help@stevenhickson.com

Consider donating to further my tinkering since I do all this and help people out for free.



Places you can find me
Read More..

3DS Max Furniture Modeling Tutorials By Wendy Huther



In These Videos We Will Learn The Basic Steps On How To Create A Furniture In 3DS Max.


SHARE BY GK
Computer Knowledge
Read More..

Wednesday, December 7, 2016

Do you want to live in a Smart City

Stephen Poole in the The Guardian has written a very interesting and thought provoking long article The truth about smart cities: In the end, they will destroy democracy that presents both sides of the vision of the future smart city; the benefits of a highly connected society and infrastructure and the potential pitfalls. With online privacy and data security such hot topics at the moment its certainly easy to see how the smart city of the future could be fraught with dangers. I recommend you read it.




from The Universal Machine http://universal-machine.blogspot.com/

IFTTT

Put the internet to work for you.

Delete or edit this Recipe

Read More..

Tuesday, December 6, 2016

Unity 3D 2D Games Development Tutorial from Beginners BY GameGeek



Unity 3D & 2D Games Development Tutorial from Beginners.

Learn To Code by Making Games : Complete Unity 5 Developer http://bit.ly/1N8Jxkg


SHARE BY GK
Computer Knowledge
Read More..

Safely Eject USB device and prevent malfunctioning

Safely Eject USB device and prevent malfunctioning
Many a times we face a problem while ejecting any USB device. The system displays "Device cannot be removed...bla..bla.." or sometimes the USB device doesnt get detected and the icon is not displayed on the system tray. Even there is no icon in Device Manager Window. Such this happen very often. At these times this software comes handy.

USB Safely Remove :
  • This helps in safely removing the USB device so that next time if you connect it, it doesnot come up with any problem.
  • It ensures the safety of data you are copying from or to the USB device.
  • The software gives full contol over the USB device.
  • USB device can be stopped with a single click.

Download

You can also read this post to solve your problem.
Fix the Problem Ejecting USB Mass Storage Device error.
Read More..

PowerShell v2 Invoke WmiMethod Create a Service

After digging around on the net for a while I did not find any real good posts telling me how to create a service. I know the Win32_Service class has a Create function but I was not sure how to get it syntactically:
Create method of the Win32_Service Class
To give myself something to play with I created a blank C# service project in Visual Studio 2010, compiled the project and got my .exe path.


NOTE: You have to have an executable with service headers or else it wont work.  Trust me, I tried.

So, my first stab at this task involved this command:
cls
[Array]$parms = Dummy,Dummy Service,G:Visual Studio2010Projects4.0DummyServiceDummyService inDebugDummyService.exe,16,2,Automatic,$false,LocalSystem
Invoke-WmiMethod -Class win32_service -name create -ArgumentList $parms
When I ran this command I got this error:
Invoke-WmiMethod : String was not recognized as a valid Boolean. At C:UserswillAppDataLocalTemp8bc972e2-a15c-41ba-bd4f-f4cfbaae9fbe.ps1:3 char:17 + Invoke-WmiMethod <<<< -Class win32_service -name create -ArgumentList $parms + CategoryInfo : NotSpecified: (:) [Invoke-WmiMethod], FormatException + FullyQualifiedErrorId : System.FormatException,Microsoft.PowerShell.Commands.InvokeWmiMethod
which basically told me nothing.  It did however point me to this post:
Invoke-WmiMethod to call "create" method of win32_service not working 
As I read through the post I saw precisely what I ran into, and, it took me a while to run the first few lines to see what jrv was referring to.  The expected order of parameters for the Create method of the class is as follows (Ill use all the commands exactly as I did in my machine):
$computer = "." # this computer
$class = "Win32_Service"
$method = "Create"
$mc = [wmiclass]"$computerROOTCIMV2:$class"
$mc.PSBase.GetMethodParameters($method)

__GENUS : 2
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 12
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
DesktopInteract :
DisplayName :
ErrorControl :
LoadOrderGroup :
LoadOrderGroupDependencies :
Name :
PathName :
ServiceDependencies :
ServiceType :
StartMode :
StartName :
StartPassword :
Now that I see the correct order I was able to come up with these two lines which worked just fine:
$argumentlist = $false, "Dummy", 0, $null, $null, "Dummy Service", "G:Visual Studio2010Projects4.0DummyServiceDummyService inDebugDummyService.exe", $null, 16, "Automatic", $null, $null
Invoke-WmiMethod –Class Win32_Service –Name Create –ArgumentList $argumentlist
As a side note, if you successfully create a service that does not exist you will get this.
Invoke-WmiMethod -Class Win32_Service -Name Create -ArgumentList $argumentlist


__GENUS : 2
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 1
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
ReturnValue : 0
If you try to run it again but the service already exists this is what you will see:
Invoke-WmiMethod -Class Win32_Service -Name Create -ArgumentList $argumentlist


__GENUS : 2
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 1
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
ReturnValue : 23
Read More..