All pastes #279010 Raw Edit

Something

public text v1 · immutable
·published 2006-12-14 16:49 UTC
rendered paste body
		#ifdef AMP_DEBUG
			// start loop at the place where cgame is loaded
			DWORD addy = (DWORD) amp.cg.module;
			bool check_call = false;
			char off[4];
			DWORD offset;
			for (; addy < (DWORD) amp.cg.module + 0x100000; addy += 0x1) {
				// push ffed7fff
				if (!check_call && !memcmp((void *) addy, "\xff\x7f\xed\xff", 4)) {
					Debug.log(va("FOUND 'push ffed7fff' at 0x%x", addy - 0x1));
					check_call = true;
				// call cg_trace
				} else if (check_call && !memcmp((void *) addy, "\xe8", 1)) {
					// etpro correction
					addy -= 0x1;
					if (amp.cgMod->type == MOD_ETPRO && !memcmp((void *) addy, "\xd9", 1)) {
						addy += 0x1;
						continue;
					}
					addy += 0x2;
					memcpy(off, (void *) addy, 4);
					offset = *(DWORD *) off + addy + 4;
					Debug.log(va("Found CG_Trace at 0x%x", offset));
					break;
				}
			}
		#endif