Hi guys, I have a few problems, I'll list them here:
When I try to compile a DLL in CodeBlocks the DDL is being made and all but when I try to run the DDL via PerX Injector, the code doesn't run.
If you know to solve this tell me how.
OK so I switched to LCC compiler and there it works, but I don't like the editor and the error log there. And it seems that I can't write a class there, either the syntax there is different or what?
And a question with a code:
Code:
#include <windows.h>
void is_activated()
{
if (activated) MessageBox(NULL, "activated", "ERROR", MB_OK);
}
void mainP()
{
HANDLE process = GetCurrentProcess();
if (!process)
{
MessageBox(NULL, "Couldn't get process handle.", "ERROR", MB_OK | MB_ICONERROR);
return;// Halt the incoming lines.
}
BOOL activated = TRUE;
if (CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)is_activated, NULL, 0, NULL) == NULL)
{
MessageBox(NULL, "Couldn't create a thread to execute within the virtual address space of the calling process.", "ERROR", MB_OK | MB_ICONERROR);
return;// Halt the incoming lines.
}
CloseHandle(process);
}
BOOL WINAPI __declspec(dllexport) LibMain(HINSTANCE hDLLInst, DWORD fdwReason, LPVOID lpvReserved)
{
if (fdwReason == DLL_PROCESS_ATTACH)
{
if (CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)mainP, NULL, 0, NULL) == NULL)
{
MessageBox(NULL, "Couldn't create a thread to execute within the virtual address space of the calling process.", "ERROR", MB_OK | MB_ICONERROR);
return FALSE;
}
}
return TRUE;
}
I want the variable "activated " to be accessible in both the "main" function and the "is_activated" function. How I do that?