aboutsummaryrefslogtreecommitdiff
path: root/storm_dll/storm_test.cpp
diff options
context:
space:
mode:
authorLadislav Zezula <zezula@volny.cz>2022-02-12 13:14:04 +0100
committerGitHub <noreply@github.com>2022-02-12 13:14:04 +0100
commit02142e8837d3803a954579f21797d6da32657853 (patch)
treed69a5a881203a87d29469b3a98ea1722ff1c5e14 /storm_dll/storm_test.cpp
parentb79a6cc62e610ed405edb38cb990bfe7e6571bd6 (diff)
parent8e053ff5334f8aafaa8e5cc449fd90a71866b0a6 (diff)
Merge pull request #242 from ladislav-zezula/LZ_AnotherSCXProtector
Updated test project for storm.dll
Diffstat (limited to 'storm_dll/storm_test.cpp')
-rw-r--r--storm_dll/storm_test.cpp45
1 files changed, 39 insertions, 6 deletions
diff --git a/storm_dll/storm_test.cpp b/storm_dll/storm_test.cpp
index 92ff061..397c4dd 100644
--- a/storm_dll/storm_test.cpp
+++ b/storm_dll/storm_test.cpp
@@ -17,30 +17,63 @@
#endif
#define STORM_ALTERNATE_NAMES // Use Storm* prefix for functions
-#include "storm_dll.h" // Header file for Storm.dll
+#include "storm.h" // Header file for Storm.dll
//-----------------------------------------------------------------------------
// Main
-int main()
+int main(int argc, char * argv[])
{
- LPCSTR szArchiveName = "e:\\war3.mpq";
+ LPCSTR szArchiveName;
+ LPCSTR szFileName;
+ LPCSTR szFormat;
HANDLE hMpq = NULL;
HANDLE hFile = NULL;
BYTE Buffer[0x100];
DWORD dwBytesRead = 0;
+ DWORD dwFileSize = 0;
+ BOOL bResult;
+ // Check parameters
+ if(argc != 3)
+ {
+ printf("Error: Missing MPQ or file name\n");
+ return 3;
+ }
+
+ // Get both arguments
+ SetLastError(ERROR_SUCCESS);
+ szArchiveName = argv[1];
+ szFileName = argv[2];
+
+ // Put Storm.dll to the current folder before running this
+ printf("[*] Opening archive '%s' ...\n", szArchiveName);
if(StormOpenArchive(szArchiveName, 0, 0, &hMpq))
{
- if(StormOpenFileEx(hMpq, "(1)TheDeathSheep.w3m", 0, &hFile))
+ printf("[*] Opening file '%s' ...\n", szFileName);
+ if(StormOpenFileEx(hMpq, "staredit\\scenario.chk", 0, &hFile))
{
- dwBytesRead = StormGetFileSize(hFile, NULL);
- StormReadFile(hFile, Buffer, sizeof(Buffer), &dwBytesRead, NULL);
+ printf("[*] Retrieving file size ... ");
+ dwFileSize = StormGetFileSize(hFile, NULL);
+ szFormat = (dwFileSize == INVALID_FILE_SIZE) ? ("(invalid)\n") : ("(%u bytes)\n");
+ printf(szFormat, dwFileSize);
+
+ printf("[*] Moving to begin of the file ...\n");
+ StormSetFilePointer(hFile, 0, NULL, FILE_BEGIN);
+
+ printf("[*] Reading file ... ");
+ bResult = StormReadFile(hFile, Buffer, sizeof(Buffer), &dwBytesRead, NULL);
+ szFormat = (bResult == FALSE) ? ("(error %u)\n") : ("(OK)\n");
+ printf(szFormat, GetLastError());
+
+ printf("[*] Closing file ...\n");
StormCloseFile(hFile);
}
+ printf("[*] Closing archive ...\n");
StormCloseArchive(hMpq);
}
+ printf("Done.\n\n");
return 0;
}