// by Franc[e]sco
define(KEY_NORMAL,0)
define(KEY_EXTENDED,1)
// you can add more virtual key codes by getting them here
// http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
// for letters, the uppercase character is enough
define(VK_HOME,24)
// -----------------------------------------------------------------------------
// Settings
// the script will feed the pet when fullness drops below or equal to this value
// (don't forget to put # in front of the value to specify that it's decimal!)
define(FeedFullness,#70)
// the key to press to feed the pet
define(FoodKey,VK_HOME)
// KEY_NORMAL for most keys, KEY_EXTENDED for special keys like CTRL
// it shouldn't matter for simple keypresses
define(FoodKeyType,KEY_NORMAL)
// -----------------------------------------------------------------------------
// Addresses and offsets
// ? ? ? ? 00 00 ? ? ? ? ? ? ? ? E8 ? ? ? ? ? ? C8 ? ? ? ? ? ? ? 00 00 ? ? E8 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? E8
define(PetFullnessAddy,00AA25B9) // v116
// TSingleton<CWndMan>::ms_pInstance
// 8B 15 ? ? ? ? 85 D2 74 23
define(TSingleton_CWndMan___ms_pInstance,01AA2E2C) // v116 0058E2D0
// virtual void __thiscall CWndMan::OnKey(unsigned int lparam, unsigned int wparam)
// ? ? ? ? ? 85 ? 74 ? 8D ? ? 8B ? 8B ? FF ? C2 08 00
define(CWndMan__OnKey,013DAB90) // v116
[Enable]
alloc(PetFullnessHook,64)
alloc(PressKey,128)
label(DontFeed)
// PressKey flags and internal stuff
define(KEY_PRESS,0)
define(KEY_UP,1)
define(MAPVK_VK_TO_VSC,0)
// Pet fullness hook
PetFullnessAddy:
jmp PetFullnessHook
nop
PetFullnessHook:
mov [esi+000000D4],edx // original code 160.3
cmp edx,FeedFullness
jg DontFeed
push KEY_PRESS // transition_state
push FoodKeyType // extended_flag
push FoodKey // virtual_key
call PressKey
DontFeed:
jmp PetFullnessAddy+6
// void __stdcall PressKey(uint32_t virtual_key, uint32_t extended_flag, uint32_t transition_state)
PressKey:
push ebx // backup
push edx // backup
push esi // backup
push ecx // backup
mov edx, [esp+10+4] // edx = virtual keycode
mov esi, [esp+10+8] // esi = is extended keycode
mov ebx, [esp+10+C] // ebx = transition state flag
mov ecx, edx // ecx = virtual keycode (will later contain the scancode)
// generate scancode with MapVirtualKeyA(virtual_key, MAPVK_VK_TO_VSC) << 16
// credits to Shadow and Waty
push MAPVK_VK_TO_VSC
push ecx
call MapVirtualKeyA
shl eax,#16
shl esi,#24 // extended flag
shl ebx,#31 // transition state
or eax, esi
or eax, ebx
mov ecx,eax
push ecx // lparam (keycode)
push edx // wparam (virtual keycode)
mov ecx,[TSingleton_CWndMan___ms_pInstance]
call CWndMan__OnKey
pop ecx // backup
pop esi // backup
pop edx // backup
pop ebx // backup
ret 000C
[Disable]
PetFullnessAddy:
mov [esi+000000D4],edx // original code 160.3
dealloc(PetFullnessHook)
dealloc(PressKey)