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
09d0556c 1/*
2 Storm.cpp
3*/
4
5#include "storm.h"
6
7struct STORMMODULE {
8 STORMMODULE();
9 ~STORMMODULE();
10} Storm;
11
12void FreeStorm();
13
14HINSTANCE hStorm = 0;
15BOOL AlreadyLoaded = FALSE;
16
17// Storm Function Names
18funcSFileCloseArchive SFileCloseArchive = 0;
19funcSFileCloseFile SFileCloseFile = 0;
20funcSFileDestroy SFileDestroy = 0;
21funcSFileGetFileArchive SFileGetFileArchive = 0;
22funcSFileGetFileSize SFileGetFileSize = 0;
23funcSFileOpenArchive SFileOpenArchive = 0;
24funcSFileOpenFile SFileOpenFile = 0;
25funcSFileOpenFileEx SFileOpenFileEx = 0;
26funcSFileReadFile SFileReadFile = 0;
27funcSFileSetBasePath SFileSetBasePath = 0;
28funcSFileSetFilePointer SFileSetFilePointer = 0;
29funcSFileSetLocale SFileSetLocale = 0;
30funcSFileGetBasePath SFileGetBasePath = 0;
31funcSFileGetArchiveName SFileGetArchiveName = 0;
32funcSFileGetFileName SFileGetFileName = 0;
33
34STORMMODULE::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;
41
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}
62
63STORMMODULE::~STORMMODULE()
64{
65 FreeStorm();
66}
67
68HINSTANCE 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;
75
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}
98
99void FreeStorm()
100{
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;
116
117 if (hStorm==0) return;
118
119 if (AlreadyLoaded==FALSE) FreeLibrary(hStorm);
120 hStorm = 0;
121}