About the magic number of PE - portable-executable

0x10b : PE32 executable
0×107 : ROM image
0x20b : PE32+ (64 bit) executable
What is the ROM image?

Interesting question, I've dabbled with manipulating PE files but never noticed that.
Here's what I believe they are used for: A ROM image can be executed 'in place' (XIP), if you search MSDN for "rom image", you'll find a number of references to it in the Windows Mobile and older Windows CE tools, e.g. Rom Image Creation.
A ROM image can thus be executed directly from the ROM without having to load and relocate it in RAM, which is pretty handy for a mobile device with limited resources.

Related

development board is shown as external storage device when connected in windows

so when I connect my development board (NUCLEO-f446re) to my laptop , everything is working normally , but there is only one thing that confuses me , see the next picture
windows recognize my development board as external storage device with 1.52 MB size (partition named NODE_F446RE(E:))
when I open it , the next image show what I see
there is only 2 files there , the .HTM file takes me to this link and the .TXT file has the follow content:
Version: V2J40M27
Build: May 5 2022 13:16:48
so I don't understand what does this mean ?, like what does 1.5MB storage represent in my MCU even though , the flash size of my MCU is only 512 KB which is way less than the shown storage , also what happens if I put any .exe file in that partition ?
From the web page you link (emphasis by me):
USB re-enumeration capability: three different interfaces supported on USB
Virtual Com port
Mass storage (USB Disk drive) for drag'n'drop programming
Debug port
Your board offers the option to program your application. Simply drap and drop the bin (binary) file of the application into this drive.
It is "just" a virtual drive, the software behind it does the flashing for you, if it receives a binary file.
Why the size of the drive is bigger than the available flash memory, is not clear. Perhaps to allow for necessary overhead to mimic a file system, and to have room for the files you see.
If you copy an exe file in it, I'd expect some kind of error message. Or that the file will not be stored. Experiment!
This functionality is perhaps not well documented, but is part of the "Mbed Enabled" functionality. It is a feature of the Mbed bootloader, to allow "drag'n'drop programming" via a "fake" mass storage device in order to avoid the need for special programming tools or protocols.
You can write to the device, but the "file" will not appear in the filesystem, rather the content will be used to program the on-chip flash memory.
The files on the fake drive are read-only - mbed.htm will open in a browser and take you to the Mbed sign-up/login where you can start developing using Mbed. details.txt contains details of the mbed firmware pre-loaded on the board.
At one time the Mbed on-line/in-browser IDE lacked hardware programming and debug capability, so this feature was the primary means of programming Mbed boards, and debugging was painful. I believe all that has changed now and the feature is perhaps less important in development.
https://os.mbed.com/platforms/ST-Nucleo-F446RE/

How to setup OpenCL in Cygwin for Intel GPU

I have a Laptop with Intel(R) HD Graphics 520 GPU in it. I added OpenCL developer package to Cygwin. I have found a small Mandelbrot-set calculator program for OpenCL in C on GitHub. It is for Apple, so I modified the Makefile to use the proper headers and settings for gcc. Now the code compiles and executes nicely (bmp file created):
$ ./mandelbrot.exe
Device 0: GenuineIntel pthread-Intel(R) Core(TM) i5-6300U CPU # 2.40GHz
I have two questions:
#1. How can I add (if it is possible) the Intel GPU to the /etc/OpenCL/vendors list? I tried to install from Intel site the Intel CPU runtime for OpenCL Applications for Windows OS and Intel Graphics Technology driver package, but I do not know where can I find the proper OpenCL dll I can point in the intel.idc file.
#2. In /etc/OpenCL/vendors I have found a pocl.icd file pointing to cygpocl-2.dll. I assume this is the pthread library. But it seems to me it is running only a single thread, although I have 4 cores. Should I do any modification to run it in multiple threads? I debugged the code and it seems that as there are only one device found, so it runs only on one thread. In the initialization function it sets the device_work_size property for processing a stirp per device of the final bmp. But as there is only one device, the whole bmp is processed by one run (one clEnqueueNDRangeKernel and one clEnqueueReadBuffer is called).
UPDATE
I have installed Intel(R) Graphics – Windows* DCH Drivers. It installed graphics drivers. I have found the intelocl64.dll (as /cygdrive/c/Program Files (x86)/Common Files/Intel/Shared Libraries/intel64/intelocl64.dll). I put this whole path into /etc/OpenCL/vendors/intel.icd file. So far, so good. Now it cannot even find pthread device... Bah...
I don't think it is possible to use the GPU from cygwin. I would recommend to either build a native Windows binary (e.g. with Visual Studio or Intel DPC++) or use WSL. See https://github.com/intel/compute-runtime/blob/master/WSL.md for requirements.

What is the image base (in windows PE files)

I read the documentation about the PE format on MSDN, there it specifies:
The preferred address of the first byte of image when loaded into memory; must be a multiple of 64 K. The default for DLLs is 0x10000000. The default for Windows CE EXEs is 0x00010000. The default for Windows NT, Windows 2000, Windows XP, Windows 95, Windows 98, and Windows Me is 0x00400000
I don't quite understand this. What is a "preferred address"? How is this field used by windows when making a new process/loading an executable?
It is the address in virtual memory where the executable should be loaded at to avoid any adjustment of absolute jump instructions in the code.
The OS may load the module to a different address (in case e.g. 2 DLLs needed by the same program have the same image base), but in that case the code needs to be patched when loaded.
For more info, see https://msdn.microsoft.com/en-us/library/ms809762.aspx (search for ImageBase there).

Simple bootloader for running Linux kernel on a simulator

We have built a simple instruction set simulator for the sparc v8 processor. The model consists of a v8 processor, a main memory and a character input and a character output device. Currently I am able to run simple user-level programs on this simulator which are built using a cross compiler and placed in the modeled main memory directly.
I am trying to get a linux kernel to run on this simulator by building a simplest bootloader. (I'm considering uClinux which is made for mmu-less systems). The uncompressed kernel and the filesystem are both assumed to be present in the main memory itself, and all that my bootloader has to do is pass the relevant information to the kernel and make a jump to the start of the kernel code. I have no experience in OS development or porting linux.
I have the following questions :
What is this bare minimum information that a bootloader has to supply to the kernel ?
How to pass this information?
How to point the kernel to use my custom input/output devices?
There is some documentation available for porting linux to ARM boards, and from this documentation, it seems that the bootloader passes information about the size of RAM etc
via a data structure called ATAGS. How is it done in the case of a Sparc processor? I could not find much documentation for Sparc on the internet. There exists a linux bootloader for the Leon3 implementation of Sparc v8, but I could not find the specific information I was looking for in its code.
I will be grateful for any links that explain the bare minimum information to be passed to a kernel and how to pass it.
Thanks,
-neha

vmware image windows 7 cannot initialize winring0 dll?

I've a vmware image with windows 7 and a program needs winring0 dll but when I start the program I get the error message: I cannot initialize winring0 dll but my program works in native Windows 7? Is this a known problem with a vmware image? How can I initialize winring0 in vmware image? In my folder there is winring0 dll for 32 bit and 64 bit.
Basically, you are attempting to find information about your hardware on virtual hardware. This concept alone is likely to be full of problems.
VMware utilizes Binary Translation(See here) to execute privileged instructions in the kernel if your processor does not support VT-x (assuming intel) . It is quite possible that it was unable to properly translate the file when attempting to load, due to the fact that the dll very well may contain instructions that vmware was not built to translate, or non-virtualizable instructions, at which point it would fail to initialize. If your processor does support hypervisor assist technology (VT-x or Pacifica), further research may be required. See Here for a high level of overview of how VMware works.
Finally, as a last ditch attempt, the dll may require that it load into a specific memory address which conflicts with VMware memory spaces, at which point it would fail to initialize as well. Like said, being inside of vmware increases the complexity of this problem.
Check out the following two links :-
http://www.techpowerup.com/realtemp/docs.php
http://openlibsys.org/
RealTemp is a CPU temperature monitoring application that uses the winring0.dll library distributed by openlibsys.org. It doesn't look like the library will run without actual Intel or AMD processors to act on.
Again, VMWare might be passing through these registers but I doubt it. What software are you trying to run?

Resources