i want to call shfileoperation from shel32.dll to copy a file with delphi
but my code dosen't work and the reason is the format of paths,I didn't find any solution for the problem.any one can help me? here is my code and the image of RemoteInfo value while debugging
here is link of the image http://www.freeimagehosting.net/uploads/219d79fc30.jpg -
-
program InjectCode;
-
uses
-
Windows,
-
shellapi, injectmemory,dialogs, strutils, sysutils, classes;
-
type
-
LPSHFILEOPSTRUCT = ^SHFILEOPSTRUCT;
-
SHFILEOPSTRUCT = packed record
-
Wnd: HWND;
-
wFunc: UINT;
-
pFrom: PAnsiChar;
-
pTo: PAnsiChar;
-
fFlags: FILEOP_FLAGS;
-
fAnyOperationsAborted: BOOL;
-
hNameMappings: Pointer;
-
lpszProgressTitle: PAnsiChar;
-
end;
-
-
type
-
TRemoteInfo = record
-
LoadLibrary: function(lpLibFileName: PChar): HMODULE; stdcall;
-
GetProcAddress: function(hModule: HMODULE;
-
lpProcName: LPCSTR): FARPROC; stdcall;
-
shf: SHFILEOPSTRUCT;
-
Kernel32: array[0..20] of Char;
-
shell32: array[0..20] of Char;
-
SHFileOperationA: array[0..20] of Char;
-
Fromlpbuff: array[0..20] of char; //Source path
-
Tolpbuff: array[0..20] of Char; //Des Path
-
-
end;
-
-
procedure RemoteThread(RemoteInfo: pointer); stdcall;
-
var
-
SHFileOperation: function(lpFileOp: LPSHFILEOPSTRUCT): Integer; stdcall;
-
begin
-
with TRemoteInfo(Remoteinfo^) do
-
begin
-
@SHFileOperation := GetProcAddress(LoadLibrary(shell32), SHFileOperationA);
-
SHFileOperation(@shf);
-
end;
-
-
end;
-
procedure RemoteThreadEnd;
-
begin
-
end;
-
var
-
RemoteInfo: TRemoteInfo;
-
s2: string;
-
s1: string;
-
i: integer;
-
pInfo, CodeAdr: pointer;
-
TID: dword;
-
Process: dword;
-
StartInfo: TStartupInfo;
-
ProcInfo: TProcessInformation;
-
-
begin
-
ZeroMemory(@StartInfo, SizeOf(TStartupInfo));
-
StartInfo.cb := SizeOf(TStartupInfo);
-
CreateProcess(nil, 'calc.exe', nil, nil, False, 0,
-
nil, nil, StartInfo, ProcInfo);
-
Process := ProcInfo.hProcess;
-
ZeroMemory(@RemoteInfo.fromlpbuff, sizeof(RemoteInfo.fromlpbuff));
-
ZeroMemory(@RemoteInfo.Tolpbuff, sizeof(RemoteInfo.Tolpbuff));
-
ZeroMemory(@RemoteInfo, SizeOf(RemoteInfo));
-
lstrcpy(RemoteInfo.shell32, 'shell32.dll');
-
lstrcpy(RemoteInfo.Kernel32, 'kernel32.dll');
-
lstrcpy(RemoteInfo.SHFileOperationA, 'SHFileOperationA');
-
RemoteInfo.shf.Wnd := 0;
-
RemoteInfo.shf.wFunc := FO_COPY;
-
RemoteInfo.shf.pFrom := @remoteInfo.Fromlpbuff;
-
RemoteInfo.shf.pto := @remoteInfo.tolpbuff;
-
lstrcpy(RemoteInfo.shf.pFrom, 'e:\1.jpg' + #0#0);
-
lstrcpy(RemoteInfo.shf.pto, 'f:\1.jpg' + #0#0);
-
RemoteInfo.shf.fFlags := FOF_ALLOWUNDO;
-
RemoteInfo.shf.fAnyOperationsAborted := false;
-
@RemoteInfo.LoadLibrary := GetProcAddress(GetModuleHandle('kernel32.dll'),
-
'LoadLibraryA');
-
@RemoteInfo.GetProcAddress := GetProcAddress(GetModuleHandle('kernel32.dll'),
-
'GetProcAddress');
-
pInfo := InjectMemory(Process, @RemoteInfo, SizeOf(TRemoteInfo));
-
CodeAdr := InjectMemory(Process, @RemoteThread,
-
dword(@RemoteThreadEnd) - dword(@RemoteThread));
-
Sleep(2000);
-
CreateRemoteThread(Process, nil, 0, CodeAdr, pInfo, 0, TID);
-
end.
-
0 1043 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Raja |
last post by:
I have a java class thats trying to call something in python. This
works fine when i do a jythonc on the python script.
When i call another python script from the __init__ of my called
python...
|
by: James L. Brown |
last post by:
Hello
I'm currently working on a project, that contains one .net (VB) executable and a C++ (MFC) DLL. Now, what I want to do is to call the functions in the dll out of my managed code
//managed...
|
by: Peter Schmitz |
last post by:
Hi,
I just created a solution that is based on unmanaged C++ code. Now, the .net
framework consists of some cool functions and classes - there is especially
one namespace I'd like to use....
|
by: chaor |
last post by:
hi,
how to convert the following strut into safe struct in c#?
struct in C++:
typedef struct
{
char m_username;
char m_password;
char m_userIP;
|
by: bobben |
last post by:
Hi everybody.
I don't know if this is possible, but I am looking for a way to
automatically inject code.
I would like to fire a Debug.Writeline() automatically when a method is
invoked and...
| |
by: Jesse McGrew |
last post by:
Hi all,
I'm trying to make a plugin DLL for a third-party application, using
VC++ .NET 2003. This DLL acts as a bridge between the C++ plugin API of
the application, and my actual plugin code...
|
by: Bill Soudan |
last post by:
Hi all,
I'm a MS/.NET newbie, diving right into CLR interop. I've worked
through the various issues foreign to me as a UNIX guy: multiple heap
issues because I was linking to different CRT...
|
by: Sati |
last post by:
Hi All,
Does anyone know how to clean a asp application from a
virus that converts labels with the word 'Insurance' into
link button to a web page. It also injects text in the
textbox when the...
|
by: sati |
last post by:
Thanks.. Since my last post, I have identified a few more
facts on this case.
This code injection occurs in the client browser. The Web
server seems to be sending correct page. So far, I have...
|
by: Klaus |
last post by:
Hi,
I have an existing VC 6 MFC application which communicates asynchronly with
a VC 2005 managed code dll.
I use an unmanaged base class with virtual functions to access methods in
the MFC...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |