All pastes #743637 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-10-20 17:01 UTC
rendered paste body
ProcessMemoryReaderLib.ProcessMemoryReader myMemReader = new ProcessMemoryReaderLib.ProcessMemoryReader();
            System.Diagnostics.Process D2Process = System.Diagnostics.Process.GetProcessesByName("Diablo II")[0];
            Console.WriteLine("Process for d2: " + D2Process.Id) ;
            //player unit  D2Client + 0x11C1E0
            //0x6FAB0000 + 0x11C1E0
            IntPtr memAddr = (IntPtr)(0x6FAB0000 + 0x11C1E0);
            IntPtr Handle = D2Process.Handle;
            int ptrBytesRead;

            //get unit pointer
            byte[] ptrBytes = myMemReader.ReadProcessMemory(Handle,memAddr,4,out ptrBytesRead);
            uint ptrUnitAdress = BitConverter.ToUInt32(ptrBytes, 0);

            //get player id
            ptrBytes = myMemReader.ReadProcessMemory(Handle, ptrUnitAdress + 0x0c, 4, ptrBytesRead);
            uint PlayerUID = BitConverter.ToUInt32(ptrBytes, 0);

            //get act pointer
            ptrBytes = myMemReader.ReadProcessMemory(Handle, ptrUnitAdress + 0x1c, 4, ptrBytesRead);
            uint ptrActAdress = BitConverter.ToUInt32(ptrBytes, 0);

            //we need to read unit adress + 0x2c to get a pointer, wich we then offset with 0x1c to get Room adress
            ptrBytes = myMemReader.ReadProcessMemory(Handle, ptrUnitAdress + 0x2c, 4, ptrBytesRead);
            uint ptrRoomBase = BitConverter.ToUInt32(ptrBytes, 0);

            //we get our pointer we now just need to offset it with 0x1c
            ptrBytes = myMemReader.ReadProcessMemory(Handle, ptrRoomBase + 0x1c, 4, ptrBytesRead);
            uint ptrRoomAdress = BitConverter.ToUInt32(ptrBytes, 0);

            uint ptr = 0;

            //here we should be able to gather map info
            //here we use the uint ptr and change it at each memory reading.
            //each memory call change the ptr (exception for the first memory is to get our base ptr from 
            // ptrUnitAdress + 0x2c
            //ptr gets read from ptrRoomBase + 0x2c
            //ptr = read ptr += 0x1c
            //ptr = read ptr += 0x38
            //ptr = read ptr += 0x1c
            
            //the values below dosent seem to get stored anywhere
            //after this point we should be able to retrieve map info (posX, poxY, sizeX, sizeY and level number)
            //posX = ptr + 0x04
            //posY = ptr + 0x08
            //sizeX = ptr + 0x0c
            //sizeY = ptr + 0x10;
            //level number = ptr +0x14

            //here we should have enough info to create a collusion map, loop thru all Room2 struct
            //not sure bout next step...