diff --git a/README.md b/README.md index 17a8fc3..2df9087 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,8 @@ You can find all the used IDs and offsets [here](https://docs.google.com/spreads - `IgnoreUpgradeMaterials` - enables or disables Ignore Upgrade Materials - `setGameSpeed` - sets game speed - `addItem` - Adds a specific quantity of items to the inventory (See item IDs at [Memory Reference](#memory-reference)) +- `removeItem` -Removes item from memory (See item IDs at [Memory Reference](#memory-reference)) - `addWeapon` - Adds a weapon to the inventory (See weapon IDs at [Memory Reference](#memory-reference)) +- `removeWeapon` - removes a weapon from the inventory (See weapon IDs at [Memory Reference](#memory-reference)) - `setHUDOpacity` - sets the opacity of the HUD - `setColor` - sets RGBColor combination diff --git a/Source/ConsoleApplication1/NierHook.cpp b/Source/ConsoleApplication1/NierHook.cpp index a849f1c..0bafdd1 100644 --- a/Source/ConsoleApplication1/NierHook.cpp +++ b/Source/ConsoleApplication1/NierHook.cpp @@ -323,6 +323,31 @@ bool NieRHook::addItem(int ID, int number) CloseHandle(pHandle); } +bool NieRHook::removeItem(int ID) +{ + HANDLE pHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, this->_pID); + uintptr_t Address = this->_baseAddress + 0x197C4C4; + unsigned int currentID; + int emptySlotID = 0xffffffff; + if (!this->_hooked) + { + //Not hooked return + return false; + } + while (Address <= this->_baseAddress + 0x197CE18) + { + ReadProcessMemory(pHandle, (LPVOID)Address, ¤tID, sizeof(currentID), NULL); + if (ID == currentID) //Item found + { + //Remove item from memory //Item found on memory + WriteProcessMemory(pHandle, (LPVOID)(Address), &emptySlotID, sizeof(emptySlotID), NULL); //Set level + return true; + } + Address += 0xC; //Go to the next slot + } + return false; +} + /* Add weapon to memory by ID returns: true if successful and false if not @@ -361,6 +386,28 @@ bool NieRHook::addWeapon(int ID, int level) CloseHandle(pHandle); } +bool NieRHook::removeWeapon(int ID) +{ + HANDLE pHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, this->_pID); + uintptr_t Address = this->_baseAddress + 0x197DCC4; + uintptr_t emptySlotID = 0xffffffff; + unsigned int currentID; + if (!this->_hooked) + { + return false; //Return if not hooked + } + while (Address <= this->_baseAddress + 0x197DFBC) + { + ReadProcessMemory(pHandle, (LPVOID)Address, ¤tID, sizeof(currentID), NULL); + if (ID == currentID) + { //Weapon found on memory + WriteProcessMemory(pHandle, (LPVOID)(Address), &emptySlotID, sizeof(emptySlotID), NULL); //Set level + return true; + } + Address += 0x14; //Go to the next slot + } +} + void NieRHook::setHUDOpacity(float opacity) { HANDLE pHandle = OpenProcess(PROCESS_ALL_ACCESS, NULL, this->_pID); diff --git a/Source/ConsoleApplication1/NierHook.hpp b/Source/ConsoleApplication1/NierHook.hpp index 03ca63c..38aed6b 100644 --- a/Source/ConsoleApplication1/NierHook.hpp +++ b/Source/ConsoleApplication1/NierHook.hpp @@ -70,7 +70,9 @@ class NieRHook //Inventory bool addItem(int ID, int number); + bool removeItem(int ID); bool addWeapon(int ID, int level); + bool removeWeapon(int ID); //Misc void setHUDOpacity(float opacity);