Tag Archive : windows

/ windows

There is a misconception in some community that Windows doesn’t support hard link and symbolic link as in Unix world. Most of us think that Windows OS only support link (with .lnk extension) and I’ve seen that there are also several articles point out that symbolic linking in Unix world is closely resemble to Windows .lnk file.

Though the concept is not very similar, we can say that Windows has three type of linking: hard link, junction, and symbolic link. Before we go through them, let’s give the concept of hard link and symbolic link (soft link).

Links in Unix

In Unix world, symbolic link (also termed as soft link) is a special kind of file that points to another file. Well, hard link too is a special kind of file that points to another file. The difference between two is symbolic link does not contain the data in the target file. It simply points to another entry somewhere in the file system. The difference gives symbolic link certain qualities that hard links does not offer, such as the ability to link to directories, or to files on remote computers network through NFS. When we delete a target file, symbolic links to the file become unusable. Whereas the hard links preserve the contents of the file. So we can say that hard link is essentially a label or another name assigned to a file. Operation executed upon any of these “different names” will be operated upon the original file. When the original file is deleted, the hard link will still persist. You can think it as a reference count.

In Unix, these commands create symbolic link and hard link respectively.

# Symbolic Link
ln -s target link

# Hard Link
ln target link

Concept of Links in Windows

Now let’s go to the Windows world. The definition of hard link and symbolic link is nearly similar.

A hard link is the file system representation of a file by which more than one path references a single file in the same volume.MSDN states that any changes to the file are instantly visible to applications that access it through the hard links that reference it. Changes in the original file will be reflected in every hard link made to that file. Thus, if there are multiple hard link point to a READ-ONLY file and we want to delete a particular hard link, then after delete it we need to reset the READONLY attribute to any of remaining hard link (or original file).

A symbolic link is a file-system object that points to another file system object. The object being pointed to is called the target. They are transparent to users; the links appear as normal file or directories and can be acted upon by the user or application in exactly the same manner.

Then, what is junction?

Junction (Microsoft refer it as soft link) is similar to hard link. Indeed it is a hard link. It differs from a hard link in that the storage object it references are separate directories and a junction can link directories located on different local volumes on the same computer. Otherwise it is identical to hard link.

The Command (Utility)

Hard Link

mklink /H link target

Symbolic Link

# File Symbolic Link
mklink link target

# Directory Symbolic Link
mklink /D link target

Junction

mklink /J link target

Create Link Programmatically

Hard Link: CreateHardLink

Symbolic Link: CreateSymbolicLink

Misc

So what’s the different of these links with .lnk file?

Well we need to see the representation. Links are file system object while the .lnk file is a file. The .lnk file is a file describe the redirection and any extra operation need to perform when it is executed. The links are only redirection to the file.

To feed our brain, NTFS has many advanced options that is unknown to us as end-user.

Why Linux/Unix is Less Infected by Malware?

December 11, 2015 | Article | 1 Comment

Initially I wrote this as a reply to local group discussion with similar question. And then my friend said I should publish my answer as a post. Thanks for the advice, and here is our discussion.

First, what is malware?

Malicious software, is any software used to disrupt computer operation, gather sensitive information, or gain access to certain computer. It can appear in the form of executable code, script, active content, anything. From user perspective, any malware often called as virus but it’s not exactly true. Virus is one malware categories. Malware can be divided into some categories such as computer virus, worm, trojan horse, adware, rootkits etc. If we want to discuss about malware, it can be another topic so let’s limit our discussion to computer virus and worm.

There’s a myth, if you are using Linux you are immune to malware. This is partially true. Viruses and Worms are exists even in Unix world. You can read some list from Wikipedia.

Now, it comes to the real question, why Linux/Unix is less infected by malware? Some people might answer from user demographic (who use Linux and other OS). Personally I don’t choose this answer and rather go to more technical answer.

Please note that this is my own opinion and might be biased.

Distribution

From OS distribution, most operating system used worldwide is still Windows. I pick the statistics from W3schools, Linux and Unix got less than 10% each. Per September 2014, most operating system used are Windows 7.

Linux and Unix mostly used for server, embedded system, devices, etc although quite many people use Linux as their main operating system. As we know one who creating something must have specific goal or purpose. As the OS market share still dominated by Windows then no wonder malware for Windows are keep popping up. Mostly they are targeting users.

If by chance Linux dominating the market share, it should be obvious malware will sprung and targetting linux. This is natural.

The Insides

To determine the answer, first we need to look to inside of both OSs.

Windows

Why Windows sucks?

  1. Windows API – Windows has rich APIs. Some of Windows API (WIN32 API) can be executed by any user. Yes, you got the point. When one user make mistakes, boom! The system is in danger. Also, Windows is famous with its being want to be backward compatible as possible (hence, we have Windows 10 instead of Windows 9) which implicate that you can use that API.
  2. Access Control List – Yes, Windows have ACL. But how many of us knows, or using it? People don’t know and maybe not apply it. Without control, malware can spread freely. Yes, you can use ACL but by default each resource you have is not affected by ACL.
  3. Multiuser Design – Windows have common user and superuser (known as Administrator). But on most system, one user on the system is also a super user.
  4. Device Access – Literally! On some Windows, any program can access any devices connected if you program it. Life is easier.
  5. Registry system – Windows use a huge database for it’s global configuration, known as registry. Like I said in point (1), whoever you are, you can access registry. Also you can change configuration easily, you can even set the autostart entry in registry to call your malware.
  6. Extensions – Most worms used other extension to camouflage. For example, a worm might disguise itself as Word Document program, using the same icon as the Microsoft Word. User can be fooled by this appearance. Also, the extension itself is registered to registry. Windows will look registry and call the appropriate program for this extension.

Linux

Now let’s compare it to Linux.

  1. API – Linux also has API for some operations. But, the operation is guaranteed always complies with Access Control. You can do what you are given. Linux/Unix access control is often called as Discretionary Access Control and it is enforced in the kernel itself. You cannot do something which you are not privileged to.
  2. Access Control – The Discretionary Access Control used by Linux/Unix is describing read/write/execute access to resource (file, directory, nodes, etc). This strict rule is integrated to kernel. Also, as a Linux/Unix user you are always inform to follow Least Privilege principle. Least Privilege principle means any operation you do should be done as low privilege as possible, you might request more privilege if the previous privilege is not sufficient but you should not always use super user privilege. Often some Linux distribution limit yourself from using root access.
  3. Multiuser Design – Linux is multiuser and multitasking. However, Linux make clear separation of each users. Linux have term users and groups to separate system power. On every Linux/Unix system you have a superuser account (root) and you are obligated to create your own user account. Most distribution will enforce you to create and use your own user account. This account however is different with root so you are guaranteed to not harm your system by accident, unless you are doing so.
  4. Device Access – be a network interface, printer, scanner, or any device connected all are managed by kernel by udev or similar mechanism. And the good news is any node has specific privilege.
  5. Registry System – what is registry? Linux/Unix doesn’t know that. To configure a system globally, one should modify config files and most of them stored in privileged directory. Unless you are root or given access to it, you are powerless.
  6. Extensions – Linux recognize file not by extension but by their header. Every file format has header and something we called magic words to distinguish the format and other formats. Even if the extensions are changed, Linux/Unix can know what it is and still give you correct information.

Apart from above comparison, there is one thing extra you should know! Windows executable is using PE (Portable Execution) format while executable format in Linux is ELF (Executable and Linkable Format). So you cannot run Windows program natively, in case you don’t know 🙂

Atmel Studio 6 and Arduino

December 11, 2015 | Article | No Comments

Atmel Studio, formerly known as AVR Studio, is a good development application to create program for Atmel’s processor (Atmel’s AVR and Atmel’s ARM). The 6th version promises to be better, faster, and easier to use than before. Here, we will discuss about the way to set up the platform for the use with Arduino.

In this article, I use:

  1. Windows 8.1 64-bit
  2. Atmel Studio 6.2
  3. Arduino 1.5.8 (BETA)

Our objective:

  1. Successfully create binary file for Arduino
  2. Successfully flash the image to Arduino
  3. Know some of Arduino core library

It is recommended that we install both Atmel Studio and Arduino IDE.

Introduction to Atmel Studio 6

This Integrated Development Platform is a rich feature development platform for developing and debugging Atmel ARM Cortex-M and Atmel AVR microcontroller (MCU) based application.

Atmel Studio 6 is released in 2011 and based on Microsoft Visual Studio. The latest version at the time of writing this article is Atmel Studio 6.2 which can be downloaded from here.

Atmel studio 6 is free of charge and is integrated with the Atmel Software Framework (ASF), a large library of free source code with 1600 ARM and AVR project examples. In summary, what Atmel Studio 6 offers in addition to creating new software for MCU:

  1. Facilitates reuse of existing software and, by doing so, enables design differentiation.
  2. Supports the product development process with easy access to integrated tools and software extensions through Atmel Gallery.
  3. Reduces time to market by providing advanced features, an extensible software eco-system, and powerful debug integration.

Why Switching from Arduino IDE to Atmel Studio 6?

Arduino is a great tools. But, it does so much under the hood that it can actually be quite limiting for experienced programmers. The lacks of compiler warnings and debugging capabilities make life hard when working on advanced projects. And here Atmel Studio comes to the rescue.

Atmel Studio is a huge step up from those limitations. If you have a big project, porting the entire thing to pure C can be a daunting task. Plus, some of those Arduino libraries are just so darn convenient.

So, why not have the best of both worlds? Arduino is basically a wrapper on top of C/C++, technically it’s possible to combine any Arduino sketch or library with your own custom code (and that it is). The trick is in setting up your project properly. Once accomplished, you can keep access to the huge Arduino user-contributed code library, but enjoy all the features of advanced AVR and a real IDE.

Arduino Core Library

Arduino is an open-source physical computing platform based on simple I/O board. Stripped the IDE part, Arduino has a library which consists of seberal things like: EEPROM, Esplora, Ethernet, Firmata, etc. But down to the innermost, Arduino has a set of library known as the Arduino core. This Arduino core is the software library which is compiled to any board of Arduino and make Arduino as Arduino.

The Arduino core can be found at “<ArduinoPath>\hardware\arduino\cores\arduino\” where <ArduinoPath> is the path you install Arduino IDE. Well, if you don’t install Arduino IDE, you can clone it from git

git clone git://github.com/arduino/Arduino

and head to “hardware\arduino\cores\arduino”. You can read the content of Arduino core library in the appendix A below.

In order to build Arduino projects, we need to grab the arduino core library. Normally, the Arduino IDE compiles this for us whenever we compile a sketch. To use it in Atmel Studio we need to compile it first.

Steps:

  1. Open Arduino IDE. Open preferences (File -> Preferences) and check on “compile” next to “Show verbose output during:”.
  2. Make sure Arduino IDE is set to whichever chip you want to use with Atmel Studio.
  3. Compile any example sketch, for example “01.Basics\Blink”. In output window at the bottom of the IDE window you should see information on where the IDE put the temporary build output. It will look something like this: “C:\Users\{Your User}\AppData\Local\Temp\build1249632912679374352.tmp”
  4. Copy the “core.a” file and paste it as “libcore.a” so Atmel Studio (and GCC toolchain) can recognizes it as a standard library.

Converting the Sketch

Now the sketch part. There are two things you can do:

  1. If you are converting an existing sketch called Sketch, open the Sketch.cpp file from temporary build directory in text editor. You can then simply copy-paste the code into AVR Studio project. This file is generated by Arduino from our sketch. Arduino automatically fix the messes for us, for example we can define function anywhere in the sketch but Arduino would make appropriate function prototype for us. This is a solution if you are compiling the sketch via Arduino IDE.
  2. Copy and paste the source code from sketch file into the project’s main .cpp file. You can also copy-paste the source from Arduino .pde sketch. If you do this, you should define the function prototypes by yourself. Adding function prototypes is easy actually. Remember to incluse prototypes for setup() and loop() and then add #include “Arduino.h” to the very beginning.

Compiler and Linker Setup

In this section we will setup the compiler and linker setup for any of our project. Our objective:

  • Define Symbols for compilation, especially F_CPU and Arduino software version.
  • Point additional Include directory.
  • Set some Optimization
  • Set Linker to include our libcore
atmel-arduino
Picture 1

Steps:

  1. Open the Project Properties (Project -> <ProjectName> Properties or press Alt+F7), then click on “Toolchain”. We need to setup a bunch of compiler options here. Select “All Configuration from the Configuration drop-down menu to modify both release and debug configuration at same time.
  2. Click on “Symbols” in the left-hand “AVR/GNU C++ Compiler” dropdown menu (see number 1 on picture 1). We need to tell some symbols to our compiler. To do it, click the green plus icon and then enter the symbol. Here is what you need to enter:
    • F_CPU=16000000L
    • ARDUINO=158
  3. Click on “Directories” in the same C++ Compiler menu (see number 2 on picture 1). We need to add the include directories, the directories that contain our Arduino core code and libraries. For any Arduino project, we’ll need to tell the compiler where to find “Arduino.h” and “pins_arduino.h”. In my case I install Arduino on C:\Arduino so the library should be on “C:\Arduino\hardware\arduino\cores\arduino” and “C:\Arduino\hardware\arduino\variants\standard”.
  4. Click on “Optimization” immediately after “Directories” (see number 3 on picture 1). Choose “Optimize for size” under “Optimization Level”. Add “-fdata-sections” to “other optimization flags” and check the box for “prepare functions for garbage collection”.
  5. Next click on “Miscellaneous” (see number 4 on picture 1). Add “-fno-exceptions” to the “Other flags” field.
  6. Now we will move to the linker. Click on “Libraries” in the left hand “AVR/GNU Linker” dropdown menu (see number 5 on picture 1).
    1. In the Libraries section you should already see an entry for “m” which is the AVR math library. Add an entry called core, which is our libcore.a file that we grabbed earlier.
    2. We also need to tell where to find the libcore.a, so add that directory path under “Library search path”
  7. Click on “Optimization” (see number 6 on picture 1) and check the box for “Garbage Collect unused sections (-Wl,-gc-sections)”. This tells the linker to leave out unused portions of each library, which reduces the final code size.

Build Project

Building process is similar like other project. Hit the “F7” button to build our solution and watch the output window.

AVRDude and Flashing

The instruction in this section is similar to other “Adding ISP Programmer to Atmel Studio”.

Once you have build the project, we need to upload it. We can achieve this using the similar method as the Arduino IDE. Arduino uses the avrdude utility to flash via serial, and we will do the same.

atmel-exttools
picture 2
atmel-exttools2
picture 3

Ignore entries other than Arduino on picture 3.

Steps:

  1. Open External Tools by clicking Tools -> External Tools (see picture 2)
  2. When the window popups, click “Add” (see number 1 on picture 3)
  3. Note which COM port Arduino uses and make the title like “Arduino on COM24” for easy identification (see number 2 on picture 3)
  4. In the “Command field” (see number 3 on picture 3), put the path to avrdude.exe in Arduino installation. For example in my case: “C:\arduino\hardware\tools\avr\bin\avrdude.exe” without the quotes.
  5. In the “Arguments” (see number 4 on picture 3), paste this line.
-CC:\arduino\hardware\tools\avr\etc\avrdude.conf -patmega328p -carduino -P\\.\COM24 -b57600 -D -Uflash:w:"$(ProjectDir)Debug\$(ItemFileName).hex":i

Edit the path to Arduino installation and change the COM port, chip target, and baud rate if necessary.

 

Appendix A: Arduino Core Library files

The Arduino core library is consists of following file:

utility function

Arduino.h
binary.h
main.cpp
new.cpp
new.h
Platform.h
WCharacter.h
WInterrupts.c
WMath.cpp
WString.cpp
WString.h

CDC communication.

CDC.cpp

Human Interface Device (HID) communication.

HID.cpp

Hardware serial, for serial communication capability.

HardwareSerial.cpp
HardwareSerial.h

Internetwork connection.

Client.h
IPAddress.cpp
IPAddress.h
Server.h
udp.h

Printing.

Print.cpp
Print.h
Printable.h

Stream oriented communication

Stream.cpp
Stream.h

USB serial communication.

USBAPI.h
USBCore.cpp
USBCore.h
USBDesc.h

Tone Generator.

Tone.cpp

Wiring project

wiring_analog.c
wiring_digital.c
wiring_private.h
wiring_pulse.c
wiring_shift.c

Installing USBasp Drivers on Windows 8.1

December 11, 2015 | Article | No Comments

When we are dealing with AVR programming, after create the codes in our development machine we should write the code into the device. For this purpose, we need a tool which we called Downloader or Programmer. This tool will “burn” the code into AVR CPU using spesific port.

One popular tool is USBasp (http://www.fischl.de/usbasp/). This tool is a USB in-circuit programmer which consists of an ATMega88 or an AtMega8 and a couple of passive components. In short, we need no special USB controller anymore.

usbaspver2

Sometimes, we might face a problem installing usbasp drivers on Windows 8.1. But, this article will discuss about how to install those drivers.

Precaution

The method described here will require machine to restart. Make sure you have write down the steps before proceeding.

Identify The Problem

The main problem is that Microsoft doesn’t allow us to install drivers which are not ‘digitally signed’ directly (or easily) on Windows Vista and later version (7, 8, and also 8.1). To get around this, we must temporarily disable the signature verification process.

Phase 1: Disable Driver Signature Enforcement

  1. Enter “start screen” and open “PC Settings”
  2. Choose “Update and recovery” option in the left panel.
  3. Choose “Recovery” option in the left panel
  4. Click on “Restart now” button, below the “Advanced startup” section then click “reset” button to begin resetting.
  5. Once machine is restarted, we will face several options which we can choose by pressing F1-F9. Choose F7 for “Disable driver signature enforcement”

Now, the machine will boot with no driver signature enforcement. We can then install the driver to our machine.

Phase 2: USBasp Driver Installation

Download the driver fro Windows from USBasp (http://www.fischl.de/usbasp/). The latest version is version 2011-05-28.zip which can be downloaded here. Read the readme first. Because I use WinAVR version 20100110, i will extract the libusb_0.1.12.1 folder as D:\libusb_0.1.12.1.

Plug the USBasp in to USB port. Windows will try to recognize the device. It should be recognized but it lacks of driver so the process is not finish.

Open “Device Manager” on “Control Panel”. Look for Other devices. We have USBasp device there.

usbasp-step-1

Right click on it and click on “Update Driver Software…”

usbasp-step-2

Click on “Browse my computer for driver software”.

usbasp-step-3

Type the location of folder “D:\libusb_0.1.12.1” and then click “Next”.

usbasp-step-4

Windows will give warning as it can’t verify the publisher of the driver. Just ignore it and select “Install this driver software anyway”

usbasp-step-5

Let the installation proceed and wait until it finish.

usbasp-step-6

Done.

Desktop Experience for Windows Server 2012

December 11, 2015 | Article | No Comments

Windows Server 2012 and Windows 8 are like twins. They have the same core technology but then differs in advance utilization. Windows Server is used for server purpose, however we can still experience Windows 8 on Windows Server 2012. The thing we need to know is Desktop Experience, a feature added by Microsoft for doing so.

In this article we will install additional desktop applications and add several GUI improvements.

After installation, we will have following effects:

  • Application added to the Start Screen:
    • Windows Store
    • Default Programs
    • Windows Media Player
    • Character Map
    • Disk Cleanup
    • Snipping Tool
    • Sound Recorder
    • Math Input Panel
  • Start screen will automatically appear instead of the classic desktop
  • Charms bar (bar on the right side of the screen) with buttons ‘Search’, ‘Start’, ‘Settings’, ‘Share’, and ‘Device’
  • The Settings option of the Charms bar will also have the ‘Change PC Settings’ option which is a Windows 8 version of the Control Panel.
  • The context menu of the classic desktop will have the ‘Personalize’ option added.
  • Applications: Windows Mail, Windows Photo Viewer
  • Services: ActiveX Installer, Offline Files, Windows Image Acquisition (WIA), System Events Broker, Time Broker, WebClient, Still Image Acquisition Events, Microsoft Account Sign-in Assistant
  • Miscelanous: Various screensavers, Ability to burn .iso’s from Windows Explorer, Sync Center in Control Panel, Adobe Flash Player

Steps

Open “Server Manager” and make sure you are on “Dasboard” tab. Click on “Add roles and features”

install-ad-1

Skip the information page by clicking “Next”

Select “Role-based or feature-based installation” as installation type and then click “Next”

install-ad-2

We want to install Desktop Experience feature on local server which is also selected by default so choose “Next”

install-ad-3

Desktop Experience is not a Role so click “Next” to bring ourselves to “Features” page.

Here expand “User Interfaces and Infrastructure” and check the “Desktop Experience”. You will be asked for installation of features required by Desktop Experience so just agreed with it.

desktop-exp

desktop-exp2

At the confirmation page, optionally check the “Restart the destination server automatically if required” checkbox as the Desktop Experience feature will need a restart to complete. You can also manually restart the server after the wizard completed.

desktop-exp3

Once your machine restarted (either you choose automatically or restart it manually) you will see your desktop now has more applications.

One of the problem with Windows Operating System is the narrow-range variety of available filesystem. When using Windows, you are limited to FAT and NTFS family file system. Now, suppose you want to access ext3, reiserfs, or XFS partition on Windows there is no way Windows facilitate this unless you do something. This article will describe the step for doing it using coLinux as tool.

In this article I use following:

  1. Windows 7 32-bit
  2. coLinux 0.7.9
  3. Ubuntu Image 9.04

Note: when this article written (18 January 2014) coLinux can only be used on 32-bit Windows!!

You can try any 32-bit Windows (Vista, 7, 8) but the system tested here is Windows 7 32-bit.

There are some alternative to Ubuntu: Alpine,Debian, Fedora, Gentoo, ArchLinux, Slackware. All of them use kernel 2.6. As the reason for using 9.04 is personal, you can use higher version available.

The Idea Behind

coLinux or cooperative Linux, is a free and open source Linux kernel running on Windows natively. We can say the linux kernel is run alongside Windows on single machine, like a virtual machine does. However the difference is we don’t emulate a machine to do this instead we run the linux kernel itself. Thus it is theoretically much more optimal than using any general purpose PC virtualization software.

So in general, we will do following scenario:

  1. install coLinux on Windows machine
  2. Assure access to disk partition
  3. Export all the mounted file system using samba

Much of the process will use command line interface (cmd.exe) which you should open using administration privilege.

Installation Step

coLinux can be obtained freely from their official site, or go to sourceforge site to download it. The version used here is 0.7.9-linux2.6.33.7. Download the installer and install it in C:\coLinux directory.

Edit the connection settings of the virtual ethernet card installed by the coLinux (It should be listed as “TAP Win32 Adapter V8 (coLinux)”). In the TCP/IP settings, set: IP address to 192.168.37.10 and Subnet Mask to 255.255.255.0

Download Ubuntu 9.04 disk image from sourceforge (listed as Ubuntu-9.04-1gb.7z). Extract the image file (Ubuntu-9.04.ext3.1gb.fs) to C:\coLinux. Note that you should have 7zip to extract this file. Now create a swap (for example 128MB swap) using following command on coLinux:

fsutil file createnew c:\coLinux\swap128.fs 134217728

You should know where the magic number comes 😉

Also make sure you run mkswap in Linux and make sure there is corresponding line in fstab.

Rename the file Ubuntu-9.04.ext3.1gb.fs to ubuntu.fs so we have two files: ubuntu.fs and swap128.fs.

Copy the example.conf to ubuntu.conf and edit it. Alternatively you can copy this text and save it as ubuntu.conf.

#
# This is an example for a configuration file that can
# be passed to colinux-daemon in this manner:
#
#    colinux-daemon @example.conf
#
# Note that you can still prepend or append configuration and 
# boot parameters before and after '@', or you can use more 
# that one '@ to load several settings one after another.
# 
#    colinux-daemon @example.conf @overrider.conf mem=32
#
# Full list of config params is listed in colinux-daemon.txt.

# The default kernel
kernel=vmlinux

# File contains the root file system.
# Download and extract preconfigured file from SF "Images for 2.6".
cobd0="c:\coLinux\ubuntu.fs"

# Swap device, should be an empty file with 128..512MB.
cobd1="c:\coLinux\swap128.fs"

# Tell kernel the name of root device (mostly /dev/cobd0,
# /dev/cobd/0 on Gentoo)
# This parameter will be forward to Linux kernel.
root=/dev/cobd0

# Additional kernel parameters (ro = rootfs mount read only)
ro

# Initrd installs modules into the root file system.
# Need only on first boot.
initrd=initrd.gz

# Maximal memory for linux guest
mem=32

# Select console size, default is 80x25
#cocon=120x40

# Slirp for internet connection (outgoing)
# Inside running coLinux configure eth0 with this static settings:
# ipaddress 10.0.2.15   broadcast  10.0.2.255   netmask 255.255.255.0
# gateway   10.0.2.2    nameserver 10.0.2.3
eth0=slirp

# Tuntap as private network between guest and host on second linux device
eth1=tuntap

# Setup for serial device
#ttys0=COM1,"BAUD=115200 PARITY=n DATA=8 STOP=1 dtr=on rts=on"

# Run an application on colinux start (Sample Xming, a Xserver)
#exec0=C:\Programs\Xming\Xming.exe,":0 -clipboard -multiwindow -ac"

If you copy and edit from example.conf, there are lines you need to change. In the end you should make sure following entries exist:

cobd0=C:\coLinux\ubuntu.fs
cobd1=C:\coLinux\swap128.fs
mem=32
eth0=slirp
eth1=tuntap

Now create ubuntu-start.cmd with following content:

set COLINUX_CONSOLE_FONT=Lucida Console:12
set COLINUX_CONSOLE_EXIT_ON_DETACH=1
colinux-daemon.exe -t nt @ubuntu.conf

Then run ubuntu-start.cmd.

Next we do some configuration. Login as root with default password “root”. You can change the root password if you want.

Run the editor and edit /etc/network/interfaces. Add following:

auto eth1
iface eth1 inet static
address 192.168.37.20
network 192.168.37.0
netmask 255.255.255.0
broadcast 192.168.37.255

Bringing up the eth1 by

ifup eth1

Test the network by pinging from our Linux to Windows. It should work now.

ping 192.168.37.10

Next we do update to install necessary package.

aptitude update
aptitude safe-upgrade
aptitude install samba openssh-server mc
apt-get clean

Open /etc/fuse.conf and remove # at the beginning of the line user_allow_other

Open /etc/ssh/sshd_config and change PermitRootLogin to “no”

Add new user named user1 (or any name you wish) and next we can login to this account via ssh:

adduser user1

But first, we need to reload the SSH server:

/et/init.d/ssh reload

At this point, use SSH client such as putty to check whether you can login to Linux via SSH.

Mount File System

First, search for the partition you want to mount. Let’ say it is \Device\Harddisk1\Partition4

If you have ran ubuntu-start.cmd (the system is running) then halt it before going further.

Edit ubuntu.conf and insert following:

cobd2="\Device\Harddisk1\Partition4"

Then run ubuntu-start.cmd (or halt the previous machine and restart it). Then login as root.

Do following to create a mount point:

mkdir /media/codb2

Then edit /etc/fstab and add following line (assuming my partition is xfs):

/dev/codb2 /media/codb2 xfs defaults 0 0

Then mount it like usual.

mount /media/cobd2

Share via Samba

Give user1 the appropriate privilege. If you want to share a whole file system with user1, you must give read and write permissions.

After setting permission, add the following at the very end of /etc/samba/smb.conf

[my data]
path = /media/cobd2
valid users = user1
read only = no

Next add the user to the password’s database of samba:

smbpasswd -a user1

Then reload the samba

/etc/init.d/samba reload

On Windows, type \\192.168.37.20 and login as user1 using the password generated by smbpasswd.

In every Windows Operating System enabled computer, there is a feature Microsoft offers which is APIPA. APIPA is a DHCP failover mechanism for local networks. With APIPA, DHCP clients can obtain IP addresses when DHCP servers are non-functional or the client couldn’t get the IP from server. APIPA exists in all modern versions of Windows except Windows NT.

When DHCP server fails, APIPA allocates IP addresses in the private range 169.254.0.1 to 169.254.255.254. This range is one of Private Network address (hence the name is Automatic Private IP Address).

The method is tested on Windows 8.1 64 bit. The method is generic one, using configuration of Registry entry.

To do, open registry edition. Before we proceed, please remember that incorrectly editing the registry may severely damage system. You can backup any valued data on your machine before making changes to the registry. You can also use the Last Know Good Configuration startup option if problems are encountered after done this guide.

On Windows Vista onward, you will face User Access Control which ask you whether you grant permission for Registry Editor. Choose yes to proceed.

In Registry Editor, navigate to the following registry key:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters

Now create a DWORD value (32 bit if there is both 32 and 64 bit DWORD value) with following name:

IPAutoconfigurationEnabled

Set the value to 0.

Close the Registry Editor. To make a change, restart the machine.

Service is also known as background process, a program which run in background and similar concept to a Unix daemon. A Windows service must conform to the interface rules and protocols of the Service Control Manager, the component responsible for managing Windows services.

As title suggests, we will discuss about how to manage Windows service using Command Line Interface (CLI) not Graphical User Interface (GUI). Specifically we will use two CLI: command prompt and Windows PowerShell. Using a command prompt, we can invoke two different program to fulfill our need: sc.exe and net.exe.

We will use a fictional service serv.exe registered as serv48 as our example.

All examples are done using Administrator privilege, no user privilege involved.

Get Service Status

Get status from a registered service, such as state (running, paused, suspended, stopped), name, etc.

Using sc (command prompt)

sc query serv48

Sample response:

SERVICE_NAME: serv48
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 1  STOPPED
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0

Using PowerShell

Get-Service mysql56serv48

Sample response:

Status   Name               DisplayName
------   ----               -----------
Stopped  Serv48             serv48

Register New Service

Creates a service entry in the registry and service database. In other word, it register the service to windows service component.

Using sc (command prompt)

sc create serv48 binPath=C:\ImportantApp\serv48d.exe DisplayName=serv48

Using PowerShell

New-Service -name serv48 -binaryPathName C:\ImportantApp\serv48d.exe -displayName serv48

Restart Service

This section will restart a service. Actually, a restart means stopping and starting the same service.

Using sc (command prompt)

sc stop serv48
sc start serv48

Using net (command prompt)

net stop serv48
net start serv48

Using PowerShell

Stop-Service serv48
Start-Service serv48

There is also a single command in Powershell to restart a service:

Restart-Service serv48

Resume Service

Resuming a service after the service is suspended.

Using sc (command prompt)

sc continue serv48

Using net (command prompt)

net continue serv48

Using PowerShell

Resume-Service serv48

Set Service

Change or set state of services with some options.

Using sc (command prompt)

sc config serv48 [option=value]

with options available (and possible value) are:

  • type= own,share,interact,kernel,filesys,rec,adapt
  • start= boot,system,auto,demand,disabled,delayed-auto
  • error= normal,servere,critical,ignore
  • binPath= binary pathname to the .exe file
  • tag= yes,no
  • depend= service it’s depended on, separated by / (forward slash)
  • DisplayName= name used to display the service

Using PowerShell

Set-Service serv48 [-option value]

with options available (and possible value) are:

  • ComputerName – specifies one or more computers, the default is local computer.
  • Description – new description for service which will appear in Computer Management.
  • DisplayName – New display name for the service
  • Name – new service name (in our case: serv48)
  • StartupType – Automatic, Manual, Disabled
  • Status – Running, Stopped, Paused

Start Service

Start a service, change the state from stopped to running.

Using sc (command prompt)

sc start serv48

Using net (command prompt)

net start serv48

Using PowerShell

Start-Service serv48

Stop Service

Stopping a service, change state from running to stopped.

Using sc (command prompt)

sc stop serv48

Using net (command prompt)

net stop serv48

Using PowerShell

Stop-Service

Suspend Service

Also known as pause. Pause a service for a moment until it is resumed.

Using sc (command prompt)

sc pause serv48

Using net (command prompt)

net pause serv48

Using PowerShell

Suspend-Service

Build Apache HTTPD for Windows from Source

December 11, 2015 | Article | No Comments

Apache HTTP Server, commonly referred to as Apache, is a popular web server application. It is notably having a key role in initial growth of World Wide Web. Originally based on the NCSA HTTPd server, development of Apache began in early 1995 after work on the NCSA code stalled. Apache quickly overtook NCSA HTTPd as the dominant HTTP server, and has remained the most popular HTTP server in use since April 1996.

In this article we will bring ourselves to build Apache HTTP Server for Windows. Some material used here are:

    1. Windows 8, 64-bit
    2. Apache HTTPD 2.4.7 (latest per November 28th, 2013)
    3. Windows 8 Platform SDK, February 2003 or later
    4. Microsoft Visual Studio 2010
    5. Perl 5.16.3
    6. awk
    7. nasm 2.11.rc1

Also for material building the Apache

    1. apr, apr-util, apr-iconv
    2. PCRE (Perl Compatible Regular Expressions)
    3. zlib library (optional)
    4. OpenSSL libraries (optional)

You should also provide free disk space at least 200MB when compiling. After installation, Apache needs approximately 80 MB of disk space.

In this article, we will use Visual Studio Command Prompt instead of common Command Prompt.

Instead of compiling to x64 code, we will target the x86 architecture.

Opening Visual Studio Command Prompt

As stated before, we use Visual Studio Command Prompt instead of common Command Prompt. I use Visual Studio 2010 (Visual Studio 10) on Windows 8 64-bit. To activate Visual Studio Command Prompt, there are two methods: search & run Visual Studio Command Prompt from Start Screen, run Command Prompt then execute script to set environment variable.

If you want to use first method, make sure you use Visual Studio Command Prompt for amd64 or 64-bit instead of 32-bit.

If you want to do second method, you can do:

"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" amd64

Here we execute vcvarsall.bat and set the argument to amd64 to obtain necessary environment variables for the toolchain basically.

Grab the Materials

Source code of Apache HTTPD can be downloaded freely from here. Choose the closest mirror for you.

There are two Perl implementation for Windows: Strawberry Perl and ActiveState perl. I leave you to choose which one. Both can be downloaded from here.

Windows Software Developer Kit (SDK) for Windows 8 can be downloaded freely from here. Download the sdksetup.exe then run it. Choose Windows SDK from options available.

AWK is standard feature of most Unix-like operating system. For Windows, there is an alternative: Brian Kernighan’s http://www.cs.princeton.edu/~bwk/btl.mirror/ site has a compiled native Win32 binary, http://www.cs.princeton.edu/~bwk/btl.mirror/awk95.exe which you must save with the name awk.exe (rather than awk95.exe). It should be installed in environment path or known by Visual Studio.

NASM or Netwide Assembler is the assembler targeting x86 family processor. We can download nasm from it’s official site. The latest (version 2.11rc1 per November 28th, 2013) can be downloaded here. The one I use here is nasm-2.11rc1-installer.exe. Make sure nasm can be executed (the path is in the environment path).

APR (Apache Project Runtime) is used for building Apache. The project is a separated project from Apache HTTPD therefore we need to download it manually. Download it here http://apr.apache.org/download.cgi, select the appropriate mirror for you. The three we should download are: apr 1.5, apr-util 1.5.3, apr-iconv 1.2.1. Download the win32 version source code.

Perl Compatible Regular Expressions is regular expression pattern matching using the same syntax and semantics as Perl 5. It can be downloaded from www.pcre.org. The latest version is 8.33 which can be downloaded from ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/.

The zlib library is optional, used for mod_deflate. The current version is 1.2.8 and can be download from http://www.zlib.net/. In this case, the filename is zlib-1.2.8.tar.xz.

OpenSSL libraries is optional, used for mod_ssl and ab.exe with ssl support. You can obtain the OpenSSL for Windows from http://www.openssl.org/source/. Assuming we have downloaded it. In this case, the file name is openssl-1.0.1e.tar.gz.

Pre-Compilation Stage

In this article, I assume awk is installed as C:\Windows\awk.exe which should on the environment path.

Extract the Apache source code. Once it’s extracted we have “httpd-2.4.7” directory (for example: D:\httpd-2.4.7).

Extract the apr package to Apache’s srclib and rename them to apr, apr-iconv, apr-util respectively. Therefore we have three subdirectories apr, apr-iconv, and apr-util inside of “httpd-2.4.7/srclib”.

Extract the PCRE package to Apache’s srclib and rename it to pcre. Therefore we have “httpd-2.4.7/srclib/pcre”.

If you want to include zlib support, extract zlib source code inside Apache’s srclib sub directory and rename the directory to zlib. Therefore, we have “httpd-2.4.7/srclib/zlib”.

If you want to include openssl support, extract openssl source code inside Apache’s srclib sub directory and rename the directory to openssl. Therefore, we have “httpd-2.4.7/srclib/openssl”.

Compilation

The makefile script for Windows is defined as Makefile.win. In this article, we will build all the optional package first, manually.

To compile & build zlib, enter the Apache’s srclib for zlib and invoke the Makefile. Assuming Apache source code is in D:\httpd-2.4.7

cd D:\httpd-2.4.7\srclib\zlib
nmake -f win32\Makefile.msc AS=ml64 LOC="-DASMV -DASMINF -I." OBJA="inffasx64.obj gvmat64.obj inffas8664.obj"
nmake -f win32\Makefile.msc test
copy zlib.lib zlib1.lib

The last command is used to copy zlib.lib as zlib1.lib. We do this because when we compile OpenSSL we need library with this name.

To compile & build openssl, enter the Apache’s srclib for zlib and invoke the Makefile. Assuming Apache source code is in D:\httpd-2.4.7. To prepareOpenSSL to be linked to Apache mod_ssl or the abs.exe project, we can use following commands:

cd D:\httpd-2.4.7\srclib\openssl
perl Configure disable-idea enable-camellia enable-mdc2 enable-zlib VC-WIN64A -ID:\httpd-2.4.7\srclib\zlib -LD:\httpd-2.4.7\srclib\zlib
ms\do_win64a.bat
nmake -f ms\ntdll.mak

The above command configures OpenSSL with Visual C++ Win64 AMD. We disable the IDEA algorithm since this is by default disabled in the pre-distributions and really shouldn’t be missed. If you do however require this then go ahead and remove disable-idea.

Because we use OpenSSL 1.0.1e, we should invoke following command:

echo. > inc32\openssl\store.h

Now go to the top level directory of our Apache HTTPD source code. We will invoke the makefile to build Apache HTTPD.

nmake /f Makefile.win installr

Finally compile and install HTTPd, you can specify INSTDIR= to specify a path of where to install HTTPd as well. You can also specify database bindings by adding DBD_LIST=”mysql sqlite” etc. Also as it points out, don’t forget to add the libraries and includes from the databases to the INCLUDE and LIB

Microsoft SQL Server, also called as SQL Server only, is a relational database management system (rdbms) developed by Microsoft. It is used to store and retrieve data as requested by other software applications, be it those on the same computer or those running on another computer across a network (including the Internet). SQL Server use structured query language (SQL), technically they are T-SQL and ANSI SQL.

Some applications are likely high-coupled with Microsoft SQL Server. In simple term, they are works with SQL Server around. This is normal for Windows applications.

In this article we will discuss about how to install Microsoft SQL Server 2012 on Windows Server 2012. SQL Server 2012 has four editions: Enterprise, Standard, Developer, and Express edition. We will use Microsoft SQL Server 2012 Developer edition. This edition only suitable for development process. However this is enough, as the installation process is roughly same for any edition.

Another Extra Info

SQL Server Standard and Enterprise Edition usually used for production, while Developer Edition used for development. If we use one of them, we can also install another tool set beside SQL Server DBMS, for example: SQL Server Reporting Service, SQL Server Analysis Service, and SQL Server Integration Service.

Stage 1: Add New Username to Active Directory

If you have installed Active Directory, you should add new username in your active Directory. This username is used for SQL Server and also this step is always done if you want to create a bigger service such as SharePoint. The username for SQL Service is service and different with other username, so we will create it to new Organizational Unit (OU). Let name it as WINDEV (My machine’s NetBIOS name) so our username would be WINDEV\SQL_Service.

Open “Start screen” and choose “Active Directory Users and Computers“. Right click to your domain controller, in my case it is “windev.xathrya.id”. Navigate to New > Organizational Unit. Then create the name you prefer.

create-new-ou

create-new-ou-2

Then, create new user under WINDEV, SQL_Service

create-new-user

Click Next and set the password. Don’t forget to uncheck “User must change the password at next logon” and check “Password never expires”.

Stage 2: SQL Server Installation

If you have the DVD, insert it to tray. If you have the ISO, mount it. Either way, you should have opened and see a setup executable file. Run it and wait until the installation window appears.

sql-server-1

Click on “Installation” on left pane. Then, click on “New SQL Server stand-alone installation or add features to an existing one”. Wait for next page.

sql-server-2

SQL Server installer will do some checks. It will be decided whether your machine is fulfilling the prerequisites or not for installation.

sql-server-3

Next, enter the product key. As said before, we are using SQL Server 2012 Developer Edition.

sql-server-4

The next screen prompts us to accept the license terms. We can also opt to send anonymous feature usage data to Microsoft. It is recommended to do this as Microsoft actually uses this data to qualify and prioritize future development efforts.

sql-server-5

SQL Server also checks for updates. However we can exclude the update for now.

sql-server-6

Setup then checks for conditions that may interfere with the installation of setup support files:

sql-server-7

On above window, I would install the SQL Server on same machine as my Domain Controller. In the real world, actually we don’t do this. We have separate machine for Domain Controller and SQL Server.

Next select the setup role in the installation process. We choose “All Features With Defaults,”

sql-server-8

Click next to continue to the Feature Selection. The content would be populated based on our machine. We also install it to default path, so we won’t lay our finger there.

sql-server-9

Setup next checks installation rules.

sql-server-10

Next we determine the instance ID. This is the ID for SQL Server in our machine. It should be unique if it is used in production level when more than one SQL Server is used. In our case, we are only using it for developing so we won’t mess with it.

sql-server-11

Setup will calculate the disk space. Roughly 7GB is required when we install all the features (default features).

Next we do service account configurations. We use WINDEV\SQL_Service for all account, and remember to set the password.

sql-server-12

Database engine configuration includes Authentication Mode and SQL Server Administrators. You can accept the defaults if you want. We use Mixed Mode Authentication (combined with very strong passwords) for my installations. Clicking the Add Current User button adds me to the SQL Server administrators

sql-server-13

Next we have Analysis Services setup. I mostly work with Tabular Model these days. As before, I click the “Add Current User” button to add this account to the Administrators:

sql-server-14

Accept the defaults for Reporting Services configuration:

sql-server-15

Click on “Add Current User” button.

sql-server-16

Give DRC (Distributed Replay Client) a name. In this case, I use XathWinServ2012Sql:

sql-server-17

Next we have Error Reporting page. Just click on Next.

Then, Installation configuration rules are checked for consistency and readiness.

sql-server-18

Next we will be presented by a confirmation page. When you decided to accept the configuration, click Install to begin installation.

sql-server-19

Installation will take some times. You should grab some food or doing something else.

sql-server-20

When the process come to end, it’s time to celebrate it. You have installed the SQL Server 2012.

sql-server-21

Social media & sharing icons powered by UltimatelySocial