admin
2023-03-07 8b06b1cbf112d55307ea8a6efe711db4e7506d89
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#pragma once
#include <client/crash_report_database.h>
#include <client/settings.h>
#include <client/crashpad_client.h>
#include <tchar.h>
#include <iostream>
using namespace std;
 
 
bool initCrashPad()
{
 
    using namespace crashpad;
    std::map<std::string, std::string> annotations;
    std::vector<std::string> arguments;
 
    annotations["format"] = "minidump";                 // Required: Crashpad setting to save crash as a minidump
    annotations["database"] = "dumps";     // Required: BugSplat database
    annotations["product"] = "gp";
    annotations["version"] = "1.0.0";
 
 
    std::string url("http://127.0.0.1:8000");
    arguments.push_back("--no-rate-limit");
 
    //std::string crashDirPath("C:/Program Files (x86)/yeshi/GP/logs/dumps/");
    //·ÅdumpµÄÎļþ¼Ð °´Ðè¸Ä
    if (0 != access("C:/Program Files (x86)/yeshi/GP/dumps", 0))
    {
        mkdir("C:/Program Files (x86)/yeshi/GP/dumps");   // ·µ»Ø 0 ±íʾ´´½¨³É¹¦£¬-1 ±íʾʧ°Ü
    }
    base::FilePath db( _T("C:/Program Files (x86)/yeshi/GP/dumps"));
    //crashpad_handler.exe °´Ðè¸Ä
    base::FilePath handler(_T("C:/Program Files (x86)/yeshi/GP/crashpad_handler.exe"));
 
    std::unique_ptr<CrashReportDatabase> database =
        crashpad::CrashReportDatabase::Initialize(db);
 
    if (database == nullptr || database->GetSettings() == NULL)
    {
        cout << "CrashReportDatabase Init Error" <<endl;
        return false;
    }
 
    database->GetSettings()->SetUploadsEnabled(TRUE);
 
    CrashpadClient *client = new CrashpadClient();
    bool ret = client->StartHandler(handler,
        db,
        db,
        url,
        annotations,
        arguments,
        true,
        true);
    if (ret == false)
    {
        return false;
    }
 
    return true;
}