Monday, January 30, 2012

Canadian iPad in the US

I needed a way to get data on a Canadian iPad while traveling to Hawaii. You can buy a micro sim from the carrier (AT&T), activate it with a prepaid US credit card and a US address. The credit card must be a VISA Gift card or similar. They can be bought at Safeway, or corner stores. It is not a VISA debit card that can be bought at Walmart. You can use any US address, such as the one for your hotel. Awesome!

Wednesday, January 11, 2012

Multibooting different WIMs from PXE

I've wondered if I could boot more than one boot.wim using PXE.  It doesn't seem that it would be easy as it looks to be hardcoded.  Thanks to I modified the script to work with my stuff.

@echo off
rem Vista WinPE 2.0 Multi Boot via pxelinux
rem Gerd Hofmann, 2007, modified by Office Broccoli (2012)

rem script depends on:
rem  o gsar    (gnuwin32 utilities)
rem  o editbin (Microsoft Visual Studio 2005 Express)
rem  o bcdedit (Windows Vista Boot Configuration Editor)

setlocal EnableDelayedExpansion
set /p max=Enter the maximum number of PXE configurations:
FOR /l %%a IN (1,1,%max%) DO (
 REM Remove the old files
 rmdir /s /q %%a
 mkdir %%a

 set /p desc=Enter a description for the %%a configuration:
 echo You entered: !desc!

 REM Use gsar to replace "bootmgr.exe" with "bootm_%%a.exe" in pxeboot.0 and %%a\pxebo_%%a.0
 gsar -f -sbootmgr.exe -rbootm_%%a.exe pxeboot.0 %%a\pxebo_%%a.0

        rem "\Boot\BCD":      \     B     o     o     t     \     B     C     D
        rem   ->UNICODE:  00 5c 00 42 00 6f 00 6f 00 74 00 5c 00 42 00 43 00 44
        rem  \BCD --> \Boot_%%a.wim.bcd
 gsar -f -s:x00\:x00B:x00C:x00D -r:x00\:x00B:x00_:x00%%a bootmgr.exe %%a\bootm_%%a.exe
 editbin %%a\bootm_%%a.exe /release

 Bcdedit -createstore %%a\Boot_%%a.wim.bcd
 Bcdedit -store %%a\Boot_%%a.wim.bcd -create {bootmgr} /d "Windows BootManager" 
 Bcdedit -store %%a\Boot_%%a.wim.bcd -set {bootmgr} timeout 30
 bcdedit -store %%a\Boot_%%a.wim.bcd -set {bootmgr} nointegritychecks Yes

 bcdedit -store %%a\Boot_%%a.wim.bcd -create {ramdiskoptions}
 bcdedit -store %%a\Boot_%%a.wim.bcd -set {ramdiskoptions} ramdisksdidevice boot
 bcdedit -store %%a\Boot_%%a.wim.bcd -set {ramdiskoptions} ramdisksdipath \Boot\boot.sdi

 REM Write the GUID to a file
 Bcdedit -store %%a\Boot_%%a.wim.bcd -create /d "!desc!" /application osloader 2>&1 > .\result.txt
 REM Blank the description for next round
 set desc=
 REM Retreive GUID from file
 for /f "tokens=3 delims= " %%i in (result.txt) do (
  for /f "tokens=1 delims={}" %%j in ("%%i") do (
  Bcdedit -store %%a\Boot_%%a.wim.bcd -set {%%j} path \windows\system32\winload.exe
  Bcdedit -store %%a\Boot_%%a.wim.bcd -set {%%j} systemroot \Windows
  Bcdedit -store %%a\Boot_%%a.wim.bcd -set {%%j} detecthal Yes
  Bcdedit -store %%a\Boot_%%a.wim.bcd -set {%%j} winpe Yes
  Bcdedit -store %%a\Boot_%%a.wim.bcd -set {%%j} osdevice ramdisk=[boot]\Boot\x64\Images\boot_%%a.wim,{ramdiskoptions}
  Bcdedit -store %%a\Boot_%%a.wim.bcd -set {%%j} device ramdisk=[boot]\Boot\x64\Images\boot_%%a.wim,{ramdiskoptions}
  Bcdedit -store %%a\Boot_%%a.wim.bcd -displayorder {%%j} -addlast
 del result.txt

After running the script may want to verify the integrity of the BCD file by using bcdedit /store 1\b_1 /enum for example.

Also wrote something to copy the files to the TFTP server.

@echo off
REM Copy boot files to TFTP folder
set /p dest=Enter the full path to the TFTP folder:
set /p max=Enter the maximum number of PXE configurations:

FOR /l %%a IN (1,1,%max%) DO (
 copy /y %%a\b_%%a %dest%\boot
 copy /y %%a\pxebo_%%a.0 %dest%\boot
 copy /y %%a\bootm_%%a.exe %dest%\ 

Edit pxelinuxcfg\default to point to the new configurations.

DEFAULT menu.c32


# Windows BartPE Loader1
 KERNEL startrom.0
 APPEND vga=normal devfs=nomount pxe ramdisk_size=70000 load_ramdisk=1 init=/linuxrc prompt_ramdisk=0 initrd=initrd.gz root=/dev/ram0 rw noacpi noapm pci=noacpi lba acpi=off apm=off

# Windows LiteTouch PE Loader2
 KERNEL /boot/pxebo_1.0

# Windows LiteTouch PE Loader3
LABEL LiteTouch 980-TEST
 KERNEL /boot/pxebo_2.0

Copy the necessary wims into the source folder and rename according to the new format. For example, litetouch64.wim might become boot_1.wim.

Monday, January 9, 2012

TightVNC plugin for BartPE

Had lost the TightVNC files when I overwrote my last install so had to make them from scratch.

With the help of the following site, I cobbled together the basic files.

I had to make some changes to TightVNC.inf to copy screenhooks.dll and tvnserver.exe instead of WinVNC.exe and VNChooks.dll.

Also had to import a bunch of settings from [HKEY_CURRENT_USER\Software\TightVNC\Server] and convert them to the PE INF file.  The server would lose the passwords even though they were configured in software section.

Added the following to TightVNC.inf.

0x1, "Software\TightVNC\Server","ExtraPorts",""
0x4, "Software\TightVNC\Server","QueryTimeout", 0x0000001e
0x4, "Software\TightVNC\Server","QueryAcceptOnTimeout", 0x00000000
0x4, "Software\TightVNC\Server","LocalInputPriorityTimeout", 0x00000003
0x4, "Software\TightVNC\Server","LocalInputPriority", 0x00000000
0x4, "Software\TightVNC\Server","BlockRemoteInput", 0x00000000
0x4, "Software\TightVNC\Server","BlockLocalInput", 0x00000000
0x1, "Software\TightVNC\Server","IpAccessControl",""
0x4, "Software\TightVNC\Server","RfbPort", 0x0000170c
0x4, "Software\TightVNC\Server","HttpPort", 0x000016a8
0x4, "Software\TightVNC\Server","DisconnectAction", 0x00000000
0x4, "Software\TightVNC\Server","AcceptRfbConnections", 0x00000001
0x4, "Software\TightVNC\Server","UseVncAuthentication", 0x00000001
0x4, "Software\TightVNC\Server","UseControlAuthentication", 0x00000000
0x4, "Software\TightVNC\Server","LoopbackOnly", 0x00000000
0x4, "Software\TightVNC\Server","AcceptHttpConnections", 0x00000001
0x4, "Software\TightVNC\Server","LogLevel", 0x00000000
0x4, "Software\TightVNC\Server","EnableFileTransfers", 0x00000001
0x4, "Software\TightVNC\Server","BlankScreen", 0x00000000
0x4, "Software\TightVNC\Server","RemoveWallpaper", 0x00000001
0x4, "Software\TightVNC\Server","EnableUrlParams", 0x00000001
0x3, "Software\TightVNC\Server","Password",\
0x4, "Software\TightVNC\Server","AlwaysShared", 0x00000000
0x4, "Software\TightVNC\Server","NeverShared", 0x00000000
0x4, "Software\TightVNC\Server","DisconnectClients", 0x00000001
0x4, "Software\TightVNC\Server","PollingInterval", 0x000003e8
0x4, "Software\TightVNC\Server","AllowLoopback", 0x00000000
0x4, "Software\TightVNC\Server","VideoRecognitionInterval", 0x00000bb8
0x4, "Software\TightVNC\Server","GrabTransparentWindows", 0x00000001
0x4, "Software\TightVNC\Server","SaveLogToAllUsersPath", 0x00000000
0x4, "Software\TightVNC\Server","RunControlInterface", 0x00000001
0x1, "Software\TightVNC\Server","VideoClasses",""
And it finally works!

XPE plugin won't run in BartPE

I did some bad revision tracking and managed to revert back to XPE 1.0.4 instead of 1.0.7. When I recopiled it using 1.0.7, XPE would not run on startup.  After a day and a half of troubleshooting here is the answer.
1) The autorun0xpe.cmd file must be present in the plugin folder for XPE 1.0.7
2) The entry


Must be in xpe.inf.  This tells the compiler to add this file to the build.