dilox77
10th February 2005 17:00 UTC
system.dll problem
Hi everybody, I'm tring to link my nsis installer with ncd by sony.
They give me dll, I put this into code:
System::Call 'libpidex_dll::cdecl_Pid_init(i) i() .r1'
System::Call 'libpidex_dll::cdecl_Pid_query_pid(t, i, *i) i(r2, r3, .r4) .r6'
System::Call 'libpidex_dll::cdecl_Pid_close(t) i() .r7'
now:
$6 is 24, means lenght of key (ok)
$4 Pointed to buffer for returned query PID strings.
$4 is 16777216
How can I read that pointer (memory address right?) by nsis?
Thank's in advance.
Regards, Pierluigi Di Lorenzo
kichik
10th February 2005 20:42 UTC
Since you've used *, System.dll read the value pointed to by the pointer for you. The value is 16777216.
dilox77
11th February 2005 10:35 UTC
Thank's kichik, but I think I'm missing something else.
This is Query Pid synopsis:
3: Query PID
Syntax
int Pid_query_pid(char *drive, BYTE *key, BYTE *dest);
Description
drive: Pointed to NULL terminated drive letter string. e.g. "D:"
key: Reserved. Please set NULL.
dest: Pointed to buffer for returned query PID strings.
We recommend at least 256 bytes for this buffer.
return:
Negative value = Error code.
Positive value = Number of bytes for return data.
"dest" buffer structure.
Byte 0-2 :Reserved. 3bytes are all zero.
Byte 3 :Pid type. 0x00=Basic 0x01=Standard 0x02=Custom
Byte 4-7 :Number of bytes for valid PID data from Byte[8].
Little endian DWORD value.
Byte 8-n :PID Data
I do not understand c so much.. so I'm not so sure I call System.dll with correct values.
Moreover.. this is test.cpp they give me:
pid_init(0);
pidLen = pid_query_pid(&drive, NULL, pid_data);
if(pidLen > 0)
{
printf("\nPID from CD in Drive %c:\n\n%s\n", drive, CStr().Buffer2Hex(pid_data, pidLen));
}
else
{
printf("\nNo valid CD Drive or no PID on CD\n");
}
pid_close();
After quering pid they have CStr().Buffer2Hex(pid_data, pidLen) function ( and result is something like: 00 00 00 01 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 00 00 27 A0), I think this is what I miss.
Can somebody help me, please?
Thanks in advance, Pierluigi Di Lorenzo
kichik
11th February 2005 11:17 UTC
If the second parameter needs NULL, don't pass the value of a register such as $2, simply use n.
Take a look at the only FAQ item in the System readme for information on the third parameter. It explains in detail how to pass a structure to a function and how to get the values of the structure. It's exactly what you should do in this case.
dilox77
11th February 2005 15:07 UTC
Great!
I put this into code:
System::Alloc 256
Pop $4
System::Call 'libpidex_dll::cdecl_Pid_init(i) i() .r1'
System::Call 'libpidex_dll::cdecl_Pid_query_pid(t, i, i) i(r2, n, r4) .r6'
System::Call 'libpidex_dll::cdecl_Pid_close(t) i() .r7'
System::Call "*$4(l.r8, l.r9, l.r10)"
System::Free $4
and I get this three long:
LONG HEX
68753031168-->00 00 00 10 02 00 00 00
0--->00 00 00 00 00 00 00 00
-4612545568545505213--->BF FC F2 3E 64 8B 00 43
key with test.exe is:
00 00 00 02 10 00 00 00 00 00 00 00 00 00 00 00 43 00 8B 64 3E F2 FC BF
Results are the equals inverting longs.
So.. it's possible to read ncd key from nsis :) (by libpidex_dll).
Thanks again kichik!