Categories > Coding > C++ >
[REL] CLIPBOARD FUNCTIONS!
Posted
These are custom clipboard functions which can be registered into the Lua environment and BLAHHHHHHHHHHHHHHHHHH...
2 years axon working so work for ur skidhax so...
int setclipboard()
{
const char* clipme = lua_tostring(rl, -1);
if (!OpenClipboard(nullptr))
return 1;
EmptyClipboard();
HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, 100);
memcpy(GlobalLock(hMem), clipme , 13);
GlobalUnlock(hMem);
SetClipboardData(CF_TEXT, hMem);
CloseClipboard();
clipme = "";
return 0;
}
tostring will get the first argument of the function which is a string and can be used like *AXON*:
local function = "my dad used to kiss me"
setclipboard(function)
wait(1)
setclipboard("why is there monkey sauce in my asian friends house?")
--or you can do something like this
HOPE THIS HELPS.
Cancel
Post
hecker dude ngl i hecked 5 ips in 1 second also luaU_loadbiglongjuicythingy(rL);
Replied
so there are things you can do better
- Use smart pointers instead of raw pointers to avoid memory leaks thats pain in the ass
- Use a constant or a variable for the string length instead of a hardcoded value.
- Check the return values of the Win32 API functions to handle errors properly
- and use this code
- int setclipboard(const char* str) { if (!OpenClipboard(nullptr)) return 1; EmptyClipboard(); const size_t len = strlen(str) + 1; HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, len); if (!hMem) { CloseClipboard(); return 1; } char* clipme = static_cast<char*>(GlobalLock(hMem)); if (!clipme) { GlobalFree(hMem); CloseClipboard(); return 1; } memcpy(clipme, str, len); GlobalUnlock(hMem); if (!SetClipboardData(CF_TEXT, hMem)) { GlobalFree(hMem); CloseClipboard(); return 1; } CloseClipboard(); return 0; }
Cancel
Post
Added
@atariXD,
- try to Use consistent variable naming conventions as an example start variable names with a lowercase letter should be better
- Check the return value of
setclipboardx
to handle errors properly - Use the
type
function to check the type of the variable not the type of an literal string
Cancel
Post
Replied
@Cr4Zed, Atari was referring to something completely different.
In the lua script that was provided by the author of the thread he used a keyword as a variable name which would error.
local function = "my dad used to kiss me" --// This is where the error would occur, since "functon" is a keyword and cannot be used as a variable name.
local Function = "kfjlds" --// Simple fix.
setclipboard(Function)
wait(1)
setclipboard("why is there monkey sauce in my asian friends house?")
--or you can do something like this
Cancel
Post
Replied
My bad. Thanks for helping.
Cancel
Post
hecker dude ngl i hecked 5 ips in 1 second also luaU_loadbiglongjuicythingy(rL);
Replied
@_realnickk, there's no chance of buffer overflow here lmao.
Comments
luxiferrwoo -5 Reputation
Commented
No buffer overflow would occur here because there is no data to be written to the buffer that exceeds its capacity.
The length of the data we have is 13 bytes, the buffer size is 100 bytes, so there will be an extra 87 bytes which will not be written to under any circumstance in that code, so there is no buffer overflow, nor is there any reason to mention it. You are correct in making the buffer size and the string length the same, but talking about overflows in this case is unnecessary at best.
Cancel
Post
Added
@Cr4Zed, constant variable for string length isn't necessary here at all, only when it may not be immediately obvious what the literal represents and if the same literal is used in the same context repeatedly.
use std::string_view instead for the parameter.
certain win32api functions don't return the actual error, they only indicate that an error occured, for that use GetLastError.
two of your points don't make sense either, "type(Name)" checks the type of the variable Name, he's not checking a string literal, Name is assigned TO a string literal.
and his naming convention is consistent, it's not what's approved but it's consistent, so I don't know what you're talking about lol.
Cancel
Post
https://media.discordapp.net/attachments/1044764388546068510/1051935933836050482/Signature_4.png
Users viewing this thread:
( Members: 0, Guests: 1, Total: 1 )
Comments
TERIHAX 30 Reputation
Commented
correction, its not monkey sauce, its cat juice (from the blender) or dog juice
0