Jump to content











Photo
- - - - -

Variables like ?_BOOT & @ROOT ...


  • Please log in to reply
11 replies to this topic

#1 gbrao

gbrao

    Frequent Member

  • Advanced user
  • 474 posts
  •  
    India

Posted 07 April 2012 - 08:04 AM

I just found that there are 'pre-defined' variables ?_BOOT & @ROOT . Are variables like this documented anywhere ? I'm looking for a variable the has the name of the current configfile.

Search forum for above variables does not work.

#2 steve6375

steve6375

    Platinum Member

  • Developer
  • 7566 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films
  •  
    United Kingdom

Posted 07 April 2012 - 08:41 AM

@date
@time
@random
@root
@path
@retval
?_BOOT
?_WENV

are only ones I can see in source code.

You could set a variable to the config file name before you load the menu with a configfile command...

#3 gbrao

gbrao

    Frequent Member

  • Advanced user
  • 474 posts
  •  
    India

Posted 07 April 2012 - 08:57 AM

^ thanks.
thing is, i have 'grldr' on (hd0,0) renamed to XRLDR and it looks for XENU.LST - suits me because there are other grldrs on my system and sometimes they end up using MENU.LST on the first partition.
I call some submenus from XENU.LST, I wanted to save the name "XENU.LST" so that I could return to it. I can hardcode it as you suggested.

#4 gbrao

gbrao

    Frequent Member

  • Advanced user
  • 474 posts
  •  
    India

Posted 07 April 2012 - 05:57 PM

looks like


call Fn.0 0 0x8217


gets you the previous (edit) current configfile.

where can i get info about :
- the internal functions ?
- locations like 0x8217 ?

#5 steve6375

steve6375

    Platinum Member

  • Developer
  • 7566 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films
  •  
    United Kingdom

Posted 07 April 2012 - 07:56 PM

Fn functions are listed below for Feb 2012 version of chenall grub4dos.
You will have to work out what parameters each one takes yourself!

0 grub_sprintf - e.g. call Fn.0 0 "id="%s","%1"" %p_hwid%
1 grub_putstr
2 putchar - e.g. call Fn.2 49 prints '1'
3 get_cmdline_obsolete
4 getxy
5 gotoxy - e.g. call Fn.5 0 2 set cursor pos to beginning of line 11
6 cls
7 wee_skip_to was obsolete setcursor
8 nul_terminate
9 safe_parse_maxint_with_suffix
10 substring
11 grub_strstr - e.g. call Fn.11 0x6000 "$$"
12 grub_strlen - e.g. call Fn.12 "freddy" && echo %@retval% - prints 6
13 grub_strtok - e.g. set /a p_hwid=0x40000 && call Fn.13 %p_hwid% "," or call Fn.13 0 "," || exit
14 grub_strncat
15 grub_strcmp
16 grub_strcpy
17 reserved
18
19 getkey - gets a kbdchar
20 checkkey
21
22 grub_memcmp
23 grub_memmove
24 grub_memset
25
26 grub_open - e.g. directly call grub_open file function it will put filesize at memory 0x8320 - this works well for non-compressed files too. call Fn.26 /myfile.gz && set /a filesize=*0x8320
27 grub_read
28 grub_close
29
30
31
32 devread
33 devwrite
34 next_partition
35 open_device
36 real_open_partition
37 set_device
38
39
40
41 parse_string
42 hexdump - e.g. call Fn.42 0x8000 0 3 - list 3 hex bytes are 0x8000
43 skip_to
44 builtin_cmd
45 get_datetime
46 find_command
47
48
49 get_mmap_entry
50 grub_malloc
51 grub_free51
52 list_partitions
53 realmode_run
54 reserved for wee
55 reserved for wee
56 reserved for wee
57 reserved for wee
58 reserved for wee
59 reserved for wee
60 reserved for wee
61 dir - e.g. Fn.61 /dir/
62 print_a_completion
63 print_completions
64 lba_to_chs
65 probe_bpb
66 probe_mbr
67 unicode_to_utf8
68 rawread
69 rawwrite
70 setcursor e.g. call Fn.70 0 to disable cursor and splashimage
71 grub_tolower
72 grub_isspace
73 grub_sleep e.g. call Fn.73 3 to sleep for 3 secs
74 mem64
75 envi_cmd
76 strncmpx
77 rectangle
78 get_cmdline
  • ilko likes this

#6 steve6375

steve6375

    Platinum Member

  • Developer
  • 7566 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films
  •  
    United Kingdom

Posted 07 April 2012 - 08:47 PM

Here are some internal variable locations (don't write to them unless you are sure you are meant to!)
0x8217 current configfile path and name
0x826C BSS start address (4 bytes)
0x8274 autonumber boot entries with a hyphen after the number - write 0x8274 0x2d01
0x8276 set /a CURDEF=*0x8276 & 0ff gets current menu item number as a variable CURDEF
0x8278 #check version of grub4dos - e.g. checkrange 20120201:-1 read 0x8278 || pause --wait=3 Please use grub4dos-0.4.5c-2012-02-01 or later! && exit 1
0x8290 Length of file in bytes -e.g cat --length=0 /myfile.iso && set /a LEN=*0x8290 && echo Length of file is %LEN% bytes
0x8298 maximum contiguous memory in KB starting at 1M and below 4G #calculate sizes in MB of iso and available memory - set /a MEMSIZE=*0x8298&0xFFFFFFFF>>10 && cat --length=0 && /myfile.iso && set FSize=*0x8290>>20 && if %FSize%>=%MEMSIZE% && echo Need More memory!
0x8280 Disk type - checkrange 0x80 read 0x8280 && pause --wait=3 I am Hard Disk 0
0x82BC CPU type - iftitle [checkrange 0,1 read 0x82Bc] 32Bit system
0x82D0 rd_base
0x82D8 rd_size
0x8320 # to get the expanded length of a compresses .gz file - use: cat --length=1 /myfile.gz && set /a filesize=*0x8320
# Or directly call grub_open file function it will put filesize at memory 0x8320 - this works well for non-compressed files too. call Fn.26 /myfile.gz && set /a filesize=*0x8320
0x8328 filepos ptr
  • ilko likes this

#7 gbrao

gbrao

    Frequent Member

  • Advanced user
  • 474 posts
  •  
    India

Posted 08 April 2012 - 02:35 AM

^ thanks. from where did you get the info ?

#8 steve6375

steve6375

    Platinum Member

  • Developer
  • 7566 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films
  •  
    United Kingdom

Posted 08 April 2012 - 07:24 AM

The source files.

#9 dencorso

dencorso

    Frequent Member

  • Advanced user
  • 142 posts
  •  
    Brazil

Posted 09 April 2012 - 03:31 AM

Sure. But... which of the source files, in particular, please?

#10 steve6375

steve6375

    Platinum Member

  • Developer
  • 7566 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films
  •  
    United Kingdom

Posted 09 April 2012 - 09:38 AM

Asms.S defines the internal variable locations.

The Fn. functions are also in Asms.S, listed in the section starting
VARIABLE(system_functions)
.long ABS(EXT_C(grub_sprintf))
.long ABS(EXT_C(grub_putstr))
VARIABLE(grub_putchar)
.long ABS(EXT_C(_putchar))

some other info is given in http://grubutils.goo...lude/grub4dos.h, the function number is in square brackets.
e.g.
#define sprintf ((int (*)(char *, const char *, ...))((*(int **)0x8300)[0]))
#define putstr ((void (*)(const char *))((*(int **)0x8300)[1]))
#define putchar ((void (*)(int))((*(int **)0x8300)[2]))

you can also search for where each function is defined in the source files - e.g. _putchar or grub_sprintf, etc.
  • dencorso likes this

#11 dencorso

dencorso

    Frequent Member

  • Advanced user
  • 142 posts
  •  
    Brazil

Posted 11 April 2012 - 08:10 AM

Thanks a lot. You rock! :thumbup:

#12 steve6375

steve6375

    Platinum Member

  • Developer
  • 7566 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films
  •  
    United Kingdom

Posted 11 April 2012 - 08:34 AM

I will keep this list updated on my site here http://www.rmprepusb...s-and-functions
  • ilko and dencorso like this




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users