|
File Mapping is a very good technique for IPC, in fact that is how COM implements its underlying IPC for local processes.
Using the system page sounds like a good way to go, then there is no file clean up afterwards. Other than that I do not think that it matters which way you do that.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Thanks for you and anyone who replied. OK I still have a question here, it may sound stupid but anyway:
Is there any possibility that the mapped file will be trespassed by other process? I mean, if I have process A and B are using the mapped file(I will generate a GUID as mapping file name), is it possible, even very very slightly possible, that any contents within the mapping can be modified by processes other than A and B?
Because I need the contents to be absolutely private and secure to process A and B, this is crucial for me, otherwise I might get fired . So before I begin it I'd like to make sure. Thanks again.
|
|
|
|
|
Bin wrote:
Is there any possibility that the mapped file will be trespassed by other process?
Yes. If you use a named object, a process with the proper security can access that object. Will it? Very unlikely, but still possible.
(Think about it, if process B can see an object owned by process A, so can process C. More importantly, your bosses need to understand that if a process has administrative rights in windows, you simply cannot make the system secure. This is akin to the adage that a physically accessable computer is not fully secure.)
|
|
|
|
|
Hi
there are some programs like MS MediaPlayer and InterVideo WinDVD which, in case of a crash, show a MessageBox with the line, the sourcefile, and a piece of the code that caused the crash. It looks like this e.g:
Unhandled exception in
"C:\Program Files\foo\main.cpp" in line: 289
ASSERT(pFoo != NULL);
How can I implement this feature into my applications?
regards
Greg
modified 12-Sep-18 21:01pm.
|
|
|
|
|
|
Well, I don't think Microsoft and Intervideo deliver debug versions of their programs tp the customers There must be another way.
Furthermore the assertion dialog (or MessageBox) doesn't look the same like in the MediaPlayer or WinDVD.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Gregor S. wrote:
Well, I don't think Microsoft and Intervideo deliver debug versions of their programs tp the customers
Well, an ASSERT is suposed to only be present on debug Builds, right?
You can achieve the same by #define _DEBUG on your release build, or creating a proprietary fancy ASSERT macro.
My latest articles:
XOR tricks for RAID data protection
Win32 process suspend/resume tool
|
|
|
|
|
While in Debug mode you could use _CrtDbgReport, however that function only exists in the debug version of the C-Runtime libraries. Look at how ATLs ATLASSERT macro works.
#define _ASSERTE(expr) \
do { if (!(expr) && \
(1 == _CrtDbgReport(_CRT_ASSERT, __FILE__, __LINE__, NULL, #expr))) \
_CrtDbgBreak(); } while (0)
For release mode you could simply create your own function that reports the data in a message box, and you would use these preprocessor defines to get the line number and file: __FILE__, __LINE__
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
I finally managed to create my own macro, could you please take a look whether it is correct? Is seems to work however
void _assert_(void *exp)
{
char err[1024];
sprintf(err, "Assertion Failed!\n\n\"%s\" in line %i.\nASSERT(%s)", \
__FILE__, \
__LINE__, \
exp); \
if(exp)
{
MessageBox(NULL, err,"Fatal Error", MB_OK|MB_ICONSTOP);
PostQuitMessage(0);
}
}
#define _ASSERT_(exp) { _assert_(#exp); }
For testing purposes:
void *pFoo = NULL;
_ASSERT_(pFoo != NULL);
thanks
btw why don't the pre-tags recognise tabs (\t) when I copy and paste my code?
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Your macro looks good to me
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
...that's bugging me...
I wrote a message about a CreateProcessAsUser problem a few hours ago titled "Is it a bird? ... No It's Superuser!".
I've managed to narrow the problem, so it should be more easy to anwser...
Given that I know the name of my administrator account and it's password, how can I get SeAssignPrimaryTokenPrivilege, operating from a regular account, in order to succesfully place a call to CreateProcessAsUser?
The idea is to copy the functionality of Linux' su...
Regards,
Georg Haan(.NL)
|
|
|
|
|
|
I use the following two line of codes to write vertical text, it works, but the text is facing the left, reads from the top to the bottom. What shall I do if I like to have the vertical text to face the right, and read from bottom up?
stringFormat.SetFormatFlags(StringFormatFlagsDirectionVertical);
graphics->DrawString(string, -1, &myFont, origin, &stringFormat, &blackBrush);
Thanks.
|
|
|
|
|
if there isnt a flag to set what u want (and i havent done so much text output stuff for a while) u could draw to a memdc and invert / flip it before displaying it
"... and so i said to him ... if it don't dance (or code) and you can't eat it either f**k it or throw it away" biz stuff about me
|
|
|
|
|
|
OK, I've never used GDI+, but in standard GDI, the font is created with the rotation factor. Check that to see whether the value of 900 for Orientation needs to be changed to 2700 where it is constructued, or visa versa.
Roger Allen
Sonork 100.10016
I think I need a new quote, I am on the prowl, so look out for a soft cute furry looking animal, which is really a Hippo in disguise. Its probably me.
|
|
|
|
|
Thanks for the reply. The computer is too heavy for me to turn it upside down.
I tried the following, but for some reason, I only see the ellipse, but no text 'HAPPY DAY!', am I missing something here?
Pen pen(Color(255, 0, 0, 255));
PointF origin(x, y);
WCHAR string[256];
x = 200;
y = 200;
graphics->RotateTransform(90.0f);
graphics->TranslateTransform(x, y, MatrixOrderAppend);
wcscpy(string, L"HAPPY DAY!");
graphics->DrawString(string, -1, &myFont, origin,
&stringFormat, &blackBrush);
graphics->DrawEllipse(&pen, 0, 0, 200, 80);
Thanks!
|
|
|
|
|
|
I am drawing both the text and ellipse on an image that I uploaded using graphics.DrawImage().
I agree that this method shall work because I can see the ellipse, but not the text... weird...
Anyways, thank you again for pointing me to the right direction.
|
|
|
|
|
Perhaps You are drawing the ellipse over the text ?
try it in this order
graphics->DrawEllipse(&pen, 0, 0, 200, 80);
graphics->DrawString(string, -1, &myFont, origin, &stringFormat, &blackBrush);
|
|
|
|
|
Thanks. It doesn't work either.
Anybody ever tried to rotate a line of text before using GDI+?
|
|
|
|
|
|
Hey, you are the best! Thank you so much, Daniel. My code is finally working!!!!!!
I shall call TranslateTransform() first before calling RotateTransform().
Still, don't know why this doesn't make a difference when drawing the ellipse though... but hey, who cares now... hee hee...
|
|
|
|
|
It is my first time here asking for help, and I had a very happy experience. All you guys are great! Thank you all.
Best wishes to you all.
|
|
|
|
|
I don't know which forum to post this, but since I'm a C++ developer and this forum is the most frequented, I post it here.
I have put the following lines to make mc generate a message table for 3 locales:
;
LanguageNames=(English=0x409:MSG0409)
;
LanguageNames=(EnglishCA=0x1009:MSG1009)
;
LanguageNames=(FrenchCA=0xC0C:MSG0C0C)
My problem is that the MS Message compiler (mc) don't output accented characters correctly. Here is an example entry:
MessageId=100
Severity=Success
Facility=Itf
SymbolicName=MSG_APPSTART
Language=English
Service has started successfully.
.
Language=EnglishCA
Service has started successfully.
.
Language=FrenchCA
Le service a démarré avec succès.
.
When I want to get the message using FormatMessage , I get the following when specifying 0x0c0c as the language:
Le service a dTmarrT avec succFs.
As one can see, the accented characters are messed up. Here is a snippet of the MSG0C0C.bin file outputted by mc:
L L e s e r v i c e a d ˜m a r r ˜ a v e c s u c c ¦s
letters above have a space between them, except for the one where should have been the accented characters.
I can't find anything in MSDN about message compiler an internationalization that explains how to make mc recognize foreign chars correctly, or how to put them in the .mc file.
Tx for your help.
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|