Current News
Archived News
Search News
Discussion Forum


Old Forum
Install Programs More Downloads...
Troubleshooting
Source Code
Format Specs.
Misc. Information
Non-SF Stuff
Links




CommitLineData
14362b19 1/*\r
2 Storm.cpp\r
3*/\r
4\r
5#include "storm.h"\r
6\r
7struct STORMMODULE {\r
8 STORMMODULE();\r
9 ~STORMMODULE();\r
10} Storm;\r
11\r
ecca31ff 12void FreeStorm();\r
13\r
14362b19 14HINSTANCE hStorm = 0;\r
15BOOL AlreadyLoaded = FALSE;\r
16\r
17// Storm Function Names\r
18funcSFileCloseArchive SFileCloseArchive = 0;\r
19funcSFileCloseFile SFileCloseFile = 0;\r
20funcSFileDestroy SFileDestroy = 0;\r
21funcSFileGetFileArchive SFileGetFileArchive = 0;\r
22funcSFileGetFileSize SFileGetFileSize = 0;\r
23funcSFileOpenArchive SFileOpenArchive = 0;\r
24funcSFileOpenFile SFileOpenFile = 0;\r
25funcSFileOpenFileEx SFileOpenFileEx = 0;\r
26funcSFileReadFile SFileReadFile = 0;\r
27funcSFileSetBasePath SFileSetBasePath = 0;\r
28funcSFileSetFilePointer SFileSetFilePointer = 0;\r
29funcSFileSetLocale SFileSetLocale = 0;\r
30funcSFileGetBasePath SFileGetBasePath = 0;\r
31funcSFileGetArchiveName SFileGetArchiveName = 0;\r
32funcSFileGetFileName SFileGetFileName = 0;\r
33\r
34STORMMODULE::STORMMODULE()\r
35{\r
36 if (hStorm!=0) return;\r
37 const char STORM_DLL[] = "Storm.dll";\r
38 hStorm = GetModuleHandle(STORM_DLL);\r
39 if (hStorm == NULL) hStorm = LoadLibrary(STORM_DLL);\r
40 else AlreadyLoaded=TRUE;\r
41\r
42 if (hStorm != NULL)\r
43 {\r
44 SFileCloseArchive = (funcSFileCloseArchive)GetProcAddress(hStorm, (LPCSTR)0xFC);\r
45 SFileCloseFile = (funcSFileCloseFile)GetProcAddress(hStorm, (LPCSTR)0xFD);\r
46 SFileDestroy = (funcSFileDestroy)GetProcAddress(hStorm, (LPCSTR)0x106);\r
47 SFileGetFileArchive = (funcSFileGetFileArchive)GetProcAddress(hStorm, (LPCSTR)0x108);\r
48 SFileGetFileSize = (funcSFileGetFileSize)GetProcAddress(hStorm, (LPCSTR)0x109);\r
49 SFileOpenArchive = (funcSFileOpenArchive)GetProcAddress(hStorm, (LPCSTR)0x10A);\r
50 SFileOpenFile = (funcSFileOpenFile)GetProcAddress(hStorm, (LPCSTR)0x10B);\r
51 SFileOpenFileEx = (funcSFileOpenFileEx)GetProcAddress(hStorm, (LPCSTR)0x10C);\r
52 SFileReadFile = (funcSFileReadFile)GetProcAddress(hStorm, (LPCSTR)0x10D);\r
53 SFileSetBasePath = (funcSFileSetBasePath)GetProcAddress(hStorm, (LPCSTR)0x10E);\r
54 SFileSetFilePointer = (funcSFileSetFilePointer)GetProcAddress(hStorm, (LPCSTR)0x10F);\r
55 SFileSetLocale = (funcSFileSetLocale)GetProcAddress(hStorm, (LPCSTR)0x110);\r
56 SFileGetBasePath = (funcSFileGetBasePath)GetProcAddress(hStorm, (LPCSTR)0x111);\r
57 SFileGetArchiveName = (funcSFileGetArchiveName)GetProcAddress(hStorm, (LPCSTR)0x113);\r
58 SFileGetFileName = (funcSFileGetFileName)GetProcAddress(hStorm, (LPCSTR)0x114);\r
59 }\r
60 if (SFileDestroy && !AlreadyLoaded) SFileDestroy();\r
61}\r
62\r
63STORMMODULE::~STORMMODULE()\r
64{\r
ecca31ff 65 FreeStorm();\r
14362b19 66}\r
67\r
68HINSTANCE LoadStorm(char * DllFileName)\r
69{\r
ecca31ff 70 FreeStorm();\r
14362b19 71 if (hStorm!=0) return 0;\r
72 hStorm = GetModuleHandle(DllFileName);\r
73 if (hStorm == NULL) hStorm = LoadLibrary(DllFileName);\r
74 else AlreadyLoaded=TRUE;\r
75\r
76 if (hStorm != NULL)\r
77 {\r
78 SFileCloseArchive = (funcSFileCloseArchive)GetProcAddress(hStorm, (LPCSTR)0xFC);\r
79 SFileCloseFile = (funcSFileCloseFile)GetProcAddress(hStorm, (LPCSTR)0xFD);\r
80 SFileDestroy = (funcSFileDestroy)GetProcAddress(hStorm, (LPCSTR)0x106);\r
81 SFileGetFileArchive = (funcSFileGetFileArchive)GetProcAddress(hStorm, (LPCSTR)0x108);\r
82 SFileGetFileSize = (funcSFileGetFileSize)GetProcAddress(hStorm, (LPCSTR)0x109);\r
83 SFileOpenArchive = (funcSFileOpenArchive)GetProcAddress(hStorm, (LPCSTR)0x10A);\r
84 SFileOpenFile = (funcSFileOpenFile)GetProcAddress(hStorm, (LPCSTR)0x10B);\r
85 SFileOpenFileEx = (funcSFileOpenFileEx)GetProcAddress(hStorm, (LPCSTR)0x10C);\r
86 SFileReadFile = (funcSFileReadFile)GetProcAddress(hStorm, (LPCSTR)0x10D);\r
87 SFileSetBasePath = (funcSFileSetBasePath)GetProcAddress(hStorm, (LPCSTR)0x10E);\r
88 SFileSetFilePointer = (funcSFileSetFilePointer)GetProcAddress(hStorm, (LPCSTR)0x10F);\r
89 SFileSetLocale = (funcSFileSetLocale)GetProcAddress(hStorm, (LPCSTR)0x110);\r
90 SFileGetBasePath = (funcSFileGetBasePath)GetProcAddress(hStorm, (LPCSTR)0x111);\r
91 SFileGetArchiveName = (funcSFileGetArchiveName)GetProcAddress(hStorm, (LPCSTR)0x113);\r
92 SFileGetFileName = (funcSFileGetFileName)GetProcAddress(hStorm, (LPCSTR)0x114);\r
93 }\r
94 if (SFileDestroy && !AlreadyLoaded) SFileDestroy();\r
95 if (AlreadyLoaded==TRUE) return 0;\r
96 return hStorm;\r
97}\r
98\r
ecca31ff 99void FreeStorm()\r
100{\r
101 SFileCloseArchive = 0;\r
102 SFileCloseFile = 0;\r
103 SFileDestroy = 0;\r
104 SFileGetFileArchive = 0;\r
105 SFileGetFileSize = 0;\r
106 SFileOpenArchive = 0;\r
107 SFileOpenFile = 0;\r
108 SFileOpenFileEx = 0;\r
109 SFileReadFile = 0;\r
110 SFileSetBasePath = 0;\r
111 SFileSetFilePointer = 0;\r
112 SFileSetLocale = 0;\r
113 SFileGetBasePath = 0;\r
114 SFileGetArchiveName = 0;\r
115 SFileGetFileName = 0;\r
116\r
117 if (hStorm==0) return;\r
118\r
119 if (AlreadyLoaded==FALSE) FreeLibrary(hStorm);\r
120 hStorm = 0;\r
121}\r