473,769 Members | 3,923 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Limitations of #pragma section shared, rws

Semprini
2 New Member
Hiya,

I'm programming a dll in VC6 which is uses windows hooks (WH_GETMESSAGE) . So I have a HOOKPROC which is called whenever messages are sent the the monitored hwnd

I have a shared data segment like so:

Expand|Select|Wrap|Line Numbers
  1. #pragma data_seg("SHARED")
  2. ...variables in here
  3. #pragma data_seg()
  4. #pragma comment(linker, "/section:SHARED,RWS")
  5.  
If I put a variable of a class, struct or std::vector (probably anything but simple types) into the shared segment when the HOOKPROC is called the variable is null

I must be missing something about how the shared segment works. Anybody have any ideas? I'd love to be able to have a std::list of a structure containing info about what messages the HOOKPROC should reply to and how to reply.

Looks like I'll have to use arrays of hwnd's and others for the moment...

Cheers,

Semprini
Aug 15 '06 #1
2 10198
Semprini
2 New Member
After further investigation it seems that all my shared variables need to be initialized:

this doesn't work:

Expand|Select|Wrap|Line Numbers
  1. #pragma data_seg("aSHARED")
  2. static DWORD g_dwProcessIDs[MAX_MSGHOOKS];
  3. #pragma data_seg()
  4. #pragma comment(linker, "/section:aSHARED,RWS")
  5.  
but this does:

Expand|Select|Wrap|Line Numbers
  1. #pragma data_seg("aSHARED")
  2. static DWORD g_dwProcessIDs[MAX_MSGHOOKS] = {0};
  3. #pragma data_seg()
  4. #pragma comment(linker, "/section:aSHARED,RWS")
  5.  
Why would the variable go out of scope if not initialized??
Aug 15 '06 #2
Cronus
1 New Member
After further investigation it seems that all my shared variables need to be initialized:

this doesn't work:

Expand|Select|Wrap|Line Numbers
  1. #pragma data_seg("aSHARED")
  2. static DWORD g_dwProcessIDs[MAX_MSGHOOKS];
  3. #pragma data_seg()
  4. #pragma comment(linker, "/section:aSHARED,RWS")
  5.  
but this does:

Expand|Select|Wrap|Line Numbers
  1. #pragma data_seg("aSHARED")
  2. static DWORD g_dwProcessIDs[MAX_MSGHOOKS] = {0};
  3. #pragma data_seg()
  4. #pragma comment(linker, "/section:aSHARED,RWS")
  5.  
Why would the variable go out of scope if not initialized??
data_seg is for initialized data. You can also specify sections for const variables (const_seg), uninitialized data (bss_seg), and functions (code_seg).
Mar 22 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
3968
by: Shri | last post by:
Can anybody tell me where i can find a detailed document on #pragma .... --shri
4
3639
by: Troy | last post by:
Hi, I am working on a mixed native/managed project involving DirectShow and am trying to decide how the modules should be partitioned. I am trying to understand the true affect of #pragma unmanaged in a managed project. From my research it seems that, assuming there are no managed/native thunks involved, the code should perform as though it were compiled in a native Win32 project. However, as a simple test, I created a project that...
1
3085
by: Gustavo L. Fabro | last post by:
Greetings! Going directly to the point: myclass.h: //-------------------------------------- #pragma managed //Forward declaration
11
2870
by: ramu | last post by:
HI, Can anyone tell me about pragma? And can u give an example of how to use it?
15
3761
by: muttaa | last post by:
Hello all, I'm a beginner in C...May i like to know the difference between a #pragma and a #define.... Also,yet i'm unclear what a pragma is all about as i can find topics on it only in high-standard books...
8
4468
by: Ender.Dai | last post by:
I have writen following demo code, but it doesn't work :( Source code: -------------------------------- /* hello.c */ #include <stdio.h> extern int hello_init() __attribute__ ((section(".init"))); extern int hello_finit() __attribute__ ((section(".finit"))); int hello_init()
3
3800
by: Oops-c++ | last post by:
All, I came to know that, we can define #pragma variables to share values between the processes. #pragma data_seg(".shared") var1 variable2 #pragma data_seg()
26
3825
by: Rick | last post by:
I'm told that "#pragma once" has made it into the ISO standard for either C or C++. I can't find any reference to that anywhere. If it's true, do any of you have a reference I can use? Thanks...
2
3921
by: aleemakhtar1 | last post by:
wat is use of pragma directive in embedded sys ??
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10049
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5309
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3965
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3565
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.