How do I get a `callFrameID` to pass to `Debugger.evaluateOnCallFrame`? - remote-debugging

WebKit's Remote Debugging Protocol went 1.0 recently and I've been playing around with it a little, mostly out of curiosity and interest. I've thrown together a very basic recreation of Chrome's developer tools console as a replacement front-end, but I'm a little confused as to how I can execute code in a specific frame/window like Chrome's Dev Tools allow you to.
At the moment, I'm using the Runtime.evaluate method to execute my console input. This seems inadequate because of the aforementioned problem and it doesn't provide the command line API. I've discovered the Debugger.evaluateOnCallFrame method, which requires a callFrameID parameter. The only problem is, it doesn't seem possible to remotely acquire a list of callFrame objects to pass to this method.
I have a feeling I'm completely missing something here. Does anyone know the solution?

Have a look at the Debugger.paused event, which will give you an array of current call frames.

Related

Using wh_shell hook for custom windows-shell(explorer.exe replacement program) C++

So I have spent that past week and a half working on code to simply setup the hook procedure for wh_shell for a program that will replace explorer.exe in the registry and will run as the main desktop program. There seems to be very little information and sources for using this outside of just the windows API which is a bit undescriptive and doesn't explain everything to a great detail. For some reason I just cant get it to work, no matter if I run it inside of explorer.exe, or if I replace the register and make it the default shell. I'm going to ask a couple of things in this post because I think that if you can answer one of these questions you likely have the answer to more.
So first I just have a question about hooks in general: When I run the SetWindowsHookEx(...) function -resource below- it says for var lpfn that a dll is not necessary if the hook is only used to monitor the current process. Now obviously when monitoring events such as window_created, those are events within a different processes which makes me think that the hookproc has to be within a DLL(which is how ive programmed so far). But this is questionable to me because when u are running SetWindowsHookEx(...) the process I wish to monitor do not yet exist until the user decides to start them. Do these processes notify the system when wh_shell events are being done so that I my hook doesnt need to get placed into every process upon creation, or is it more like when I run SetWindowsHookEx(...) with wh_shell that it will place a hook in all processes when the are created. The second resource states that the system just calls the hookproc when these things happen, so then do I even need a DLL, or what process does it need to be hooked to because I dont think it needs to be hooked into everything.
So second I have a question regarding setting my process as default shell - see resources - the resource states any process that registers itself as the default shell(which I assume is just modifying the registry to my process, if not and there is more please let me know) needs to call the SystemsParameterInfo(...) function. So first, does this func need to be called before running SetWindowsHookEx(...) or is there some expected spot it should be elsewhere in my code? Then in regards to the other variables it doesnt specify for, just curious what the recommended would be to set them as, like what are they set as for explorer.exe, and maybe a few other examples(including things NOT to do).
Finally for the sake of testing, using the console will be the most helpful to me here. The console will be used for input to run functions and commands for now(like open the register and swap back the shell to explorer.exe). If my hookproc is within a DLL, I need it to output some messages, I dont want to muddle the same console and I also dont even know if it will output to the same console, so what might be a recommended or potential solution for outputs(again this is temporary and for testing so it doesnt have to be perfect or even great)?
Also I would think windows 11 shouldn't be an issue, but I havent tested on windows 10 system...
I havent included any code as Im pretty sure most of this stuff can be answered without it and that its so few lines of code that its not like typical questions where its like examine my code and help me, maybe some example code you can show me would be really helpful.
Thankyou!
SetWindowsHookEx(...)
https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowshookexa
defaultShell
https://learn.microsoft.com/en-us/windows/win32/winmsg/about-hooks#wh_shell
regards to WH_SHELL section
Testing Environment:
Windows 11 vm running in Hyper-V Manager
You haven't mentioned an important parameter in your description and that is the last argument of SetWindowsHookEx, the thread id.
When it is set to 0 then ..
'[in] Specifies the identifier of the thread with which the hook procedure is to be associated. If this parameter is zero, the hook procedure is associated with all existing threads running in the same desktop as the calling thread.'
That said, then like everything in Windows programming nothing is as what the documentation states, its as if the documentation is a wish-list Microsoft will like Windows to be when it grows up.
Actually even if you manage to get everything right you will see that the shell messages you will get will be VERY few compared to what the documentation states.
I am working on the same issue and when I get it going I will post the results here.

Monitor registry using C++

I want to monitor when a key is changed/added/deleted to the registry whenever application is being installed or removed. I have tested the sample code from the msdn(link) and it works fine.
But the problem is that it does not tell me which key has actually been modified/added/deleted. How can i retrieve this information using c++?
There are only 3 ways, none of which is both easy and adequate:
RegNotifyChangeKeyValue:
Doesn't give you the info you need, but is very easy to use.
EVENT_TRACE_FLAG_REGISTRY which is part of Event Tracing for Windows
which is what ProcMon uses. It works well, but it's quite difficult to use.
I'm not sure exactly how to use it myself, but if I figure it out I'll post it here.
CmRegisterCallback:
Requires kernel-mode driver, which is a pain in 64-bit.
But it's the most perfect solution otherwise.
Unfortunately Event Tracing for Windows (EWT) does not allow to see full key path in the event. You get only a partial key name and a strange handle with is actually a key control block. It's not so simple to get information from this block.
Yes the process monitor uses EWT, but it does not use Windows Kernel Trace as a provider.

Where's the source-code for base::Thread

I was looking up something, and stumbled upon this code:
http://google.com/codesearch?q=kBrowserThreadNames
Where can I find the source for base::Thread?
(Thing is, in debugging something running under firefox.exe, I notice Gecko_IOThread is setting it's thread name in some kind of way and wanted to look up how.)
A quick Mozilla MXR lookup seems to indicate that it's defined in mozilla/ipc/chromium/src/base/thread.h
Edit:
I was also curious about the presence of Chronium code in Mozilla so I googled a bit and found this on the blog of Benjamin Smedberg the commiter of the code:
IPDL is a language which precisely
describes the messages that can be
passed between processes, and allows
developers to define a state machine
and error handling conditions for
messages and resources shared across
processes. IPDL layers on top of an
IPC stack that Mozilla copied from the
Chromium codebase
Just click your way into the code...
http://google.com/codesearch/p?hl=en#cFooKvxdTls/ipc/chromium/src/base/thread.cc&q=kBrowserThreadNames&d=2

How to trace Coldfusion template execution in details?

I have some 'spaghetti'-style code that is generously saused with Custom tags and Stored procedures calls. Templates include each other, custom tags nested and stored procedures are callind other stored procedures in their place.
Problem is that one template call is hanging somewhere in between. I cannot get any error out and cannot see debug output. What is best way to debug such 'hanging' request with as much detail as possible ?
Thanks!
If you are using CF 8+, you can use the Step Debugging tools in Eclipse to step through the code: http://www.adobe.com/devnet/coldfusion/articles/debugger.html
If you are using an earlier version, you can use a 3rd party product like Fusion Debug ( http://www.fusion-debug.com/fd/ ) to do the same thing.
If you are using CF8, you can also use the CF Admin Server Monitor to see where a thread is hanging as well: http://www.adobe.com/devnet/coldfusion/articles/monitoring_pt1.html
If the built-in debugger is of no use cause the request just hang the other quick way is to just start with a cfabort at the top and keep moving it down until you hit the file causing the request to hang.
CFTrace is a great tool for this. It is native and reports time information as well.
Have you looked at the standard coldfusion server log files to see what might be in there?
Have you run the server in a console window so you can see what is appearing in the console as the templates are running (or not as the case might be)?
You could Take jvm thread dumps. You can do from command line or via server monitoring if you have Enterprise 8+

IThumbnailProvider and IInitializeWithItem

I am trying to develop an IThumbnailProvider for use in Windows 7. Since this particular thumbnail would also be dependant on some other files in the same directory, I need to use something other than IInitializeWithStream to a path to work with, this being IInitializeWithItem. (Alternatively, I could use IInitializeWithFile, but that is even more frowned upon apparently.)
No matter what I do, I cannot get it to work. I have Microsoft's FileTypeVerifier.exe tool which gives the green light on using IInitializeWithItem, but when explorer calls it, it only seems to try IInitializeWithStream, ever. (This was tested by temporarily implementing said interface, and Beep()ing away in its Initialize()) Did I forget to configure something?
In short: how do I get this to work?
Okay, I finally found out what is the matter. To quote the Building Thumbnail Providers link on the MSDN website:
There are cases where initialization with streams is not possible. In scenarios where your thumbnail provider does not implement IInitializeWithStream, it must opt out of running in the isolated process where the system indexer places it by default when there is a change to the stream. To opt out of the process isolation feature, set the following registry value.
HKEY_CLASSES_ROOT
CLSID
{66742402-F9B9-11D1-A202-0000F81FEDEE}
DisableProcessIsolation = 1
I knew I was running out of process since I read elsewhere that thumbnailproviders ALWAYS ran out of process. But since that particular snippet is on almost -all- shell extension handlers, I interpreted it to be a overly happy copy-paste job, since it was -required- to run in-process the way I understood it.
And I was wrong. I hope this will help someone else in the near future. :)