472,146 Members | 1,310 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,146 software developers and data experts.

SAFESEH setting

Hi,
I'm trying to write my own 'safe' exception handler for Microsoft
Visual Studio .NET 2003.
1) It seems that you cannot mark a C++ function as a safe exception
handler.
2) I can't get the .SAFESEH directive to work with ml.

Has anyone tried and succeeded with the /safeseh option and .SAFESEH
directive with ML?
I've stripped my code to the barest minimum, and assembling
'testit.asm' like this:
ml /safeseh /c testit.asm libc.lib /link /dll
I am getting this linker error:
testit.obj : fatal error LNK1279: invalid or corrupt file: file
contains
invalid .sxdata contributions.

The code looks like this:

--------------- testit.asm ---------------
title testit - test safeseh
.586
..model FLAT

testit SEGMENT

fred PROC PUBLIC
push ebp
pop ebp
ret
fred ENDP

..SAFESEH fred

testit ENDS

END
--------------- testit.asm ---------------

Any help, anyone?

Roger Orr
--
[Originally posted to microsoft.public.vstudio.general]
Nov 16 '05 #1
2 4493
Hello Roger,

I am not familar with it. However, I will contact other engineers and reply you as soon as possible here. Thanks very much.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
!From: ro****@howzatt.demon.co.uk (Roger Orr)
!Newsgroups: microsoft.public.dotnet.languages.vc
!Subject: SAFESEH setting
!Date: 16 Jul 2003 01:39:28 -0700
!Organization: http://groups.google.com/
!Lines: 44
!Message-ID: <7a**************************@posting.google.com >
!NNTP-Posting-Host: 141.228.156.225
!Content-Type: text/plain; charset=ISO-8859-1
!Content-Transfer-Encoding: 8bit
!X-Trace: posting.google.com 1058344769 8275 127.0.0.1 (16 Jul 2003 08:39:29 GMT)
!X-Complaints-To: gr**********@google.com
!NNTP-Posting-Date: 16 Jul 2003 08:39:29 GMT
!Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed 00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!
newsfeed.online.be!216.170.153.135.MISMATCH!tdsnet-transit!newspeer.tds.net!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-08!sn-xit-09!
supernews.com!postnews1.google.com!not-for-mail
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vc:26219
!X-Tomcat-NG: microsoft.public.dotnet.languages.vc
!
!Hi,
!I'm trying to write my own 'safe' exception handler for Microsoft
!Visual Studio .NET 2003.
!1) It seems that you cannot mark a C++ function as a safe exception
!handler.
!2) I can't get the .SAFESEH directive to work with ml.
!
!Has anyone tried and succeeded with the /safeseh option and .SAFESEH
!directive with ML?
!I've stripped my code to the barest minimum, and assembling
!'testit.asm' like this:
! ml /safeseh /c testit.asm libc.lib /link /dll
!I am getting this linker error:
! testit.obj : fatal error LNK1279: invalid or corrupt file: file
!contains
! invalid .sxdata contributions.
!
!The code looks like this:
!
!--------------- testit.asm ---------------
! title testit - test safeseh
! .586
!.model FLAT
!
!testit SEGMENT
!
!fred PROC PUBLIC
! push ebp
! pop ebp
! ret
!fred ENDP
!
!.SAFESEH fred
!
!testit ENDS
!
! END
!--------------- testit.asm ---------------
!
!Any help, anyone?
!
!Roger Orr
!--
![Originally posted to microsoft.public.vstudio.general]
!
Nov 16 '05 #2
"Brandon Bray [MSFT]" <br******@online.microsoft.com> wrote in message
news:#9**************@TK2MSFTNGP12.phx.gbl...
testit is a data section. It has to be executable. Change the
SEGMENT directive to

testit SEGMENT 'CODE'


Aha - thanks Brandon.
The joys of Intel - you can of course execute code even when it is in a data
segment - it is just .safeseh which is unhappy....
It's been too long since I used the assembler - _asm is my tool of choice
for the tiny bits I write nowadays!

However even with this help there's something elseI still can't do. I want
to mark a C++ function as a safe exception handler:
Something like this:

handler.cpp
DWORD handler( ... )
{
...
}

and then:

makesafe.asm

.386
..model FLAT

EXTRN _handler:NEAR
..SAFESEH _handler

END

but this generates the same linker error as before.
Is what I am trying to do possible, if so how. Or is there a way to mark
the function as a safeseh in C++ ?

Regards,
Roger Orr
Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Niyazi | last post: by
reply views Thread by Roger Orr | last post: by
reply views Thread by Rohini | last post: by
1 post views Thread by Matej Trampus | last post: by
reply views Thread by sathish74 | last post: by
reply views Thread by Saiars | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.