Valhalla Legends Forums Archive | C/C++ Programming | Quick question regarding scope.

AuthorMessageTime
sixb0nes
Take a quick look at:
http://unixforge.org/~sixb0nes/PatchEngine.cpp  and
http://unixforge.org/~sixb0nes/PatchEngine.h

This is a class I wrote which patches a group of addresses. New patches can be declared by simply declaring new instances of CPatchEngine, like:
[code]
CPatchEngine Patch_NoOpponent(0x45481D,"\xEB",1);
CPatchEngine Patch_Foo(0x454F00,"\xFF",1);
etc
[/code]
The pointers of new CPatchEngine classes are stored in a static vector which is a member of CPatchEngine.

In my DllMain, I call CPatchEngine::PatchAll() to iterate through this vector and call each instances' PatchInstance() method.

My current problem is that the patches must be declared inside a function, and not in global scope. Why is this?

Edit: Just more info, when declaring CPatchEngine's globally, and then calling PatchAll(), my log file will report 0 patches. =/ This isn't the case when declaring in a function.

That's all there is.
July 11, 2005, 8:05 PM

Search