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 Small banner for links to this site: ![]() |
![]() diff --git a/loadstorm/Storm.cpp b/loadstorm/Storm.cpp
--- /dev/null
+++ b/loadstorm/Storm.cpp
@@ -0,0 +1,121 @@
+/*\r
+ Storm.cpp\r
+*/\r
+\r
+#include "storm.h"\r
+\r
+struct STORMMODULE {\r
+ STORMMODULE();\r
+ ~STORMMODULE();\r
+} Storm;\r
+\r
+void FreeStorm();\r
+\r
+HINSTANCE hStorm = 0;\r
+BOOL AlreadyLoaded = FALSE;\r
+\r
+// Storm Function Names\r
+funcSFileCloseArchive SFileCloseArchive = 0;\r
+funcSFileCloseFile SFileCloseFile = 0;\r
+funcSFileDestroy SFileDestroy = 0;\r
+funcSFileGetFileArchive SFileGetFileArchive = 0;\r
+funcSFileGetFileSize SFileGetFileSize = 0;\r
+funcSFileOpenArchive SFileOpenArchive = 0;\r
+funcSFileOpenFile SFileOpenFile = 0;\r
+funcSFileOpenFileEx SFileOpenFileEx = 0;\r
+funcSFileReadFile SFileReadFile = 0;\r
+funcSFileSetBasePath SFileSetBasePath = 0;\r
+funcSFileSetFilePointer SFileSetFilePointer = 0;\r
+funcSFileSetLocale SFileSetLocale = 0;\r
+funcSFileGetBasePath SFileGetBasePath = 0;\r
+funcSFileGetArchiveName SFileGetArchiveName = 0;\r
+funcSFileGetFileName SFileGetFileName = 0;\r
+\r
+STORMMODULE::STORMMODULE()\r
+{\r
+ if (hStorm!=0) return;\r
+ const char STORM_DLL[] = "Storm.dll";\r
+ hStorm = GetModuleHandle(STORM_DLL);\r
+ if (hStorm == NULL) hStorm = LoadLibrary(STORM_DLL);\r
+ else AlreadyLoaded=TRUE;\r
+\r
+ if (hStorm != NULL)\r
+ {\r
+ SFileCloseArchive = (funcSFileCloseArchive)GetProcAddress(hStorm, (LPCSTR)0xFC);\r
+ SFileCloseFile = (funcSFileCloseFile)GetProcAddress(hStorm, (LPCSTR)0xFD);\r
+ SFileDestroy = (funcSFileDestroy)GetProcAddress(hStorm, (LPCSTR)0x106);\r
+ SFileGetFileArchive = (funcSFileGetFileArchive)GetProcAddress(hStorm, (LPCSTR)0x108);\r
+ SFileGetFileSize = (funcSFileGetFileSize)GetProcAddress(hStorm, (LPCSTR)0x109);\r
+ SFileOpenArchive = (funcSFileOpenArchive)GetProcAddress(hStorm, (LPCSTR)0x10A);\r
+ SFileOpenFile = (funcSFileOpenFile)GetProcAddress(hStorm, (LPCSTR)0x10B);\r
+ SFileOpenFileEx = (funcSFileOpenFileEx)GetProcAddress(hStorm, (LPCSTR)0x10C);\r
+ SFileReadFile = (funcSFileReadFile)GetProcAddress(hStorm, (LPCSTR)0x10D);\r
+ SFileSetBasePath = (funcSFileSetBasePath)GetProcAddress(hStorm, (LPCSTR)0x10E);\r
+ SFileSetFilePointer = (funcSFileSetFilePointer)GetProcAddress(hStorm, (LPCSTR)0x10F);\r
+ SFileSetLocale = (funcSFileSetLocale)GetProcAddress(hStorm, (LPCSTR)0x110);\r
+ SFileGetBasePath = (funcSFileGetBasePath)GetProcAddress(hStorm, (LPCSTR)0x111);\r
+ SFileGetArchiveName = (funcSFileGetArchiveName)GetProcAddress(hStorm, (LPCSTR)0x113);\r
+ SFileGetFileName = (funcSFileGetFileName)GetProcAddress(hStorm, (LPCSTR)0x114);\r
+ }\r
+ if (SFileDestroy && !AlreadyLoaded) SFileDestroy();\r
+}\r
+\r
+STORMMODULE::~STORMMODULE()\r
+{\r
+ FreeStorm();\r
+}\r
+\r
+HINSTANCE LoadStorm(char * DllFileName)\r
+{\r
+ FreeStorm();\r
+ if (hStorm!=0) return 0;\r
+ hStorm = GetModuleHandle(DllFileName);\r
+ if (hStorm == NULL) hStorm = LoadLibrary(DllFileName);\r
+ else AlreadyLoaded=TRUE;\r
+\r
+ if (hStorm != NULL)\r
+ {\r
+ SFileCloseArchive = (funcSFileCloseArchive)GetProcAddress(hStorm, (LPCSTR)0xFC);\r
+ SFileCloseFile = (funcSFileCloseFile)GetProcAddress(hStorm, (LPCSTR)0xFD);\r
+ SFileDestroy = (funcSFileDestroy)GetProcAddress(hStorm, (LPCSTR)0x106);\r
+ SFileGetFileArchive = (funcSFileGetFileArchive)GetProcAddress(hStorm, (LPCSTR)0x108);\r
+ SFileGetFileSize = (funcSFileGetFileSize)GetProcAddress(hStorm, (LPCSTR)0x109);\r
+ SFileOpenArchive = (funcSFileOpenArchive)GetProcAddress(hStorm, (LPCSTR)0x10A);\r
+ SFileOpenFile = (funcSFileOpenFile)GetProcAddress(hStorm, (LPCSTR)0x10B);\r
+ SFileOpenFileEx = (funcSFileOpenFileEx)GetProcAddress(hStorm, (LPCSTR)0x10C);\r
+ SFileReadFile = (funcSFileReadFile)GetProcAddress(hStorm, (LPCSTR)0x10D);\r
+ SFileSetBasePath = (funcSFileSetBasePath)GetProcAddress(hStorm, (LPCSTR)0x10E);\r
+ SFileSetFilePointer = (funcSFileSetFilePointer)GetProcAddress(hStorm, (LPCSTR)0x10F);\r
+ SFileSetLocale = (funcSFileSetLocale)GetProcAddress(hStorm, (LPCSTR)0x110);\r
+ SFileGetBasePath = (funcSFileGetBasePath)GetProcAddress(hStorm, (LPCSTR)0x111);\r
+ SFileGetArchiveName = (funcSFileGetArchiveName)GetProcAddress(hStorm, (LPCSTR)0x113);\r
+ SFileGetFileName = (funcSFileGetFileName)GetProcAddress(hStorm, (LPCSTR)0x114);\r
+ }\r
+ if (SFileDestroy && !AlreadyLoaded) SFileDestroy();\r
+ if (AlreadyLoaded==TRUE) return 0;\r
+ return hStorm;\r
+}\r
+\r
+void FreeStorm()\r
+{\r
+ SFileCloseArchive = 0;\r
+ SFileCloseFile = 0;\r
+ SFileDestroy = 0;\r
+ SFileGetFileArchive = 0;\r
+ SFileGetFileSize = 0;\r
+ SFileOpenArchive = 0;\r
+ SFileOpenFile = 0;\r
+ SFileOpenFileEx = 0;\r
+ SFileReadFile = 0;\r
+ SFileSetBasePath = 0;\r
+ SFileSetFilePointer = 0;\r
+ SFileSetLocale = 0;\r
+ SFileGetBasePath = 0;\r
+ SFileGetArchiveName = 0;\r
+ SFileGetFileName = 0;\r
+\r
+ if (hStorm==0) return;\r
+\r
+ if (AlreadyLoaded==FALSE) FreeLibrary(hStorm);\r
+ hStorm = 0;\r
+}\r
|