summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/directoryentry.cpp7
-rw-r--r--src/shared/directoryentry.h5
-rw-r--r--src/shared/inject.cpp5
-rw-r--r--src/shared/stackdata.cpp8
-rw-r--r--src/shared/util.cpp44
-rw-r--r--src/shared/util.h6
6 files changed, 8 insertions, 67 deletions
diff --git a/src/shared/directoryentry.cpp b/src/shared/directoryentry.cpp
index 7c0e7119..f34b0566 100644
--- a/src/shared/directoryentry.cpp
+++ b/src/shared/directoryentry.cpp
@@ -24,16 +24,13 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include <ctime>
#include <algorithm>
#include <bsatk.h>
-#include "error_report.h"
-#include "util.h"
#include "windows_error.h"
#include <boost/bind.hpp>
#include <boost/scoped_array.hpp>
#include <boost/foreach.hpp>
-#include "util.h"
#include "leaktrace.h"
-
#include <map>
+#include "error_report.h"
namespace MOShared {
@@ -155,7 +152,7 @@ void FilesOrigin::removeFile(FileEntry::Index index)
-std::wstring tail(const std::wstring &source, const size_t count)
+static std::wstring tail(const std::wstring &source, const size_t count)
{
if (count >= source.length()) {
return source;
diff --git a/src/shared/directoryentry.h b/src/shared/directoryentry.h
index c06a49a1..7a39b576 100644
--- a/src/shared/directoryentry.h
+++ b/src/shared/directoryentry.h
@@ -36,11 +36,6 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include "util.h"
-
-#include "error_report.h"
-
-
-
namespace MOShared {
diff --git a/src/shared/inject.cpp b/src/shared/inject.cpp
index 5a111c4a..cf2a8972 100644
--- a/src/shared/inject.cpp
+++ b/src/shared/inject.cpp
@@ -93,7 +93,7 @@ void injectDLL(HANDLE processHandle, HANDLE threadHandle, const std::string &dll
0x68, 0xBA, 0xAD, 0xF0, 0x0D, // PUSH imm32 ("Init")
0x50, // PUSH EAX
0xB8, 0xBA, 0xAD, 0xF0, 0x0D, // MOVE EAX, imm32 (GetProcAddress)
- 0xFF, 0xD0, // CALL EAX (GetProcAddress)
+ 0xFF, 0xD0, // CALL EAX (=GetProcAddress, leaves address of init function in eax)
0x68, 0xBA, 0xAD, 0xF0, 0x0D, // PUSH imm32 (profile name)
0x68, 0xBA, 0xAD, 0xF0, 0x0D, // PUSH imm32 (log level)
0xFF, 0xD0, // CALL EAX (=InitFunction)
@@ -109,9 +109,6 @@ void injectDLL(HANDLE processHandle, HANDLE threadHandle, const std::string &dll
throw windows_error("failed to allocate memory for stub");
}
TParameters *remoteParams = reinterpret_cast<TParameters*>(remoteMem);
- // determine the remote addresses of each of the parameters
-// ULONG remoteDLLName = reinterpret_cast<ULONG>(remoteMem);
-// ULONG remoteInitString = remoteDLLName + MAX_PATH * sizeof(char);
// dizzy yet? we still have to calculate the entry point as an address relative to our stub
ULONG entryPoint = 0;
diff --git a/src/shared/stackdata.cpp b/src/shared/stackdata.cpp
index 7f6f6e52..016fb346 100644
--- a/src/shared/stackdata.cpp
+++ b/src/shared/stackdata.cpp
@@ -5,12 +5,14 @@
#include <TlHelp32.h>
#include <util.h>
#include <set>
+#include "error_report.h"
+#include <boost/predef.h>
using namespace MOShared;
-void initDbgIfNecess()
+static void initDbgIfNecess()
{
HANDLE process = ::GetCurrentProcess();
static std::set<DWORD> initialized;
@@ -88,8 +90,7 @@ void StackData::load_modules(HANDLE process, DWORD processID) {
CloseHandle(snap);
}
-#include "error_report.h"
-#include <boost/predef.h>
+#pragma warning( disable : 4748 )
void StackData::initTrace() {
load_modules(::GetCurrentProcess(), ::GetCurrentProcessId());
@@ -134,6 +135,7 @@ void StackData::initTrace() {
}
}
+#pragma warning( enable : 4748 )
bool MOShared::operator==(const StackData &LHS, const StackData &RHS) {
if (LHS.m_Count != RHS.m_Count) {
diff --git a/src/shared/util.cpp b/src/shared/util.cpp
index 1cbf088b..0f49d036 100644
--- a/src/shared/util.cpp
+++ b/src/shared/util.cpp
@@ -141,48 +141,4 @@ VS_FIXEDFILEINFO GetFileVersion(const std::wstring &fileName)
}
-
-
-std::string GetStack()
-{
-#ifdef _DEBUG
- HANDLE process = ::GetCurrentProcess();
- static std::set<DWORD> initialized;
- if (initialized.find(::GetCurrentProcessId()) == initialized.end()) {
- static bool firstCall = true;
- if (firstCall) {
- ::SymSetOptions(SYMOPT_UNDNAME | SYMOPT_DEFERRED_LOADS);
- firstCall = false;
- }
- if (!::SymInitialize(process, NULL, TRUE)) {
- log("failed to initialize symbols: %d", ::GetLastError());
- }
- initialized.insert(::GetCurrentProcessId());
- }
-
- LPVOID stack[32];
- WORD frames = ::CaptureStackBackTrace(0, 100, stack, NULL);
-
- char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR)];
- PSYMBOL_INFO symbol = (PSYMBOL_INFO)buffer;
- symbol->SizeOfStruct = sizeof(SYMBOL_INFO);
- symbol->MaxNameLen = MAX_SYM_NAME;
-
- std::ostringstream stackStream;
- for(unsigned int i = 0; i < frames; ++i) {
- DWORD64 addr = (DWORD64)stack[i];
- DWORD64 displacement = 0;
- if (!::SymFromAddr(::GetCurrentProcess(), addr, &displacement, symbol)) {
- stackStream << frames - i - 1 << ": " << stack[i] << " - " << ::GetLastError() << " (error)\n";
- } else {
- stackStream << frames - i - 1 << ": " << symbol->Name << "\n";
- }
- }
- return stackStream.str();
-#else
- return "";
-#endif
-}
-
-
} // namespace MOShared
diff --git a/src/shared/util.h b/src/shared/util.h
index eba3fb3c..14017526 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -27,9 +27,6 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
namespace MOShared {
-
-static const int MAXPATH_UNICODE = 32767;
-
/// Test if a file (or directory) by the specified name exists
bool FileExists(const std::string &filename);
bool FileExists(const std::wstring &filename);
@@ -47,9 +44,6 @@ std::wstring ToLower(const std::wstring &text);
VS_FIXEDFILEINFO GetFileVersion(const std::wstring &fileName);
-/// Get a stack trace as a line-break separated list of function names. This only works in debug builds
-std::string GetStack();
-
} // namespace MOShared
#endif // UTIL_H