"Games"
{
	"left4dead2"
	{
		"MemPatches"
		{
			"sgspread"
			{
				"signature"						"CTerrorPlayer::FireBullet"
				
				// 0:  8d 8d a4 f9 ff ff		lea		ecx, [ebp-0x65c]
				// 6:  f3 0f 11 01				movss	DWORD PTR [ecx], xmm0
				// a:  8b 55 20					mov		edx, DWORD PTR [ebp+0x20]
				// d:  8b c4					mov		eax, esp
				// f:  83 fa 04					cmp		edx, 0x4								; "Bullet offset 0"
				// 12: 7f 02					jg		0x16									; ring2
				// 14: eb 1c					jmp		0x32									; ring1
				//
				// ring2:
				// 16: 89 10					mov		DWORD PTR [eax], edx
				// 18: 8b bd 50 f9 ff ff 01 38	mov		edi, DWORD PTR [ebp-0x6b0]
				// 20: 83 28 04					sub		DWORD PTR [eax], 0x4					; "Bullet offset 1"
				// 23: db 00					fild	DWORD PTR [eax]
				// 25: c7 00 00 00 34 43		mov		DWORD PTR [eax], 0x43340000				; 180.0f
				// 2b: d8 38					fdivr	DWORD PTR [eax]
				// 2d: 83 ea 05					sub		edx, 0x5								; "Bullet offset 2"
				// 30: eb 17					jmp		0x49									; end
				//
				// ring1:
				// 32: c7 00 02 00 00 00		mov		DWORD PTR [eax], 0x2					; "Factor offset"
				// 38: db 00					fild	DWORD PTR [eax]
				// 3a: d8 39					fdivr	DWORD PTR [ecx]
				// 3c: d9 19					fstp	DWORD PTR [ecx]
				// 3e: 83 ea 02					sub		edx, 0x2
				// 41: c7 00 00 00 70 42		mov		DWORD PTR [eax], 0x42700000				; 60.0f ; "Bullet offset 3"
				// 47: d9 00					fld		DWORD PTR [eax]
				//
				// end:
				// 49: 89 10					mov		DWORD PTR [eax], edx
				// 4b: da 08					fimul	DWORD PTR [eax]
				// 4d: d9 9d b0 f9 ff ff		fstp	DWORD PTR [ebp-0x650]
				// 53: 90						nop
				// 54: 90						nop
				
				"linux"
				{
					"offset"					"1047"
					"patch"						"\x8d\x8d\xa4\xf9\xff\xff\xf3\x0f\x11\x01\x8b\x55\x20\x8b\xc4\x83\xfa\x04\x7f\x02\xeb\x1c\x89\x10\x8b\xbd\x50\xf9\xff\xff\x01\x38\x83\x28\x04\xdb\x00\xc7\x00\x00\x00\x34\x43\xd8\x38\x83\xea\x05\xeb\x17\xc7\x00\x02\x00\x00\x00\xdb\x00\xd8\x39\xd9\x19\x83\xea\x02\xc7\x00\x00\x00\x70\x42\xd9\x00\x89\x10\xda\x08\xd9\x9d\xb0\xf9\xff\xff\x90\x90"
				}
				
				// 0:  56						push esi			; needs to be written due to instruction offset after update
				// 1:  83 ec 0c					sub esp, 0ch		; keep the stack correct
				// 4:  31 c0					xor eax, eax
				// 6:  89 45 9c					mov [ebp+a0], eax	; spread = 0.0f
				// 9:  8b d6					mov edx, esi
				// b:  8b c4					mov eax, esp		; eax = esp
				// d:  83 fa 04					cmp edx, 4			; if edx > 4							"Bullet offset 0"
				// 10: 7f 02					jg ring2
				// 12: eb 1f					jmp ring1
				//
				// ring2:
				// 14: c7 45 9c 00 00 a0 40 	mov [ebp+a0], 5.0f	; spread = 5.0f
				// 1b: 89 10					mov [esp], edx
				// 1d: 01 38					add [esp], edi
				// 1f: 83 28 04					sub [esp], 4		; esp = max_bullets - 4					"Bullet offset 1"
				// 22: db 00					fild [esp]
				// 24: c7 00 00 00 b4 43		mov [esp], 360.0f
				// 2a: d9 00					fld [esp]
				// 2c: de f1					fdivrp				; st(0) = 360 / (max_bullets - 4)
				// 2e: 83 ea 05					sub edx, 5			; edx = i - 4							"Bullet offset 2"
				// 31: eb 12					jmp end
				//
				// ring1:
				// 33: c7 45 9c 00 00 40 40		mov [ebp+a0], 3.0f	; spread = 3.0f							"Factor offset"
				// 3a: 83 ea 02					sub edx, 2			; edx = i - 1
				// 3d: c7 00 00 00 f0 42		mov [esp], 120.0f	;										"Bullet offset 3"
				// 43: d9 00					fld [esp]			; st(0) = 120.0f
				//
				// end:
				// 45: 89 10					mov [esp], edx
				// 47: db 00					fild [esp]
				// 49: de c9					fmulp				; st(0) = spread_dir

				"windows"
				{
					"offset"					"802"
					"patch"						"\x56\x83\xec\x0c\x31\xc0\x89\x45\x9c\x8b\xd6\x8b\xc4\x83\xfa\x04\x7f\x02\xeb\x1f\xc7\x45\x9c\x00\x00\xa0\x40\x89\x10\x01\x38\x83\x28\x04\xdb\x00\xc7\x00\x00\x00\xb4\x43\xd9\x00\xde\xf1\x83\xea\x05\xeb\x12\xc7\x45\x9c\x00\x00\x40\x40\x83\xea\x02\xc7\x00\x00\x00\xf0\x42\xd9\x00\x89\x10\xdb\x00\xde\xc9"
				}
			}
		}
		
		"Offsets"
		{
			"OS"
			{
				"linux"		"1"
				"windows"	"0"
			}
		}
		
		"Signatures"
		{
			/* @A1m`:
			 * How to find in windows:
			 * Can be found by string "CTerrorPlayer::FireBullet Spread" or "CTerrorPlayer::FireBullet SpreadDir"
			 */
			"CTerrorPlayer::FireBullet"
			{
				"library"						"server"
				"linux"							"@_ZN13CTerrorPlayer10FireBulletE6VectorRK6QAngle10CSWeaponIDi"
				"windows"						"\x55\x8b\xec\x81\xec\x2a\x2a\x2a\x2a\x8b\x45\x18\x57\x8b\xf9"
			}
		}
	}
}