flat assembler
Message board for the users of flat assembler.
Index
> Windows > Load a binary file to memory |
Author |
|
r22 31 Jan 2005, 02:53
The best way I can think of is file mapping...
xor ebx,ebx push ebx push 1FFFFFFFh ;size you want push ebx ;high end of 64bit max size push dword 4 ;page readwrite push ebx push dword 0FFFFFFFFh ;invalid handle call [CreateFileMapping] push ebx push ebx push ebx push dword 0F001Fh ;SECTION_ALL_ACCESS push eax call [MapViewOfFile] mov dword[baseAddr],eax Now you can just open, read, write your file into the baseAddr, you can also filemap the file you want instead of passing an invalid handle pass the handle to the file. |
|||
31 Jan 2005, 02:53 |
|
vid 31 Jan 2005, 15:13
i quess windows won't really handle that, iff file is over ~3gb, because it has to allocate large chunk of virtual memory which it can't do (it can handle only 4 gigs at all). I suggest you hadnling file sequentially or writing your own routine that simulates memory reads you would do if file was loaded in memory.
|
|||
31 Jan 2005, 15:13 |
|
f0dder 01 Feb 2005, 09:59
What kind of processing do you need to do?
If you need random access, file mapping is probably the best; you don't have to map the entire file at once (with very large files this is a bad thing to do anyway, especially on Win9x because of the shared address space). If you process the file from start to end, it's probably better to use normal ReadFile and process the file in chunks - this uses less total memory, and avoids the need for other processes to have their working set trimmed. |
|||
01 Feb 2005, 09:59 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.