~ares-developers/ares/gd03

« back to all changes in this revision

Viewing changes to Misc/IniIteratorChar.cpp

  • Committer: Renegade
  • Date: 2010-05-29 08:12:17 UTC
  • Revision ID: git-v1:0a1bb6321f04d723afe64d1b843dc87b4da783ec
Creating /trunk/src.

git-svn-id: svn://svn.renegadeprojects.com/ares/trunk@622 859b54a9-7a54-0410-aeb3-f8d2f1fa40fd

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include "IniIteratorChar.h"
2
 
 
3
 
const char IniIteratorChar::iteratorChar[] = "+";
4
 
const char IniIteratorChar::iteratorReplacementFormat[] = "%d";
5
 
 
6
 
char IniIteratorChar::buffer[0x800] = "\0";
7
 
 
8
 
int IniIteratorChar::iteratorValue = 0;
9
 
 
10
 
DEFINE_HOOK(5260A2, IteratorChar_Process_Method1, 6)
11
 
{
12
 
        GET(CCINIClass*, ini, EBP);
13
 
        GET(CCINIClass::INIEntry*, entry, ESI);
14
 
        GET_STACK(CCINIClass::INISection*, section, 0x40);
15
 
 
16
 
        if(strcmp(entry->Key, IniIteratorChar::iteratorChar) == 0) {
17
 
                sprintf(IniIteratorChar::buffer, "%d", IniIteratorChar::iteratorValue++);
18
 
 
19
 
                CRT::free(entry->Key);
20
 
                entry->Key = CRT::strdup(IniIteratorChar::buffer);
21
 
        }
22
 
 
23
 
        //debug
24
 
        //Debug::Log("[%s] %s = %s (Method 1)\n", section->Name, entry->Key, entry->Value);
25
 
 
26
 
        return 0;
27
 
}
28
 
 
29
 
DEFINE_HOOK(525D23, IteratorChar_Process_Method2, 5)
30
 
{
31
 
        GET(char*, value, ESI);
32
 
        LEA_STACK(char*, key, 0x78)
33
 
        LEA_STACK(char*, section, 0x278);
34
 
 
35
 
        if(strcmp(key, IniIteratorChar::iteratorChar) == 0) {
36
 
                strcpy(IniIteratorChar::buffer, value);
37
 
                sprintf(key, "%d", IniIteratorChar::iteratorValue++);
38
 
 
39
 
                char* newValue = key + strlen(key) + 1;
40
 
                strcpy(newValue, IniIteratorChar::buffer);
41
 
                R->ESI<char*>(newValue);
42
 
                value = newValue; //for correct debug display
43
 
        }
44
 
 
45
 
        //Debug::Log("[%s] %s = %s (Method 2)\n", section, key, value);
46
 
        return 0;
47
 
}
48
 
 
49
 
//Uncomment this hook to have all INI sections and their entries printed to the log!
50
 
/*
51
 
A_FINE_HOOK(474230, IteratorChar_SectionInfo, 5)
52
 
{
53
 
        GET(CCINIClass*, ini, ESI);
54
 
 
55
 
        GenericNode* sectionNode = &ini->Sections.First;
56
 
        while(sectionNode)
57
 
        {
58
 
                if(*((unsigned int*)sectionNode) == 0x7EB73C)
59
 
                {
60
 
                        INIClass::INISection* section = (INIClass::INISection*)sectionNode;
61
 
                        Debug::Log("[%s]\n", section->Name);
62
 
 
63
 
                        GenericNode* entryNode = &section->Entries.First;
64
 
                        while(entryNode)
65
 
                        {
66
 
                                if(*((unsigned int*)entryNode) == 0x7EB734)
67
 
                                {
68
 
                                        INIClass::INIEntry* entry = (INIClass::INIEntry*)entryNode;
69
 
                                        unsigned int checksum = 0xAFFEAFFE;
70
 
 
71
 
                                        for(int i = 0; i < section->CheckedEntries.Count; i++)
72
 
                                        {
73
 
                                                if(section->CheckedEntries.Entries[i].Entry == entry)
74
 
                                                {
75
 
                                                        checksum = section->CheckedEntries.Entries[i].Checksum;
76
 
                                                        break;
77
 
                                                }
78
 
                                        }
79
 
                                        Debug::Log("\t%s = %s (Checksum: %08X)\n", entry->Key, entry->Value, checksum);
80
 
                                }
81
 
                                entryNode = entryNode->Next;
82
 
                        }
83
 
                }
84
 
                sectionNode = sectionNode->Next;
85
 
        }
86
 
 
87
 
        return 0;
88
 
}
89
 
*/