Skip to content
This repository was archived by the owner on Jun 22, 2020. It is now read-only.

Commit 93a16f0

Browse files
committed
Formatted the code
1 parent a882dba commit 93a16f0

File tree

4 files changed

+48
-11
lines changed

4 files changed

+48
-11
lines changed
28 Bytes
Binary file not shown.

Eldorado.HttpProxy/include/winhttp_functions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#pragma once
12
#include <Windows.h>
23

34
// WINHTTP_QUERY_RAW_HEADERS

Eldorado.HttpProxy/source/Logger.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ void Logger::Log(std::wstring message)
1818
time_t time = std::time(nullptr);
1919
tm localtime;
2020
localtime_s(&localtime, &time);
21-
log_stream << _T("[") << std::put_time(&localtime, _T("%d.%m.%Y %H:%M:%S")) << _T("] ") << message.c_str() << _T("\n") << std::flush;
21+
log_stream << _T("[") << std::put_time(&localtime, _T("%d.%m.%Y %H:%M:%S")) << _T("] ");
22+
log_stream << message.c_str() << _T("\n") << std::flush;
2223
}
2324

2425
void Logger::LogFormat(const _TCHAR* format, ...)
@@ -31,7 +32,8 @@ void Logger::LogFormat(const _TCHAR* format, ...)
3132
time_t time = std::time(nullptr);
3233
tm localtime;
3334
localtime_s(&localtime, &time);
34-
log_stream << _T("[") << std::put_time(&localtime, _T("%d.%m.%Y %H:%M:%S")) << _T("] ") << message << _T("\n") << std::flush;
35+
log_stream << _T("[") << std::put_time(&localtime, _T("%d.%m.%Y %H:%M:%S")) << _T("] ");
36+
log_stream << message << _T("\n") << std::flush;
3537
va_end(args);
3638
}
3739

Eldorado.HttpProxy/source/main.cpp

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
#include <string>
2+
13
#include <Windows.h>
24
#include <tchar.h>
3-
#include "winhttp_functions.h"
45
#include "Logger.h"
5-
#include <string>
6+
7+
#include "winhttp_functions.h"
68

79
// globals
810

@@ -71,8 +73,23 @@ HINTERNET WINAPI WinHttpOpenRequest(
7173
IN DWORD dwFlags
7274
)
7375
{
74-
theLogger().LogFormatW(L"Calling WinHttpOpenRequest(%x, %s, %s, %s, %s, %s, %d)", hConnect, pwszVerb, pwszObjectName, pwszVersion, pwszReferrer, ppwszAcceptTypes, dwFlags);
75-
HINTERNET result = oWinHttpOpenRequest(hConnect, pwszVerb, pwszObjectName, pwszVersion, pwszReferrer, ppwszAcceptTypes, dwFlags);
76+
theLogger().LogFormatW(
77+
L"Calling WinHttpOpenRequest(%x, %s, %s, %s, %s, %s, %d)",
78+
hConnect,
79+
pwszVerb,
80+
pwszObjectName,
81+
pwszVersion,
82+
pwszReferrer,
83+
ppwszAcceptTypes,
84+
dwFlags);
85+
HINTERNET result = oWinHttpOpenRequest(
86+
hConnect,
87+
pwszVerb,
88+
pwszObjectName,
89+
pwszVersion,
90+
pwszReferrer,
91+
ppwszAcceptTypes,
92+
dwFlags);
7693
theLogger().LogFormat(_T("WinHttpOpenRequest(%x, ...) returned %x"), hConnect, result);
7794
return result;
7895
}
@@ -112,7 +129,11 @@ BOOL WINAPI WinHttpQueryHeaders(
112129
default:
113130
break;
114131
}
115-
theLogger().LogFormatW(L"WinHttpQueryHeaders(%x, %d, ... ) returned: %s: %s", hRequest, dwInfoLevel, headerName.c_str(), headerValue.c_str());
132+
theLogger().LogFormatW(
133+
L"WinHttpQueryHeaders(%x, %d, ... ) returned: %s: %s",
134+
hRequest, dwInfoLevel,
135+
headerName.c_str(),
136+
headerValue.c_str());
116137
return result;
117138
}
118139

@@ -169,7 +190,14 @@ BOOL WINAPI WinHttpSendRequest(
169190
std::string body = dwOptionalLength == -1 ? std::string(pBody) : std::string(pBody, dwOptionalLength);
170191
theLogger().LogFormatA("WinHttpSendRequest(%x, ...) called with body: %s", hRequest, body.c_str());
171192

172-
return oWinHttpSendRequest(hRequest, lpszHeaders, dwHeadersLength, lpOptional, dwOptionalLength, dwTotalLength, dwContext);
193+
return oWinHttpSendRequest(
194+
hRequest,
195+
lpszHeaders,
196+
dwHeadersLength,
197+
lpOptional,
198+
dwOptionalLength,
199+
dwTotalLength,
200+
dwContext);
173201
}
174202

175203
WINHTTP_STATUS_CALLBACK WINAPI WinHttpSetStatusCallback(
@@ -191,7 +219,13 @@ BOOL WINAPI WinHttpSetTimeouts(
191219
IN int nReceiveTimeout
192220
)
193221
{
194-
theLogger().LogFormat(_T("Calling WinHttpSetTimeouts(%x, %d, %d, %d, %d)"), hInternet, nResolveTimeout, nConnectTimeout, nSendTimeout, nReceiveTimeout);
222+
theLogger().LogFormat(
223+
_T("Calling WinHttpSetTimeouts(%x, %d, %d, %d, %d)"),
224+
hInternet,
225+
nResolveTimeout,
226+
nConnectTimeout,
227+
nSendTimeout,
228+
nReceiveTimeout);
195229
return oWinHttpSetTimeouts(hInternet, nResolveTimeout, nConnectTimeout, nSendTimeout, nReceiveTimeout);
196230
}
197231

@@ -260,14 +294,14 @@ HMODULE LoadOriginalDll()
260294

261295
void InitializeDll(HINSTANCE hInstance)
262296
{
263-
theLogger().LogFormat(_T("####################################################################################################"));
297+
theLogger().LogFormat(_T("("###############################################"));
264298
theLogger().LogFormat(_T("Initializing the winhttp proxy dll"));
265299
DisableThreadLibraryCalls(hInstance);
266300
g_proxy_dll_hInstance = hInstance;
267301
g_original_dll_hInstance = LoadOriginalDll();
268302
InitializeOriginalDllFunctions();
269303
theLogger().LogFormat(_T("Proxy dll initialized"));
270-
theLogger().LogFormat(_T("####################################################################################################"));
304+
theLogger().LogFormat(_T("("###############################################"));
271305
}
272306

273307
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD reason, LPVOID /*reserved*/)

0 commit comments

Comments
 (0)