Quote Originally Posted by jsvenu View Post
Dear smkperu,

You have to use specific type instead of PVOID for pointers when using GetMem4 or RtlMoveMemory.
All the errors are related to GetMem4 api call of msvbvm60.dll.

You also have to create a new copy of vbheader for initializing runtime in vb6 standard exe which is CreateVBheadercopy function in modmultithreading module of Trick's code.

regards,
JSVenu
Dear smkperu,

Replace your export function initruntime with the following code in the project and then your project builds without errors:


Code:
// This is an example of an exported function.
VBSIM1_API int initvbruntime(void)
{
	INT		vbDLLPointer;
	PVOID	VBLIBPointerThunRTMain;
	PVOID	VBLIBPointerVDGCO;
	HANDLE	VBThread;
	PVOID	VBLIBPointerDGCO;
    PVOID   ptr;
	 CLSID      clsid;
	 HRESULT	   hr,hr1;
	ULONG lOldProtect;
	msvbvmvbHandle=LoadLibrary("msvbvm60.dll");
	pRtlMoveMemory=(pGetMem4)GetProcAddress((struct HINSTANCE__ *)msvbvmvbHandle, "GetMem4");
	vbHandle = GetModuleHandle(NULL);//LoadLibrary(DLLName);	
	//VBLIBPointerDGCO = GetProcAddress(vbHandle,"DllGetClassObject");
	/* Load the VB DLL								*/
	//vbDLLPointer = *(int*)((int)VBLIBPointerDGCO + 2);																/* Get the Project Pointer						*/
	// Get e_lfanew
	pRtlMoveMemory((int*)((int)vbHandle + 0x3C),ptr);
    //GetMem4 ByVal hModule + &H3C, ptr
    // Get AddressOfEntryPoint
    // pRtlMoveMemory(*(int*)((int)ptr) + 0x28 + vbHandle,ptr);
	ptr=(int*)((int*)ptr + 0x28 + (int)vbHandle);
    //GetMem4 ByVal ptr + &H28 + hModule, ptr
    // Get VBHeader
	pRtlMoveMemory((int*)ptr + (int)vbHandle + 1,VBLIBPointerDGCO);


     // Allow to write to that page
    VirtualProtect(VBLIBPointerDGCO, 0x64, PAGE_EXECUTE_READWRITE, &lOldProtect);
    
     // 'Remove Sub Main
    //ptr = mpVbHeader + &H2C
    //GetMem4 0&, ByVal ptr ' 'AddressOf mymain
    pRtlMoveMemory((int*)((int)VBLIBPointerDGCO + 0x2C),0);
    VirtualProtect(VBLIBPointerDGCO, 0x64, lOldProtect, 0);



    //GetMem4 ByVal ptr + hModule + 1, GetVBHeader
	//msvbvmvbHandle=LoadLibrary("msvbvm60.dll");
	VBLIBPointerThunRTMain = GetProcAddress((struct HINSTANCE__ *)msvbvmvbHandle,"ThunRTMain");								/* Get the VB Runtime Initialization Pointer	*/
    pv1=(pVBDllGetClassObject)GetProcAddress((struct HINSTANCE__ *)msvbvmvbHandle, "VBDllGetClassObject");

	try
{
hr1=	pv1((struct HINSTANCE__ *)vbHandle,0, VBLIBPointerDGCO,clsid, IID_IDispatch, (LPVOID *)&IDisp);//IID_IClassFactory, (LPVOID *)&pIFactory);
}
catch(...)
{
	if( FAILED( hr1 ) )
{
MessageBox(0,"\nDllGetClassObject failed",0,0);
}
}
    
	return 42;
}

regards,
JSVenu