can i make readable only data inside proc. ????
Posted on 2004-01-22 14:10:57 by AceEmbler
shouldn't be a problem... define a label at the end of your proc, after the ret, and put your data there?
Posted on 2004-01-22 15:30:42 by f0dder
Afternoon, AceEmbler.



.code
...
jmp @F
mylabel db "My read-only data",0
@@:
invoke MessageBox, NULL, addr mylabel, NULL, MB_OK
...


Cheers,
Scronty
Posted on 2004-01-22 15:31:49 by Scronty
This is the best way for the processor.

MyProc PROC something:DWORD

mov eax, something

CONST SEGMENT
somthingElse DWORD 123
CONST ENDS

add eax, somthingElse
ret
MyProc ENDP
...it told me so itself. ;)
Posted on 2004-01-22 15:32:46 by bitRAKE
scronty, why do the jmp version when you can just place the data after the final ret?
Posted on 2004-01-22 15:34:31 by f0dder

This is the best way for the processor.

MyProc PROC something:DWORD

mov eax, something

CONST SEGMENT
somthingElse DWORD 123
CONST ENDS

add eax, somthingElse
ret
MyProc ENDP
...it told me so itself. ;)


Is this method working for *.lib or *.dll ???
Posted on 2004-01-22 18:19:22 by AceEmbler

Is this method working for *.lib or *.dll ???
Yes, I cannot see where it would result in a problem?
Posted on 2004-01-22 19:45:42 by bitRAKE
AceEmbler,

Bitrake's code places your data in another segment (section), if I am not wrong, therefore it works for both dll and lib

Anyway fodder's suggestion for code after ret is applicable, but just remember that if you place data in code section, you cannot write to it unless of course you change the section flags to writeable too.
Posted on 2004-01-22 19:49:27 by roticv

Yes, I cannot see where it would result in a problem?


So where are section defined in our app ??
Posted on 2004-01-23 05:00:59 by AceEmbler



So where are section defined in our app ??
.MODEL FLAT defines the default SEGMENTs or you can do it manually to have greater control of alignment:
	_TEXT SEGMENT READONLY PAGE PUBLIC FLAT 'CODE'

_TEXT ENDS

CONST SEGMENT READONLY PAGE PUBLIC FLAT 'CONST'
CONST ENDS

_DATA SEGMENT PAGE PUBLIC FLAT 'DATA'
_DATA ENDS

_BSS SEGMENT PAGE PUBLIC FLAT 'BSS'
_BSS ENDS

ASSUME CS:FLAT, DS:FLAT, SS:FLAT, ES:FLAT
The above is a direct replacement for .MODEL FLAT except using PAGE alignment.
Posted on 2004-01-23 08:00:21 by bitRAKE
how our app knows that this is segment with data not instructions ??? i thought its somewhere in PE
Posted on 2004-01-24 05:18:49 by AceEmbler
The linker will create another section in the PE file based on the SEGMENT name and parameters.
Posted on 2004-01-24 07:50:42 by bitRAKE