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




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