Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- UInt8 * mm_factory_method(UInt32 p_Trampoline, UInt8 p_Length)
- {
- //!
- //! 0xA0 = Epilogue + Prologue
- //! 0x03 = Parameter
- //! 0x05 = Call
- //! 0x03 = Return
- //!
- auto r_Length = 0x0A + (p_Length * 0x03) + 0x05 + 0x03;
- auto r_Index = 0;
- auto r_Bytes = new uint8_t[r_Length];
- //!
- //! Assembly::Epilogue
- //!
- r_Bytes[r_Index++] = 0x55;
- r_Bytes[r_Index++] = 0x89;
- r_Bytes[r_Index++] = 0xE5;
- r_Bytes[r_Index++] = 0x60;
- r_Bytes[r_Index++] = 0x9C;
- //!
- //! Assembly::Call
- //!
- for (auto i = 0; i < p_Length; i++)
- {
- r_Bytes[r_Index++] = 0xFF;
- r_Bytes[r_Index++] = 0x75;
- r_Bytes[r_Index++] = (p_Length - i) * sizeof(UInt32) + 0x04;
- }
- r_Bytes[r_Index++] = 0xE8;
- *(UInt32 *)(r_Bytes + r_Index) = p_Trampoline;
- r_Index += 0x04;
- //!
- //! Assembly::Prologue
- //!
- r_Bytes[r_Index++] = 0x9D;
- r_Bytes[r_Index++] = 0x61;
- r_Bytes[r_Index++] = 0x89;
- r_Bytes[r_Index++] = 0xEC;
- r_Bytes[r_Index++] = 0x5D;
- //!
- //! Assembly::Return
- //!
- r_Bytes[r_Index++] = 0xC2;
- *(UInt16 *)(r_Bytes + r_Index) = p_Length * sizeof(UInt32);
- return r_Bytes;
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- UInt8 * mm_factory_method_jump(UInt32 p_Trampoline, UInt32 p_Original, UInt8 p_Length)
- {
- //!
- //! 0xA0 = Epilogue + Prologue
- //! 0x03 = Parameter
- //! 0x05 = Call
- //! 0x05 = Jump
- //!
- auto r_Length = 0x0A + (p_Length * 0x03) + 0x05 + 0x05;
- auto r_Index = 0;
- auto r_Bytes = new uint8_t[r_Length];
- //!
- //! Assembly::Epilogue
- //!
- r_Bytes[r_Index++] = 0x55;
- r_Bytes[r_Index++] = 0x89;
- r_Bytes[r_Index++] = 0xE5;
- r_Bytes[r_Index++] = 0x60;
- r_Bytes[r_Index++] = 0x9C;
- //!
- //! Assembly::Call
- //!
- for (auto i = 0; i < p_Length; i++)
- {
- r_Bytes[r_Index++] = 0xFF;
- r_Bytes[r_Index++] = 0x75;
- r_Bytes[r_Index++] = (p_Length - i) * sizeof(UInt32) + 0x04;
- }
- r_Bytes[r_Index++] = 0xE8;
- *(UInt32 *)(r_Bytes + r_Index) = p_Trampoline;
- r_Index += 0x04;
- //!
- //! Assembly::Prologue
- //!
- r_Bytes[r_Index++] = 0x9D;
- r_Bytes[r_Index++] = 0x61;
- r_Bytes[r_Index++] = 0x89;
- r_Bytes[r_Index++] = 0xEC;
- r_Bytes[r_Index++] = 0x5D;
- //!
- //! Assembly::Return
- //!
- r_Bytes[r_Index++] = 0xE9;
- *(UInt32 *)(r_Bytes + r_Index) = p_Original;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement