Miseryk

C++ Memory 2 Struct / Vector

May 17th, 2021
599
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. Visual Studio 2019 Professional -> Release
  3.  
  4. You can use detours and patch it for every call, this one only can be used with the touched vector, if you use a normal one, gonna crash, you gotta patch it in detour function.
  5.  
  6. It allocs memory (VirtualAlloc)
  7.  
  8. the cast that to Vector<int>/Vector<struct>
  9.  
  10. after cast you can use STL push, set =, resize, sort, shrink_to_fit, clear, pop, etc, all working
  11. */
  12.  
  13. #include <iostream>
  14. #include <Windows.h>
  15. #include <vector>
  16.  
  17. #include <algorithm> //sort
  18. #include <random> //randomnumber
  19.  
  20. long RandomNumber(long LowerBound, long UpperBound);
  21.  
  22. std::random_device rd;     // only used once to initialise (seed) engine
  23.  
  24. long RandomNumber(long LowerBound, long UpperBound)
  25. {
  26.     if (LowerBound < 0) LowerBound = 0;
  27.     if (UpperBound < 0) UpperBound = 0;
  28.  
  29.     if (LowerBound > UpperBound) UpperBound = LowerBound;
  30.     /*srand((unsigned)time(0));
  31.  
  32.     return (rand() % ((UpperBound - LowerBound) + 1) + LowerBound);*/
  33.  
  34.     std::mt19937 rng(rd());    // random-number engine used (Mersenne-Twister in this case)
  35.     std::uniform_int_distribution<long> uni(LowerBound, UpperBound); // guaranteed unbiased
  36.  
  37.     return uni(rng);
  38. }
  39.  
  40. ULONGLONG RandomNumberULONGLONG(ULONGLONG LowerBound, ULONGLONG UpperBound)
  41. {
  42.     if (LowerBound < 0) LowerBound = 0;
  43.     if (UpperBound < 0) UpperBound = 0;
  44.  
  45.     if (LowerBound > UpperBound) UpperBound = LowerBound;
  46.     /*srand((unsigned)time(0));
  47.  
  48.     return (rand() % ((UpperBound - LowerBound) + 1) + LowerBound);*/
  49.  
  50.     std::mt19937 rng(rd());    // random-number engine used (Mersenne-Twister in this case)
  51.     std::uniform_int_distribution<ULONGLONG> uni(LowerBound, UpperBound); // guaranteed unbiased
  52.  
  53.     return uni(rng);
  54. }
  55.  
  56. #pragma pack(push)  /* push current alignment to stack */
  57. #pragma pack(1)     /* set alignment to 1 byte boundary */
  58. struct tHook
  59. {
  60.     DWORD Base;
  61.     DWORD Offset;
  62.     char DllPath[MAX_PATH - 1];
  63.     bool Activated;
  64.     DWORD HookedAddress;
  65.     ULONGLONG Count;
  66.     //WORD Timer
  67.  
  68.     bool operator<(const tHook& a) const
  69.     {
  70.         return HookedAddress < a.HookedAddress;
  71.     }
  72.  
  73.     bool operator>(const tHook& a) const
  74.     {
  75.         return HookedAddress > a.HookedAddress;
  76.     }
  77. };
  78. #pragma pack(pop)   /* restore original alignment from stack */
  79.  
  80. tHook GenRandomStruct()
  81. {
  82.     tHook tmp;
  83.  
  84.     tmp.Base = RandomNumber(0x10000000, 0x70000000);
  85.     tmp.Offset = RandomNumber(0x100, 0xFFFFFF0);
  86.     FillMemory(tmp.DllPath, sizeof(tmp.DllPath), (char)RandomNumber('!', 'z'));
  87.     tmp.DllPath[sizeof(tmp.DllPath) - 1] = '\0';
  88.     tmp.Activated = (RandomNumber(0x10000000, 0x70000000) % 2 == 0);
  89.     //strncpy(a, "iqbal", sizeof(a) - 1);
  90.     tmp.HookedAddress = tmp.Base + tmp.Offset + 3;
  91.     tmp.Count = RandomNumberULONGLONG(0x1000000000000000, 0x7FFFFFFFFFFFFFFF);
  92.    
  93.     return tmp;
  94. }
  95.  
  96. bool compareByHookedAddress(const tHook& a, const tHook& b)
  97. {
  98.     return a.HookedAddress < b.HookedAddress;
  99. }
  100.  
  101. enum eTaipu
  102. {
  103.     eInt,
  104.     eStruct
  105. };
  106.  
  107. eTaipu CurrentType;
  108.  
  109. LPVOID AddressAlloc = NULL;
  110. DWORD VectorHoldingSize; //in the future I gotta do it with structs or <int, int>, DONE
  111.  
  112. /*
  113. Memory2DynamicStruct.exe+1E40 - 55                    - push ebp
  114. Memory2DynamicStruct.exe+1E41 - 8B EC                 - mov ebp,esp
  115. Memory2DynamicStruct.exe+1E43 - 8B | 51 04              - mov edx,[ecx+04]
  116. Memory2DynamicStruct.exe+1E46 - 3B 51 | 08              - cmp edx,[ecx+08]
  117. Memory2DynamicStruct.exe+1E49 - 74 0F                 - je Memory2DynamicStruct.exe+1E5A
  118. Memory2DynamicStruct.exe+1E4B - 8B | 45 08              - mov eax,[ebp+08]
  119. Memory2DynamicStruct.exe+1E4E - 8B 00 |                 - mov eax,[eax]
  120. Memory2DynamicStruct.exe+1E50 - 89 02                 - mov [edx],eax
  121. Memory2DynamicStruct.exe+1E52 - 83 41 | 04 04           - add dword ptr [ecx+04],04 { 4 }
  122. Memory2DynamicStruct.exe+1E56 - 5D                    - pop ebp
  123. Memory2DynamicStruct.exe+1E57 - C2 | 0400               - ret 0004 { 4 } ----------------------------> scasd
  124. Memory2DynamicStruct.exe+1E5A - FF 75 | 08              - push [ebp+08]
  125. Memory2DynamicStruct.exe+1E5D - 52                    - push edx
  126. Memory2DynamicStruct.exe+1E5E - E8 6D040000           - call Memory2DynamicStruct.exe+22D0
  127. Memory2DynamicStruct.exe+1E63 - 5D                    - pop ebp
  128. Memory2DynamicStruct.exe+1E64 - C2 0400               - ret 0004 { 4 }
  129. -
  130. Memory2DynamicStruct.exe+24A0 - 55                    - push ebp
  131. Memory2DynamicStruct.exe+24A1 - 8B EC                 - mov ebp,esp
  132. Memory2DynamicStruct.exe+24A3 - 8B C1                 - mov eax,ecx
  133. Memory2DynamicStruct.exe+24A5 - 8B 50 04              - mov edx,[eax+04]
  134. Memory2DynamicStruct.exe+24A8 - 3B 50 08              - cmp edx,[eax+08]
  135. Memory2DynamicStruct.exe+24AB - 74 1B                 - je Memory2DynamicStruct.exe+24C8
  136. Memory2DynamicStruct.exe+24AD - 56                    - push esi
  137. Memory2DynamicStruct.exe+24AE - 8B 75 08              - mov esi,[ebp+08]
  138. Memory2DynamicStruct.exe+24B1 - B9 46000000           - mov ecx,00000046 { 70 }
  139. Memory2DynamicStruct.exe+24B6 - 57                    - push edi
  140. Memory2DynamicStruct.exe+24B7 - 8B FA                 - mov edi,edx
  141. Memory2DynamicStruct.exe+24B9 - F3 A5                 - repe movsd
  142. Memory2DynamicStruct.exe+24BB - 81 40 04 18010000     - add [eax+04],00000118 { 280 }
  143. Memory2DynamicStruct.exe+24C2 - 5F                    - pop edi
  144. Memory2DynamicStruct.exe+24C3 - 5E                    - pop esi
  145. Memory2DynamicStruct.exe+24C4 - 5D                    - pop ebp
  146. Memory2DynamicStruct.exe+24C5 - C2 0400               - ret 0004 { 4 }
  147. Memory2DynamicStruct.exe+24C8 - FF 75 08              - push [ebp+08]
  148. Memory2DynamicStruct.exe+24CB - 52                    - push edx
  149. Memory2DynamicStruct.exe+24CC - E8 9F030000           - call Memory2DynamicStruct.exe+2870
  150. Memory2DynamicStruct.exe+24D1 - 5D                    - pop ebp
  151. Memory2DynamicStruct.exe+24D2 - C2 0400               - ret 0004 { 4 }
  152. */
  153. DWORD Push_Back_VS2019_MagicNumber; // = 0x75FF0004; //0x0004C25D //scasd
  154. DWORD Address_Push_Back = NULL;
  155. BYTE Bk_Push_Back[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
  156.  
  157. /*
  158. Memory2DynamicStruct.exe+23A0 - 55                    - push ebp
  159. Memory2DynamicStruct.exe+23A1 - 8B EC                 - mov ebp,esp
  160. Memory2DynamicStruct.exe+23A3 - 53 |                    - push ebx
  161. Memory2DynamicStruct.exe+23A4 - 56                    - push esi
  162. Memory2DynamicStruct.exe+23A5 - 8B 75 08 |              - mov esi,[ebp+08]
  163. Memory2DynamicStruct.exe+23A8 - 57                    - push edi
  164. Memory2DynamicStruct.exe+23A9 - 8B F9                 - mov edi,ecx
  165. Memory2DynamicStruct.exe+23AB - 8B | 5F 04              - mov ebx,[edi+04]
  166. Memory2DynamicStruct.exe+23AE - 8B CB |                - mov ecx,ebx
  167. Memory2DynamicStruct.exe+23B0 - 8B 17                 - mov edx,[edi]
  168. Memory2DynamicStruct.exe+23B2 - 2B CA |                - sub ecx,edx
  169. Memory2DynamicStruct.exe+23B4 - C1 F9 02              - sar ecx,02 { 2 }
  170. Memory2DynamicStruct.exe+23B7 - 3B | F1                 - cmp esi,ecx
  171. Memory2DynamicStruct.exe+23B9 - 73 0D                 - jae Memory2DynamicStruct.exe+23C8 ------------> above or equal
  172. Memory2DynamicStruct.exe+23BB - 8D | 04 B2              - lea eax,[edx+esi*4] -----------------> 2 to 1, 2 to 0
  173. Memory2DynamicStruct.exe+23BE - 89 47 | 04              - mov [edi+04],eax
  174. Memory2DynamicStruct.exe+23C1 - 5F                    - pop edi
  175. Memory2DynamicStruct.exe+23C2 - 5E                    - pop esi
  176. Memory2DynamicStruct.exe+23C3 - 5B |                    - pop ebx
  177. Memory2DynamicStruct.exe+23C4 - 5D                    - pop ebp
  178. Memory2DynamicStruct.exe+23C5 - C2 0400 |               - ret 0004 { 4 }
  179. Memory2DynamicStruct.exe+23C8 - 76 33                 - jna Memory2DynamicStruct.exe+23FD
  180. Memory2DynamicStruct.exe+23CA - 8B 47 | 08              - mov eax,[edi+08]
  181. Memory2DynamicStruct.exe+23CD - 2B C2                 - sub eax,edx
  182. Memory2DynamicStruct.exe+23CF - C1 | F8 02              - sar eax,02 { 2 }
  183. Memory2DynamicStruct.exe+23D2 - 3B F0 |                 - cmp esi,eax
  184. Memory2DynamicStruct.exe+23D4 - 76 10                 - jna Memory2DynamicStruct.exe+23E6
  185. Memory2DynamicStruct.exe+23D6 - 51                    - push ecx
  186. Memory2DynamicStruct.exe+23D7 - 56 |                    - push esi
  187. Memory2DynamicStruct.exe+23D8 - 8B CF                 - mov ecx,edi
  188. Memory2DynamicStruct.exe+23DA - E8 31060000           - call Memory2DynamicStruct.exe+2A10 ------------> 2 to 2, 2 to 3, etc
  189.         Memory2DynamicStruct.exe+2A80 - 55                    - push ebp
  190.         Memory2DynamicStruct.exe+2A81 - 8B EC                 - mov ebp,esp
  191.         Memory2DynamicStruct.exe+2A83 - 83 EC 08              - sub esp,08 { 8 }
  192.         Memory2DynamicStruct.exe+2A86 - 53                    - push ebx
  193.         Memory2DynamicStruct.exe+2A87 - 8B 5D 08              - mov ebx,[ebp+08]
  194. Memory2DynamicStruct.exe+23DF - 5F                    - pop edi
  195. Memory2DynamicStruct.exe+23E0 - 5E                    - pop esi
  196. Memory2DynamicStruct.exe+23E1 - 5B                    - pop ebx
  197. Memory2DynamicStruct.exe+23E2 - 5D                    - pop ebp
  198. Memory2DynamicStruct.exe+23E3 - C2 0400               - ret 0004 { 4 }
  199. Memory2DynamicStruct.exe+23E6 - 2B F1                 - sub esi,ecx
  200. Memory2DynamicStruct.exe+23E8 - C1 E6 02              - shl esi,02 { 2 }
  201. Memory2DynamicStruct.exe+23EB - 56                    - push esi
  202. Memory2DynamicStruct.exe+23EC - 6A 00                 - push 00 { 0 }
  203. Memory2DynamicStruct.exe+23EE - 53                    - push ebx
  204. Memory2DynamicStruct.exe+23EF - E8 5D180000           - call Memory2DynamicStruct.exe+3C51 { ->->VCRUNTIME140.dll+3C90 }
  205. Memory2DynamicStruct.exe+23F4 - 8D 04 1E              - lea eax,[esi+ebx]
  206. Memory2DynamicStruct.exe+23F7 - 83 C4 0C              - add esp,0C { 12 }
  207. Memory2DynamicStruct.exe+23FA - 89 47 04              - mov [edi+04],eax
  208. Memory2DynamicStruct.exe+23FD - 5F                    - pop edi
  209. Memory2DynamicStruct.exe+23FE - 5E                    - pop esi
  210. Memory2DynamicStruct.exe+23FF - 5B                    - pop ebx
  211. Memory2DynamicStruct.exe+2400 - 5D                    - pop ebp
  212. Memory2DynamicStruct.exe+2401 - C2 0400               - ret 0004 { 4 }
  213. */
  214. DWORD Resize_AboveOrEqual_VS2019_MagicNumber; // = 0x00005651; //scasw
  215. DWORD Address_Resize_AboveOrEqual = NULL;
  216. BYTE Bk_Resize_AboveOrEqual[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
  217.  
  218. // ------- DEBUG ------- //
  219. class StructVector
  220. {
  221. public:
  222.     DWORD backVectorPointer; //0x0000
  223.     DWORD v00000000_0x4; //0x0004
  224.     DWORD vFDFDFDFD_0x8; //0x0008
  225.     DWORD vDDDDDDDD_0xC; //0x000C
  226. }; //Size=0x0010
  227.  
  228. class VectorPointers
  229. {
  230. public:
  231.     StructVector* pStructVector; //0x0000
  232.     DWORD pMyFirst; //0x0004
  233.     DWORD pMyLast; //0x0008
  234.     DWORD pMyEnd; //0x000C Equal to pMyLast
  235.     DWORD vFDFDFDFD_0x10; //0x0010
  236. }; //Size=0x0014
  237.  
  238. class BaseVector
  239. {
  240. public:
  241.     VectorPointers* pVectorPointers; //0x0000
  242.     DWORD vCCCCCCCC_0x4; //0x0004
  243.     DWORD vCCCCCCCC_0x8; //0x0008
  244. }; //Size=0x000C
  245. // ------- DEBUG ------- //
  246.  
  247. // ------- RELEASE ------- //
  248. class VectorPointers_Release
  249. {
  250. public:
  251.     DWORD pMyFirst; //0x0000
  252.     DWORD pMyLast; //0x0004
  253.     DWORD pMyEnd; //0x0008 Equal to pMyLast
  254.     DWORD vABABABAB_0xC; //0x000C
  255.     DWORD vABABABAB_0x10; //0x0010
  256.     DWORD vFEEEFEEE_0x14; //0x0014
  257.     //DWORD vFEEEFEEE_0x18; //0x0018
  258.     //DWORD vFEEEFEEE_0x1C; //0x001C
  259.     //DWORD v00000000_0x20; //0x0020
  260.     //DWORD v00000000_0x24; //0x0024
  261. }; //Size=0x0028
  262.  
  263. class BaseVector_Release
  264. {
  265. public:
  266.     VectorPointers_Release* pVectorPointers; //0x0000
  267. }; //Size=0x0004
  268. // ------- RELEASE ------- //
  269.  
  270. DWORD dwOldProtectionByte;
  271. void WriteInProcessBYTE(DWORD Address, BYTE Value)
  272. {
  273.     MEMORY_BASIC_INFORMATION mbi = { 0 };
  274.  
  275.     if (VirtualQuery((LPVOID)Address, &mbi, sizeof(mbi)) == 0)
  276.     {
  277.         VirtualQueryEx(GetCurrentProcess(), (LPVOID)Address, &mbi, sizeof(mbi));
  278.     }
  279.  
  280.     //*(BYTE*)Address = Value; //typecast variable to a pointer of a byte and dereference the pointer, letting you change what it holds
  281.     //VirtualProtect((LPVOID)Address, 1, PAGE_EXECUTE_READWRITE, &dwOldProtectionByte);
  282.     VirtualProtect((LPVOID)mbi.BaseAddress, mbi.RegionSize, PAGE_EXECUTE_READWRITE, &dwOldProtectionByte);
  283.  
  284.     *(BYTE*)Address = Value;
  285.  
  286.     //VirtualProtect((LPVOID)Address, 1, dwOldProtectionByte, &dwOldProtectionByte);
  287.     VirtualProtect((LPVOID)mbi.BaseAddress, mbi.RegionSize, dwOldProtectionByte, &dwOldProtectionByte);
  288. }
  289.  
  290. BYTE ReadInProcessBYTE(DWORD Address)
  291. {
  292.     return *(BYTE*)Address;
  293. }
  294.  
  295. DWORD dwOldProtectionWORD;
  296. void WriteInProcessWORD(DWORD Address, WORD Value)
  297. {
  298.     MEMORY_BASIC_INFORMATION mbi = { 0 };
  299.  
  300.     if (VirtualQuery((LPVOID)Address, &mbi, sizeof(mbi)) == 0)
  301.     {
  302.         VirtualQueryEx(GetCurrentProcess(), (LPVOID)Address, &mbi, sizeof(mbi));
  303.     }
  304.  
  305.     //*(BYTE*)Address = Value; //typecast variable to a pointer of a byte and dereference the pointer, letting you change what it holds
  306.     //VirtualProtect((LPVOID)Address, 2, PAGE_EXECUTE_READWRITE, &dwOldProtectionWORD);
  307.     VirtualProtect((LPVOID)mbi.BaseAddress, mbi.RegionSize, PAGE_EXECUTE_READWRITE, &dwOldProtectionWORD);
  308.  
  309.     *(WORD*)Address = Value;
  310.  
  311.     //VirtualProtect((LPVOID)Address, 2, dwOldProtectionWORD, &dwOldProtectionWORD);
  312.     VirtualProtect((LPVOID)mbi.BaseAddress, mbi.RegionSize, dwOldProtectionWORD, &dwOldProtectionWORD);
  313. }
  314.  
  315. WORD ReadInProcessWORD(DWORD Address)
  316. {
  317.     return *(WORD*)Address;
  318. }
  319.  
  320. DWORD dwOldProtectionDWORD;
  321. void WriteInProcessDWORD(DWORD Address, DWORD Value)
  322. {
  323.     MEMORY_BASIC_INFORMATION mbi = { 0 };
  324.  
  325.     if (VirtualQuery((LPVOID)Address, &mbi, sizeof(mbi)) == 0)
  326.     {
  327.         VirtualQueryEx(GetCurrentProcess(), (LPVOID)Address, &mbi, sizeof(mbi));
  328.     }
  329.  
  330.     VirtualProtect((LPVOID)mbi.BaseAddress, mbi.RegionSize, PAGE_EXECUTE_READWRITE, &dwOldProtectionDWORD);
  331.  
  332.     *(DWORD*)Address = Value;
  333.  
  334.     VirtualProtect((LPVOID)mbi.BaseAddress, mbi.RegionSize, dwOldProtectionDWORD, &dwOldProtectionDWORD);
  335. }
  336.  
  337. DWORD ReadInProcessDWORD(DWORD Address)
  338. {
  339.     return *(DWORD*)Address;
  340. }
  341.  
  342. /*
  343. Address + [Address + 1] + 5
  344. */
  345. DWORD GetRealCALL(DWORD VarAddress)
  346. {
  347.     return VarAddress + ReadInProcessDWORD(VarAddress + 0x1) + 0x5;
  348. }
  349.  
  350. void FitAddress2Vector_Debug()
  351. {
  352.     BaseVector* VarBaseVector;
  353.  
  354.     VarBaseVector = (BaseVector*)(AddressAlloc);
  355.  
  356.     VarBaseVector->pVectorPointers = (VectorPointers*)((DWORD)(AddressAlloc) + 0xC);
  357.     VarBaseVector->vCCCCCCCC_0x4 = 0xCCCCCCCC;
  358.     VarBaseVector->vCCCCCCCC_0x8 = 0xCCCCCCCC;
  359.  
  360.     //StructVector* pStructVector; //0x0000
  361.     //DWORD pMyFirst; //0x0004
  362.     //DWORD pMyLast; //0x0008
  363.     //DWORD pMyEnd; //0x000C Equal to pMyLast
  364.     //DWORD vFDFDFDFD_0x10; //0x0010
  365.  
  366.     VarBaseVector->pVectorPointers->pStructVector = (StructVector*)((DWORD)(AddressAlloc) + 0x28);
  367.  
  368.     //DWORD backVectorPointer; //0x0000
  369.     //DWORD v00000000_0x4; //0x0004
  370.     //DWORD vFDFDFDFD_0x8; //0x0008
  371.     //DWORD vDDDDDDDD_0xC; //0x000C
  372.     VarBaseVector->pVectorPointers->pStructVector->backVectorPointer = (DWORD)&VarBaseVector->pVectorPointers->pStructVector;
  373.     VarBaseVector->pVectorPointers->pStructVector->v00000000_0x4 = 0x00000000;
  374.     VarBaseVector->pVectorPointers->pStructVector->vFDFDFDFD_0x8 = 0xFDFDFDFD;
  375.     VarBaseVector->pVectorPointers->pStructVector->vDDDDDDDD_0xC = 0xDDDDDDDD;
  376.     //
  377.  
  378.     VarBaseVector->pVectorPointers->pMyFirst = ((DWORD)(AddressAlloc) + 0x38);
  379.     VarBaseVector->pVectorPointers->pMyLast = ((DWORD)(AddressAlloc) + 0x3C);
  380.     VarBaseVector->pVectorPointers->pMyEnd = VarBaseVector->pVectorPointers->pMyLast;
  381.     VarBaseVector->pVectorPointers->vFDFDFDFD_0x10 = 0xFDFDFDFD;
  382.  
  383.     WriteInProcessDWORD((DWORD)(AddressAlloc) + 0x38, 0x00000333); //[0]
  384.     WriteInProcessDWORD((DWORD)(AddressAlloc) + 0x3C, 0xFDFDFDFD);
  385. }
  386.  
  387. void FitAddress2Vector_Release()
  388. {
  389.     DWORD Offset = 0x0;
  390.  
  391.     BaseVector_Release* VarBaseVector;
  392.  
  393.     VarBaseVector = (BaseVector_Release*)(AddressAlloc);
  394.  
  395.     VarBaseVector->pVectorPointers = (VectorPointers_Release*)((DWORD)(AddressAlloc) + 0x4);
  396.  
  397.     /*
  398.     DWORD pVectorArray; //0x0000
  399.     DWORD pMyFirst; //0x0004
  400.     DWORD pMyLast; //0x0008
  401.     DWORD vABABABAB_0xC; //0x000C
  402.     DWORD vABABABAB_0x10; //0x0010
  403.     DWORD vFEEEFEEE_0x14; //0x0014
  404.     */
  405.  
  406.     Offset = sizeof(VectorPointers_Release) + 0x04;
  407.  
  408.     // -------------------- <int> o lo que fuera --------------------
  409.     DWORD IntroValues[] = { 0x00000333 , 0x00000666 , 0x00000999 };
  410.  
  411.     int array_size = sizeof(IntroValues) / sizeof(IntroValues[0]);
  412.  
  413.     // -------------------- <struct> --------------------
  414.     //CurrentType
  415.     tHook tmp;
  416.  
  417.     tmp.Base = 0x12345678;
  418.     tmp.Offset = 0x1234;
  419.     FillMemory(tmp.DllPath, sizeof(tmp.DllPath), 0x45);
  420.     tmp.DllPath[sizeof(tmp.DllPath) - 1] = '\0';
  421.     //strncpy(a, "iqbal", sizeof(a) - 1);
  422.     tmp.Activated = true;
  423.     tmp.HookedAddress = tmp.Base + tmp.Offset + 3;
  424.     tmp.Count = 0x1234567887654321;
  425.  
  426.     // --------------------------------------------------------------
  427.  
  428.     //std::cout << "array_size: " << std::dec << array_size << std::endl;
  429.  
  430.     VarBaseVector->pVectorPointers->pMyFirst = ((DWORD)(AddressAlloc) + Offset); //0x4
  431.     //VarBaseVector->pVectorPointers->pMyLast = ((DWORD)(AddressAlloc) + Offset + (0x04 * array_size)); //0x8
  432.  
  433.     switch (CurrentType)
  434.     {
  435.         case eTaipu::eInt:
  436.             VarBaseVector->pVectorPointers->pMyLast = ((DWORD)(AddressAlloc) + Offset + (sizeof(IntroValues[0]) * array_size)); //0x8
  437.             Push_Back_VS2019_MagicNumber = 0x000075FF; //0x75FF0004;
  438.             Resize_AboveOrEqual_VS2019_MagicNumber = 0x00005651;
  439.             VectorHoldingSize = sizeof(int);
  440.  
  441.             break;
  442.         case eTaipu::eStruct:
  443.             VarBaseVector->pVectorPointers->pMyLast = ((DWORD)(AddressAlloc) + Offset + sizeof(tmp)); //0x8
  444.             Push_Back_VS2019_MagicNumber = 0x000075FF; //0x0004C25D;
  445.             Resize_AboveOrEqual_VS2019_MagicNumber = 0x00005651;
  446.             VectorHoldingSize = sizeof(tHook);
  447.  
  448.             break;
  449.     }
  450.  
  451.     VarBaseVector->pVectorPointers->pMyEnd = VarBaseVector->pVectorPointers->pMyLast; //0xC
  452.     VarBaseVector->pVectorPointers->vABABABAB_0xC = 0xABABABAB; //0x10
  453.     VarBaseVector->pVectorPointers->vABABABAB_0x10 = 0xABABABAB; //0x14
  454.     VarBaseVector->pVectorPointers->vFEEEFEEE_0x14 = 0xFEEEEEEE; //0x18
  455.     //VarBaseVector->pVectorPointers->vFEEEFEEE_0x18 = 0xFEEEEEEE; //0x1C
  456.     //VarBaseVector->pVectorPointers->vFEEEFEEE_0x1C = 0xFEEEEEEE; //0x20
  457.     //VarBaseVector->pVectorPointers->v00000000_0x20 = 0x00000000; //0x24
  458.     //VarBaseVector->pVectorPointers->v00000000_0x24 = 0x00000000; //0x28
  459.  
  460.     switch (CurrentType)
  461.     {
  462.         case eTaipu::eInt:
  463.             for (size_t i = 0; i < array_size; i++)
  464.             {
  465.                 WriteInProcessDWORD((DWORD)(AddressAlloc) + Offset + (0x04 * i), IntroValues[i]);
  466.             }
  467.  
  468.             break;
  469.         case eTaipu::eStruct:
  470.             CopyMemory((LPVOID)((DWORD)(AddressAlloc) + Offset), &tmp, sizeof(tmp));
  471.  
  472.             break;
  473.     }
  474.  
  475.     //Offset += (array_size * 0x04);
  476.  
  477.     //WriteInProcessDWORD((DWORD)(AddressAlloc) + Offset + 0x00, 0xABABABAB);
  478.     //WriteInProcessDWORD((DWORD)(AddressAlloc) + Offset + 0x04, 0xABABABAB);
  479.     //WriteInProcessDWORD((DWORD)(AddressAlloc) + Offset + 0x08, 0x00000000);
  480.     //WriteInProcessDWORD((DWORD)(AddressAlloc) + Offset + 0x0C, 0x00000000);
  481. }
  482.  
  483. BOOL InitAllocation()
  484. {
  485.     AddressAlloc = VirtualAlloc(NULL, 100, MEM_RESERVE, PAGE_EXECUTE_READWRITE);
  486.  
  487.     //std::cout << "AddressAlloc.MEM_RESERVE, AddressAlloc: " << std::hex << AddressAlloc << std::endl;
  488.  
  489.     AddressAlloc = VirtualAlloc(AddressAlloc, 100, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
  490.  
  491.     std::cout << "AddressAlloc.MEM_COMMIT, AddressAlloc: " << std::hex << AddressAlloc << std::endl;
  492.  
  493.     if (AddressAlloc)
  494.     {
  495.         FitAddress2Vector_Release();
  496.     }
  497.  
  498.     return (AddressAlloc != NULL);
  499. }
  500.  
  501. void Patch_Mov_Eax_Jmp_Eax(DWORD SrcAddress, DWORD DstAddress, DWORD OutPutBKBytes, DWORD NumberOfBytes)
  502. {
  503.     CopyMemory((LPVOID)OutPutBKBytes, (LPVOID)SrcAddress, NumberOfBytes);
  504.  
  505.     /*
  506.     Memory2DynamicStruct.exe+1870 - 55                    - push ebp
  507.     Memory2DynamicStruct.exe+1871 - 8B EC                 - mov ebp,esp
  508.     Memory2DynamicStruct.exe+1873 - 83 EC 0C              - sub esp,0C { 12 }
  509.     Memory2DynamicStruct.exe+1876 - 8B 45 08              - mov eax,[ebp+08]
  510.     ...
  511.     Memory2DynamicStruct.exe+19B4 - C2 0800               - ret 0008 { 8 }
  512.  
  513.     Memory2DynamicStruct.exe+1870 - B8 78563412           - mov eax,12345678 { 305419896 }
  514.     Memory2DynamicStruct.exe+1875 - FF E0                 - jmp eax
  515.     Memory2DynamicStruct.exe+1877 - 90                    - nop
  516.     Memory2DynamicStruct.exe+1878 - 90                    - nop
  517.     */
  518.     WriteInProcessBYTE(SrcAddress, 0xB8);
  519.     WriteInProcessDWORD(SrcAddress + 0x01, DstAddress);
  520.     WriteInProcessWORD(SrcAddress + 0x05, 0xE0FF);
  521.  
  522.     for (size_t i = 7; i < NumberOfBytes; i++)
  523.     {
  524.         WriteInProcessBYTE(SrcAddress + i, 0x90);
  525.     }
  526.  
  527.     /*std::cout << "BK" << std::endl;
  528.  
  529.     for (size_t i = 0; i < NumberOfBytes; i++)
  530.     {
  531.         std::cout << std::hex << (DWORD)ReadInProcessBYTE(OutPutBKBytes + i) << std::endl;
  532.     }
  533.  
  534.     std::cout << "---" << std::endl;*/
  535. }
  536.  
  537. void Restore_Move_Eax_Jmp_Eax(DWORD SrcAddress, DWORD OutPutBKBytes, DWORD NumberOfBytes)
  538. {
  539.     //CopyMemory((LPVOID)SrcAddress, (LPVOID)OutPutBKBytes, sizeof(OutPutBKBytes));
  540.  
  541.     for (size_t i = 0; i < NumberOfBytes; i++)
  542.     {
  543.         WriteInProcessBYTE(SrcAddress + i, ReadInProcessBYTE(OutPutBKBytes + i));
  544.     }
  545. }
  546.  
  547. void WINAPI boku_no_push_back(DWORD pMyLast, DWORD PointerWithValue)
  548. {
  549.     //DWORD Value = 0;
  550.  
  551.     BaseVector_Release* VarBaseVector;
  552.  
  553.     VarBaseVector = (BaseVector_Release*)(AddressAlloc);
  554.  
  555.     //std::cout << std::hex << "pMyLast: " << pMyLast << std::endl;
  556.  
  557.     /*switch (CurrentType)
  558.     {
  559.         case eTaipu::eInt:
  560.             //Value = ReadInProcessDWORD(PointerWithValue);
  561.             //std::cout << std::hex << "PointerWithValue: " << Value << std::endl;
  562.  
  563.             //WriteInProcessDWORD(pMyLast, Value);
  564.             //WriteInProcessDWORD(pMyLast + 0x04, 0xABABABAB);
  565.             //WriteInProcessDWORD(pMyLast + 0x08, 0xABABABAB);
  566.             //WriteInProcessDWORD(pMyLast + 0x0C, 0x00000000);
  567.             //WriteInProcessDWORD(pMyLast + 0x10, 0x00000000);
  568.  
  569.             break;
  570.         case eTaipu::eStruct:
  571.             //std::cout << std::hex << "PointerWithValue: " << Value << std::endl;
  572.  
  573.             //CopyMemory((LPVOID)pMyLast, (LPVOID)PointerWithValue, sizeof(tHook));
  574.  
  575.             break;
  576.     }*/
  577.  
  578.     CopyMemory((LPVOID)pMyLast, (LPVOID)PointerWithValue, VectorHoldingSize);
  579.  
  580.     VarBaseVector->pVectorPointers->pMyLast = pMyLast + VectorHoldingSize; //0x8
  581.     VarBaseVector->pVectorPointers->pMyEnd = VarBaseVector->pVectorPointers->pMyLast; //0xC
  582. }
  583.  
  584. void HookVector_push_back()
  585. {
  586.     DWORD tmpAdd = 0;
  587.  
  588.     /*
  589.     * push_back:
  590.     *       minkernel\crts\ucrt\src\appcrt\heap\debug_heap.cpp
  591.     *       _CrtlsValidHeapPointer(block)
  592.     */
  593.     //FitAddress2Vector_Debug((DWORD)Add);
  594.     //std::vector<int>* v = (std::vector<int>*)AddressAlloc;
  595.     std::vector<int>* v = (std::vector<int>*)(ReadInProcessDWORD((DWORD)AddressAlloc));
  596.     //std::vector<int>* v = new std::vector<int>(10);
  597.  
  598.     __asm
  599.     {
  600.         ; int 3
  601.         ; nop
  602.         ; int 3
  603.         lea eax, [v]
  604.         mov tmpAdd, eax
  605.         jmp _next
  606.     }
  607.  
  608.     v->push_back(0x666);
  609.  
  610.     __asm
  611.     {
  612.     _next:
  613.         call _t
  614.     _t :
  615.         pop eax
  616.         sub eax, 0x0A
  617.  
  618.         mov tmpAdd, eax
  619.         ; int 3
  620.         ; nop
  621.         ; int 3
  622.     }
  623.  
  624.     std::cout << std::hex << "HookVector_push_back::GetRealCall: " << GetRealCALL(tmpAdd) << std::endl;
  625.  
  626.     tmpAdd = GetRealCALL(tmpAdd);
  627.  
  628.     __asm
  629.     {
  630.         mov ecx, -1
  631.         mov edi, tmpAdd
  632.         mov eax, Push_Back_VS2019_MagicNumber; 0x75FF0004
  633.         cld
  634.     _keep:
  635.         repne scasb
  636.         cmp byte ptr [edi], ah
  637.         jne _keep
  638.         inc edi
  639.         inc edi
  640.         inc edi
  641.         mov tmpAdd, edi
  642.     }
  643.  
  644.     /*
  645.     Memory2DynamicStruct.exe+1870 - 55                    - push ebp
  646.     Memory2DynamicStruct.exe+1871 - 8B EC                 - mov ebp,esp
  647.     Memory2DynamicStruct.exe+1873 - 83 EC 0C              - sub esp,0C { 12 }
  648.     Memory2DynamicStruct.exe+1876 - 8B 45 08              - mov eax,[ebp+08]
  649.     ...
  650.     Memory2DynamicStruct.exe+19B4 - C2 0800               - ret 0008 { 8 }
  651.  
  652.     Memory2DynamicStruct.exe+1870 - B8 78563412           - mov eax,12345678 { 305419896 }
  653.     Memory2DynamicStruct.exe+1875 - FF E0                 - jmp eax
  654.     Memory2DynamicStruct.exe+1877 - 90                    - nop
  655.     Memory2DynamicStruct.exe+1878 - 90                    - nop
  656.     */
  657.     std::cout << std::hex << "HookVector_push_back::GetRealCall: " << GetRealCALL(tmpAdd) << std::endl;
  658.  
  659.     Address_Push_Back = GetRealCALL(tmpAdd);
  660.  
  661.     //std::cin.get();
  662.  
  663.     Patch_Mov_Eax_Jmp_Eax(Address_Push_Back, (DWORD)&boku_no_push_back, (DWORD)&Bk_Push_Back[0], sizeof(Bk_Push_Back));
  664. }
  665.  
  666. void HookVector_push_back_struct()
  667. {
  668.     DWORD tmpAdd = 0;
  669.  
  670.     tHook tmp;
  671.  
  672.     tmp.Base = 0x12345678;
  673.     tmp.Offset = 0x1234;
  674.     FillMemory(tmp.DllPath, sizeof(tmp.DllPath), 0x45);
  675.     tmp.DllPath[sizeof(tmp.DllPath) - 1] = '\0';
  676.     tmp.Activated = true;
  677.     //strncpy(a, "iqbal", sizeof(a) - 1);
  678.     tmp.HookedAddress = tmp.Base + tmp.Offset + 3;
  679.     tmp.Count = 0x1234567887654321;
  680.  
  681.     /*
  682.     * push_back:
  683.     *       minkernel\crts\ucrt\src\appcrt\heap\debug_heap.cpp
  684.     *       _CrtlsValidHeapPointer(block)
  685.     */
  686.     //FitAddress2Vector_Debug((DWORD)Add);
  687.     //std::vector<int>* v = (std::vector<int>*)AddressAlloc;
  688.     std::vector<tHook>* v = (std::vector<tHook>*)(ReadInProcessDWORD((DWORD)AddressAlloc));
  689.     //std::vector<int>* v = new std::vector<int>(10);
  690.  
  691.     //std::cin.get();
  692.  
  693.     __asm
  694.     {
  695.         ; int 3
  696.         ; nop
  697.         ; int 3
  698.         lea eax, [v]
  699.         mov tmpAdd, eax
  700.         jmp _next
  701.     }
  702.  
  703.     v->push_back(tmp);
  704.  
  705.     __asm
  706.     {
  707.     _next:
  708.         call _t
  709.     _t :
  710.         pop eax
  711.         sub eax, 0x0A
  712.  
  713.         mov tmpAdd, eax
  714.         ; int 3
  715.         ; nop
  716.         ; int 3
  717.     }
  718.  
  719.     std::cout << std::hex << "HookVector_push_back_struct::GetRealCall: " << GetRealCALL(tmpAdd) << std::endl;
  720.  
  721.     tmpAdd = GetRealCALL(tmpAdd);
  722.  
  723.     __asm
  724.     {
  725.         mov ecx, -1
  726.         mov edi, tmpAdd
  727.         mov eax, Push_Back_VS2019_MagicNumber; 0x0004C25D (struct)
  728.         cld
  729.         ; repne scasd
  730.         ; add edi, 0x04
  731.     _keep:
  732.         repne scasb
  733.         cmp byte ptr [edi], ah
  734.         jne _keep
  735.         inc edi
  736.         inc edi
  737.         inc edi
  738.         mov tmpAdd, edi
  739.     }
  740.  
  741.     /*
  742.     Memory2DynamicStruct.exe+1870 - 55                    - push ebp
  743.     Memory2DynamicStruct.exe+1871 - 8B EC                 - mov ebp,esp
  744.     Memory2DynamicStruct.exe+1873 - 83 EC 0C              - sub esp,0C { 12 }
  745.     Memory2DynamicStruct.exe+1876 - 8B 45 08              - mov eax,[ebp+08]
  746.     ...
  747.     Memory2DynamicStruct.exe+19B4 - C2 0800               - ret 0008 { 8 }
  748.  
  749.     Memory2DynamicStruct.exe+1870 - B8 78563412           - mov eax,12345678 { 305419896 }
  750.     Memory2DynamicStruct.exe+1875 - FF E0                 - jmp eax
  751.     Memory2DynamicStruct.exe+1877 - 90                    - nop
  752.     Memory2DynamicStruct.exe+1878 - 90                    - nop
  753.     */
  754.     std::cout << std::hex << "HookVector_push_back_struct::GetRealCall: " << GetRealCALL(tmpAdd) << std::endl;
  755.  
  756.     Address_Push_Back = GetRealCALL(tmpAdd);
  757.  
  758.     //std::cin.get();
  759.  
  760.     Patch_Mov_Eax_Jmp_Eax(Address_Push_Back, (DWORD)&boku_no_push_back, (DWORD)&Bk_Push_Back[0], sizeof(Bk_Push_Back));
  761. }
  762.  
  763. void WINAPI boku_no_resize_AboveOrEqual(DWORD NewSize, DWORD OldSize)
  764. {
  765.     //std::cout << std::dec << "NewSize: " << NewSize << " (0x" << std::hex << NewSize << ")" << std::endl;
  766.     //std::cout << std::dec << "OldSize: " << OldSize << " (0x" << std::hex << OldSize << ")" << std::endl;
  767.  
  768.     BaseVector_Release* VarBaseVector;
  769.  
  770.     VarBaseVector = (BaseVector_Release*)(AddressAlloc);
  771.  
  772.     DWORD bkLast = VarBaseVector->pVectorPointers->pMyLast;
  773.     DWORD DeltaSize = 0;
  774.  
  775.     switch (CurrentType)
  776.     {
  777.         case eTaipu::eInt:
  778.  
  779.             break;
  780.         case eTaipu::eStruct:
  781.             OldSize /= sizeof(tHook);
  782.  
  783.             //std::cout << std::dec << "New OldSize Struct: " << OldSize << " (0x" << std::hex << OldSize << ")" << std::endl;
  784.  
  785.             break;
  786.     }
  787.  
  788.     if ((DWORD)NewSize >= (DWORD)OldSize)
  789.     {
  790.         DeltaSize = (NewSize - OldSize);
  791.         //std::cout << "111111111111" << std::endl;
  792.     }
  793.     else
  794.     {
  795.         DeltaSize = NewSize - ((VarBaseVector->pVectorPointers->pMyLast - VarBaseVector->pVectorPointers->pMyFirst) / VectorHoldingSize);
  796.         //std::cout << "222222222222" << std::endl;
  797.     }
  798.  
  799.     //std::cout << std::dec << "DeltaSize: " << DeltaSize << " (0x" << std::hex << DeltaSize << ")" << std::endl << std::endl;
  800.  
  801.     //VarBaseVector->pVectorPointers->pMyLast = VarBaseVector->pVectorPointers->pMyLast + (0x04 * DeltaSize); //0x8
  802.     VarBaseVector->pVectorPointers->pMyLast = VarBaseVector->pVectorPointers->pMyLast + (VectorHoldingSize * DeltaSize); //0x8
  803.     VarBaseVector->pVectorPointers->pMyEnd = VarBaseVector->pVectorPointers->pMyLast; //0xC
  804.  
  805.     ZeroMemory((LPVOID)bkLast, (VectorHoldingSize * DeltaSize));
  806.  
  807.     /*for (size_t i = 0; i < DeltaSize; i++)
  808.     {
  809.         WriteInProcessDWORD(bkLast + (i * 0x04), 0x00000000);
  810.     }*/
  811.  
  812.     //WriteInProcessDWORD(VarBaseVector->pVectorPointers->pMyLast + 0x00, 0xABABABAB);
  813.     //WriteInProcessDWORD(VarBaseVector->pVectorPointers->pMyLast + 0x04, 0xABABABAB);
  814.     //WriteInProcessDWORD(VarBaseVector->pVectorPointers->pMyLast + 0x08, 0x00000000);
  815.     //WriteInProcessDWORD(VarBaseVector->pVectorPointers->pMyLast + 0x0C, 0x00000000);
  816. }
  817.  
  818. void HookVector_resize_AboveOrEqual()
  819. {
  820.     DWORD tmpAdd = 0;
  821.  
  822.     //std::vector<int>* v = (std::vector<int>*)AddressAlloc;
  823.     std::vector<int>* v = (std::vector<int>*)(ReadInProcessDWORD((DWORD)AddressAlloc));
  824.     //std::vector<int>* v = new std::vector<int>(10);
  825.  
  826.     //std::cin.get();
  827.  
  828.     __asm
  829.     {
  830.         ; int 3
  831.         ; nop
  832.         ; int 3
  833.         lea eax, [v]
  834.         mov tmpAdd, eax
  835.         jmp _next
  836.     }
  837.  
  838.     /*
  839.     Memory2DynamicStruct.exe+15DC - 6A 03                 - push 03 { 3 }
  840.     Memory2DynamicStruct.exe+15DE - 8B 4D F4              - mov ecx,[ebp-0C]
  841.     Memory2DynamicStruct.exe+15E1 - E8 5A0A0000           - call Memory2DynamicStruct.exe+2040
  842.     */
  843.     v->resize(7);
  844.  
  845.     __asm
  846.     {
  847.     _next:
  848.         call _t
  849.     _t :
  850.         pop eax
  851.         sub eax, 0x0A
  852.  
  853.         mov tmpAdd, eax
  854.         ; int 3
  855.         ; nop
  856.         ; int 3
  857.     }
  858.  
  859.     std::cout << std::hex << "HookVector_resize_AboveOrEqual::GetRealCall: " << GetRealCALL(tmpAdd) << std::endl;
  860.  
  861.     tmpAdd = GetRealCALL(tmpAdd);
  862.  
  863.     //std::cin.get();
  864.  
  865.     __asm
  866.     {
  867.         ; int 3
  868.         ; nop
  869.         ; int 3
  870.         mov ecx, -1
  871.         mov edi, tmpAdd
  872.         mov eax, Resize_AboveOrEqual_VS2019_MagicNumber; 0x00005651
  873.         cld
  874.     _keep:
  875.         repne scasb
  876.         cmp byte ptr [edi], ah
  877.         jne _keep
  878.         inc edi
  879.         inc edi
  880.         inc edi
  881.         mov tmpAdd, edi
  882.     }
  883.  
  884.     std::cout << std::hex << "HookVector_resize_AboveOrEqual::GetRealCall: " << GetRealCALL(tmpAdd) << std::endl;
  885.  
  886.     Address_Resize_AboveOrEqual = GetRealCALL(tmpAdd);
  887.  
  888.     Patch_Mov_Eax_Jmp_Eax(Address_Resize_AboveOrEqual, (DWORD)&boku_no_resize_AboveOrEqual, (DWORD)&Bk_Resize_AboveOrEqual[0], sizeof(Bk_Resize_AboveOrEqual));
  889.  
  890.     //std::cin.get();
  891. }
  892.  
  893. void HookVector_resize_AboveOrEqual_struct()
  894. {
  895.     DWORD tmpAdd = 0;
  896.  
  897.     //std::vector<int>* v = (std::vector<int>*)AddressAlloc;
  898.     std::vector<tHook>* v = (std::vector<tHook>*)(ReadInProcessDWORD((DWORD)AddressAlloc));
  899.     //std::vector<int>* v = new std::vector<int>(10);
  900.  
  901.     //std::cin.get();
  902.  
  903.     __asm
  904.     {
  905.         ; int 3
  906.         ; nop
  907.         ; int 3
  908.         lea eax, [v]
  909.         mov tmpAdd, eax
  910.         jmp _next
  911.     }
  912.  
  913.     /*
  914.     Memory2DynamicStruct.exe+15DC - 6A 03                 - push 03 { 3 }
  915.     Memory2DynamicStruct.exe+15DE - 8B 4D F4              - mov ecx,[ebp-0C]
  916.     Memory2DynamicStruct.exe+15E1 - E8 5A0A0000           - call Memory2DynamicStruct.exe+2040
  917.     */
  918.     v->resize(7);
  919.  
  920.     __asm
  921.     {
  922.     _next:
  923.         call _t
  924.     _t :
  925.         pop eax
  926.         sub eax, 0x0A
  927.  
  928.         mov tmpAdd, eax
  929.         ; int 3
  930.         ; nop
  931.         ; int 3
  932.     }
  933.  
  934.     std::cout << std::hex << "HookVector_resize_AboveOrEqual_struct::GetRealCall: " << GetRealCALL(tmpAdd) << std::endl;
  935.  
  936.     tmpAdd = GetRealCALL(tmpAdd);
  937.  
  938.     //std::cin.get();
  939.  
  940.     __asm
  941.     {
  942.         ; int 3
  943.         ; nop
  944.         ; int 3
  945.         mov ecx, -1
  946.         mov edi, tmpAdd
  947.         mov eax, Resize_AboveOrEqual_VS2019_MagicNumber; 0x00005651
  948.         cld
  949.     _keep:
  950.         repne scasb
  951.         cmp byte ptr [edi], ah
  952.         jne _keep
  953.         inc edi
  954.         inc edi
  955.         inc edi
  956.         mov tmpAdd, edi
  957.     }
  958.  
  959.     std::cout << std::hex << "HookVector_resize_AboveOrEqual_struct::GetRealCall: " << GetRealCALL(tmpAdd) << std::endl;
  960.  
  961.     Address_Resize_AboveOrEqual = GetRealCALL(tmpAdd);
  962.  
  963.     Patch_Mov_Eax_Jmp_Eax(Address_Resize_AboveOrEqual, (DWORD)&boku_no_resize_AboveOrEqual, (DWORD)&Bk_Resize_AboveOrEqual[0], sizeof(Bk_Resize_AboveOrEqual));
  964.  
  965.     //std::cin.get();
  966. }
  967.  
  968. //Cool, but finally not necessary
  969. template <typename T>
  970. void M_resize(std::vector<T>& vec, DWORD NewValue)
  971. {
  972.     vec.resize(NewValue);
  973.  
  974.     BaseVector_Release* VarBaseVector;
  975.  
  976.     VarBaseVector = (BaseVector_Release*)(AddressAlloc);
  977.  
  978.     if (VarBaseVector->pVectorPointers->pMyLast == VarBaseVector->pVectorPointers->pMyEnd) return;
  979.  
  980.     DWORD Delta = (VarBaseVector->pVectorPointers->pMyEnd - VarBaseVector->pVectorPointers->pMyLast) / VectorHoldingSize;
  981.  
  982.     WriteInProcessDWORD(VarBaseVector->pVectorPointers->pMyEnd + 0x04, 0x00000000);
  983.  
  984.     for (size_t i = 0; i < Delta; i++)
  985.     {
  986.         WriteInProcessDWORD(VarBaseVector->pVectorPointers->pMyEnd - (i * 0x04), 0x00000000);
  987.     }
  988.  
  989.     //WriteInProcessDWORD(VarBaseVector->pVectorPointers->pMyLast + 0x00, 0xABABABAB);
  990.     //WriteInProcessDWORD(VarBaseVector->pVectorPointers->pMyLast + 0x04, 0xABABABAB);
  991.  
  992.     VarBaseVector->pVectorPointers->pMyEnd = VarBaseVector->pVectorPointers->pMyLast;
  993. }
  994.  
  995. void TestMemory2Vector()
  996. {
  997.     if (InitAllocation())
  998.     {
  999.         HookVector_push_back();
  1000.         HookVector_resize_AboveOrEqual();
  1001.  
  1002.         //std::vector<int>* v = (std::vector<int>*)(*(DWORD*)(AddressAlloc));
  1003.  
  1004.         //std::cout << "v->push_back(666);" << std::endl;
  1005.         //std::cin.get();
  1006.  
  1007.         //std::cout << std::dec << v->size() << std::endl;
  1008.         //std::vector<int>& vr = *v;
  1009.         std::vector<int>& vr = *(std::vector<int>*)(*(DWORD*)(AddressAlloc));
  1010.         DWORD NewSize = 0;
  1011.         DWORD LastSize = vr.size();
  1012.         int ValToPush = 0;
  1013.  
  1014.         // ------------------------------------------------------------------------------- //
  1015.         std::cout << std::endl << "Listing items:"; // << std::endl;
  1016.         std::cin.get();
  1017.  
  1018.         for (size_t i = 0; i < vr.size(); i++)
  1019.         {
  1020.             std::cout << std::hex << "\t" << "var[" << std::dec << (DWORD)i << "]: 0x" << std::hex << vr[i] << std::endl;
  1021.         }
  1022.  
  1023.         // ------------------------------------------------------------------------------- //
  1024.         ValToPush = 0x111;
  1025.         std::cout << std::endl << "Pushing 0x" << std::hex << ValToPush << " and Listing items:"; // << std::endl;
  1026.         std::cin.get();
  1027.  
  1028.         vr.push_back(ValToPush);
  1029.  
  1030.         for (size_t i = 0; i < vr.size(); i++)
  1031.         {
  1032.             std::cout << std::hex << "\t" << "var[" << std::dec << (DWORD)i << "]: 0x" << std::hex << vr[i] << std::endl;
  1033.         }
  1034.         LastSize = vr.size();
  1035.  
  1036.         // ------------------------------------------------------------------------------- //
  1037.         ValToPush = 0x222;
  1038.         std::cout << std::endl << "Modify index 0 to 0x" << std::hex << ValToPush << " and Listing items:"; // << std::endl;
  1039.         std::cin.get();
  1040.  
  1041.         vr[0] = ValToPush;
  1042.  
  1043.         for (size_t i = 0; i < vr.size(); i++)
  1044.         {
  1045.             std::cout << std::hex << "\t" << "var[" << std::dec << (DWORD)i << "]: 0x" << std::hex << vr[i] << std::endl;
  1046.         }
  1047.  
  1048.         // ------------------------------------------------------------------------------- //
  1049.         std::cout << std::endl << "B4 resizing Above or Equal"; // << std::endl;
  1050.         std::cin.get();
  1051.         /*__asm
  1052.         {
  1053.             int 3
  1054.             nop
  1055.             int 3
  1056.         }*/
  1057.  
  1058.         NewSize = 7;
  1059.  
  1060.         vr.resize(NewSize); //don't need M_resize(vr, NewSize); because it is Above or Equal, but it's good to call it to avoid shits
  1061.  
  1062.         std::cout << std::dec << "resize " << LastSize << " to " << NewSize << " and Listing items:" << std::endl;
  1063.  
  1064.         for (size_t i = 0; i < vr.size(); i++)
  1065.         {
  1066.             std::cout << std::hex << "\t" << "var[" << std::dec << (DWORD)i << "]: 0x" << std::hex << vr[i] << std::endl;
  1067.         }
  1068.  
  1069.         //std::cin.get();
  1070.  
  1071.         // ------------------------------------------------------------------------------- //
  1072.         std::cout << std::endl << "sort ascending and Listing items:"; // << std::endl;
  1073.         std::cin.get();
  1074.  
  1075.         std::sort(vr.begin(), vr.end());
  1076.  
  1077.         for (size_t i = 0; i < vr.size(); i++)
  1078.         {
  1079.             std::cout << std::hex << "\t" << "var[" << std::dec << (DWORD)i << "]: 0x" << std::hex << vr[i] << std::endl;
  1080.         }
  1081.  
  1082.         // ------------------------------------------------------------------------------- //
  1083.         std::cout << std::endl << "vr.empty(): " << (vr.empty() ? "YES" : "NO"); // << std::endl;
  1084.         std::cin.get();
  1085.  
  1086.         // ------------------------------------------------------------------------------- //
  1087.         std::cout << std::endl << "vr.shrink_to_fit()"; // << std::endl;
  1088.         std::cin.get();
  1089.  
  1090.         vr.shrink_to_fit();
  1091.  
  1092.         // ------------------------------------------------------------------------------- //
  1093.         std::cout << std::endl << "clear and Listing items:"; // << std::endl;
  1094.         std::cin.get();
  1095.  
  1096.         vr.clear();
  1097.  
  1098.         if (vr.size())
  1099.         {
  1100.             for (size_t i = 0; i < vr.size(); i++)
  1101.             {
  1102.                 std::cout << std::hex << "\t" << "var[" << std::dec << (DWORD)i << "]: 0x" << std::hex << vr[i] << std::endl;
  1103.             }
  1104.         }
  1105.         else
  1106.         {
  1107.             std::cout << "NO ITEMS" << std::endl;
  1108.         }
  1109.         LastSize = vr.size();
  1110.  
  1111.         // ------------------------------------------------------------------------------- //
  1112.         std::cout << std::endl << "vr.empty(): " << (vr.empty() ? "YES" : "NO"); // << std::endl;
  1113.         std::cin.get();
  1114.  
  1115.         // ------------------------------------------------------------------------------- //
  1116.         std::cout << std::endl << "Pushing for and Listing items:"; // << std::endl;
  1117.         std::cin.get();
  1118.  
  1119.         for (size_t i = 0; i < 12; i++)
  1120.         {
  1121.             vr.push_back(i);
  1122.         }
  1123.  
  1124.         for (size_t i = 0; i < vr.size(); i++)
  1125.         {
  1126.             std::cout << std::hex << "\t" << "var[" << std::dec << (DWORD)i << "]: 0x" << std::hex << vr[i] << std::endl;
  1127.         }
  1128.         LastSize = vr.size();
  1129.  
  1130.         // ------------------------------------------------------------------------------- //
  1131.         std::cout << std::endl << "B4 resizing below or check"; // << std::endl;
  1132.         std::cin.get();
  1133.         /*__asm
  1134.         {
  1135.             int 3
  1136.             nop
  1137.             int 3
  1138.         }*/
  1139.  
  1140.         NewSize = 3;
  1141.  
  1142.         vr.resize(NewSize); //M_resize(vr, NewSize); //not necessary, but good to keep in mind the internal functionality
  1143.  
  1144.         std::cout << std::dec << "resize " << LastSize << " to " << NewSize << " and Listing items:" << std::endl;
  1145.  
  1146.         for (size_t i = 0; i < vr.size(); i++)
  1147.         {
  1148.             std::cout << std::hex << "\t" << "var[" << std::dec << (DWORD)i << "]: 0x" << std::hex << vr[i] << std::endl;
  1149.         }
  1150.  
  1151.         //std::cin.get();
  1152.  
  1153.         // ------------------------------------------------------------------------------- //
  1154.         std::cout << std::endl << "pop_back x3 and Listing items:"; // << std::endl;
  1155.         std::cin.get();
  1156.         vr.pop_back();
  1157.         vr.pop_back();
  1158.         vr.pop_back();
  1159.  
  1160.         if (vr.size())
  1161.         {
  1162.             for (size_t i = 0; i < vr.size(); i++)
  1163.             {
  1164.                 std::cout << std::hex << "\t" << "var[" << std::dec << (DWORD)i << "]: 0x" << std::hex << vr[i] << std::endl;
  1165.             }
  1166.         }
  1167.         else
  1168.         {
  1169.             std::cout << "NO ITEMS" << std::endl;
  1170.         }
  1171.         LastSize = vr.size();
  1172.  
  1173.         // ------------------------------------------------------------------------------- //
  1174.         // ------------------------------------------------------------------------------- //
  1175.         ValToPush = 0x12345678;
  1176.         std::cout << std::endl << "Pushing 0x" << std::hex << ValToPush << " and Listing items:"; // << std::endl;
  1177.         std::cin.get();
  1178.  
  1179.         /*__asm
  1180.         {
  1181.             int 3
  1182.             nop
  1183.             int 3
  1184.         }*/
  1185.  
  1186.         vr.push_back(ValToPush);
  1187.  
  1188.         /*__asm
  1189.         {
  1190.             int 3
  1191.             nop
  1192.             int 3
  1193.         }*/
  1194.  
  1195.         for (size_t i = 0; i < vr.size(); i++)
  1196.         {
  1197.             std::cout << std::hex << "\t" << "var[" << std::dec << (DWORD)i << "]: 0x" << std::hex << vr[i] << std::endl;
  1198.         }
  1199.         LastSize = vr.size();
  1200.  
  1201.         // ------------------------------------------------------------------------------- //
  1202.         std::cout << std::endl << "Gonna VirtualFree" << std::endl;
  1203.         std::cin.get();
  1204.  
  1205.         VirtualFree(AddressAlloc, 0, MEM_RELEASE);
  1206.  
  1207.         std::cout << "Freed" << std::endl;
  1208.     }
  1209.  
  1210.     Restore_Move_Eax_Jmp_Eax(Address_Push_Back, (DWORD)&Bk_Push_Back[0], sizeof(Bk_Push_Back));
  1211.     Restore_Move_Eax_Jmp_Eax(Address_Resize_AboveOrEqual, (DWORD)&Bk_Resize_AboveOrEqual[0], sizeof(Bk_Resize_AboveOrEqual));
  1212.  
  1213.     std::cout << std::endl << "Normal vector push_back..." << std::endl;
  1214.     std::cin.get();
  1215.  
  1216.     std::vector<int> asd;
  1217.  
  1218.     asd.push_back(0x123);
  1219.  
  1220.     for (size_t i = 0; i < asd.size(); i++)
  1221.     {
  1222.         std::cout << std::dec << "asd[" << (DWORD)i << "]: 0x" << std::hex << asd[i] << std::endl;
  1223.     }
  1224.  
  1225.     std::cout << std::endl << "Normal vector resize Above or Equal..." << std::endl;
  1226.     std::cin.get();
  1227.  
  1228.     asd.resize(3);
  1229.  
  1230.     asd[1] = 0x456;
  1231.     asd[2] = 0x789;
  1232.  
  1233.     for (size_t i = 0; i < asd.size(); i++)
  1234.     {
  1235.         std::cout << std::dec << "asd[" << (DWORD)i << "]: 0x" << std::hex << asd[i] << std::endl;
  1236.     }
  1237.  
  1238.     std::cout << std::endl << "Normal vector resize less..." << std::endl;
  1239.     std::cin.get();
  1240.  
  1241.     asd.resize(1);
  1242.  
  1243.     for (size_t i = 0; i < asd.size(); i++)
  1244.     {
  1245.         std::cout << std::dec << "asd[" << (DWORD)i << "]: 0x" << std::hex << asd[i] << std::endl;
  1246.     }
  1247. }
  1248.  
  1249. void TestMemory2VectorStruct_debugging()
  1250. {
  1251.     std::vector<tHook>* v = new std::vector<tHook>;
  1252.  
  1253.     std::cin.get();
  1254.  
  1255.     __asm
  1256.     {
  1257.         int 3
  1258.         nop
  1259.         int 3
  1260.         lea eax, v
  1261.     }
  1262.  
  1263.     tHook tmp;
  1264.  
  1265.     tmp.Base = 0x12345678;
  1266.     tmp.Offset = 0x1234;
  1267.     FillMemory(tmp.DllPath, sizeof(tmp.DllPath), 0x45);
  1268.     tmp.DllPath[sizeof(tmp.DllPath) - 1] = '\0';
  1269.     tmp.Activated = true;
  1270.     //strncpy(a, "iqbal", sizeof(a) - 1);
  1271.     tmp.HookedAddress = tmp.Base + tmp.Offset + 3;
  1272.     tmp.Count = 0x1234567887654321;
  1273.  
  1274.     v->push_back(tmp);
  1275.  
  1276.     __asm
  1277.     {
  1278.         int 3
  1279.         nop
  1280.         int 3
  1281.     }
  1282. }
  1283.  
  1284. void TestMemory2VectorStruct()
  1285. {
  1286.     tHook tmp;
  1287.  
  1288.     tmp.Base = 0x22222222;
  1289.     tmp.Offset = 0x333;
  1290.     FillMemory(tmp.DllPath, sizeof(tmp.DllPath), 0x46);
  1291.     tmp.DllPath[sizeof(tmp.DllPath) - 1] = '\0';
  1292.     tmp.Activated = false;
  1293.     //strncpy(a, "iqbal", sizeof(a) - 1);
  1294.     tmp.HookedAddress = tmp.Base + tmp.Offset + 3;
  1295.     tmp.Count = 0x1234000000004321;
  1296.  
  1297.     if (InitAllocation())
  1298.     {
  1299.         HookVector_push_back_struct();
  1300.         HookVector_resize_AboveOrEqual_struct();
  1301.  
  1302.         //std::vector<int>* v = (std::vector<int>*)(*(DWORD*)(AddressAlloc));
  1303.  
  1304.         //std::cout << "v->push_back(666);" << std::endl;
  1305.         //std::cin.get();
  1306.  
  1307.         //std::cout << std::dec << v->size() << std::endl;
  1308.         //std::vector<int>& vr = *v;
  1309.         std::vector<tHook>& vr = *(std::vector<tHook>*)(*(DWORD*)(AddressAlloc));
  1310.         DWORD NewSize = 0;
  1311.         DWORD LastSize = vr.size();
  1312.  
  1313.         // ------------------------------------------------------------------------------- //
  1314.         std::cout << std::endl << "Listing items:"; // << std::endl;
  1315.         std::cin.get();
  1316.  
  1317.         for (size_t i = 0; i < vr.size(); i++)
  1318.         {
  1319.             std::cout << std::hex << "\t" << "var[" << std::dec << (DWORD)i << "]:" << std::endl;
  1320.             std::cout << "\t\t" << "Base: " << std::hex << vr[i].Base << std::endl;
  1321.             std::cout << "\t\t" << "Offset: " << std::hex << vr[i].Offset << std::endl;
  1322.             std::cout << "\t\t" << "DllPath: " << vr[i].DllPath << std::endl;
  1323.             std::cout << "\t\t" << "Activated: " << (vr[i].Activated ? "YES" : "NO") << std::endl;
  1324.             std::cout << "\t\t" << "HookedAddress: " << std::hex << vr[i].HookedAddress << std::endl;
  1325.             std::cout << "\t\t" << "Count: " << std::hex << vr[i].Count << std::endl;
  1326.         }
  1327.         std::cout << std::endl;
  1328.  
  1329.         // ------------------------------------------------------------------------------- //
  1330.         std::cout << std::endl << "Pushing struct and Listing items:"; // << std::endl;
  1331.         std::cin.get();
  1332.  
  1333.         vr.push_back(tmp);
  1334.  
  1335.         for (size_t i = 0; i < vr.size(); i++)
  1336.         {
  1337.             std::cout << std::hex << "\t" << "var[" << std::dec << (DWORD)i << "]:" << std::endl;
  1338.             std::cout << "\t\t" << "Base: " << std::hex << vr[i].Base << std::endl;
  1339.             std::cout << "\t\t" << "Offset: " << std::hex << vr[i].Offset << std::endl;
  1340.             std::cout << "\t\t" << "DllPath: " << vr[i].DllPath << std::endl;
  1341.             std::cout << "\t\t" << "Activated: " << (vr[i].Activated ? "YES" : "NO") << std::endl;
  1342.             std::cout << "\t\t" << "HookedAddress: " << std::hex << vr[i].HookedAddress << std::endl;
  1343.             std::cout << "\t\t" << "Count: " << std::hex << vr[i].Count << std::endl;
  1344.         }
  1345.         std::cout << std::endl;
  1346.         LastSize = vr.size();
  1347.  
  1348.         // ------------------------------------------------------------------------------- //
  1349.         tmp.Base = 0x11111111;
  1350.         tmp.Offset = 0x666;
  1351.         FillMemory(tmp.DllPath, sizeof(tmp.DllPath), 0x47);
  1352.         tmp.DllPath[sizeof(tmp.DllPath) - 1] = '\0';
  1353.         tmp.Activated = false;
  1354.         //strncpy(a, "iqbal", sizeof(a) - 1);
  1355.         tmp.HookedAddress = tmp.Base + tmp.Offset + 3;
  1356.         tmp.Count = 0x1234999999994321;
  1357.  
  1358.         std::cout << std::endl << "Modify index 0 and Listing items:"; // << std::endl;
  1359.         std::cin.get();
  1360.  
  1361.         vr[0] = tmp;
  1362.  
  1363.         for (size_t i = 0; i < vr.size(); i++)
  1364.         {
  1365.             std::cout << std::hex << "\t" << "var[" << std::dec << (DWORD)i << "]:" << std::endl;
  1366.             std::cout << "\t\t" << "Base: " << std::hex << vr[i].Base << std::endl;
  1367.             std::cout << "\t\t" << "Offset: " << std::hex << vr[i].Offset << std::endl;
  1368.             std::cout << "\t\t" << "DllPath: " << vr[i].DllPath << std::endl;
  1369.             std::cout << "\t\t" << "Activated: " << (vr[i].Activated ? "YES" : "NO") << std::endl;
  1370.             std::cout << "\t\t" << "HookedAddress: " << std::hex << vr[i].HookedAddress << std::endl;
  1371.             std::cout << "\t\t" << "Count: " << std::hex << vr[i].Count << std::endl;
  1372.         }
  1373.         std::cout << std::endl;
  1374.  
  1375.         // ------------------------------------------------------------------------------- //
  1376.         std::cout << std::endl << "B4 resizing Above or Equal"; // << std::endl;
  1377.         std::cin.get();
  1378.         /*__asm
  1379.         {
  1380.             int 3
  1381.             nop
  1382.             int 3
  1383.         }*/
  1384.  
  1385.         NewSize = 7;
  1386.  
  1387.         vr.resize(NewSize); //don't need M_resize(vr, NewSize); because it is Above or Equal, but it's good to call it to avoid shits
  1388.  
  1389.         std::cout << std::dec << "resize " << LastSize << " to " << NewSize << " and Listing items:" << std::endl;
  1390.  
  1391.         for (size_t i = 0; i < vr.size(); i++)
  1392.         {
  1393.             std::cout << std::hex << "\t" << "var[" << std::dec << (DWORD)i << "]:" << std::endl;
  1394.             std::cout << "\t\t" << "Base: " << std::hex << vr[i].Base << std::endl;
  1395.             std::cout << "\t\t" << "Offset: " << std::hex << vr[i].Offset << std::endl;
  1396.             std::cout << "\t\t" << "DllPath: " << vr[i].DllPath << std::endl;
  1397.             std::cout << "\t\t" << "Activated: " << (vr[i].Activated ? "YES" : "NO") << std::endl;
  1398.             std::cout << "\t\t" << "HookedAddress: " << std::hex << vr[i].HookedAddress << std::endl;
  1399.             std::cout << "\t\t" << "Count: " << std::hex << vr[i].Count << std::endl;
  1400.         }
  1401.         std::cout << std::endl;
  1402.  
  1403.         //std::cin.get();
  1404.  
  1405.         // ------------------------------------------------------------------------------- //
  1406.         std::cout << std::endl << "sort ascending and Listing items:"; // << std::endl;
  1407.         std::cin.get();
  1408.  
  1409.         //std::sort(vr.begin(), vr.end(), compareByHookedAddress);
  1410.         std::sort(vr.begin(), vr.end());
  1411.  
  1412.         for (size_t i = 0; i < vr.size(); i++)
  1413.         {
  1414.             std::cout << std::hex << "\t" << "var[" << std::dec << (DWORD)i << "]:" << std::endl;
  1415.             std::cout << "\t\t" << "Base: " << std::hex << vr[i].Base << std::endl;
  1416.             std::cout << "\t\t" << "Offset: " << std::hex << vr[i].Offset << std::endl;
  1417.             std::cout << "\t\t" << "DllPath: " << vr[i].DllPath << std::endl;
  1418.             std::cout << "\t\t" << "Activated: " << (vr[i].Activated ? "YES" : "NO") << std::endl;
  1419.             std::cout << "\t\t" << "HookedAddress: " << std::hex << vr[i].HookedAddress << std::endl;
  1420.             std::cout << "\t\t" << "Count: " << std::hex << vr[i].Count << std::endl;
  1421.         }
  1422.         std::cout << std::endl;
  1423.  
  1424.         // ------------------------------------------------------------------------------- //
  1425.         std::cout << std::endl << "sort descending and Listing items:"; // << std::endl;
  1426.         std::cin.get();
  1427.  
  1428.         std::sort(vr.begin(), vr.end(), std::greater<tHook>());
  1429.  
  1430.         for (size_t i = 0; i < vr.size(); i++)
  1431.         {
  1432.             std::cout << std::hex << "\t" << "var[" << std::dec << (DWORD)i << "]:" << std::endl;
  1433.             std::cout << "\t\t" << "Base: " << std::hex << vr[i].Base << std::endl;
  1434.             std::cout << "\t\t" << "Offset: " << std::hex << vr[i].Offset << std::endl;
  1435.             std::cout << "\t\t" << "DllPath: " << vr[i].DllPath << std::endl;
  1436.             std::cout << "\t\t" << "Activated: " << (vr[i].Activated ? "YES" : "NO") << std::endl;
  1437.             std::cout << "\t\t" << "HookedAddress: " << std::hex << vr[i].HookedAddress << std::endl;
  1438.             std::cout << "\t\t" << "Count: " << std::hex << vr[i].Count << std::endl;
  1439.         }
  1440.         std::cout << std::endl;
  1441.  
  1442.         // ------------------------------------------------------------------------------- //
  1443.         std::cout << std::endl << "vr.empty(): " << (vr.empty() ? "YES" : "NO"); // << std::endl;
  1444.         std::cin.get();
  1445.  
  1446.         // ------------------------------------------------------------------------------- //
  1447.         std::cout << std::endl << "vr.shrink_to_fit()"; // << std::endl;
  1448.         std::cin.get();
  1449.  
  1450.         vr.shrink_to_fit();
  1451.  
  1452.         // ------------------------------------------------------------------------------- //
  1453.         std::cout << std::endl << "clear and Listing items:"; // << std::endl;
  1454.         std::cin.get();
  1455.  
  1456.         vr.clear();
  1457.  
  1458.         if (vr.size())
  1459.         {
  1460.             for (size_t i = 0; i < vr.size(); i++)
  1461.             {
  1462.                 std::cout << std::hex << "\t" << "var[" << std::dec << (DWORD)i << "]:" << std::endl;
  1463.                 std::cout << "\t\t" << "Base: " << std::hex << vr[i].Base << std::endl;
  1464.                 std::cout << "\t\t" << "Offset: " << std::hex << vr[i].Offset << std::endl;
  1465.                 std::cout << "\t\t" << "DllPath: " << vr[i].DllPath << std::endl;
  1466.                 std::cout << "\t\t" << "Activated: " << (vr[i].Activated ? "YES" : "NO") << std::endl;
  1467.                 std::cout << "\t\t" << "HookedAddress: " << std::hex << vr[i].HookedAddress << std::endl;
  1468.                 std::cout << "\t\t" << "Count: " << std::hex << vr[i].Count << std::endl;
  1469.             }
  1470.         }
  1471.         else
  1472.         {
  1473.             std::cout << "NO ITEMS" << std::endl;
  1474.         }
  1475.         LastSize = vr.size();
  1476.  
  1477.         // ------------------------------------------------------------------------------- //
  1478.         std::cout << std::endl << "vr.empty(): " << (vr.empty() ? "YES" : "NO"); // << std::endl;
  1479.         std::cin.get();
  1480.  
  1481.         // ------------------------------------------------------------------------------- //
  1482.         std::cout << std::endl << "Pushing for and Listing items:"; // << std::endl;
  1483.         std::cin.get();
  1484.  
  1485.         for (size_t i = 0; i < 12; i++)
  1486.         {
  1487.             vr.push_back(GenRandomStruct());
  1488.         }
  1489.  
  1490.         for (size_t i = 0; i < vr.size(); i++)
  1491.         {
  1492.             std::cout << std::hex << "\t" << "var[" << std::dec << (DWORD)i << "]:" << std::endl;
  1493.             std::cout << "\t\t" << "Base: " << std::hex << vr[i].Base << std::endl;
  1494.             std::cout << "\t\t" << "Offset: " << std::hex << vr[i].Offset << std::endl;
  1495.             std::cout << "\t\t" << "DllPath: " << vr[i].DllPath << std::endl;
  1496.             std::cout << "\t\t" << "Activated: " << (vr[i].Activated ? "YES" : "NO") << std::endl;
  1497.             std::cout << "\t\t" << "HookedAddress: " << std::hex << vr[i].HookedAddress << std::endl;
  1498.             std::cout << "\t\t" << "Count: " << std::hex << vr[i].Count << std::endl;
  1499.         }
  1500.         std::cout << std::endl;
  1501.         LastSize = vr.size();
  1502.  
  1503.         // ------------------------------------------------------------------------------- //
  1504.         std::cout << std::endl << "B4 resizing below or check"; // << std::endl;
  1505.         std::cin.get();
  1506.         /*__asm
  1507.         {
  1508.             int 3
  1509.             nop
  1510.             int 3
  1511.         }*/
  1512.  
  1513.         NewSize = 3;
  1514.  
  1515.         vr.resize(NewSize); //M_resize(vr, NewSize); //not necessary, but good to keep in mind the internal functionality
  1516.  
  1517.         std::cout << std::dec << "resize " << LastSize << " to " << NewSize << " and Listing items:" << std::endl;
  1518.  
  1519.         for (size_t i = 0; i < vr.size(); i++)
  1520.         {
  1521.             std::cout << std::hex << "\t" << "var[" << std::dec << (DWORD)i << "]:" << std::endl;
  1522.             std::cout << "\t\t" << "Base: " << std::hex << vr[i].Base << std::endl;
  1523.             std::cout << "\t\t" << "Offset: " << std::hex << vr[i].Offset << std::endl;
  1524.             std::cout << "\t\t" << "DllPath: " << vr[i].DllPath << std::endl;
  1525.             std::cout << "\t\t" << "Activated: " << (vr[i].Activated ? "YES" : "NO") << std::endl;
  1526.             std::cout << "\t\t" << "HookedAddress: " << std::hex << vr[i].HookedAddress << std::endl;
  1527.             std::cout << "\t\t" << "Count: " << std::hex << vr[i].Count << std::endl;
  1528.         }
  1529.         std::cout << std::endl;
  1530.  
  1531.         //std::cin.get();
  1532.  
  1533.         // ------------------------------------------------------------------------------- //
  1534.         std::cout << std::endl << "pop_back x3 and Listing items:"; // << std::endl;
  1535.         std::cin.get();
  1536.         vr.pop_back();
  1537.         vr.pop_back();
  1538.         vr.pop_back();
  1539.  
  1540.         if (vr.size())
  1541.         {
  1542.             for (size_t i = 0; i < vr.size(); i++)
  1543.             {
  1544.                 std::cout << std::hex << "\t" << "var[" << std::dec << (DWORD)i << "]:" << std::endl;
  1545.                 std::cout << "\t\t" << "Base: " << std::hex << vr[i].Base << std::endl;
  1546.                 std::cout << "\t\t" << "Offset: " << std::hex << vr[i].Offset << std::endl;
  1547.                 std::cout << "\t\t" << "DllPath: " << vr[i].DllPath << std::endl;
  1548.                 std::cout << "\t\t" << "Activated: " << (vr[i].Activated ? "YES" : "NO") << std::endl;
  1549.                 std::cout << "\t\t" << "HookedAddress: " << std::hex << vr[i].HookedAddress << std::endl;
  1550.                 std::cout << "\t\t" << "Count: " << std::hex << vr[i].Count << std::endl;
  1551.             }
  1552.             std::cout << std::endl;
  1553.         }
  1554.         else
  1555.         {
  1556.             std::cout << "NO ITEMS" << std::endl;
  1557.         }
  1558.         LastSize = vr.size();
  1559.  
  1560.         // ------------------------------------------------------------------------------- //
  1561.         // ------------------------------------------------------------------------------- //
  1562.         std::cout << std::endl << "Pushing and Listing items:"; // << std::endl;
  1563.         std::cin.get();
  1564.  
  1565.         /*__asm
  1566.         {
  1567.             int 3
  1568.             nop
  1569.             int 3
  1570.         }*/
  1571.  
  1572.         vr.push_back(GenRandomStruct());
  1573.  
  1574.         /*__asm
  1575.         {
  1576.             int 3
  1577.             nop
  1578.             int 3
  1579.         }*/
  1580.  
  1581.         for (size_t i = 0; i < vr.size(); i++)
  1582.         {
  1583.             std::cout << std::hex << "\t" << "var[" << std::dec << (DWORD)i << "]:" << std::endl;
  1584.             std::cout << "\t\t" << "Base: " << std::hex << vr[i].Base << std::endl;
  1585.             std::cout << "\t\t" << "Offset: " << std::hex << vr[i].Offset << std::endl;
  1586.             std::cout << "\t\t" << "DllPath: " << vr[i].DllPath << std::endl;
  1587.             std::cout << "\t\t" << "Activated: " << (vr[i].Activated ? "YES" : "NO") << std::endl;
  1588.             std::cout << "\t\t" << "HookedAddress: " << std::hex << vr[i].HookedAddress << std::endl;
  1589.             std::cout << "\t\t" << "Count: " << std::hex << vr[i].Count << std::endl;
  1590.         }
  1591.         std::cout << std::endl;
  1592.         LastSize = vr.size();
  1593.  
  1594.         // ------------------------------------------------------------------------------- //
  1595.         std::cout << std::endl << "Gonna VirtualFree" << std::endl;
  1596.         std::cin.get();
  1597.  
  1598.         VirtualFree(AddressAlloc, 0, MEM_RELEASE);
  1599.  
  1600.         std::cout << "Freed" << std::endl;
  1601.     }
  1602.  
  1603.     Restore_Move_Eax_Jmp_Eax(Address_Push_Back, (DWORD)&Bk_Push_Back[0], sizeof(Bk_Push_Back));
  1604.     Restore_Move_Eax_Jmp_Eax(Address_Resize_AboveOrEqual, (DWORD)&Bk_Resize_AboveOrEqual[0], sizeof(Bk_Resize_AboveOrEqual));
  1605.  
  1606.     std::cout << std::endl << "Normal vector push_back..." << std::endl;
  1607.     std::cin.get();
  1608.  
  1609.     std::vector<int> asd;
  1610.  
  1611.     asd.push_back(0x123);
  1612.  
  1613.     for (size_t i = 0; i < asd.size(); i++)
  1614.     {
  1615.         std::cout << std::dec << "asd[" << (DWORD)i << "]: 0x" << std::hex << asd[i] << std::endl;
  1616.     }
  1617.  
  1618.     std::cout << std::endl << "Normal vector resize Above or Equal..." << std::endl;
  1619.     std::cin.get();
  1620.  
  1621.     asd.resize(3);
  1622.  
  1623.     asd[1] = 0x456;
  1624.     asd[2] = 0x789;
  1625.  
  1626.     for (size_t i = 0; i < asd.size(); i++)
  1627.     {
  1628.         std::cout << std::dec << "asd[" << (DWORD)i << "]: 0x" << std::hex << asd[i] << std::endl;
  1629.     }
  1630.  
  1631.     std::cout << std::endl << "Normal vector resize less..." << std::endl;
  1632.     std::cin.get();
  1633.  
  1634.     asd.resize(1);
  1635.  
  1636.     for (size_t i = 0; i < asd.size(); i++)
  1637.     {
  1638.         std::cout << std::dec << "asd[" << (DWORD)i << "]: 0x" << std::hex << asd[i] << std::endl;
  1639.     }
  1640. }
  1641.  
  1642. int main()
  1643. {
  1644.     CurrentType = eTaipu::eStruct;
  1645.     //std::cout << sizeof(tHook) << std::endl;
  1646.  
  1647.     switch (CurrentType)
  1648.     {
  1649.         case eTaipu::eInt:
  1650.             TestMemory2Vector();
  1651.  
  1652.             break;
  1653.         case eTaipu::eStruct:
  1654.             //TestMemory2VectorStruct_debugging();
  1655.             TestMemory2VectorStruct();
  1656.  
  1657.             break;
  1658.     }
  1659.  
  1660.     std::cout << std::endl << "Press enter to exit the program..." << std::endl;
  1661.     std::cin.get();
  1662.  
  1663.     return 0;
  1664. }
RAW Paste Data