Check for overlapping memory views and delete the offending view if
[wine] / dlls / imagehlp / imagehlp_main.c
1 /*
2  *      IMAGEHLP library
3  *
4  *      Copyright 1998  Patrik Stridvall
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include <stdarg.h>
22
23 #include "windef.h"
24 #include "winbase.h"
25 #include "imagehlp.h"
26 #include "winerror.h"
27 #include "wine/debug.h"
28
29 WINE_DEFAULT_DEBUG_CHANNEL(imagehlp);
30
31 /**********************************************************************/
32
33 HANDLE IMAGEHLP_hHeap = NULL;
34
35 static API_VERSION IMAGEHLP_ApiVersion = { 4, 0, 0, 5 };
36
37 /***********************************************************************
38  *           DllMain (IMAGEHLP.init)
39  */
40 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
41 {
42   switch(fdwReason)
43     {
44     case DLL_PROCESS_ATTACH:
45       DisableThreadLibraryCalls(hinstDLL);
46       IMAGEHLP_hHeap = HeapCreate(0, 0x10000, 0);
47       break;
48     case DLL_PROCESS_DETACH:
49       HeapDestroy(IMAGEHLP_hHeap);
50       IMAGEHLP_hHeap = NULL;
51       break;
52     default:
53       break;
54     }
55   return TRUE;
56 }
57
58 /***********************************************************************
59  *           ImagehlpApiVersion (IMAGEHLP.@)
60  */
61 LPAPI_VERSION WINAPI ImagehlpApiVersion(VOID)
62 {
63   return &IMAGEHLP_ApiVersion;
64 }
65
66 /***********************************************************************
67  *           ImagehlpApiVersionEx (IMAGEHLP.@)
68  */
69 LPAPI_VERSION WINAPI ImagehlpApiVersionEx(LPAPI_VERSION AppVersion)
70 {
71   if(!AppVersion)
72     return NULL;
73
74   AppVersion->MajorVersion = IMAGEHLP_ApiVersion.MajorVersion;
75   AppVersion->MinorVersion = IMAGEHLP_ApiVersion.MinorVersion;
76   AppVersion->Revision = IMAGEHLP_ApiVersion.Revision;
77   AppVersion->Reserved = IMAGEHLP_ApiVersion.Reserved;
78
79   return AppVersion;
80 }
81
82 /***********************************************************************
83  *           MakeSureDirectoryPathExists (IMAGEHLP.@)
84  */
85 BOOL WINAPI MakeSureDirectoryPathExists(LPCSTR DirPath)
86 {
87     if (CreateDirectoryA(DirPath,NULL))
88         return TRUE;
89     if (GetLastError() == ERROR_ALREADY_EXISTS)
90     {
91         SetLastError(ERROR_SUCCESS);
92         return TRUE;
93     }
94     return FALSE;
95 }
96
97 /***********************************************************************
98  *           MarkImageAsRunFromSwap (IMAGEHLP.@)
99  * FIXME
100  *   No documentation available.
101  */
102
103 /***********************************************************************
104  *           SearchTreeForFile (IMAGEHLP.@)
105  */
106 BOOL WINAPI SearchTreeForFile(
107   LPSTR RootPath, LPSTR InputPathName, LPSTR OutputPathBuffer)
108 {
109   FIXME("(%s, %s, %s): stub\n",
110     debugstr_a(RootPath), debugstr_a(InputPathName),
111     debugstr_a(OutputPathBuffer)
112   );
113   SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
114   return FALSE;
115 }
116
117 /***********************************************************************
118  *           TouchFileTimes (IMAGEHLP.@)
119  */
120 BOOL WINAPI TouchFileTimes(
121   HANDLE FileHandle, LPSYSTEMTIME lpSystemTime)
122 {
123   FIXME("(%p, %p): stub\n",
124     FileHandle, lpSystemTime
125   );
126   SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
127   return FALSE;
128 }