Original Post
well i was playing around a bit with windows hooks and ran into a problem:
i wanted to write a little prog that would run in the background and only allow certain programs to be run. (and no, i'm not trying to write a trojan or something, i just want a way to secure my pc from my sister, so she can only start the internet connection[so her pc can go online over the network] and not mess anything up when i'm not at home)
anyway, i figured that a CBT Hook would do what i want, since it is called before a window gets created and can thus immediately stop the program.
So far as installing the hook everything went fine and my CBTProc in the dll is called with code HCBT_CREATEWND whenever i start any programs.
But my problem lies in finding out what program it is that is about to be started.
According to the help files the way to access the info i want is to cast the LPARAM of the CBTProc callback to a CBT_CREATEWND*, which has a pointer to a LPCREATESTRUCT, which has a lpszClass member, which should be a pointer to the string with the class name.
This works fine when i start notepad and some other small progs, but for some reason it crashes my computer whenever i open windows explorer (i'm on win98 btw) or the internet connection dialog.
its always crashing in kernel32.dll or user32.dll, when i'm trying to access the lpszClass or lpszName string: casting and assigning the stringpointer works, but when i try a fprintf with the string or a strcmp then it crashes the computer and i have to reboot...
its just looking like windows doesnt want to let me read the memory in which it keeps the class and name strings for windows explorer and other programs.
so i would be really happy if someone knows whats going on and how i can get read-access to that simple string without crashing the computer.
[edited by - burning_ice on May 13, 2003 12:24:05 PM]