+/*
+ * Load batch file into memory
+ *
+ */
+void BatchFile2Mem(HANDLE hBatchFile)
+{
+ TRACE ("BatchFile2Mem ()\n");
+
+ bc->memsize = GetFileSize(hBatchFile, NULL);
+ bc->mem = (char *)cmd_alloc(bc->memsize+1); /* 1 extra for '\0' */
+
+ /* if memory is available, read it in and close the file */
+ if (bc->mem != NULL)
+ {
+ TRACE ("BatchFile2Mem memory %08x - %08x\n",bc->mem,bc->memsize);
+ SetFilePointer (hBatchFile, 0, NULL, FILE_BEGIN);
+ ReadFile(hBatchFile, (LPVOID)bc->mem, bc->memsize, &bc->memsize, NULL);
+ bc->mem[bc->memsize]='\0'; /* end this, so you can dump it as a string */
+ bc->memfree=TRUE; /* this one needs to be freed */
+ }
+ else
+ {
+ bc->memsize=0; /* this will prevent mem being accessed */
+ bc->memfree=FALSE;
+ }
+ bc->mempos = 0; /* set position to the start */
+}