In general, you can't.
When executables are compiled, references to static variables are resolved by the linker, in the machine code, to the raw address of the variable. No indication that such a reference existed is left, and due to the nature of x86 machine code, it is very difficult to find these references later (you can't necessarily tell where instructions begin unambiguously).
Moreover, you don't know if that's just an ordinary variable. It might be part of a static class or structure. These distinctions are lost after compilation, but when trying to move variables, it makes it that much more difficult - it could be that code is referencing it based on an offset from another variable (ie, the start of the struct).
What are you really trying to accomplish here? There may be a better way than just messing with virtual memory layouts.
If you're just trying to break existing trainers, one approach (untested!) might be to alter the process ACL. When creating the process, use CreateProcess
and pass in a custom security descriptor for lpProcessAttributes
and lpThreadAttributes
(for a process that's already running, you can do this with SetSecurityInfo
). Set the DACL in the security descriptor so that only SYNCHRONIZE | PROCESS_QUERY_INFORMATION | PROCESS_SUSPEND_RESUME | PROCESS_TERMINATE
rights are granted (ie, revoke all other rights on all DACL entries). This technique is not foolproof - a trainer aware you're doing this can simply set the DACL back to default; however it should break existing trainers, by denying them debug access.