flat assembler
Message board for the users of flat assembler.

Index > Main > Align section .bbs or import ?

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
MatQuasar



Joined: 25 Oct 2023
Posts: 99
MatQuasar 05 Mar 2024, 18:11
Thanks for testing, macomics.

There seems to be typo in your second call to HeapAlloc.
You didn't pass the [ _heap ] handle, instead you pass eax.

Code:
invoke   HeapAlloc,eax,...
    


...should be:

Code:
invoke   HeapAlloc,[_heap],...
    


Isn't it?

I will test your code tomorrow because I am sleeping...
Post 05 Mar 2024, 18:11
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 913
Location: Russia
macomics 05 Mar 2024, 18:34
Thanks.

I tested it again. Indeed, this is my mistake. Heap continues to work. And further memory allocation is possible.
Post 05 Mar 2024, 18:34
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1701
Roman 05 Mar 2024, 18:41
After section .bss I write this:
Code:
section '.code' code readable writeable executable
            some data
Start:    main code Directx11
             call renderToTexture

section '.bss' readable writeable
            all_data   rb 610 mb

;add new section and now work fine.
section '.text' code readable writeable executable
 include 'procs\renderToTexture.txt'
    

Now render fine character.

And what is mean ?! Fasm bug or some sections have limit size ?
Post 05 Mar 2024, 18:41
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 913
Location: Russia
macomics 05 Mar 2024, 19:13
There are two sections of code in your example. Two sections containing the code cannot be specified in the PE format. There are only 16 available sections and they have their own purposes. You have set two sections of the code. I suspect that fasm simply overwrites the code section of the second one without an error message.

To prevent this, I usually use the following macro
Code:
macro .code aim=main { purge .code
  macro .code var& \{ err \}
  section '.text' code readable executable
  entry aim
}    

If you call such a macro twice, the second call will generate the err directive

Code:
struc PE64_OPTIONAL_HEADER
{
; ...
   .DataDirectory       PE32_DATA_DIRECTORY ; <- sections
   repeat PE32_NUMOF_DIR_ENTRIES - 1
                        db .DataDirectory.Length dup ?
   end repeat
}    
I'm telling you about this array.
Code:
struc PE32_SECTION_HEADER
{
 .:
   .Name                db PE32_SIZEOF_SHORT_NAME dup ?
   .VirtualSize         dd ?
   .VirtualAddress      dd ? ; Later, there is a comparison by virtual address
   .RAWSize             dd ?
   .RAWPointer          dd ? ; or raw pointer
   .pRelocations        dd ?
   .pLinenumbers        dd ?
   .cRelocations        dw ?
   .cLinenumbers        dw ?
   .Characteristic      dd ?
 .Length                = $ - .
}    
Although a separate header will be created for each section, the code can only be in one section.

In general, you can see everything in the debugger and understand where and what is wrong. Try running the game in the debugger, rather than simply executing it with an error message.
Post 05 Mar 2024, 19:13
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1701
Roman 05 Mar 2024, 19:46
Practices show me my variant.
Now my render to texture work right.
How should be !
On characters i out put render from texture. I need do variance shadow map(blurred shadows) and need render to texture for post processing.
https://rutube.ru/video/39f494afdb7700443c700775cc198b7d/?r=plemwd


Last edited by Roman on 05 Mar 2024, 19:52; edited 2 times in total
Post 05 Mar 2024, 19:46
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 913
Location: Russia
macomics 05 Mar 2024, 19:50
As you wish. I warned you. If your program stops loading in Win 11 and later because of some new check for the presence of unnecessary section headers, then you will deal with it later.
Post 05 Mar 2024, 19:50
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1701
Roman 05 Mar 2024, 19:51
Quote:
If your program stops loading in Win 11 and later because of some new check for the presence of unnecessary section headers, then you will deal with it later.


Maybe it will happen.
Post 05 Mar 2024, 19:51
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1701
Roman 06 Mar 2024, 06:03
This code compiled
Code:
section '.bss' readable writeable
org 500000h
            ;all_data   rb 610 mb
gltf_names = 60000
gltfMapKeyNamesOfst      rd 1
gltfMapKeyNames          rb 64*gltf_names  
gltflvlData              rd 8000000 ;in hear load file
gltflvlDataCountrOfst    rd 1
gltflvlDataCountr        rd 1*gltf_names
gltflvlDataEnd:
    

lvl.bin size 36 mb
But my load File proc write file lvl.bin not loaded!
Whithout org, file load normal.
GetLastError show 0x03e6 (Invalid Access to Memory Location). File name correct 'lvl.bin',0
ReadFile() Error 3e6 (Invalid Access to Memory Location)
Why?!
I try do this code in another project and all work fine ! File load fine with org 500000h
Maybe i found some interesting bug in my game code !
Post 06 Mar 2024, 06:03
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.