How to prepare the Ubuntu created by Hyper-V to be a Azure IoT Edge device

Create Unbunt VM using Hyper-V quick create

  • Open Hyper-V Manager, select Quick Create

Hyper-V Quick Create

  • Select Ubunto 20.04

Hyper-V Quick Create Ubuntu

Depends on your internet connection, it is going to take awhile

Hyper-V Quick Create Ubuntu Progress Bar

Hyper-V Quick Create Ubuntu Successful

  • Click Edit Settings… Hyper-V Quick Create Ubuntu Successful Give enough disk space (>100GB) to the virtual machine.

  • Connect to the VM

Please follow the instruction on this post to expand the disk in Ubunto the all the disk space just allocated

  • Update all the components.

Most likely when you installed the VM, some of the components are outdated

 sudo apt install update

This will update all components to the latest.

  • Enable SSH server

Sometime you don’t want to connect to the VM using Hyper-V, instead tools like Putty is preferred. In this case, the SSH server needs to be installed on the VM

 sudo apt update
 sudo apt install openssh-server

Once the installation is complete, the SSH service will start automatically. You can verify that SSH is running by typing

 sudo systemctl status ssh

Press q to get back to the command line prompt

Ubunto shipped with Firewall configuration tool called UFW. make sure SSH port is allowed in the Firewall

 sudo ufw allow ssh
  • Register IoT edge device on IoT hub
    • get the connection string information, it will be needed in later step
  • Install on IoT Edge device
    • Ubuntu 20.04
      wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
      sudo dpkg -i packages-microsoft-prod.deb
      rm packages-microsoft-prod.deb
      
  • Install a container engine
    sudo apt-get update; \
    sudo apt-get install moby-engine
    
  • Install IoT Edge runtime
    sudo apt-get update; \
    sudo apt-get install aziot-edge
    
    • to list other versions of IoT Edge and the IoT identity service that are avialble, use the following command
      apt list -a aziot-edge aziot-identity-service
      
    • Provision the device with its cloud identity
      sudo iotedge config mp --connection-string 'PASTE_DEVICE_CONNECTION_STRING_HERE'
      sudo iotedge config apply
      

    If you want to see the configuration file, you can open it

    sudo nano /etc/aziot/config.toml
    

    Verify successful configuration

    • Check to see that the IoT Edge system service is running.
sudo iotedge system status

A successful status response is ok

  • Check the service logs
     sudo iotedge system logs
    
  • use the check tool to verify configuration and connection status of the device
     sudo iotedge check
    
  • view all modules running on the edge device.
    • When the service starts for the first time, you should only see the edgeAgent module running. The edgeAgent modules runs by default and helps to install and start any additional moduels that you deploy to your devicec
      sudo iotedge list
      

    When you create a new IoT edge device, it will display the status code 417 -- The device's deployment configuration is not set in the Azure portal. This status is normal, and means that the device is ready to receive a moduel deployment.


Hack Candy Crush Soda Saga using cheat engine

Candy Crush Soda Saga is a very popular relaxing game. It is a free game for windows 10 user.

It is getting more and more chllenging if you win many games. Some time it is almost imposibble to pass the game without losing games. That is frustrating.

I like to play games, I don’t like to be played by the game

So I started my cheatengine

  • Launch CheatEngine
  • find the process called stritz.exe
    • This is the acual process runs the Candy Crush Soda Saga
  • Using the current number of moves allowed, for example 32
  • first scan
  • make one move, now the number of move is 31
  • next scan 31
  • after few time, you will be able to see 3~4 address show up
    • start with 1*
    • start with 2*
    • start with 2*
    • start with 2*
  • Freeze the value of these addresses, the game will not reduce the number of moves when you make a move.

This way, there is unlimited number of moves for the game. You can crush more candies without worring about our of move.

Update:

The steps described above definitly works. But the address will change slightly for each new game. These steps need to be repeated for each new game. It is not convienient at all.

For each of the address discoved by the previous step, right click the address then select Find out who writes to this address, By doing so, cheat engine will attach a debugger to the application. Then go back to the game and make 1 move. There should be an address of the instruction displayed in the debugger. Here is a list of example addresses:

  • 00B4BD5A
  • 00DCB670
  • 00E8AF96
  • 00DC9F3B

Among all addresses, 00B4BD5A seems the one which actually contains the instruction to reduce the number of moves after each move.

The original code at that address is

mov [edi+38],esi

It seems like the code is trying to move the value in register to another value.

  • mov
  • The mov instruction copies the data item referred to by its second operand (i.e. register contents, memory contents, or a constant value) into the location referred to by its first operand (i.e. a register or memory). While register-to-register moves are possible, direct memory-to-memory moves are not. In cases where memory transfers are desired, the source memory contents must first be loaded into a register, then can be stored to the destination memory address.

Replace with NOP instruction, then any move will not reduce the number of move. and it is consistent game after game.