hi everyone!
I want to make a function for everyone to change a icon.
but i have to less experience:
I updated the source.
Greets BBB
I want to make a function for everyone to change a icon.
but i have to less experience:
.386
.model flat,stdcall
option casemap:none
include <windows.inc>
include <kernel32.inc>
include <user32.inc>
includelib <user32.lib>
includelib <kernel32.lib>
.data
lpmsg1 DB 1024 DUP (0)
lpmsg DD 0
ErrorMessage macro
; DWORD lpmsg;string pointer
call GetLastError
mov ecx,eax
invoke FormatMessage, FORMAT_MESSAGE_ALLOCATE_BUFFER or FORMAT_MESSAGE_FROM_SYSTEM, NULL, eax, LANG_NEUTRAL,ADDR lpmsg,0,NULL
invoke MessageBox, NULL, lpmsg, 0, MB_OK
endm
hRessource DD 0
hIcon DD 0
hLockRes DD 0
hExe DD 0
hOwnIcon DD 0
hInstance DD 0
Error DB 'Super-Error', 0
Buffer DB 'c:\target1.exe', 0
checkforErros macro HandleRe:REQ
LOCAL error1
LOCAL noError
OR EAX, EAX
JZ error1
MOV HandleRe, EAX
JMP noError
error1:
INVOKE MessageBox, 0, ADDR Error, ADDR Error,0
JMP endesdf
noError:
ENDM
.code
start:
MOV EAX, offset lpmsg1
MOV lpmsg, EAX
invoke GetModuleHandle, NULL
mov hInstance, eax
INVOKE LoadLibrary, addr Buffer ;hExe
checkforErros hExe
INVOKE LoadIcon, hExe, 1000
checkforErros hIcon
INVOKE LoadIcon, hInstance, 1000
checkforErros hOwnIcon
INVOKE LockResource, hIcon
INVOKE BeginUpdateResource, ADDR Buffer, 0
;ErrorMessage
checkforErros hRessource
mov ecx, SUBLANG_DEFAULT
shl ecx, 10
add ecx, LANG_NEUTRAL
invoke SizeofResource, hRessource, hOwnIcon
INVOKE UpdateResource, hRessource, RT_ICON, hIcon,ECX, hOwnIcon, eax
endesdf:
ret
END start
I updated the source.
Greets BBB
I can't begin to list the misconceptions there, first the value returned by LoadIcon is not useable in update resource, you must first convert it to raw data. The proper sequence to update a resource is as follows:
; Create buffers to store the data
invoke GlobalAlloc,GMEM_FIXED,ResourceSize
mov pData,eax
; ##################################
; You must copy the data into the buffer here
; ##################################
invoke BeginUpdateResource,OFFSET TargetFile,FALSE
mov hUpdate,eax
; Write the data to the resource section
invoke UpdateResource, hUpdate, RT_TYPE, ResNumber, NULL, pData, ResourceSize
; End the update
invoke EndUpdateResource,hUpdate,FALSE
; Done with the buffer
invoke GlobalFree,pData
more things about your code:
You cannot update the resources of a file that is executing, if you perform a load library the file is in effect executing at that point and you are not allowed to update the resources. The BeginUpdateResource will always fail.:
[b]INVOKE LoadLibrary, addr Buffer[/b] ;hExe
checkforErros hExe
[b]INVOKE BeginUpdateResource, ADDR Buffer, 1[/b]
checkforErros hRessource
You cannot update the resources of a file that is executing, if you perform a load library the file is in effect executing at that point and you are not allowed to update the resources. The BeginUpdateResource will always fail.:
pFileName
Pointer to a null-terminated string that specifies the executable file in which to update resources. An application must be able to obtain write access to this file; it cannot be currently executing. If pFileName does not specify a full path, the system searches for the file in the current directory.
Pointer to a null-terminated string that specifies the executable file in which to update resources. An application must be able to obtain write access to this file; it cannot be currently executing. If pFileName does not specify a full path, the system searches for the file in the current directory.
Maybe you should use SetClassLong.
C example : SetClassLong(hwndDlg,GCL_HICON,(LONG)LoadIcon(hInstance,MAKEINTRESOURCE(IDC_ICONO)));
MSDN SetClassLong
I hope it works for you.
:alright:
C example : SetClassLong(hwndDlg,GCL_HICON,(LONG)LoadIcon(hInstance,MAKEINTRESOURCE(IDC_ICONO)));
MSDN SetClassLong
I hope it works for you.
:alright:
Hi donkey,
the things wich are clear for me yoiu underlined.:tongue:
But how the Icon(with fails everytime) and obtain the datasize is unclear for me.
that's just the dingbat i stop at.
Greets BBB!
the things wich are clear for me yoiu underlined.:tongue:
But how the Icon(with fails everytime) and obtain the datasize is unclear for me.
; Create buffers to store the data
invoke GlobalAlloc,GMEM_FIXED,ResourceSize
mov pData,eax
; ##################################
; You must copy the data into the buffer here
; ##################################
that's just the dingbat i stop at.
Greets BBB!
Dont let my thread die, please.
Greets BBB
Greets BBB
I think I already told you how to do it...
:o
:o
Hi, i want to change the exe-icon.
But I have troubles to load and convert the icon from the sourceexe.
Greets
But I have troubles to load and convert the icon from the sourceexe.
Greets
If you want to change it in design time download reshacker.
Do you want to change the icon on run-time?
If you, then you must use the SetClassLong as I told you before.
Do you want to change the icon on run-time?
If you, then you must use the SetClassLong as I told you before.
thank Eternal Idol Birmingham.
But I dont want to change it at runtime. And the icon shuld be replaced.
Si I cant use your suggestion, or?
Greets your BBB
But I dont want to change it at runtime. And the icon shuld be replaced.
Si I cant use your suggestion, or?
Greets your BBB
Read this please:
DOWNLOAD RESHACKER : http://www.users.on.net/johnson/resourcehacker/
Now I'm your babysitter ;)
DOWNLOAD RESHACKER : http://www.users.on.net/johnson/resourcehacker/
Now I'm your babysitter ;)
hi Eternal Idol Birmingham
i want to programm that by my self.
I love programming.
Greets !
i want to programm that by my self.
I love programming.
Greets !
You were in right path then, you want to make a resouce editor.
Please try to improve your English.
I'll try to help you next weekend, now I'm at work and I'cant code that much.
See you.
:)
Please try to improve your English.
I'll try to help you next weekend, now I'm at work and I'cant code that much.
See you.
:)
Eternal Idol Birmingham your shouldn;t code anything for me.
That I want programm it by my selfe should be clear cuz i startet to programm it.
Greets !
I have just problems to get the icon from a exe.
Greets your BBB
That I want programm it by my selfe should be clear cuz i startet to programm it.
Greets !
I have just problems to get the icon from a exe.
INVOKE LoadLibrary, addr Buffer ;hExe
checkforErros hExe
INVOKE LoadIcon, hExe, 100
;fails !!!!!! but why
Greets your BBB
now the source ist like this:
.386
.model flat,stdcall
option casemap:none
include <windows.inc>
include <kernel32.inc>
include <user32.inc>
includelib <user32.lib>
includelib <kernel32.lib>
.data
lpmsg1 DB 1024 DUP (0)
lpmsg DD 0
ErrorMessage macro
; DWORD lpmsg;string pointer
call GetLastError
mov ecx,eax
invoke FormatMessage, FORMAT_MESSAGE_ALLOCATE_BUFFER or FORMAT_MESSAGE_FROM_SYSTEM, NULL, eax, LANG_NEUTRAL,ADDR lpmsg,0,NULL
invoke MessageBox, NULL, lpmsg, 0, MB_OK
endm
hRessource DD 0
hIcon DD 0
hLockRes DD 0
hExe DD 0
hOwnIcon DD 0
hInstance DD 0
Error DB 'Super-Error', 0
Buffer DB 'c:\target1.exe', 0
checkforErros macro HandleRe:REQ
LOCAL error1
LOCAL noError
OR EAX, EAX
JZ error1
MOV HandleRe, EAX
JMP noError
error1:
INVOKE MessageBox, 0, ADDR Error, ADDR Error,0
JMP endesdf
noError:
ENDM
.code
start:
MOV EAX, offset lpmsg1
MOV lpmsg, EAX
invoke GetModuleHandle, NULL
mov hInstance, eax
INVOKE LoadLibrary, addr Buffer ;hExe
checkforErros hExe
INVOKE LoadIcon, hExe, 1000
checkforErros hIcon
INVOKE LoadIcon, hInstance, 1000
checkforErros hOwnIcon
INVOKE LockResource, hIcon
INVOKE BeginUpdateResource, ADDR Buffer, 0
;ErrorMessage
checkforErros hRessource
mov ecx, SUBLANG_DEFAULT
shl ecx, 10
add ecx, LANG_NEUTRAL
invoke SizeofResource, hRessource, hOwnIcon
INVOKE UpdateResource, hRessource, RT_ICON, hIcon,ECX, hOwnIcon, eax
endesdf:
ret
END start
come on! Boby-Boy is back.
Whats about my cute sample, who will tell me, what i have made wrong.
Thanks you in advance.
Your BBB
Whats about my cute sample, who will tell me, what i have made wrong.
Thanks you in advance.
Your BBB