How do you configure the email settings in CrashRpt to send the crash dump? - c++

After reading this discussion and this discussion about using CrashRpt to generate a crash dump and email it to the developers, I've been having a difficult time finding any instructions/tutorials for configuring the email settings used by the library to send the email.
When you call the install() function to initialize CrashRpt, you specify the email address you want the crash dump sent to, but how does the CrashPrt library know how to send the email to that address? Wouldn't the library have to know the email client settings for each individual user?
When a fatal crash occurs in my code, the CrashRpt dialog box pops up and when I enter my email address and click the send button, it takes me to a "Save File" dialog box where I can save the zipped package and the account specified in the Install() function never receives an email.
Thanks in advance for any and all help! I'm clearly missing something.

What CrashRpt does for emailing:
The email system simply uses MAPI to send your email. Which would try to use your default mail client if you have one, and if it supports MAPI. Take a look at MailMsg.cpp for details.
Personal experience:
In my company's usage of CrashRpt, we modified it a bit though to call a web service that we created which submits the crash report. So we gutted the emailing code completely from CrashRpt. And instead we have in our bug tracking system a section for crashes that were auto submitted when crashes happen.
To find your problem:
I would maybe try to debug the CrashRpt code to see why it's giving you a save dialog. It should instead just open your default mail client. Maybe you have an older version of the library, or maybe the dialog resources are a little messed. Debugging the code will tell you this though.
Most likely MailReport is being called but is failing.
Set a breakpoint in the original CrashRpt code's CrashHandler.cpp at just after the DoModal:
mainDlg.m_pUDFiles = &m_files;
if (IDOK == mainDlg.DoModal())
{
//Put breakpoint here <---------
if (m_sTo.IsEmpty() ||
!MailReport(rpt, sTempFileName, mainDlg.m_sEmail, mainDlg.m_sDescription))
{
SaveReport(rpt, sTempFileName);
}
}
Check to see why MailReport is not getting called. It's either the dialog resource, or your m_sTo is not filled or you can step through MailMsg.cpp and see where MAPI is failing.
Alternate solution:
An easy fix, if you find above that MailReport is being called, but not succeeding, is to instead just do a ShellExecute and specify a mailto:
You could even try to use the MAPI method, but if that fails to do a mailto:

You can find the CrashRpt documentation, FAQ and download a new CrashRpt v1.1 here http://code.google.com/p/crashrpt/

Related

Python Selenium Alert Authentication Trouble

I am trying to access a website that requires a login thru an alert box such as the one below:
I have tried to look up many different ways to do this and they dont seem to work. what i have tried are listed below:
Didnt work and gave me the same login alert.
start_url = 'http://username:password#example.com'
agent.get(start_url)
Keep getting an error message saying "NoAlertPresentException: Message: no alert open"
start_url = 'http://www.example.com'
alert = agent.switch_to_alert()
alert.send_keys("username")
alert.send_keys("password")
Get an error saying webdriver has no attribute "switchTo"
start_url = 'http://www.example.com'
agent.switchTo().alert().sendKeys("username")
I have to use Chrome because of the versions of IE and Firefox I have and can get, do not support the functions in the site
I have been having this exact same issue for some time now - with my end goal being to do this headless (in the background without visually launching an instance of Chromedriver).
Non-Ideal Solution 1:
I first used a library called pynput to automatically type the credentials in to the alert box and click the ok button, it was pretty simple to get working but:
still didn't work headlessly
I had to be focused on the browser or it would type the credentials elsewhere
This worked great in the meantime as everywhere I looked online it seemed like there was nothing I could do to overcome authentication alerts headlessly...
I'm a relative beginner (started programming <1 year ago) so perhaps I just wasn't looking in the right places!
I've now solved this issue though like so:
First I logged in to the alert as normal on Chrome while monitoring the Network section of devtools to get a good look at the GET request for the protected page screencap here:
Upon seeing that the Authorization was Basic (this will work for Bearer too) I tested just copying the same request in Postman with this header and it worked! Now if only there was a way to make http requests from Selenium???
I first tried the library selenium-requests (which didn't work for me: I got the same error as this person https://github.com/cryzed/Selenium-Requests/issues/33
This library seems absolutely excellent and exactly what I needed, I just don't currently have the know-how to get past firewalls/whatever was stopping me at this stage...
What eventually worked for me was the library selenium-wire. I followed this guide https://pypi.org/project/selenium-wire/#intercepting-requests-and-responses to have the webdriver navigate to the protected page as normal, but intercept the request and add the Authorization header before sending it :) now this works for me totally headlessly. Granted, this won't work on more secure websites but I hope it helps someone having the same issue.
This is Pythoncode
Problem with alert boxes (especially sweet-alerts is that they have a
delay and Selenium is pretty much too fast)
An Option that worked for me is: (just exchange the button click in the end with whatever action you want to have)
while True:
try:
driver.find_element_by_xpath('//div[#class="sweet-alert showSweetAlert visible"]')
break
except:
wait = WebDriverWait(driver, 1000)
confirm_button = driver.find_element_by_xpath('//button[#class="confirm"]')
confirm_button.click()
Note to 2: Here is probably the error due to the alert taking more time to load than the single elements (such as username, etc.)
Note to 3.: I think it should be switch_to

Minifilter: Block applications with notification

I'm writing a minifilter to block application execution. The minifilter will request a file scan on IRP_MJ_CREATE to the usermode apps. The usermode application will scan whether to allow the PE file (.exe/.dll/etc) execution or no.
Currently, when the usermode apps says no, the minifilter will issue an access denied status, and cancelling the file open. (Yes, using FltCancelFileOpen)
The problem when issuing access denied return value is, from the user perspective, they will get a message box from the system like this:
Another example, when blocking the specific dll from being loaded, another messagebox will appear:
What I want to accomplish is to still deny the open but suppress the message box and have a notification of my own, which is a user friendly error message indicating the apps were blocked. Example are like windows 8 smartscreen feature, which will notify the user when running blocked exe without any messagebox saying access denied or similar.
How can I do that?
Let's take the DLL example. You get that error because there's code in Windows equivalent to
if (!LoadLibrary(szDllName))
{
MessageBox("Application Error", ...);
}
else
{
DllMain = GetProcAddress("DllMain");
DllMain(DLL_PROCESS_ATTACH);
So, if you don't want the first branch of the code to be taken, you should allow the DLL to load. There's no third option.
The Windows 8 example is misleading. If you're Microsoft, of course you can add that third option.
[edit]
On second thought, did you cancel the operation using FltCancelFileOpen ? If not, then how did you do it?

Writing to the Windows Security Log with C++

I have been tasked with writing entries to the Windows security log. The entire project is Win32 C++ code. I have already written (with help from various online resources) a logging class that handles registration, deregistration, and code for executing the ReportEvent() call. Also, I've done the mc.exe and rc.exe steps for my event logging, if that helps establish where I'm at in the project.
My question is a multi-parter:
I've noticed at Filling Windows XP Security Event Log that there are some who believe this is not allowed by Windows. Others ( How to write log to SECURITY event Log in C#? ) imply otherwise. Possible or not?
If it is possible, how to get it to write to the security log. Is it as simple as specifying "Security" as my source name when calling RegisterEventSource()?
As far as deregistration, when should that occur? When the app is uninstalled? When the app closes? When the log entry is written?
How do I look up my log entries? I look in the Windows Event Viewer, but I don't see the entries I add with my test app, despite all the appropriate return values from the system calls. Where would I look up the events that I specified with a source name of "yarp" when I made my call to RegisterEventSource()?
For the moment, I'll just deal with the first question, because the answer to that probably renders the rest irrelevant.
Only Local Security Authority (lsass.exe) can write to the security log. This isn't a matter that something else attempting to get the privilege will fail -- it's a matter of there not being a way for anything else to even request the privilege at all (and this is by design).
From there, about the only answer to your other questions is "Sorry!"

How to open source file in specific instance of Visual Studio (2008)

I have several instances of Visual Studio 2008 opened and I want to open a source file in a specific instance.
I plan to do this with Win32 API and something like ShellExecute(...), but I can't find solution yet.
Is there any way to do so? Any thoughts?
Unless the application opening the file (VS2008) has a message handler set up to initiate opening a file (not sure if it does or not; this would be the easiest method), you could probably simulate a drag-and-drop of the file to the application's client area (via message sending directly to the client window's message handler). You would need to get a handle to the client window of VS2008 for the instance you are sending the message to.
Don't know what the purpose would be, though. You can generally call up a new instance to open the file using ShellExecute(), but that wouldn't refer to a specific instance that is already running.
Another method you might consider is to hook VS2008's message handler for the main window, and log all messages sent relating to menu commands. You might be able to determine if there is a message event associated with opening a file. Figuring out the parameters sent to the WndProc() function would be another story. Hopefully it would be sent as a string pointer (for the filename) to lParam.
You could try using AutoHotKey. It's got a built-in scripting language and has various alternative ways of identifying which application to send its messages to.

Is a separate message file library for my native Win32 service necessary?

We've got an old legacy win32 service, developed with C++, and we've just recently noticed that when the service starts up and stops, there is an informational message in the event logs about our missing event descriptions. To be more precise, the message looks like this:
The description for Event ID 0 from source [application] cannot be
found. Either the component that raises this event is not installed on
your local computer or the installation is corrupted. You can install
or repair the component on the local computer.
So we understand what this means, basically we're missing a library which has a message table compiled into it. This way when the event ID for changing status (start/stop) arrives, it can look up the message and print it in the event logs.
The question is, for these universal messages (changing status etc) which pretty much every service is going to have, surely there are default message table that we can use, rather than having to go to the trouble of creating another project, just for this, adding registries and updating our installer.
Seems like a lot of hassle for something that should surely be a default somewhere? Like the standard win32 error messages?
I've created a number of managed services in the past, and I'm pretty sure we didn't need to do anything like this before!
So to wrap this up, I guess the answer is that the a new message table/file is always required, regardless (so no there are no default messages you can use), so I'll just have to chuck in a message table into my services resource file and add a registry entry to the installer.
Still find it baffling thought that every native service has it's own 'service has stopped/started' message...!
Thanks!