i coded Software_Register.dll in asm:

.386
.MODEL FLAT, StdCall
OPTION CASEMAP: NONE

    include \masm32\include\windows.inc
    include \masm32\include\user32.inc
    include \masm32\include\advapi32.inc

    includelib  \masm32\lib\user32.lib
    includelib  \masm32\lib\advapi32.lib



.data

pmessage DB "Registered",0
Baslik DB "Event!",0
rank1 DB "1",0
rank2 DB "2",0
rank3 DB "3",0


.code

; #########################################################################
Dll_Olustur    PROC Ornek:DWORD, Durum:DWORD, Yeni:DWORD

    mov eax,1
    ret

Dll_Olustur    ENDP
; #########################################################################

SoftwareReg proc RegSubKey :DWORD, Reg_Value:DWORD,  Exe_Name:DWORD 

LOCAL RegKey:DWORD

  invoke RegCreateKey, HKEY_LOCAL_MACHINE, ADDR RegSubKey, ADDR RegKey
  .if eax==ERROR_SUCCESS
    invoke MessageBox,NULL,ADDR rank1,addr Baslik,MB_OK 
    invoke RegSetValueEx, , ADDR Reg_Value, 0, REG_SZ, ADDR Exe_Name, SIZEOF Exe_Name
    .if eax==ERROR_SUCCESS
      invoke MessageBox,NULL,ADDR rank2,addr Baslik,MB_OK
      invoke RegCloseKey,
      .if eax==ERROR_SUCCESS
        invoke MessageBox,NULL,ADDR rank3,addr Baslik,MB_OK
        invoke MessageBox,NULL,ADDR pmessage,addr Baslik,MB_OK
      .endif
    .endif
  .endif   


ret
SoftwareReg endp
; #########################################################################


End Dll_Olustur


ParaNTeZ_Reg.def:

LIBRARY ParaNTeZ_Reg
EXPORTS
SoftwareReg


my pc user: Administrator and i want use  "Software_Register" proc in delphi, i used that;

implementation
function Software_Register(RegSubKey,Reg_Value,Exe_Name:String): Integer; stdcall; external 'ParaNTeZ_Reg.dll' name 'Software_Register';

procedure TForm1.Button2Click(Sender: TObject);
begin
Software_Register('Software\Microsoft\Windows\CurrentVersion\Run','ParaNTeZ','C:\Button\Autoload.exe');
end;




delphi project1.exe works but not registered :( why?
Posted on 2009-02-08 07:35:43 by makets
In Delphi you should declare parameters of the function as PChar, not String.
Posted on 2009-02-08 16:17:31 by Morris
i declared parameters of the function as PChar, but my parametre is only Reg_Value and myproc is

SoftwareReg proc Reg_Value:Dword
..
..
ret
SoftwareReg endp


i edited "ParaNTeZ_Reg.dll" in this wise.

And Delphi:

implementation
function Software_Register(Reg_Value:Pchar): Integer; stdcall; external 'ParaNTeZ_Reg.dll' name 'Software_Register';

procedure TForm1.Button2Click(Sender: TObject);
begin
Software_Register(pchar('ParaNTeZ'));
end;


i want this :
http://img24.imageshack.us/img24/6492/goodya5.th.png


but -->
http://img443.imageshack.us/img443/5792/badsn7.th.png



Posted on 2009-02-09 07:22:01 by makets
http://img24.imageshack.us/img24/6492/goodya5.png

and

http://img443.imageshack.us/img443/5792/badsn7.png
Posted on 2009-02-09 07:24:06 by JimmyClif

i coded Software_Register.dll in asm:


SoftwareReg proc RegSubKey :DWORD, Reg_Value:DWORD,  Exe_Name:DWORD
...
    invoke RegSetValueEx, , ADDR Reg_Value, 0, REG_SZ, ADDR Exe_Name, SIZEOF Exe_Name



Sorry, my first reply was incomplete, I did not analyze your code.
Anyway, you've got at least two errors here:
1. "ADDR Exe_Name" is wrong, because it will get the address of the address of the string passed as an argument, so just use "Exe_Name" here.
2. "SIZEOF Exe_Name" will not give you the length of the string pointed to by Exe_Name, but the size of the pointer itself (which is 4 bytes). If you want to get the length of the string, try calling, for example, the lstrlen function (it is declared in kernel32.inc).

HTH
Morris
Posted on 2009-02-09 08:04:56 by Morris
very thanks Morris, i will try your said soonish.
Posted on 2009-02-10 14:40:03 by makets
Posted on 2009-02-13 18:59:27 by makets
Be sure to add 1 to the length returned by lstrlen, the NULL terminator must be included in the count.

invoke lstrlen, Exe_Name
inc eax ; assuming ansi string
invoke RegSetValueEx, , Reg_Value, 0, REG_SZ, Exe_Name, eax


This is ofcourse working under the assumption that you are passing pointers to the procedure, no need for ADDR in that case. It's actually amazing that the example you posted up top didn't GPF, it certainly would never work as you are using the address to pointers that contain the address to the data, you should have only gotten garbage back.

Should have looked more like this...

SoftwareReg proc RegSubKey :DWORD, Reg_Value:DWORD,  Exe_Name:DWORD 

LOCAL RegKey:DWORD

  invoke RegCreateKey, HKEY_LOCAL_MACHINE, RegSubKey, ADDR RegKey
  .if eax==ERROR_SUCCESS
    invoke MessageBox,NULL,ADDR rank1,addr Baslik,MB_OK
    invoke lstrlen, Exe_Name
    inc eax
    invoke RegSetValueEx, , Reg_Value, 0, REG_SZ, Exe_Name, eax
    .if eax==ERROR_SUCCESS
      invoke MessageBox,NULL,ADDR rank2,addr Baslik,MB_OK
      invoke RegCloseKey,
      .if eax==ERROR_SUCCESS
        invoke MessageBox,NULL,ADDR rank3,addr Baslik,MB_OK
        invoke MessageBox,NULL,ADDR pmessage,addr Baslik,MB_OK
      .endif
    .endif
  .endif 


ret
SoftwareReg endp
Posted on 2009-02-14 00:27:10 by donkey
you're wonderfull problem solved  8)

big thanks..
Posted on 2009-02-14 18:25:41 by makets