I am curious as I have attempted to create a system wide hook and regardless of what I do it only responds when the calling application is active.
Any help is appreciated.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2003-08-13
Beats me how the message body relates to the message subject, but you sound like you know what you are doing.
I'll answer the subject, since I do not understand the message (I suggest you post some code to explain).
The authors of GCC (of which MinGW is a Windows port) are pathalogically averse to #pragma directives. To do the same thing as #pragma data_seg you need to use a section attribute, the syntax for data is as follows:
e.g.
int foo __attribute__((section ("shared_seg"), shared)) = 0;
The 'shared' keyword is Windows NT specific (and presumably 2K and XP although the documentation does not state that). It allows the section to be shared among multiple executables/DLLs.
Section attribute can also be specified for functions, e.g:
The documentation does not mention the 'shared' keyword in relation to functions, so I am not sure on that one, I guess you could try it, or maybe it does not matter?.
I've not ever done any of this BTW, I just know my way around the documentation!
Attributes do loads of stuff you'd otherwise use a pragma for.
I'm assuming it's for a shared data segment, which I thought was possible on 9x. I could be very, very wrong though (as Clifford gave some very nice docs on)
What do you mean by "when the calling application is active?" I wonder if we can avoid shared anything with some clever thinking.
JMan
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The documentation indicated that the shared keyword was for only nt based machines. When I implemented it to test it on a 9x series it compiled then produced and error at run time.
I don't think it is possible to avoid the shared segment as the system hook needs this capacity to be system wide rather than just attached to the application setting the hook. I have been attempting to work a mapped memory file as an alternative without any success todate.
If anyone can recommend a site that discusses mapped memory files in relation to creating an alternative form of shared segment for dll's I would appreciate it.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am curious as I have attempted to create a system wide hook and regardless of what I do it only responds when the calling application is active.
Any help is appreciated.
Beats me how the message body relates to the message subject, but you sound like you know what you are doing.
I'll answer the subject, since I do not understand the message (I suggest you post some code to explain).
The authors of GCC (of which MinGW is a Windows port) are pathalogically averse to #pragma directives. To do the same thing as #pragma data_seg you need to use a section attribute, the syntax for data is as follows:
<type/class> <identifier> __attribute__((section ("<segment_name>"), shared)) [= <initializer>] ;
e.g.
int foo __attribute__((section ("shared_seg"), shared)) = 0;
The 'shared' keyword is Windows NT specific (and presumably 2K and XP although the documentation does not state that). It allows the section to be shared among multiple executables/DLLs.
Section attribute can also be specified for functions, e.g:
extern void foobar (void) __attribute__ ((section ("bar")));
The documentation does not mention the 'shared' keyword in relation to functions, so I am not sure on that one, I guess you could try it, or maybe it does not matter?.
I've not ever done any of this BTW, I just know my way around the documentation!
Attributes do loads of stuff you'd otherwise use a pragma for.
References:
http://gcc.gnu.org/onlinedocs/gcc-3.2.3/gcc/Function-Attributes.html#Function%20Attributes
http://gcc.gnu.org/onlinedocs/gcc-3.2.3/gcc/Attribute-Syntax.html#Attribute%20Syntax
http://gcc.gnu.org/onlinedocs/gcc-3.2.3/gcc/Variable-Attributes.html#Variable%20Attributes
http://gcc.gnu.org/onlinedocs/gcc-3.2.3/gcc/Type-Attributes.html#Type%20Attributes
http://gcc.gnu.org/onlinedocs/gcc-3.2.3/gcc/C---Attributes.html#C++%20Attributes
There are some pragmas for som GCC variants, but not i386 versions:
http://gcc.gnu.org/onlinedocs/gcc-3.2.3/gcc/Pragmas.html#Pragmas
Clifford
Thanks, this was exactly what I was after. I just need to look for an alternative now to work on 9x series as well.
I'm assuming it's for a shared data segment, which I thought was possible on 9x. I could be very, very wrong though (as Clifford gave some very nice docs on)
What do you mean by "when the calling application is active?" I wonder if we can avoid shared anything with some clever thinking.
JMan
The documentation indicated that the shared keyword was for only nt based machines. When I implemented it to test it on a 9x series it compiled then produced and error at run time.
I don't think it is possible to avoid the shared segment as the system hook needs this capacity to be system wide rather than just attached to the application setting the hook. I have been attempting to work a mapped memory file as an alternative without any success todate.
If anyone can recommend a site that discusses mapped memory files in relation to creating an alternative form of shared segment for dll's I would appreciate it.
Here are two sites where you will find some information and source code about file mappings used as shared memory:
http://www.codeguru.com/system/index.shtml
http://www.codeproject.com/system
( codeproject is down for the moment)
Liviu
Thanks the sample code looks like it is exactly what I was after.
Thanks again