The MASM Forum

General => The Campus => Topic started by: sukratu on June 29, 2016, 06:04:04 PM

Title: how to add new data section in .asm file.
Post by: sukratu on June 29, 2016, 06:04:04 PM
Hi,

In my current project I have VS solution which includes some .c file and some .asm file.
I moved some global variables from .c file in a secure section by defining

#pragma section("SECURE",read,write)
#pragma data_seg("SECURE")

__declspec(allocate("SECURE"))
char buffer[MAX_SIZE]

In .asm file there are some variables which I want to move to this SECURE section.

I want to know how to create a new data section named "SECURE" in .asm file and how to move a variable in that section.

Thanks & Regards,
Sukrut


Title: Re: how to add new data section in .asm file.
Post by: sinsi on June 29, 2016, 09:02:17 PM
Not sure about VS but with MASM you would do this

SECURE segment public ;might not need public
myvar dd 4
SECURE ends

Title: Re: how to add new data section in .asm file.
Post by: sukratu on July 04, 2016, 07:49:20 PM
Thanks for the reply sinsi,

It is not working with VS.
Title: Re: how to add new data section in .asm file.
Post by: jj2007 on November 04, 2016, 11:37:29 PM
sgSeg segment public read write 'BSS'
gvStart dd ?
sgSeg ends


Works but only for 4096 bytes. Beyond that, I can see the memory in Olly but get an access violation.

Any trick to force a bigger segment?
Title: Re: how to add new data section in .asm file.
Post by: mabdelouahab on November 05, 2016, 01:40:51 AM
   Dim macro   name__,n
      SECURE      SEGMENT PUBLIC BYTE 'BSS'   
         IFB <n>
            name__   DB   ?
         ELSE
            name__   DB   n    dup(?)
         ENDIF
      SECURE      ENDS
   endm
   DimD macro   name__
      SECURE      SEGMENT PUBLIC BYTE 'BSS'   
         name__   DD   ?
      SECURE      ENDS
   endm
   DimW macro   name__
      SECURE      SEGMENT PUBLIC BYTE 'BSS'   
         name__   DW   ?
      SECURE      ENDS
   endm
   
   Dim s,8192
   Dim s2,4096
   DimW ww
   DimD bb

Quote from: jj2007 on November 04, 2016, 11:37:29 PM
Works but only for 4096 bytes. Beyond that, I can see the memory in Olly but get an access violation.
Any trick to force a bigger segment?
it works fine
Title: Re: how to add new data section in .asm file.
Post by: jj2007 on November 05, 2016, 04:21:11 AM
Thanks, will test it :icon14: