R
rohit
I am porting a C code from Windows base to Linux/Macintosh OS and need
an implementation of "IsBadWritePtr" for gcc to run the app on
Mac/Linux.
Below is the detailed info:
IsBadWritePtr in Windows, basically verifies that the calling process
has write access to the specified range of memory.
But unfortunately I am not finding any way to verify the memory on Mac
(using gcc 4.0)
I have a structure called DevCon, and I check if the validity of the
same in windows using the following macro:
#define IsValid(DevCon) IsBadWritePtr(DevCon,4)
So if the calling process has write access to all bytes in the
specified memory range, then it returns 0 else 1. This way I easily get
to know the validity.
In Linux/Mac, I tried to simulate the same using below code, but it
gave me the segmentation fault.
int IsValid(DEV_CON DevCon){
if(DevCon->MyFirstElement == "FIXEDVALUE") ===> I get the segmentation
fault.
{
}
}
Please Note: The app is designed in such a way that the pointer
pointing to the structure always have some value. (it is never null) On
the other hand the structure it is pointing to is only freed. So this
is the reason we used IsBadWritePtr in Windows.
1) Do we have try catch throws in gcc ? So that it can be possible to
suppress the crash ?
2) Is there readily available API of IsBadWritePtr in gcc ? If not, can
anybody show the implementaion for the same?
Please let me know for any clarification in this regards,
Rohit
an implementation of "IsBadWritePtr" for gcc to run the app on
Mac/Linux.
Below is the detailed info:
IsBadWritePtr in Windows, basically verifies that the calling process
has write access to the specified range of memory.
But unfortunately I am not finding any way to verify the memory on Mac
(using gcc 4.0)
I have a structure called DevCon, and I check if the validity of the
same in windows using the following macro:
#define IsValid(DevCon) IsBadWritePtr(DevCon,4)
So if the calling process has write access to all bytes in the
specified memory range, then it returns 0 else 1. This way I easily get
to know the validity.
In Linux/Mac, I tried to simulate the same using below code, but it
gave me the segmentation fault.
int IsValid(DEV_CON DevCon){
if(DevCon->MyFirstElement == "FIXEDVALUE") ===> I get the segmentation
fault.
{
}
}
Please Note: The app is designed in such a way that the pointer
pointing to the structure always have some value. (it is never null) On
the other hand the structure it is pointing to is only freed. So this
is the reason we used IsBadWritePtr in Windows.
1) Do we have try catch throws in gcc ? So that it can be possible to
suppress the crash ?
2) Is there readily available API of IsBadWritePtr in gcc ? If not, can
anybody show the implementaion for the same?
Please let me know for any clarification in this regards,
Rohit