|
how can i use a switch structure to compare words? (since switch does not work with CString, char* or char[])
Any help would be appreciated
|
|
|
|
|
seeing as switch does not work with CString, char*, or char[], you can't. You'll need to do what the compiler does internally in any case, a string of if else statements.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
Christian Graus wrote:
You'll need to do what the compiler does internally in any case, a string of if else statements.
'String of if eles statements' isn't always used. Compiler can build a lookup table with addresses of code fragments to execute appropriate 'case'.
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
Hello,
I have some theoretical questions about the hooking stuff, I know that different processes might have different premissions, now lets call two processes #1 and #2, while #1 has only read premission from the HD and #2 has both read/write premission. (it's only to get the idea), now lets say there is a global hook procedure which writes log file to the HD, the question is wether it will act differently for process #1 and number #2, and if so, maybe #1 can use this trick to write file, which it has no premission to.
I hope I'm clear, because even I don't really understand what I wrote.
thanks,
Guy.
|
|
|
|
|
As long as your global hook procedure is implemented
in a dll, the library is loaded into process, and
shared code inherit process properties, so, the process
without permissions, will be unable to write to disk.
What you really write about is the inheritance of process permisions
over dll's which process use.
Hope to give you an ideea.
|
|
|
|
|
Short answer: No, your process #1 is not able to write to file via the Hook.
Long answer:
Global Hooks are implemented in DLLs and loaded into the target process address space. The target process may contain more than one thread. Therefore the hooks code is executed in the security context of the thread that triggers the hook event. Things are even a (small) bit more complicated: If the WriteFile() succeeds depends on the token of the current (calling) thread, which is usually the process' token, but may be also an impersonation token.
This is the point another thing comes into the context. If the hooks code is always executed in the secuity context of the target process/thread, one could use this to insert code into processes with a higher privilege level (and e.g. make himself a member of the Admins group). Therefore it is usually not possible to install a hook in a "foreign" process (a process that runs in another user context, like services or processes started via RunAs).
According to MSDN a process could enable hooks of foreign processes "running on the same desktop" by opening the desktop with the "DF_ALLOWOTHERACCOUNTHOOK" flag. (The complete thing is a bit underdocumented in MSDN and I don't understand what a "process running on the same desktop" is, because, once again, it's the thread that is attached to a desktop - not the process.)
Hope I did not totally confuse you
--
Daniel Lohmann
http://www.losoft.de
|
|
|
|
|
Errr... thanks?!?
just kidding, in fact that what I was getting to that you can improve your premission state. well, it's interesting to hear about the account thing, but if I use two processes at the same account and one has less premmission by definition of the programmer at the creation time, I think it will be able to get the maximum premissions of the user that is now logged on.
I guess we will have to try and learn
thanks,
Guy.
|
|
|
|
|
Oh, seems I have confused you a bit by all this security stuff
Sorry about that, but here we have to go on
Anonymous wrote:
but if I use two processes at the same account and one has less premmission by definition of the programmer at the creation time, I think it will be able to get the maximum premissions of the user that is now logged on.
Uh, oh no I am a bit confused. The thing is, there is no "limitation of permissions at creation time". NT security is completly user related. Of course, the programer decides which kind of access rights his program code utilizes e.g. by simply not doing any write operations. But thats not a limitation of the access rights of the process which executes the program.
It's simply the difference between beeing forbidden to do something and just not doing it. Only the user context of the process defines what is allowed and forbidden.
--
Daniel Lohmann
http://www.losoft.de
|
|
|
|
|
Hi all,
I have a basic question regarding size of struct.
I have following code:
struct MyStruct
{
int PortAddress;
char onmask;
char offmask;
int *PortData;
};
void main(void)
{
struct MyStruct m_struct;
int* pInt;
printf("size of char = %d\n",sizeof(char));
printf("size of int = %d\n",sizeof(int));
printf("size of int Pointer= %d\n",sizeof(pInt));
printf("size of MyStruct= %d\n",sizeof(m_struct));
}
Out put looks like:
size of char = 1
size of int = 4
size of int Pointer = 4
size of MyStruct= 12
Now my question is why I get the size of Mystruct = 12 instead of 10 (4 + 1 +1 + 4) ?
thanks for help
regards
/rsasalm
|
|
|
|
|
Struct member alignment in the compiler options.
Normski. - the next bit of code is self modifying ... jmp 0xCODE
|
|
|
|
|
I try to intercept some message coming from a menu item.
I get correct values for nID and nCode when rolling over the menu item. When clicking, nID points to something that seems unrecognizable.
How should i get the click?
rechi
|
|
|
|
|
I think nID is the handle of the menu...
|
|
|
|
|
Is there any special requirement that stops you from using message map and handler for nID?
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
Yes, it is. I have to handle dinamically added menus, in the main frame's queue. Thus, i cannot provide message map entries because i don't use static menu structure. Also i have to filter the menu messages before they reach the view's queue.
Anyway, PreTranslateMessage solved the problem.
rechi
|
|
|
|
|
Assuming that your dynamic ids are located in predefined range, you may also use ON_COMMAND_RANGE.
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
Hai ...
I just want to know what is the reason to display exception error of this simple code ?
CFileDialog cfdlg(true, NULL, NULL, 0,"Sound Files (*.wav; *.mp3)|*.wav;*.mp3||", this);
end exception is :
-------
First-chance exception in kTalk.exe (KERNEL32.DLL): 0x000006B5: (none)
First-chance exception in kTalk.exe (KERNEL32.DLL): 0x000006B5: (none)
-------
it does not occures if opendlg.Flags &= ~OFN_EXPLORER is set ...
i am running w2k Advanced Server ... and have not any probles with other apps.
Downloading some demos from here I also have this exceptions .. ):
maybe somebody knows, how to thix this bug !??
thanks.
----------------------------
my eng is bad, so am i .. (:
|
|
|
|
|
|
Are you sure to do this !??
Is this OK for W2k !? (-:
but i want to get app without any exceptions ... (:
----------------------------
my eng is bad, so am i .. (:
|
|
|
|
|
Your program actually crashes, or you're just getting 'first-chance exception' in output pane when running under debugger?
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
Yee .. a have just exception in debuger pane....
but program still works correctly and all vars are correctly written ...
just when changing filter, this exception occures ...
- when changing to old style dialog (win95), everything is OK !!
----------------------------
my eng is bad, so am i .. (:
|
|
|
|
|
Don't worry about these first-chance exceptions - they're used as signaling mechanism by Windows itself. See KB article Q105675 for more details.
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
I want to capture file system events.eg when one copies a file from one folder to another,I want to be able to capture this event. Or someone deletes a particular file. Which events I need to capture for that?
It would be gr8 if someone can atleast give some pointers to that
Thanks
sunil
|
|
|
|
|
See: FindFirstChangeNotification, FindNextChangeNotification, FindCloseChangeNotification; ReadDirectoryChangesW.
|
|
|
|
|
I want to add links in the system pop up menus.eg When u right click any file icon on windows,a pop up menus appear having options (Open,Print,Sendto,Cut,Copy ...) .So how can i add my own options to this?
Thanks
Sunil
|
|
|
|
|