All pastes #408443 Raw Edit

Miscellany

public text v1 · immutable
#408443 ·published 2007-03-24 20:52 UTC
rendered paste body
for teh linny, here ya go

void WriteJmp(DWORD Address, DWORD Destination, DWORD AmountOfNops)
{
	BYTE jmp[] = {0x00, 0x00, 0x00, 0x00, 0x00};

	DWORD offset = Destination - (Address + 2);

	if(offset < 0x7F) || (offset > 0xFFFFFF80) 
	{
		jmp[0] = 0xEB;
		jmp[1] = offset;
		memcpy((LPVOID)Address, jmp, 2);
		Address += 2;
	}
	else
	{
		offset -= 3;
		jmp[0] = 0xE9;
		jmp[1] = offset;
		jmp[2] = (offset >> 8);
		jmp[3] = (offset >> 16);
		jmp[4] = (offset >> 24);
		memcpy((LPVOID)Address, jmp, 5);
		Address += 5;
	}

	for(int i = 0; i < AmountOfNops; i++)
	{
		*((BYTE*)Address) = 0x90;
		Address++;
	}
}