Autor | Thema: SaveResource | | Datum:29.04.02 10:44 
(schmidts@flat2serv.de) | |
Hallo Thorsten,
sorry, aber Mabuse (*lol*) hat Recht. Ist sogar recht einfach, wenn man's einmal raushat. Hier der Source, mit dem ich in Delphi rumgespielt habe. Müsste sich leicht auf Profan übertragen lassen:
"
Function AddResourceData(Filename, ResName: String; Value:Pointer; Size:Integer):Boolean;
var h : THandle;
begin
h := BeginUpdateResource(PChar(FileName), false);
if h<>0 then begin
Result := UpdateResource(h, RT_RCDATA, PChar(ResName), 0, Value, Size);
EndUpdateResource(h, false);
End else Result := false;
end;
"
Beispiel (ebenfalls Pascal):
"
FileName := 'c:\test.exe';
Value := 'Testeintrag';
AddResourceData(FileName, 'myData', PChar(Value), length(Value));
"
Mfg.
Sven Schmidts
|
| | Datum:29.04.02 16:52 
(mrk@mrk-soft.de) | |
Hi Sven,
Stimmt, von der Seite hab ich das noch garnit betrachtet,
kommt aber meiner Routine in Res-Shop ziemlich nah ...,
hab nur gesehn, das es nun sogar noch etwas einfacher
geht ...
|
| | Datum:29.04.02 16:01 
| |
Ach, ja kennt denn keiner ne möglichkeit
|
| | Datum:29.04.02 16:34 
(schmidts@flat2serv.de) | |
???
Über Deinem Eintrag steht die Möglichkeit, muss nur noch nach Profan umgesetzt werden.
|
| | Datum:29.04.02 18:00 
| |
Hallo Sven,
>>BeginUpdateResource
das funktioniert aber erst unter NT
Gruss
Andreas
|
| | Datum:30.04.02 10:27 
(schmidts@flat2serv.de) | |
Stimmt, ganz übersehen. Dann muss wohl doch Mabuse einspringen ;)
Mfg.
Sven Schmidts
|
| | Datum:30.04.02 10:56 
(Pascalxd@owl-online.de) | |
Hallo Leute!
@ Sven: Irgendeine Ähnlichkeit zwischen deiner Demo und dem Beispiel unseres guten Doktors
sehe ich da nicht, ganz im Gegenteil ;-)
@ Florian: Warum willst du eine exe in eine dll packen? Du kannst sie innerhalb
der dll sowieso nicht starten oder sonstwie nutzen; sie müsste erst "ausgepackt"
werden. Und in dem Fall wäre es einfacher, sie hinten dranzuhängen.
@ Dr.Mabuse: Erklär doch mal, wozu die Funktion "LockResource" eigendlich gut
ist (ernsthaft!). Bei meinen Versuchen war der zurückgegebene Pointer identisch
mit dem übergebenen Handle und auch sonst hatte sie keinen Einfluss auf irgendwas.
Darum verzichte ich beim Umgang mit Resourcen darauf, bisher ohne irgendwelche
Nachteile.
SeeYou
Pascal
|
| | Datum:30.04.02 12:02 
(mrk@mrk-soft.de) | |
>wozu die Funktion "LockResource" eigendlich gut ist (ernsthaft!).
Hi,
Lock Sperrt die Resource (DLL) im Speicher gegen andere Zugriffe,
so das nur das Programm, welches die DLL angefordert hat,
alleine drauf zugreifen kann, bis diese wieder Freigegeben
wird.
(Ohne Garantie ..... !!)
|
| | Datum:30.04.02 16:43 
| |
Ich will verschiedene dateien in eine dll kopieren
mhh werde mal schauen ob ich das umsetzen kann habe aber net so die erfahrung
ich danke euch
|
| | Datum:30.04.02 19:16 
| |
So:
declare Filename%
declare ResName$
DEF AddResourceData(2) ! "USER32","AddResourceData"
DEF BeginUpdateResource(2) ! "USER32","BeginUpdateResource"
Proc AddResourceData
Parameter THandle%
Declare h%
Value%="testeintrag"
h%=BeginUpdateResource(FileName,Value%)
If @Or(N1,N2) 'Gegenteil von @EQU(A%,B%)
UpdateResource(h,FileName)
EndUpdateResource(h,FileName,Value%)
EndProc
Filename%="test.exe"
ResName$="test.dll"
ResName%=usedll(ResName$)
FileName%="c:\test.exe"
Value%="Testeintrag"
AddResourceData(FileName,Value%)
|
| | Datum:01.05.02 10:59 
| |
Aber das geht net
|
| | Datum:01.05.02 16:59 
(schmidts@flat2serv.de) | |
Hallo,
ohne es nun weiter zu testen ...
1) Verwende LongInt statt Integer (& statt %)
2) Du musst einen Zeiger auf "Filename" an die API übergeben, also "Addr(FileName)"
3) Die Parameter-Anzahl von "UpdateResource" stimmt nicht.
Hier nochmal der Ausschnitt aus der WIN32.HLP, falls Du die nicht hast:
"
The UpdateResource function adds, deletes, or replaces a resource in an executable file.
BOOL UpdateResource(
HANDLE hUpdate, // update-file handle
LPCTSTR lpType, // address of resource type to update
LPCTSTR lpName, // address of resource name to update
WORD wLanguage, // language identifier of resource
LPVOID lpData, // address of resource data
DWORD cbData // length of resource data, in bytes
);
Parameters
hUpdate
Specifies an update-file handle. This handle is returned by the BeginUpdateResource function.
lpType
Points to a null-terminated string specifying the resource type to be updated. This parameter can also be an integer value passed to the MAKEINTRESOURCE macro, or it can be one of the following predefined resource types:
Value Meaning
RT_ACCELERATOR Accelerator table
RT_ANICURSOR Animated cursor
RT_ANIICON Animated icon
RT_BITMAP Bitmap resource
RT_CURSOR Hardware-dependent cursor resource
RT_DIALOG Dialog box
RT_FONT Font resource
RT_FONTDIR Font directory resource
RT_GROUP_CURSOR Hardware-independent cursor resource
RT_GROUP_ICON Hardware-independent icon resource
RT_ICON Hardware-dependent icon resource
RT_MENU Menu resource
RT_MESSAGETABLE Message-table entry
RT_RCDATA Application-defined resource (raw data)
RT_STRING String-table entry
RT_VERSION Version resource
lpName
Points to a null-terminated string specifying the name of the resource to be updated. This parameter can also be an integer value passed to the MAKEINTRESOURCE macro.
wLanguage
Specifies the language identifier of the resource to be updated. For a list of the primary language identifiers and sublanguage identifiers that make up a language identifier, see the MAKELANGID macro
lpData
Points to the resource data to be inserted into the executable file. If the resource is one of the predefined types, the data must be valid and properly aligned. Note that this is the raw binary data stored in the executable file, not the data provided by LoadIcon, LoadString, or other resource-specific load functions. All data containing strings or text must be in Unicode format; lpData must not point to ANSI data.
If lpData is NULL, the specified resource is deleted from the executable file.
cbData
Specifies the size, in bytes, of the resource data at lpData.
Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Remarks
An application can use UpdateResource repeatedly to make changes to the resource data. Each call to UpdateResource contributes to an internal list of additions, deletions, and replacements but does not actually write the data to the executable file. The application must use the EndUpdateResource function to write the accumulated changes to the executable file.
"
Mfg.
Sven Schmidts
|
| | Datum:01.05.02 17:50 
(prof.chaos@netcologne.de) | |
Hallo,
UpdateResource funktioniert nur unter Windows NT/2000/XP.
Obwohl ich selbst kein NT habe, hab ich mal versucht, einen Quellcode zu schreiben.
Allerdings konnte ich ihn auch nicht testen. Muss also nicht unbedingt funktionieren.
Sebastian
declare res#
def BeginUpdateResource(2) !"KERNEL32","BeginUpdateResourceA"
def UpdateResource(6) !"KERNEL32","UpdateResourceA"
def EndUpdateResource(2) !"KERNEL32","EndUpdateResourceA"
def GetLastError(0) !"KERNEL32","GetLastError"
' SaveResource S1,S2,S3,S4
' S1 : DLL- oder EXE-Datei
' S2 : Datei
' S3 : Resource-Typ
' S4 : Resource-Name
' Speichert eine Datei als Resource in eine DLL
proc SaveResource
parameters dll$,Datei$,Typ$,Name$
declare dll&,max&,err&
dll&=BeginUpdateResource(addr(dll$),0)
err&=GetLastError()
ifnot err&
assign #1,Datei$
openrw #1
max&=getfilesize(#1)
dim res#,max&
blockread(#1,res#,0,max&)
closerw #1
UpdateResource(dll&,addr(Typ$),addr(Name$),7,res#,max&)
dispose res#
err&=GetLastError()
EndUpdateResource(dll&,0)
casenot err&:err&=GetLastError()
endif
return err&
endproc
cls
SaveResource "LEER32.DLL","APPLAUS2.WAV","WAVE","BEIFALL"
print if(%(0)=120,"UpdateResource funktioniert nur Windows NT.","Fehler "+str$(%(0)))
waitinput
|
| | Datum:01.05.02 18:53 
| |
boah werde sofort getestet
|
| | Datum:02.05.02 19:38 
| |
klappt wie gesagt net :(
|
| | Datum:02.05.02 20:04 
(webmaster@rokosoft.de) | |
Hallöchen,
doch eigentlich ist die Umsetzung stark!
Nagut ich arbeite mit XP. Jedoch:
Icons klappen nicht - dort gibt es ja noch ein extra Eintrag in den Dll's ICON GROUP (und die gehört irgendwie zu dem Eintrag Icon) -
ausserdem werden immer wieder neue Einträge ICON angelegt.
Beispiel:
Icon
--- Test1
--- Icon1
Bitmap
--- Blabla
--- Bit1
Icon 'Dieser Eintrag gehört doch normal
--- Test2 'oben hin, wie bei einer Inidatei.
--- Icon2
Alles mit Reshacker nachgeschaut.
Bitmaps kann man komischerweise nur 2 einfügen - es wird ab dem 3ten Bitmap immer das erste überschrieben.
Was bei mir Super klappte sind WAV und AVI.
Rolf
|
| | Datum:03.05.02 16:57 
| |
Das bringt mir ldeir nix muss etwas sein das auf allen rechner läuft
|
| | Datum:03.05.02 20:07 
(ingobordasch@gmx.de) | |
Hallo Rolf,
>Icons klappen nicht - dort gibt es ja noch ein extra Eintrag
>in den Dll's ICON GROUP (und die gehört irgendwie zu dem
>Eintrag Icon) -
versuche mal den Eintrag "RT_ICON" statt nur "Icon", als 2. Parameter der Windowsfunktion "UpdateResource" dann werden diese auch richtig eingetragen.
Ingo
http://www.zupmaker.de
|
| | Datum:03.05.02 21:27 
(webmaster@rokosoft.de) | |
Nee leider auch nicht,
jetzt steht halt RT_ICON dort mit der Resource als Text im Reshacker.
Rolf
|
| | Datum:03.05.02 22:02 
(prof.chaos@netcologne.de) | |
Hallo Rolf !
das mit RT_ICON ist etwa so gemeint:
$H WINDOWS.PH
UpdateResource(dll&,~RT_ICON,addr(Name$),7,res#,max&)
Wenn meine Prozedur benutzt wird, muss sie allerdings entsprechend erweitert werden, z.B....
err&=addr(Typ$)
case Typ$="RT_CURSOR":err&=1
case Typ$="RT_BITMAP":err&=2
case Typ$="RT_ICON":err&=3
'[...]
UpdateResource(dll&,err&,addr(Name$),7,res#,max&)
Gruß, Sebastian
|
|
|