]> git.notmuchmail.org Git - apitrace/blobdiff - os_win32.cpp
More parameters. Cleanups.
[apitrace] / os_win32.cpp
index 2e28ec8695967b15e9f636f0dfc0eaaef8c7b0f5..e96cc93d63431f9a74b5f5057313b113422986af 100644 (file)
 
 #include <windows.h>
 #include <string.h>
+#include <stdio.h>
 
 #include "os.hpp"
+#include "log.hpp"
 
 
 namespace OS {
@@ -37,21 +39,21 @@ namespace OS {
  */
 static CRITICAL_SECTION
 CriticalSection = {
-    (_CRITICAL_SECTION_DEBUG *)-1, -1, 0, 0, 0, 0
+    (PCRITICAL_SECTION_DEBUG)-1, -1, 0, 0, 0, 0
 };
 
 
 void
 AcquireMutex(void)
 {
-    EnterCriticalSection(&CriticalSection); 
+    //EnterCriticalSection(&CriticalSection); 
 }
 
 
 void
 ReleaseMutex(void)
 {
-    LeaveCriticalSection(&CriticalSection); 
+    //LeaveCriticalSection(&CriticalSection); 
 }
 
 
@@ -69,7 +71,7 @@ GetProcessName(char *str, size_t size)
 
     lpProcessExt = strrchr(lpProcessName, '.');
     if (lpProcessExt) {
-       *lpProcessExt = '\0';
+        *lpProcessExt = '\0';
     }
 
     strncpy(str, lpProcessName, size);
@@ -77,5 +79,55 @@ GetProcessName(char *str, size_t size)
     return true;
 }
 
+bool
+GetCurrentDir(char *str, size_t size)
+{
+    DWORD ret;
+    ret = GetCurrentDirectoryA(size, str);
+    str[size - 1] = 0;
+    return ret == 0 ? false : true;
+}
+
+void
+DebugMessage(const char *message)
+{
+   OutputDebugStringA(message);
+   if (!IsDebuggerPresent()) {
+      fflush(stdout);
+      fputs(message, stderr);
+      fflush(stderr);
+   }
+}
+
+void
+Abort(void)
+{
+#ifndef NDEBUG
+    DebugBreak();
+#else
+    ExitProcess(0);
+#endif
+}
+
+
 
 } /* namespace OS */
+
+
+#if 0
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
+    switch(fdwReason) {
+    case DLL_PROCESS_ATTACH:
+    case DLL_THREAD_ATTACH:
+        return TRUE;
+    case DLL_THREAD_DETACH:
+        return TRUE;
+    case DLL_PROCESS_DETACH:
+        Log::Close();
+        return TRUE;
+    }
+    (void)hinstDLL;
+    (void)lpvReserved;
+    return TRUE;
+}
+#endif