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