Replacing x address with y address?

First of all, let me go ahead and establish that I am modifying memory of a different program that I obviously don't have the source code to. Alright, so lets say that the assembly of this the programs function in question looks like this..
 
mov     word_A45200, ax


I want to change this to..
 
mov     pData, ax


With pData being something I put in my DLL. To be clear, 0xA45200 is where the data is being held in this program for the function in question. I'm looking to replace this address, which has limited space, with data from my DLL so that I can put as big of a size as I want.

One more thing is that this function has this code..
push word_A45200
Right before the "ax" register is moved into it. This is where all the data is held. Also, this function sets up all the data and everything before calling another function that executes it and one of the parameters in the call is a pointer to this data.

So I'm thinking that I don't really need to even mess with the mov part, correct me if I'm wrong. Rather, I need to change...
push word_A45200
To..
push pData

With pData being where I hold the data in my DLL. Because I could change the mov so that instead of moving ax into word_A45200, it moves it into another address. But then when this code calls the function that executes this data, then &word_A45200 is still going to be a parameter, so the only thing that will do is empty out my data completely.

Here is how I imagine my code will look...
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
//Define our function
#define     __data_setup               0x403050

//Define where data offset is setup [push word_A45200]
#define     __data_address_create      0x403060

//Call our function
typedef VOID (__cdecl *fDataSetup)();
fDataSetup data_setup = (fDataSetup)__data_setup;

//Old Size[word_A45200]: 0x40 (64)
//New Size[DataHolder]: 0x140 (320)
typedef struct _DataHolder {
CHAR Data1 [0x40];
CHAR Data2 [0x40];
CHAR Data3 [0x40];
CHAR Data4 [0x40];
CHAR Data5 [0x40];
} Data, *pData;

VOID CustomizeOurFunction(PVOID pData)
{

     /*  [mov word_A45200, ax] HEX: "68 08 74 99  00"  */

     //Setup our new data array
     unsigned char pDataChange[5] = { 68, xx xx xx 00 };

     ChangeMemory(__data_address_create, 0x5, (BYTE*)pDataChange);

//Setup our new data and then call function with the altered data
   Data Setup;
   ZeroMemory(&setup, sizeof(setup));
sprintf(Data.Data1, "Test");
sprintf(Data.Data2, "Test2");
sprintf(Data.Data3, "Test3");
sprintf(Data.Data4, "Test4");
sprintf(Data.Data5, "Test5");
   data_setup();
}


I may be wrong, but that's how I was thinking it would be done. The only part I'm confused about is how to change word_A45200 to the Data structure I set up, as in this part of the code...
1
2
     //Setup our new data array
     unsigned char pDataChange[5] = { 68, xx xx xx 00 };


Any help appreciated, thanks.
Last edited on
Topic archived. No new replies allowed.