--************************************************************************************* -- *** -- Codes Helper For EFIS Method (Embedding File In Sources) By AMSWaves *** -- *** -- Danger : Dont Change These Codes if you are not a advanced programmer. *** -- spurious changes maybe have very bad effect on your files, so be aware.*** -- *** --************************************************************************************* function FileTable2Memory(File_Table, mem) local ending = 0 local counter = 0 for Pos = 0, (File_Table.Size - File_Table.Bytes), 8 do counter = counter + 1 ending = Pos if File_Table[counter] == nil then break; end Memory.PutInt64(mem+Pos, File_Table[counter]) -- Walk On Memory Method end if File_Table.Bytes then for i = 0, File_Table.Bytes-1 do Memory.PutByte(mem+ending+i, rawget(File_Table, "B"..(i+1))) -- Walk On Memory Method end end end function FileTable2File(File_Table, File_Name) mem = Memory.Allocate(File_Table.Size) FileTable2Memory(File_Table, mem) ret = Memory2File(mem, File_Name) Memory.Free(mem) return ret end function Memory2File(Mem, File_Name) _File = Memory.Allocate(260) count = Memory.Allocate(260) if String.Lower(File_Name) ~= ":temp:" then Memory.PutString(_File, File_Name, -1, Ascii) handle = tonumber(DLL.CallFunction("kernel32.dll", "CreateFileA", _File..", 3221225472, 3, 0, 2, 128, 0", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL)) Memory.Free(_File) else temp = Memory.Allocate(246) perfix = Memory.Allocate(246) Memory.PutString(perfix, "NEW", -1, Ascii) DLL.CallFunction("kernel32.dll", "GetTempPathA", "246, "..temp, DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL) DLL.CallFunction("kernel32.dll", "GetTempFileNameA", temp..", "..perfix..", 0, ".._File, DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL) handle = tonumber(DLL.CallFunction("kernel32.dll", "CreateFileA", _File..", 3221225472, 3, 0, 2, 128, 0", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL)) end DLL.CallFunction("kernel32.dll", "SetFilePointer", handle..", 0, 0, 0", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL) DLL.CallFunction("kernel32.dll", "WriteFile", handle..", "..Mem..", "..Memory.Size(Mem)..", "..count..", 0", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL) DLL.CallFunction("kernel32.dll", "CloseHandle", handle, DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL) Memory.Free(count) if String.Lower(File_Name) == ":temp:" then local out = Memory.GetString(_File, -1, Ascii) Memory.Free(_File) return out end end