hi everyone !

How is it to set or modify the security attributes of an existing file (MyFile.txt) in HLA (MyProg.exe), using the 'w.CreateFile' function, or any other ?

My aim is to change the attributes that anyone can find manually by right-clicking on the name of the file in the Explorer, then properties, security,...

The param. 'lpSecurityAttributes' seems to accept only the NULL value under HLA ?
That value gives the default security descriptor ?
Does it mean that it's not possible to modify the security of a given file, throughout a HLA program ?

I 'd like to set the security of MyFile.txt so that it's impossible to copy it, during the whole time MyProg.exe is running...

thanks for help and advices,

Juan
(Belgium).
Posted on 2004-09-08 08:31:40 by Juan
All you need to do is pass a pointer to a SECURITY_ATTRIBUTES structure. If you are still having problems some one would would be able to identify the problem if you post a code snippet.
Posted on 2004-09-08 09:26:29 by Odyssey
If you just need to make it impossible to read the file while the app is running, forget about security attributes. Use "0" as dwShareMode argument for CreateFile - if HLA maps those directly, it's parameter #3 (right after dwDesiredAccess).
Posted on 2004-09-08 13:56:28 by f0dder
thanks a lot for having answered, both of you...

naturally, I tried to set the dwShareMode to 0, but my aim is not reached... what did I miss I don't catch it... :?

here's the code I used :

program Abra;


// makes a copy of Myprog.exe file to p1.exe. (example with calc.exe)
// then loads P1.exe.
// After execution, deletes the p1.exe
// the aim is to make p1.exe impossible to copy during execution...
// please try this with any *.exe file

#include( "stdlib.hhf" )
#include( "fileio.hhf" )
#include( "stdout.hhf" )
#include( "w.hhf" )

static
Fich: dword;
P1exist: boolean;
endstatic;

const
MonF1:string:="C:\WINNT\system32\calc.exe";
MonF2:string:="C:\WINNT\system32\P1.exe";
endconst;

begin Abra;

// make the copy
w.CopyFile
(
MonF1,
MonF2,
P1exist
);

// open a handle on it with dwShareMode set to 0, but the aim is not reached...
w.CreateFile
(
MonF2,
w.GENERIC_READ | w.GENERIC_WRITE,
0,
NULL,
w.OPEN_EXISTING,
w.FILE_ATTRIBUTE_NORMAL,
NULL
);

mov (eax, Fich);

// w.CloseHandle(Fich); // - if I close the handle here, the P1.exe loads actually but you will notice
// that it's quite simple, through the Explorer, to make a copy of it (exactly what I don't want)
// - if I don't close the handle, then the os.system() command does not work
// --> doesn't load P1.exe in memory...

os.system("C:\WINNT\system32\P1.exe");
fileio.delete("C:\WINNT\system32\p1.exe");

end Abra;

can you see something I did not ?
thanks a lot for help,

bye,
until soon,

Juan, Belgium...
Posted on 2004-09-09 04:31:02 by Juan
Hi !

In the meanwhile, I heard about a solution that seems interesting too :

why not create an image of the P1.exe directly into memory, and then launch the application from it ?

It's interesting, but as to me, unfortunately I have no other information about the procedure to create that image... do you ?

something like a virtual disk in memory ?

What do you think about this ?

bye,
until soon,

Juan.
Posted on 2004-09-10 01:24:59 by Juan