• R/O
  • SSH
  • HTTPS

netoffice: Commit


Commit MetaInfo

Revision196 (tree)
Time2018-07-23 21:43:23
Authorsebastiandotnet

Log Message

- complete shim logging

Change Summary

Incremental Difference

Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
--- NetOfficeShimLoader/ShimLoader/DllRegister32On64.cpp (revision 195)
+++ NetOfficeShimLoader/ShimLoader/DllRegister32On64.cpp (revision 196)
@@ -97,7 +97,7 @@
9797 NetOffice_ShimLoader_Analytics::WriteUnRegisterError(L"Register32On64::DllUnregister::Error#UnregisterCOMComponent", hr);
9898
9999 if(SUCCEEDED(addin != S_OK ? addin : hr))
100- NetOffice_ShimLoader_Analytics::WriteRegisterLog(L"Register32On64::DllUnregister::Exit");
100+ NetOffice_ShimLoader_Analytics::WriteUnRegisterLog(L"Register32On64::DllUnregister::Exit");
101101 else
102102 NetOffice_ShimLoader_Analytics::WriteUnRegisterError(L"Register32On64::DllUnregister::FailExit", (addin != S_OK ? addin : hr));
103103
--- NetOfficeShimLoader/ShimLoader/Module.hpp (nonexistent)
+++ NetOfficeShimLoader/ShimLoader/Module.hpp (revision 196)
@@ -0,0 +1,55 @@
1+#pragma once
2+#include "stdafx.h"
3+#include "atlbase.h"
4+#include <fstream>
5+#include <iosfwd>
6+#include <iostream>
7+#include <ctime>
8+
9+namespace NetOffice_ShimLoader_Module
10+{
11+ static HRESULT GetModuleFileName(WCHAR* szPath, DWORD nPathBufferSize)
12+ {
13+ HMODULE hInstance = _AtlBaseModule.GetModuleInstance();
14+ if (0 == hInstance)
15+ {
16+ return E_FAIL;
17+ }
18+
19+ DWORD dwFLen = ::GetModuleFileName(hInstance, szPath, nPathBufferSize);
20+ if (0 != dwFLen)
21+ {
22+ return S_OK;
23+ }
24+ else
25+ {
26+ return E_FAIL;
27+ }
28+ }
29+
30+ static HRESULT GetDllDirectory(WCHAR* szPath, DWORD nPathBufferSize)
31+ {
32+ HMODULE hInstance = _AtlBaseModule.GetModuleInstance();
33+ if (0 == hInstance)
34+ {
35+ return E_FAIL;
36+ }
37+
38+ TCHAR szModule[MAX_PATH + 1];
39+ DWORD dwFLen = ::GetModuleFileName(hInstance, szModule, MAX_PATH);
40+ if (0 == dwFLen)
41+ {
42+ return E_FAIL;
43+ }
44+
45+ TCHAR* pszFileName;
46+ dwFLen = ::GetFullPathName(szModule, nPathBufferSize, szPath, &pszFileName);
47+ if (0 == dwFLen || dwFLen >= nPathBufferSize)
48+ {
49+ return E_FAIL;
50+ }
51+
52+ *pszFileName = 0;
53+ return S_OK;
54+ }
55+}
\ No newline at end of file
--- NetOfficeShimLoader/ShimLoader/WriteLog.hpp (revision 195)
+++ NetOfficeShimLoader/ShimLoader/WriteLog.hpp (revision 196)
@@ -5,10 +5,9 @@
55 #include <iosfwd>
66 #include <iostream>
77 #include <ctime>
8+#include "Module.hpp"
89
910 extern WCHAR* LogFile_Path;
10-extern WCHAR* LogFile_Register_Path;
11-extern WCHAR* LogFile_UnRegister_Path;
1211 extern BOOL Internal_LogError_MessageBoxes_Enabled;
1312
1413 namespace NetOffice_ShimLoader_Analytics
@@ -15,51 +14,6 @@
1514 {
1615 static const int _bufferSize = 1024;
1716
18- static HRESULT GetModuleFileName(WCHAR* szPath, DWORD nPathBufferSize)
19- {
20- HMODULE hInstance = _AtlBaseModule.GetModuleInstance();
21- if (0 == hInstance)
22- {
23- return E_FAIL;
24- }
25-
26- DWORD dwFLen = ::GetModuleFileName(hInstance, szPath, nPathBufferSize);
27- if (0 != dwFLen)
28- {
29- return S_OK;
30- }
31- else
32- {
33- return E_FAIL;
34- }
35- }
36-
37- static HRESULT GetDllDirectory(WCHAR* szPath, DWORD nPathBufferSize)
38- {
39- HMODULE hInstance = _AtlBaseModule.GetModuleInstance();
40- if (0 == hInstance)
41- {
42- return E_FAIL;
43- }
44-
45- TCHAR szModule[MAX_PATH + 1];
46- DWORD dwFLen = ::GetModuleFileName(hInstance, szModule, MAX_PATH);
47- if (0 == dwFLen)
48- {
49- return E_FAIL;
50- }
51-
52- TCHAR* pszFileName;
53- dwFLen = ::GetFullPathName(szModule, nPathBufferSize, szPath, &pszFileName);
54- if (0 == dwFLen || dwFLen >= nPathBufferSize)
55- {
56- return E_FAIL;
57- }
58-
59- *pszFileName = 0;
60- return S_OK;
61- }
62-
6317 static HRESULT InitializeLog()
6418 {
6519 HRESULT hr = S_OK;
@@ -67,13 +21,11 @@
6721 WCHAR moduleFolderPath[MAX_PATH];
6822 WCHAR moduleFileName[MAX_PATH];
6923 WCHAR logFileName[MAX_PATH];
70- WCHAR logRegisterFileName[MAX_PATH];
71- WCHAR logUnregisterFileName[MAX_PATH];
7224
73- hr = GetDllDirectory(moduleFolderPath, MAX_PATH);
25+ hr = NetOffice_ShimLoader_Module::GetDllDirectory(moduleFolderPath, MAX_PATH);
7426 if (FAILED(hr))
7527 goto Error;
76- hr = GetModuleFileName(moduleFileName, MAX_PATH);
28+ hr = NetOffice_ShimLoader_Module::GetModuleFileName(moduleFileName, MAX_PATH);
7729 if (FAILED(hr))
7830 goto Error;
7931 PathStripPath(moduleFileName);
@@ -81,14 +33,6 @@
8133 StringCchCopy(logFileName, MAX_PATH, moduleFileName);
8234 StringCchCat(logFileName, MAX_PATH, L".log");
8335
84- StringCchCopy(logRegisterFileName, MAX_PATH, moduleFileName);
85- StringCchCat(logRegisterFileName, MAX_PATH, L".Register");
86- StringCchCat(logRegisterFileName, MAX_PATH, L".log");
87-
88- StringCchCopy(logUnregisterFileName, MAX_PATH, moduleFileName);
89- StringCchCat(logUnregisterFileName, MAX_PATH, L".Unregister");
90- StringCchCat(logUnregisterFileName, MAX_PATH, L".log");
91-
9236 PathAppend(LogFile_Path, moduleFolderPath);
9337 if (LogFile_Path && SUCCEEDED(PathAppend(LogFile_Path, logFileName)))
9438 {
@@ -98,24 +42,6 @@
9842 }
9943 }
10044
101- PathAppend(LogFile_Register_Path, moduleFolderPath);
102- if (LogFile_Register_Path && SUCCEEDED(PathAppend(LogFile_Register_Path, logRegisterFileName)))
103- {
104- if (PathFileExists(LogFile_Register_Path))
105- {
106- DeleteFile(LogFile_Register_Path);
107- }
108- }
109-
110- PathAppend(LogFile_UnRegister_Path, moduleFolderPath);
111- if (LogFile_UnRegister_Path && SUCCEEDED(PathAppend(LogFile_UnRegister_Path, logUnregisterFileName)))
112- {
113- if (PathFileExists(LogFile_UnRegister_Path))
114- {
115- DeleteFile(LogFile_UnRegister_Path);
116- }
117- }
118-
11945 return hr;
12046
12147 Error:
@@ -139,39 +65,6 @@
13965 }
14066 }
14167
142- static void _WriteRegister(LPCWSTR text)
143- {
144- std::wofstream myfile(LogFile_Register_Path, std::ios::app);
145- if (LogFile_Register_Path && myfile.is_open())
146- {
147- myfile << text << std::endl;
148- myfile.close();
149- }
150- else
151- {
152- #ifdef DEBUG
153- MessageBox(GetDesktopWindow(), LogFile_Register_Path, L"WriteLog::_WriteRegister::OpenFileError", 0);
154- #endif
155- }
156- }
157-
158- static void _WriteUnRegister(LPCWSTR text)
159- {
160- MessageBox(NULL, LogFile_UnRegister_Path, text, 0);
161- std::wofstream myfile(LogFile_UnRegister_Path, std::ios::app);
162- if (LogFile_UnRegister_Path && myfile.is_open())
163- {
164- myfile << text << std::endl;
165- myfile.close();
166- }
167- else
168- {
169- #ifdef DEBUG
170- MessageBox(GetDesktopWindow(), LogFile_UnRegister_Path, L"WriteLog::_WriteUnRegister::OpenFileError", 0);
171- #endif
172- }
173- }
174-
17568 static void WriteError(LPCWSTR text, ULONG value)
17669 {
17770 WCHAR buffer[_bufferSize];
@@ -186,34 +79,6 @@
18679 #endif
18780 }
18881
189- static void WriteRegisterError(LPCWSTR text, HRESULT value)
190- {
191- WCHAR buffer[_bufferSize];
192- swprintf_s(buffer, _bufferSize, L"%s(HR:%d)", text, value);
193- _WriteRegister(text);
194-
195- #ifdef DEBUG
196-
197- if (Internal_LogError_MessageBoxes_Enabled)
198- MessageBox(GetDesktopWindow(), buffer, L"WriteError", 0);
199-
200- #endif
201- }
202-
203- static void WriteUnRegisterError(LPCWSTR text, HRESULT value)
204- {
205- WCHAR buffer[_bufferSize];
206- swprintf_s(buffer, _bufferSize, L"%s(HR:%d)", text, value);
207- _WriteUnRegister(text);
208-
209- #ifdef DEBUG
210-
211- if (Internal_LogError_MessageBoxes_Enabled)
212- MessageBox(GetDesktopWindow(), buffer, L"WriteError", 0);
213-
214- #endif
215- }
216-
21782 static void WriteError(LPCWSTR text, HRESULT value)
21883 {
21984 WCHAR buffer[_bufferSize];
@@ -261,16 +126,6 @@
261126 _Write(text);
262127 }
263128
264- static void WriteRegisterLog(LPCWSTR text)
265- {
266- _WriteRegister(text);
267- }
268-
269- static void WriteUnRegisterLog(LPCWSTR text)
270- {
271- _WriteUnRegister(text);
272- }
273-
274129 static void WriteLog(LPCWSTR text)
275130 {
276131 _Write(text);
--- NetOfficeShimLoader/ShimLoader/WriteRegisterLog.hpp (revision 195)
+++ NetOfficeShimLoader/ShimLoader/WriteRegisterLog.hpp (revision 196)
@@ -1 +1,91 @@
11 #pragma once
2+#include "stdafx.h"
3+#include "atlbase.h"
4+#include <fstream>
5+#include <iosfwd>
6+#include <iostream>
7+#include <ctime>
8+#include "Module.hpp"
9+
10+extern WCHAR* LogFile_Register_Path;
11+extern BOOL Internal_LogError_MessageBoxes_Enabled;
12+
13+namespace NetOffice_ShimLoader_Analytics
14+{
15+ static HRESULT InitializeWriteRegisterLog()
16+ {
17+ HRESULT hr = S_OK;
18+
19+ WCHAR moduleFolderPath[MAX_PATH];
20+ WCHAR moduleFileName[MAX_PATH];
21+ WCHAR logRegisterFileName[MAX_PATH];
22+
23+ hr = NetOffice_ShimLoader_Module::GetDllDirectory(moduleFolderPath, MAX_PATH);
24+ if (FAILED(hr))
25+ goto Error;
26+ hr = NetOffice_ShimLoader_Module::GetModuleFileName(moduleFileName, MAX_PATH);
27+ if (FAILED(hr))
28+ goto Error;
29+ PathStripPath(moduleFileName);
30+
31+ StringCchCopy(logRegisterFileName, MAX_PATH, moduleFileName);
32+ StringCchCat(logRegisterFileName, MAX_PATH, L".Register");
33+ StringCchCat(logRegisterFileName, MAX_PATH, L".log");
34+
35+ PathAppend(LogFile_Register_Path, moduleFolderPath);
36+ if (LogFile_Register_Path && SUCCEEDED(PathAppend(LogFile_Register_Path, logRegisterFileName)))
37+ {
38+ if (PathFileExists(LogFile_Register_Path))
39+ {
40+ DeleteFile(LogFile_Register_Path);
41+ }
42+ }
43+
44+ return hr;
45+
46+ Error:
47+
48+ return hr;
49+ }
50+
51+ static void _WriteRegister(LPCWSTR text)
52+ {
53+ std::wofstream myfile(LogFile_Register_Path, std::ios::app);
54+ if (LogFile_Register_Path && myfile.is_open())
55+ {
56+ myfile << text << std::endl;
57+ myfile.close();
58+ }
59+ else
60+ {
61+ #ifdef DEBUG
62+ MessageBox(GetDesktopWindow(), text, L"WriteLog::_WriteRegister::OpenFileError", 0);
63+ #endif
64+ }
65+ }
66+
67+ static void WriteRegisterError(LPCWSTR text, HRESULT value)
68+ {
69+ WCHAR buffer[_bufferSize];
70+ swprintf_s(buffer, _bufferSize, L"%s(HR:%d)", text, value);
71+ _WriteRegister(text);
72+
73+ #ifdef DEBUG
74+
75+ if (Internal_LogError_MessageBoxes_Enabled)
76+ MessageBox(GetDesktopWindow(), buffer, L"WriteError", 0);
77+
78+ #endif
79+ }
80+
81+ static void WriteRegisterError(LPCWSTR text)
82+ {
83+ _WriteRegister(text);
84+ }
85+
86+ static void WriteRegisterLog(LPCWSTR text)
87+ {
88+ _WriteRegister(text);
89+ }
90+
91+}
--- NetOfficeShimLoader/ShimLoader/WriteUnRegisterLog.hpp (revision 195)
+++ NetOfficeShimLoader/ShimLoader/WriteUnRegisterLog.hpp (revision 196)
@@ -1 +1,90 @@
11 #pragma once
2+#include "stdafx.h"
3+#include "atlbase.h"
4+#include <fstream>
5+#include <iosfwd>
6+#include <iostream>
7+#include <ctime>
8+#include "Module.hpp"
9+
10+extern WCHAR* LogFile_UnRegister_Path;
11+extern BOOL Internal_LogError_MessageBoxes_Enabled;
12+
13+namespace NetOffice_ShimLoader_Analytics
14+{
15+ static HRESULT InitializeUnRegisterLog()
16+ {
17+ HRESULT hr = S_OK;
18+
19+ WCHAR moduleFolderPath[MAX_PATH];
20+ WCHAR moduleFileName[MAX_PATH];
21+ WCHAR logUnregisterFileName[MAX_PATH];
22+
23+ hr = NetOffice_ShimLoader_Module::GetDllDirectory(moduleFolderPath, MAX_PATH);
24+ if (FAILED(hr))
25+ goto Error;
26+ hr = NetOffice_ShimLoader_Module::GetModuleFileName(moduleFileName, MAX_PATH);
27+ if (FAILED(hr))
28+ goto Error;
29+ PathStripPath(moduleFileName);
30+
31+ StringCchCopy(logUnregisterFileName, MAX_PATH, moduleFileName);
32+ StringCchCat(logUnregisterFileName, MAX_PATH, L".Unregister");
33+ StringCchCat(logUnregisterFileName, MAX_PATH, L".log");
34+
35+ PathAppend(LogFile_UnRegister_Path, moduleFolderPath);
36+ if (LogFile_UnRegister_Path && SUCCEEDED(PathAppend(LogFile_UnRegister_Path, logUnregisterFileName)))
37+ {
38+ if (PathFileExists(LogFile_UnRegister_Path))
39+ {
40+ DeleteFile(LogFile_UnRegister_Path);
41+ }
42+ }
43+
44+ return hr;
45+
46+ Error:
47+
48+ return hr;
49+ }
50+
51+ static void _WriteUnRegister(LPCWSTR text)
52+ {
53+ std::wofstream myfile(LogFile_UnRegister_Path, std::ios::app);
54+ if (LogFile_UnRegister_Path && myfile.is_open())
55+ {
56+ myfile << text << std::endl;
57+ myfile.close();
58+ }
59+ else
60+ {
61+ #ifdef DEBUG
62+ MessageBox(GetDesktopWindow(), text, L"WriteLog::_WriteUnRegister::OpenFileError", 0);
63+ #endif
64+ }
65+ }
66+
67+ static void WriteUnRegisterError(LPCWSTR text, HRESULT value)
68+ {
69+ WCHAR buffer[_bufferSize];
70+ swprintf_s(buffer, _bufferSize, L"%s(HR:%d)", text, value);
71+ _WriteUnRegister(text);
72+
73+ #ifdef DEBUG
74+
75+ if (Internal_LogError_MessageBoxes_Enabled)
76+ MessageBox(GetDesktopWindow(), buffer, L"WriteError", 0);
77+
78+ #endif
79+ }
80+
81+ static void WriteUnRegisterError(LPCWSTR text)
82+ {
83+ _WriteUnRegister(text);
84+ }
85+
86+ static void WriteUnRegisterLog(LPCWSTR text)
87+ {
88+ _WriteUnRegister(text);
89+ }
90+}
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Show on old repository browser