[Solved] Is there any way to detect than PloP is already loaded?

Started by kDn, March 03, 2010, 08:24:32 AM

Previous topic - Next topic

kDn

If I use that boot order: ntldr -> PloP -> ntldr -> PloP ... all work fine.
But if I try to use: grub4dos -> PloP -> grub4dos -> (Halt system) PloP. I want prevent second call PloP, but I don't know how...
grub4dos have userful feature wich can help to analize byte(s) in memory or another one - locate any string address in the memory. With result I can process different operators depending condition. So question is: what and where can I testing to detect PloP in memory?

Elmar

hi,
when you say "plop is already loaded", then you mean the plop usb driver is loaded, or?

regards
elmar

kDn

Quote from: Elmar on March 03, 2010, 09:46:31 AM
hi,
when you say "plop is already loaded", then you mean the plop usb driver is loaded, or?

regards
elmar

Hello :)
Yes, I mean PLoP Boot Manager 5.0.8 one time loaded normal, and I try found way to prevent its second start (even somebody try to do it).

title PLoP boot Manager
# some conditions to block second start will be putted here...
kernel /boot/plop/plpbt.bin

Elmar

you don't understand me. it makes a difference if you boot from the plop boot manager an internal harddisk or you boot a usb/cd drive.

kDn

Quote from: Elmar on March 03, 2010, 10:49:54 AM
you don't understand me. it makes a difference if you boot from the plop boot manager an internal harddisk or you boot a usb/cd drive.
I have MotherBoard(s) USB2.0 compatible, but with slow boot speed without using PloP. So I use boot variant where boot from USB-FlashDrive (BIOS slow) to USB-FlashDrive (speed up with PloP).

Elmar

ok, so you are booting usb. thats all i wanted to know.

you can check the ram for "PoLPu@" below the 640k memory. if you find it, then plop was started and the usb driver is in the ram.

kDn

Quote from: Elmar on March 03, 2010, 12:32:19 PM
ok, so you are booting usb. thats all i wanted to know.

you can check the ram for "PoLPu@" below the 640k memory. if you find it, then plop was started and the usb driver is in the ram.

Thank you very much. I just test this and found signature on address 0x9ac21 on my computer :)

Icecube

@ Elmar
Is there any sort of alignment for the "PoLPu@" string?
Such as, "it's always on a multiple of 16 bytes."
Or, "it's always on a multiple of 4 bytes."

Elmar

code to check the installed driver



mov eax,"PLoP"
mov ebp,"CHKD"
int 13h
cmp eax,"yes "  ; driver returns "yes "



regards
elmar

kDn

FYI:

This strings were tested on different versions grub4dos, base address 0x3D0*0x200 becouse grub4dos have strings buffer and I don't want read signature from it :)

title Start PloP only once
cat --hex --locate=PoLPu@ (md)0x3D0 0x130 || kernel /boot/plop/plpbt.bin
configfile /menu.lst


title Test PloP loaded
cat --hex --locate=PoLPu@ (md)0x3D0 0x130 && pause  --wait=5 PloP loaded!
configfile /menu.lst


***

Also same strange things appears when I boot grub4dos from PloP (USB:grub4dos-PloP-grub4dos)
Example:
1. I have one HDD and one USB-Flash Drive, so devices shown by command "find" are: (hd0) - USB-Flash and (hd1) - HDD
2. When I start PloP devices are: (hd0) - USB-Flash, (hd1) - none, (hd2) - none, but HDD
3. If I try something like map --harddrives=100 then see: (hd0) - USB-Flash, (hd1) - none, (hd2) - HDD

If I need to remap drives I can use:
map (hd1) (hd0) || map (hd2) (hd0)
map (hd0) (hd1)


but when I need additional checks then I need to use 0.4.5a version grub4dos or more "hard" understood sintax in grub4dos.

checkrange 0x80 read 0x8280 && map (hd1) () || map (hd2) ()
checkrange 0x80 read 0x8280 && map () (hd1)


Why this appears, and where is the bug, in PloP or in grub4dos?

Elmar

Quote from: kDn on March 11, 2010, 07:22:54 AM
Also same strange things appears when I boot grub4dos from PloP (USB:grub4dos-PloP-grub4dos)
Example:
1. I have one HDD and one USB-Flash Drive, so devices shown by command "find" are: (hd0) - USB-Flash and (hd1) - HDD
2. When I start PloP devices are: (hd0) - USB-Flash, (hd1) - none, (hd2) - none, but HDD

this is because your bios has usb support and the bios is adding the usb device as hard disk. when you use now the boot manager usb driver, then it does the same like your bios and is adding the usb device as hard disk. the bios usb device connection does not work any more because plop usb driver has control over the usb controller. to avoid this, the plop usb driver has to search for any usb hard disk that is provided by the bios and handle them in any way.


regards
elmar


ded2007

Quote
this is because your bios has usb support and the bios is adding the usb device as hard disk. when you use now the boot manager usb driver, then it does the same like your bios and is adding the usb device as hard disk. the bios usb device connection does not work any more because plop usb driver has control over the usb controller. to avoid this, the plop usb driver has to search for any usb hard disk that is provided by the bios and handle them in any way.

Let's consider more difficult situation. 2 HDDs with any partitions + 1 Flash.
http://forum.plop.at/index.php/topic,151.0.html
Are "Fantoms" the bug of  PloP or of grub4dos in this case?

Icecube

This doesn't work with NASM:mov eax,"PLoP"
mov ebp,"CHKD"
int 13h
cmp eax,"yes "  ; driver returns "yes "

You need to reverse all the strings:
; Test if PLoP already has booted a CDROM or USB drive
; by checking for the presence of the PLoP INT13 hook
; When PLoP INT13 hook is present, it will return 'yes '
; when called with the following values.

mov eax,'PoLP' ; Reverse of 'PLoP'
mov ebp,'DKHC'  ; Reverse of 'CHKD'
int 13h
cmp eax,' sey'  ; Reverse of 'yes '
jz plop_active

In the attachment (binary and source), you can find a small comboot module for Syslinux (should work in dos too), which tells you if PLoP (INT13 hook) was active before or not.

It currently doesn't support booting a specific entry in your syslinux config file depending on the presence/absence of the PLoP INT13 hook.

Elmar


Icecube

In the attachment, you can find a COM32 for Syslinux (ifplop.c32), which detects if PLoP has booted an USB stick or a CDROM drive (INT13 hook present).

An example of a syslinux.cfg, which shows the possibilities of the ifplop.c32 module:
default plopcheck

# Check for the presence of PLoP (run by default)
#   When PLoP INT13 hook is found, run the first label
#   When PLoP INT13 hook isn't found, run the second label
label plopcheck
    com32 ifplop.c32
    append plop_detected -- plop_not_detected

# When PLoP INT13 hook was found, boot the menu system.
# PLoP can have added USB2.0 speed, so the entries we want to boot
# will be read from disk much faster (supposing that we have a BIOS
# that only supports USB1.1 speed).
label plop_detected
    com32 menu.c32
    append syslinux.cfg

# PLoP INT13 hook wasn't found, so we boot PLoP
label plop_not_detected
    linux plpbt.bin

You need to install Syslinux 3.86 (COM32 modules should match the Syslinux version number).

Icecube

When I boot my USB stick with Syslinux and my ifplop.c32 module:
1. Boot USB stick with Syslinux
2. ifplop.c32 will boot plpbt.bin (no PLoP INT13 active)
3. Select USB option in PLoP
4. Boots USB stick with Syslinux again
5. ifplop.c32 loads menu system

==> works like designed

Now the problem:
1. Boot USB stick with Syslinux
2. ifplop.c32 will boot plpbt.bin (no PLoP INT13 active)
3. Select the partition of USB stick and boot it (not the USB option) in PLoP (PLoP INT13 not active)
4. Boots USB stick with Syslinux again
5. ifplop.c32 loads plpbt.bin again (PLoP INT13 not active)
Loading plpbt.bin ..... ready
==> PLoP hangs (doesn't display menu)

Icecube

Another test:
1. Boot USB stick with Syslinux
2. ifplop.c32 will boot plpbt.bin (no PLoP INT13 active)
3. In PLoP, press ESC to return to previous bootloader (Syslinux)

4. Boots USB stick with Syslinux again
5. ifplop.c32 loads plpbt.bin again (PLoP INT13 not active)
6. PLoP boots completely

I can repeat this steps indefinitely, without any problem.

Any idea why selecting the partiton boot option in PLoP and loading plpbt.bin again afterwards, results in a hang?

Elmar

Quote from: Icecube on June 13, 2010, 17:34:50 PM
Any idea why selecting the partiton boot option in PLoP and loading plpbt.bin again afterwards, results in a hang?

i tried it now  and on my pc it works without any problem.

regards
elmar

Icecube

It hangs in qemu (at least for me):
sudo qemu -boot c -hda /dev/sdf

Elmar

no problem here with qemu. which boot manager version do you use?


Elmar


Icecube

To mimic the method of detecting Plop with grub4dos like done in the ifplop.c32 Syslinux module:

#autoload Plop - with plopbt.bin set to boot from USB on the fly.
/plpbt/bios int=0x13 eax=0x504c6f50 ebp=0x43484b44 > (md)0x300+1 &&  cat --locate="EAX=79657320" (md)0x300+1  || kernel /plpbt/plpbt.bin hiddenusb


You will need a recent version of grub4dos:
http://code.google.com/p/grub4dos-chenall/downloads/list
and the bios module for grub4dos:
http://code.google.com/p/grubutils/downloads/list

Explanation:

/plpbt/bios int=0x13 eax=0x504c6f50 ebp=0x43484b44 > (md)0x300+1
Call BIOS interupt 13h with 'PLoP' in eax and 'CHKD' in ebp and save the result at memory address 0x300 (512 byte 'sector')

cat --locate="EAX=79657320" (md)0x300+1
See if eax returns 'yes ' (by searching the output of the bios command which is stored in the 512 byte sector at 0X300). If this is the case, Plop's USB or CD driver is active.

|| kernel /plpbt/plpbt.bin hiddenusb
If Plop's USB or CD driver is not active, start Plop's USB driver directly.

Edit: link update
See http://www.plop.at/en/bootmanager/plpbt-parameter.html for other parameters to pass to Plop.

ilko_t

Quote from: Elmar on March 11, 2010, 11:48:55 AM
Quote from: kDn on March 11, 2010, 07:22:54 AM
Also same strange things appears when I boot grub4dos from PloP (USB:grub4dos-PloP-grub4dos)
Example:
1. I have one HDD and one USB-Flash Drive, so devices shown by command "find" are: (hd0) - USB-Flash and (hd1) - HDD
2. When I start PloP devices are: (hd0) - USB-Flash, (hd1) - none, (hd2) - none, but HDD

this is because your bios has usb support and the bios is adding the usb device as hard disk. when you use now the boot manager usb driver, then it does the same like your bios and is adding the usb device as hard disk. the bios usb device connection does not work any more because plop usb driver has control over the usb controller. to avoid this, the plop usb driver has to search for any usb hard disk that is provided by the bios and handle them in any way.


regards
elmar


Quote from: Elmar on March 11, 2010, 11:48:55 AMto avoid this, the plop usb driver has to search for any usb hard disk that is provided by the bios and handle them in any way.

Elmar, would consider this quite useful improvement when thinking about a new version?

kDn, Icecube- thanks, very helpful.