flat assembler
Message board for the users of flat assembler.
Index
> Windows > 32bit readfile access invalid. Goto page 1, 2 Next |
Author |
|
macomics 08 Mar 2024, 08:12
See who else is using your file. 998 - no access
|
|||
08 Mar 2024, 08:12 |
|
Hrstka 08 Mar 2024, 08:17
Your buffer is too small. You have space for 64 * 60000 + 8 000 000 * 4 = 35 840 000 bytes, but your file has 36 080 008 bytes.
Last edited by Hrstka on 08 Mar 2024, 08:21; edited 1 time in total |
|||
08 Mar 2024, 08:17 |
|
Roman 08 Mar 2024, 08:18
No else.
Minimal example show only my program 1 time load file this file. Hrstka read again. My buffer size 36 080 008 bytes Plus 200 000 bytes Status. But readfile get error if org 500000h Without org 500000h, readfile load file fine. Last edited by Roman on 08 Mar 2024, 08:22; edited 1 time in total |
|||
08 Mar 2024, 08:18 |
|
Tomasz Grysztar 08 Mar 2024, 08:22
Even if the buffer is enough, the ORG command there changes the addresses of labels, and so the pointer to the buffer does not really point where it's supposed to. This is not how ORG should be used.
|
|||
08 Mar 2024, 08:22 |
|
Roman 08 Mar 2024, 08:24
And how fix this?
I try variant with Virtualalloc, work fine for readfile. |
|||
08 Mar 2024, 08:24 |
|
Roman 08 Mar 2024, 08:39
I found this
https://masm32.com/board/index.php?topic=2130.0 ALIGNSIZE EQU 4096 ALIGNLOC EQU $ - DATASTART rb ALIGNSIZE - (ALIGNLOC and (ALIGNSIZE-1)) |
|||
08 Mar 2024, 08:39 |
|
Hrstka 08 Mar 2024, 08:55
Okay, then the buffer size is all right. With the org directive, Fasm will change the line
Code: mov edx,gltfMapKeyNamesOfst ;zbuf2 Code: mov edx, 500000h Code: times 500000h nop |
|||
08 Mar 2024, 08:55 |
|
Roman 08 Mar 2024, 09:16
Quote:
My exe file 5 mb! Buffer begin address 903000h And this variant load file ok. No error. |
|||
08 Mar 2024, 09:16 |
|
Hrstka 08 Mar 2024, 09:29
Yes, this increases exe size. Exactly as it would be with real (useful) code.
|
|||
08 Mar 2024, 09:29 |
|
macomics 08 Mar 2024, 09:39
I tried to create a file of the specified length and run your program. I don't have any errors.
Let's do the math: org 500000h + rd + rb 64 * 60000 + rd 8000000 + rd + rd 1 * 60000=500000h+4+3780000+32000000+4+240000=2759F28h As you can see on the memory map, the bss section starts at 403000h and has a size of 023F9000h 403000h+023F9000h=27FC000h 2759F28h < 27FC000h => There is enough memory to fit Well, the result of the program is also visible in 1 screen. The file was fully loaded into memory without errors. Last edited by macomics on 08 Mar 2024, 10:34; edited 1 time in total |
|||
08 Mar 2024, 09:39 |
|
Roman 08 Mar 2024, 09:43
file size 36 080 008
Try do repet 36 080 008 |
|||
08 Mar 2024, 09:43 |
|
macomics 08 Mar 2024, 09:48
Roman wrote: file size 36 080 008 Roman wrote: Try do repet 36 080 008 403000h+023F9000h=27FC000h < 280F880h Quote: gltfMapKeyNamesOfst rd 1 Last edited by macomics on 08 Mar 2024, 10:21; edited 1 time in total |
|||
08 Mar 2024, 09:48 |
|
Roman 08 Mar 2024, 10:01
Code: gltf_names = 60000 gltfMapKeyNamesOfst rd 1 gltfMapKeyNames rb 64*gltf_names gltflvlData rd 8000000 gltflvlDataCountrOfst rd 1 gltflvlDataCountr rd 1*gltf_names gltflvlDataEnd: In fasm mov eax,gltflvlDataEnd-gltfMapKeyNamesOfst IDA Pro show: mov eax, 2268988h = 36 080 008 macomics You variant work(and for me too) , because you do. Code: Status rd 51200*1 ; error load rd 51200*7 ;with this load ok. Without load error Try do Code: Status rd 51200*1 ; error load |
|||
08 Mar 2024, 10:01 |
|
macomics 08 Mar 2024, 10:25
In general, your problem is the address discrepancy: the section starts at 403000h, and you calculate the addresses for the 500000h buffer
The declared amount of data in the section is placed completely. But the base address of the buffer is incorrect because of the org directive. Don't use it, as Tomasz already said. Last edited by macomics on 08 Mar 2024, 10:26; edited 1 time in total |
|||
08 Mar 2024, 10:25 |
|
Roman 08 Mar 2024, 10:25
Quote:
Ok. How i do set start address(from 500000h) for .bss section data ? And get correct result. Tomasz Grysztar did org will it be fixed? Or add new command 'BeginFromAddr' Last edited by Roman on 08 Mar 2024, 10:32; edited 2 times in total |
|||
08 Mar 2024, 10:25 |
|
macomics 08 Mar 2024, 10:28
Roman wrote: How i do set start address(from 500000h) for .bss section data ? Roman wrote: Tomasz Grysztar did org will it be fixed? |
|||
08 Mar 2024, 10:28 |
|
revolution 08 Mar 2024, 16:43
Roman wrote: Tomasz Grysztar did org will it be fixed? Or add new command 'BeginFromAddr' To "fix" it you must manually create a memory region at the address you wanted. So you can call VirtualAlloc to make the necessary memory addresses available to you. However, I suggest that you don't do any of that, because it is both unnecessary and not guaranteed to work the way you expect. Instead just use the normal PE sections the way they were designed, and let the loader do its job, then you will not have such problems. TL;DR: Don't use org |
|||
08 Mar 2024, 16:43 |
|
bitRAKE 08 Mar 2024, 18:40
With multiple fixed base address PE's it's possible to create a complex layout in memory. For example, if you create a DLL and set the base address.
Although there is no practical reason? I've done it for fun because I wanted the addresses to also be valid code, lol. If you want a buffer without ballooning the size of the executable, why not reserve the space at the end of the section? ... or create another .bss section? ... what is the actual goal? _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
08 Mar 2024, 18:40 |
|
Furs 08 Mar 2024, 21:48
revolution wrote: Tomasz can't help you here, even if Tomasz wanted to make changes to do what you wanted, it isn't possible. The PE format doesn't support setting arbitrary address for each section. |
|||
08 Mar 2024, 21:48 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.