Problems with C++

Posts 1–5 of 5 · Page 1 of 1
Problems with C++
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?
Declare "activated" as a global scope.
Thanks it worked.

Can you suggest me an alternative for CodeBlocks software? Or a solution on how to make the DDL work there?
Use Microsoft Visual C++ Express.
you can click declair activate
Posts 1–5 of 5 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?