flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
shism2 23 Dec 2005, 04:01
Can anyone tell me the fastest ways to load files into memory and be able to manipulate and then write it back into it's original file???
|
|||
![]() |
|
comrade 23 Dec 2005, 06:04
memory maps
CreateFileMapping, MapViewOfFile, etc |
|||
![]() |
|
comrade 23 Dec 2005, 14:44
What is it supposed to show? "255"?
Maybe you want to reset the file pointer after WriteFile Code: invoke WriteFile,[datahandle],buffer,eax,databytes,0 invoke SetFilePointer,[datahandle],0,0,FILE_BEGIN invoke ReadFile,[datahandle],bufin,3h,byteread,0 |
|||
![]() |
|
Reverend 23 Dec 2005, 16:37
You had:
Code: cinvoke wsprintf,bufin2,shi,bufin invoke MessageBox,0,bufin2,bufin2,0 bufin dd 4096 dup (?) bufin2 dd 4096 dup (?) shi db "%d",0 As I understand the code. You write something into file, then read 3 bytes after it. The three bytes are some binary values which you want to convert into ascii and show in a messagebox. So do this: Code: and dword [bufin], 0 ; when zeroing and is smaller than mov invoke ReadFile, [datahandle], bufin, 3, byteread, 0 cinvoke wsprintf, bufin2, shi, dword [bufin] invoke MessageBox, 0, bufin2, bufin2, 0 Code: and dword [bufin], 0 ; when zeroing and is smaller than mov invoke ReadFile, [datahandle], bufin, 3, byteread, 0 invoke lstrcpy, bufin2, bufin ; it's better to use lstrcpy than to use %s format invoke MessageBox, 0, bufin2, bufin2, 0 Some suggestions: give more precise labels' names - bufin, bufin2, etc. will surely mean nothing to you if you let this project away for a week. Next, always presume how much memory will you need. I doubt you need 32 kB for only bufin and bufin2. Try to imagine how much at most will you need and if it's impossible reserve memory dynamically, e.g. buffer of file size. |
|||
![]() |
|
shism2 23 Dec 2005, 16:48
Code: invoke CreateFile,[dname],GENERIC_ALL, \ NULL, NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_ARCHIVE, NULL mov [datahandle],eax mov ebx,255 cinvoke wsprintf,buffer,shi,ebx invoke WriteFile,[datahandle],buffer,eax,databytes,0 invoke SetFilePointer,[datahandle],0,0,FILE_BEGIN invoke ReadFile,[datahandle],bufin,3h,byteread,0 cinvoke wsprintf,bufin2,shi1,bufin invoke MessageBox,0,bufin2,bufin2,0 invoke CloseHandle,[datahandle] ret datahandle dd 0 buffer rb 20h bufin dd 40 dup (?) bufin2 dd 40 dup (?) databytes rb 20h byteread dd ? hWnd2 dd 0 database db "hello",0 This is comrades way... |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.