MCPcopy Create free account
hub / github.com/BeneficialCode/WinArk / DownloadSymbol

Function DownloadSymbol

PdbParser/main.cpp:17–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15}PDBINFO, * PPDBINFO;
16
17BOOLEAN
18WINAPI
19DownloadSymbol(
20 IN PCHAR SymbolUrl,
21 IN PCHAR SavePath
22)
23{
24 BOOL Success = FALSE;
25 ULONG numOfBytesRead = 0;
26
27 HINTERNET hSession = NULL;
28 HINTERNET hConnect = NULL;
29 HINTERNET hRequest = NULL;
30
31 FILE* fp = NULL;
32
33 UCHAR Buffer[8192] = { 0 };
34
35 hSession = InternetOpenA("", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
36 if (!hSession)
37 {
38 return FALSE;
39 }
40
41 hConnect = InternetConnectA(hSession, "msdl.microsoft.com", 80, "", "", INTERNET_SERVICE_HTTP, 0, 0);
42 if (!hConnect)
43 {
44 InternetCloseHandle(hSession);
45 return FALSE;
46 }
47
48 hRequest = HttpOpenRequestA(hConnect, "GET", SymbolUrl, NULL, NULL, NULL, 0, 0);
49 if (!hRequest)
50 {
51 InternetCloseHandle(hConnect);
52 InternetCloseHandle(hSession);
53 return FALSE;
54 }
55
56 Success = HttpSendRequestA(hRequest, NULL, 0, NULL, 0);
57 if (Success)
58 {
59 fp = fopen(SavePath, "wb+");
60 if (fp)
61 {
62 do
63 {
64 RtlZeroMemory(Buffer, sizeof(Buffer));
65 Success = InternetReadFile(hRequest, Buffer, 8192, &numOfBytesRead);
66 if (Success)
67 {
68 if (numOfBytesRead != 0)
69 {
70 fwrite(Buffer, numOfBytesRead, 1, fp);
71 }
72 else
73 {
74 break;

Callers 1

GetSymbolFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected