How to encrypt memory block in C? : I need a function which takes a start address as first parameter and a size as second and it should xor that range in memory at runtime. How can I accomplish that?

My naive approach was this:

    void EncryptDecrypt(DWORD StartAddress, DWORD dwSize)
    {
    	DWORD *Start = &StartAddress;
    	DWORD size = StartAddress + dwSize;
    	DWORD *End = &size;
    
    	while(*Start < *End)
    	{
    		*Start++ ^= 0x83;
    	}
    	
    }

But it fails when needs to decrypt. How to fix it?