Sunday, 26 December 2021

Writing a Linux UI app - choosing the framework

Gnome and KDE are desktop environments. Ubuntu defaults to Gnome, but you can switch it to KDE.

Gnome was built using GTK. GTK is written in C and had American roots.

KDE was built using Qt, which is written in C++ and had European roots.

GTK & Qt are application frameworks & widget libraries. Both are built on top of Xlib in Linux.

xlib, the X Library, is the lowest-level API of the X Window program. If compared with Windows, Xlib is the same as the Windows APIs (or Windows SDK). It is the programming interface that is closest to X Server. It only provides the most Basic drawing and handling of message events.

When writing apps, you could also use Electron, which is based upon Javascript and NodeJS.

Friday, 24 December 2021

PC boots into Windows after installing Ubuntu

After installing Ubuntu alongside Windows, the PC would boot into Windows without going into Grub first.

This article explains how to solve it.

Saturday, 13 November 2021

Reinstalling Grub on a dual-boot Windows/Ubuntu laptop

I had a Windows/Ubuntu laptop, and I was forced to reinstall Windows.

Windows replaces grub with it's own bootloader.
This article explains how to get it back without having to reinstall anything.

I followed the steps that involved using boot-repair.

"Boot using a live usb/cd of ubuntu. Use boot-repair to fix the problem."

Monday, 20 September 2021

Surface Pro 4 display issues: clear registry cache

From this article - to clear the display cache:

Windows Registry Editor Version 5.00



Saturday, 4 September 2021

HP EliteBook 840 G2 - WiFi keeps turning off

After a reinstall of Windows 10 on my HP EliteBook 840 G2, I found that I could not get the WiFi to work. 

The hardware Wifi button in the top right corner of the laptop was showing white. Whenever I discconect the Ethernet cable you would get the globe symbol in the system tray. If you turned WiFi on from this pop-up, you would see the list of SSIDs and then they would disappear one second later and the WiFi would show disconnected. The fact they appeared showed the adapter was physically working.

The machine dual-booted to Linux and there were no problems there, so this was clearly a Windows [driver] problem.

Nothing was visible in the Event Log.

I ran the network troubleshooter and it said:

Result of diagnosis: Problem found

Root cause:
Wireless capability is turned off

Detailed root cause:
Radio is off (SW switch)

Repair option:
Turn on wireless capability

The correct drivers had been installed.

I had unchecked the "Allow the computer to turn off this device to save power".

I uninstalled the drivers.

I installed the HP Wireless Button Driver.

The WiFI/LAN switching was turned off in the BIOS.

None of this worked.

In the end this post found the problem.

My list of network adapters included a TAP-Windows Adapter. This is deemed to be an ethernet connection. Although you disconnect the physical ethernet connection ("Ethernet" in my list), the Ethernet2 remains virtually "connected". And Windows will not allow both an Ethernet and a Wifi connection to remain active simultaneously, so it turns off your Wifi again. Disabling this allowed the Wifi to work continuously.

Examining the TAP adapter, I could see it was installed by a VPN provider.

Clicking the properties, I could see a setting "Media Status". It defaulted to Always Connected. Setting this to "Application Controlled" meant that the adapter would only be active when the VPN demanded it, thus it would be disabled at other times. This meant that if the physical ethernet was disabled and the VPN was not active, the TAP adapter would be disabled and WiFi would resume. Voila!

Wednesday, 25 August 2021

Visual Studio function address different in watch window from code

 In my code I had:

void function2()


    std::cout << "Malware payload that should never be run!\n";



void (*pFun)() = &function2;

When I inspect pFun it returns the address 

0x0092141f {BufferOverrunExample.exe!function2(void)}

But in the watch window it is

Why the difference?

If we inspect 0x0092141f  in the dissasembly window:

You can see it simply jumps to the same address as shown in the watch window. This is a jump table.


This explains about incremental linking
c++ - Why doesn't VS2015 debugger show the function address correctly in the watch window? - Stack Overflow

"This behavior seems to be because of incremental linking. When it is enabled, the function is assembled in one memory address and another address contains a jump table entry with one jump instruction to the 'real' address. The function is always called by calling the jump table. If you disable incremental linking, the 'detour' via the jump table goes away and also your example case shows just one address.

Everything else seems to show the address to the jump table, but the 'printStuff' and '&printStuff' watch expressions show the actual address where the function code is located."

Linkers & Jump tables

Canary bytes, prologues and epilogues

Stack Guard

Address layout randomisation

CC bytes

Mitigate threats by using Windows 10 security features (Windows 10) - Windows security | Microsoft Docs

Friday, 6 August 2021

Terraform fails to import App Service Plan: ID was missing the `serverfarms` element

 When importing an Azure App Service Plan, using the resource ID copied from Azure Resource Explorer:

terraform import "/subscriptions<mysubscriptionId>/resourceGroups<myresoureegroup>/providers/Microsoft.Web/serverFarms/<myAppServicePlan>"

I got the error:

Error: parsing Resource ID "XXX": ID was missing the `serverfarms` element

Note serverfarms is case sensitive and should all be lower case, wherease Azure Resource Explorer is camelCase.