[{"content":"Abstract Game developers use gcinfo to detect memory (GC) spikes. You can bypass by using hookfunction, but make sure to return a sensible and dynamic value to avoid more advanced detection. However, the root cause can be functions like getgc which create a copy of the entire GC, almost doubling it. To avoid that, use filtergc which only pick out the specific values you want. Excessive use of instances like Frames/TextBoxes can also cause spikes.\nIntroduction Thanks to Roblox\u0026rsquo;s sandbox, the only tool game developers have to check memory is gcinfo, returning the \u0026ldquo;total memory heap size in kilobytes\u0026rdquo;. Under usual loads, gcinfo is relatively stable within a range. However, when a script is executed, it could suddenly spike, casuing you to get \u0026ldquo;detected\u0026rdquo;. Game developers can benchmark the usual range and then flag anything outside of that.\nExample Code local function Detected() while true do end end local function Range(Values) local Min = math.huge local Max = 0 for Value in ipairs(Values) do if Value \u0026gt; Max then Max = Value elseif Value \u0026lt; Min then Mix = Value end end return Max, Min end local PreviousValues = {} RunService.RenderStepped:Connect(function() local Memory = gcinfo() if Memory \u0026gt; 600 or Memory \u0026lt; 300 then Detected() end table.insert(PreviousValues, Memory) if #PreviousValues \u0026gt; 5 then table.remove(PreviousValues, 1) end local Min, Max = Range(PreviousValues) local Range = Max - Min if Range == 0 or Range \u0026lt; 5 or Range \u0026gt; 100 then Detected() end end) Understanding the example code To start, it\u0026rsquo;s important to realise that the code is just an example (and untested). It can easily be disabled through various methods, however, that isn\u0026rsquo;t the focus. The magic numbers chosen are random, and aren\u0026rsquo;t real values. Anyway, the code is able to detect spikes or troughs in memory usage. It can also detect lazy hooks that don\u0026rsquo;t properly simulate realistic memory usage.\nInitial approach local old old = hookfunction(getrenv().gcinfo, function() return 0 end) This approach will get detected, due to the trough check. Note the usage of getrenv. This ensures we hook the game\u0026rsquo;s version of gcinfo, and not our own (if the executor properly implements getrenv aka get roblox environment). However, we can improve the hook by making it return a random value between the range that the game wants:\nlocal old old = hookfunction(getrenv().gcinfo, function() return math.random(300, 600) end) Why do spikes occur? However, I think it would be better if we address the actual problem at hand: the memory spikes. Majority of scripts should not spike so drastically. It could happen due to making many instances at once, like with Dex explorer. However, more commonly, iterating through getgc. Lets look at an example of how getgc is implemented within executors. Do not worry if you do not understand.\nint RbxApi::getgc(DWORD rL) { const syn::RbxLua RL(rL); auto IncludeTables = false; if (RL.IsBoolean(1)) IncludeTables = RL.ToBoolean(1); const auto GlobalState = (DWORD) syn::PointerObfuscation::DeObfuscateGlobalState(RL + L_GS); const auto DeadMask = *(BYTE*)(GlobalState + G_WMASK) ^ 3; auto Object = *(GCObject**)(GlobalState + G_ROOTGC); RL.NewTable(); auto n = 1; while (Object != nullptr) { const auto TT = *(BYTE*)((DWORD) Object + GCO_TT); /* Make sure the object is not dead and is a \u0026#39;safe\u0026#39; type (without including tables) */ if ((TT == R_LUA_TFUNCTION || (IncludeTables ? TT == R_LUA_TTABLE : TT == R_LUA_TFUNCTION) || (IncludeTables ? TT == R_LUA_TUSERDATA : TT == R_LUA_TFUNCTION)) \u0026amp;\u0026amp; (*(BYTE*)((DWORD) Object + GCO_MARKED) ^ 3) \u0026amp; DeadMask) { RL.PushInteger(n++); RL.PushRawObject((DWORD) Object, TT); RL.SetTable(-3); } Object = Object-\u0026gt;gch.next; } return 1; } The main takeaways are that it creates a new lua table, then adds each element inside of the gc (garbage collector) into that new table, essentially making a copy of the garbage collector. The GC contains all tables, functions and userdata currently in use by the game. Therefore, understandably, adding everything into a new table would cause a spike in memory. Note that it being a lua table is important. Since it\u0026rsquo;s a lua table, it\u0026rsquo;s now also in the GC, resulting a spike in what gcinfo returns.\nThe better approach However, how do you avoid using getgc? Introduced by Synapse V3, and being introduced into sUNC, a new function called filtergc is being implemented into many executors. While seeming lame at first, it can be very powerful and more efficient. Instead of adding every element inside of the GC, it only adds the specific ones you want, therefore no memory spike! Note that some executors implement a lua version which uses getgc, and while it does the same thing in the end, it does not have these performance benefits and is detected.\n","date":"2025-03-24T00:00:00Z","permalink":"https://stefanuk12.github.io/blog/post/roblox_exploiting_staying_undetected_1/","title":"Staying Undetected: Memory Checks"},{"content":"Embarking on the journey of learning how to program can be a bit overwhelming at first. You might have already done some research and compiled a list of languages that pique your interest. For instance, you could delve into classic C languages like C++, C#, or regular C. Alternatively, you might explore more abstract (higher level) languages like Python and Lua. The choice is yours, and each path holds its own potential for growth and learning.\nWhy is programming so hard? It\u0026rsquo;s a common question: why aren\u0026rsquo;t programming languages more user-friendly, like Python? When programming languages first emerged, they were already a significant step up from writing pure binary, ones and zeros. Assembly language even introduced mnemonics to aid memorisation. However, Assembly was still quite complex, so we developed C. Yet, even C had its complexities, so we continued to abstract them away. The truth is, no matter how much we simplify, there will always be a learning curve that is universally challenging, and you are not alone in this journey.\nAbstraction also comes at a cost. It makes understanding what your code is doing under the hood difficult. Abstraction may hinder your programming progress and make it harder to transition to other languages.\nProgramming is different from how it is in films. It is more complex than it seems. For people entering the industry, it is something completely new that they have never seen before. If this is your first time looking into coding, it\u0026rsquo;s complicated and overwhelming, and that\u0026rsquo;s okay. It\u0026rsquo;s a journey that requires patience and perseverance, but it\u0026rsquo;s a journey that is worth taking.\nHow you should start out Mastering fundamental concepts is key. Once you do, you can learn any language you wish. If you understand these concepts, the only things you need to learn are the syntax, which should take little time, and the best practices, which can take a while to develop. Many of the skills you learn with one language can transfer to others, so it\u0026rsquo;s best to be the master of one first rather than the jack of all trades but the master of none. There are far too many concepts to list, and you shouldn\u0026rsquo;t learn each one by one. That is not how you learn to program.\nLearning to program is all about experience and trying things out. Set a simple goal like creating a terminal calculator app. Attempt to create it. If you ever get stuck, follow these three to four steps:\nGoogle your exact issue Look at the documentation (if applicable) Ask AI about your issue Ask someone else about your issue Learning how to read documentation and Google is a vital skill that many beginners overlook. If you can Google and read documentation, you can find the answers to your questions much faster. Many people Google what they\u0026rsquo;re trying to do. For example, they would Google \u0026ldquo;how to make \u0026hellip;\u0026rdquo; This is wrong. It would help if you were more specific. Let\u0026rsquo;s make a hypothetical scenario. You can get the user input but are not sure how to make the user input a number. In this case, you should Google \u0026ldquo;convert string to number\u0026rdquo;, followed by your programming language. Following the query with your programming language is essential as you will get answers for other languages that won\u0026rsquo;t apply to you. As you learn, you will learn more terminology and, therefore, be able to express your question better. A more experienced programmer would Google \u0026ldquo;cast string to number [language]\u0026rdquo;.\nReading documentation can be hard to learn as it\u0026rsquo;s filled with technical jargon, but over time, you will learn to love the technical jargon because it usually tells you exactly how you should do certain things.\nTo sum up, learning comes down to experience. To get as much experience as possible, try to make as many projects as possible—progress by increasing the difficulty of your projects. I recommend focusing on that one language alone while learning it.\nThe use of AI in learning Do not use AI entirely. It can do the majority of your projects with ease. Misusing it can spoil the full answer rather than the part you are stuck on, meaning you learn nothing. However, keen readers might\u0026rsquo;ve pointed out that I recommend talking AI over to another human about any issues you have. You can use AI, but you must be specific—precisely the same way I showed you how to Google.\nThe use of tutorials Applying what I said previously, tutorials could be worse for you. Experience is what matters. Refrain from falling into the trap of watching 10 hours of how to program in a specific language because you will not learn anything. You should only refer to these tutorials if you are stuck on a specific concept. However, Googling, reading documentation, etc., should have solved these issues. As a more advanced programmer, I never watch tutorials because they provide little value - even when learning something completely new. Often, reading someone else\u0026rsquo;s code is more beneficial.\nCommon misconception A common misconception beginners have is that they need to memorise every function. This is not true. Provided your Googling skills are good enough, you should be able to find examples of what you\u0026rsquo;re trying to do. For example, if you want to get the first three characters in a string, the function you may want to use is substring. However, you would not be expected to know that. After Googling \u0026ldquo;get first three characters Python\u0026rdquo;, you should be able to find your answer relatively quickly. Also, IDEs have autocomplete and intellisense that can tell you all the possible functions that object has. Programming is so vast that you never need to memorise anything except the fundamental concepts, syntax, and best practices - as stated earlier. Not memorising is unlike what you might expect when considering other academic subjects.\nFormat your code A common beginner mistake is not formatting the code correctly and adding things like comments. Please learn the skill of formatting and commenting early. It will provide a lot less headache for yourself and others when reviewing the code at a future date.\nConclusion Learning how to program takes work. There are so many different areas to explore, which can seem overwhelming. However, with the correct mindset, dedication, and technique, you can achieve anything. Good luck!\n","date":"2024-05-18T00:00:00Z","permalink":"https://stefanuk12.github.io/blog/post/learning_your_first_programming_language/","title":"Learning Your First Programming Language"}]