Permalink
Browse files

批处理 %~m0 修改

因为批处理在运行的时候,内存中批处理文件的内容已经被修改过,所以%~m0跳过批处理文件自身长度.这样如果只有一个续尾文件的话那%~m0就是该文件内容.
  • Loading branch information...
chenall committed Nov 26, 2014
1 parent 9852870 commit cc7664c01e3a51caf13dff9838f5687c93ae1296
Showing with 3 additions and 5 deletions.
  1. +3 −5 stage2/builtins.c
View
@@ -15989,12 +15989,10 @@ static int grub_exec_run(char *program, int flags)
struct bat_label *label_entry =(struct bat_label *)((char *)p_bat_array + 0x200);
char **bat_entry = (char **)(label_entry + 0x80);//0x400/sizeof(label_entry)
unsigned long i_bat = 1,i_lab = 1;//i_bat:lines of script;i_lab=numbers of label.
- grub_u32_t size = 0;
+ grub_u32_t size = grub_strlen(program);
- while(*p_bat++) ++size;
-
- p_bat_array->size = size;
- sprintf(p_bat_array->md,"(md,0x%x,0x%x)",program,*(unsigned long *)(program - 20));
+ p_bat_array->size = size++;
+ sprintf(p_bat_array->md,"(md,0x%x,0x%x)",program + size,*(unsigned long *)(program - 20) - size);
program = skip_to(SKIP_LINE,program);//skip head
while ((p_bat = program))//scan batch file and make label and bat entry.
{

0 comments on commit cc7664c

Please sign in to comment.