blog.area23.at - a simple url encoder/decoder

 a simple url encoder/decoder
 https://blog.area23.at

Labels

Wirtschaft (156) Pressefreiheit (149) Österreich (125) IT (108) code (69) Staatsschulden (37) EZB (27) Pensionssystem (16) Geopolitik (10)
Posts mit dem Label code werden angezeigt. Alle Posts anzeigen
Posts mit dem Label code werden angezeigt. Alle Posts anzeigen

2025-09-12

Exception handling in C#, Java, C++

C#

In C# Exception is root of all exceptions extends base class System.Exception : ISerializable¹ and differs basically between System.SystemException and System.ApplicationException.
Of course, that are a lot of Exception derived directly from System.Exception.


ExternalException, Win32Exception, WebException, IOException, SocketException and all exceptions thrown during os system operations extend SystemException or it's children.

Java

In Java Throwable (root of all errors & exceptions) extends base class object. Error and Exception both extend from Throwable.

Errors such StackOverflowError (endless recursion), OutOfMemoryError (endless allocation) and VirtualMachineError are thrown, when critical limits of java virtual machine exceeded.

In java some exceptions like IOException or SocketException are "checked at compile time". This does NOT mean, that javac compiler knows when IOException or SocketExcpetion will be thrown at program flow at runtime. Furthermore javac compiler knows if reading from or writing to a file needs catching an IOExceptiuon, because disk might be full or USB stick could be unplugged or fs mount point is now unmounted or remounter ro. When reading from or writing to a socket javac compiler knows, that you must catch a SocketException in case of a linux system init runlevel 1 or 2, unplugging USB network adapter or dog bites CAT5 or CAT7 network cable.

C++

In C++ there is no binary split at the root of "exception tree" as in C# (System Exception &
ApplicationException) or in Java (Error & Exception both extend from Throwable).

In C++ bad_cast, bad_alloc, bad_function_call, logic_error & runtime_error extend from exception.
Most common Exceptions in C++ extend from logic_error & runtime_error.b.


2025-08-09

Is there a way under windows to mount a in exe included disk image at runtime

[ Original question postetd at stackoverflow 
maybe you have an idea how that will work under Windows >= 7 or in any case >= 10

I want to generate an executable, where an disk image is added (linked at compile time) to the exe.

Under linux, it's possible to mount an image with a certain offset

  • mount

    mount -o loop,offset=$((1024 * 512 * 8)) image.raw /mnt

  • losetup

    losetup /dev/loop0 image.raw -o $((1024 * 512 * 8)) mount /dev/loop0 /mnt

  • I wrote a simple shell script, that demonstrates that with the efi boot partition added afterwards to a zero image with 8*512k blocks.

#!/usr/bin/bash
 
BLOCKSIZE=`echo '512  * 1024' | bc`
SEEK=8
OFFSET=$(echo "$BLOCKSIZE * $SEEK" | bc)
 
dd if=/dev/zero of=zero.img bs=512k count=8
cp zero.img offset_disk.img
dd if=/dev/nvme0n1p15 of=offset_disk.img bs=$BLOCKSIZE seek=$SEEK oflag=append
 
mkdir -p /mnt/efi
mount -o loop,offset=$OFFSET offset_disk.img /mnt/efi
du -h -s *.img ; df -h  | grep efi
 
sleep 1 ; umount /mnt/efi ; rm -f zero.img offset_disk.img
exit 0

Output of shell script -x (debug


The creation of the image file added to an executable would not be the problem, because I understand:

How to link a dll or dll embedded resource or image file to an executable with C++ linker

and also C# .Net crossgen2 to produce a big static exe, that needs no Framework anymore

The only problem I have, is how to mount disk / iso9660 image files with a certain offset.