-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathafstest.cpp
45 lines (37 loc) · 1.02 KB
/
afstest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <windows.h>
#include <stdio.h>
#include "config.h"
#include "afsreader.h"
KSERV_CONFIG g_config;
// Simple AFS-reader test.
// Searches for a given filename in the AFS.
// (First item that matches the filename is returned.)
void main(int argc, char* argv[])
{
char afsFileName[1024];
ZeroMemory(afsFileName, 1024);
if (argc < 2)
{
printf("Usage: %s <filename> [<afs-file>]\n", argv[0]);
return;
}
// if specific filename not specified, assume default AFS
if (argc > 2)
lstrcpy(afsFileName, argv[2]);
else
lstrcpy(afsFileName, "0_text.afs");
AFSITEMINFO itemInfo;
ZeroMemory(&itemInfo, sizeof(AFSITEMINFO));
DWORD base = 0;
DWORD result = GetItemInfo(afsFileName, argv[1], &itemInfo, &base);
if (result != AFS_OK)
{
printf("ERROR: %s\n", GetAfsErrorText(result));
return;
}
printf("base = %08x\n", base);
printf("itemInfo.dwOffset = %08x\n", itemInfo.dwOffset);
printf("itemInfo.dwSize = %08x\n", itemInfo.dwSize);
printf("\n");
printf("absolute offset = %08x\n", base + itemInfo.dwOffset);
}