Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
FPD25- C loader and copy protection
Message
 
To
19/09/2002 03:11:25
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
FoxPro 2.x
Miscellaneous
Thread ID:
00701158
Message ID:
00702179
Views:
44
Wow!!
Thanks for the insight. I guess this is heavy weight, I can manage C function calls, asm was tough when I last tried it. I just might gather the courage to do it, if so let you know.

>You're welcome.
>absread() - I think that's your problem. Absolute read uses int 13 (bios direct disk services) and is prohibited under w2k, ntfs. W2K and NTFS doesn't let you do direct accesses to disk and I think it should report it somehow. If you use int 25, 26 then I think it'd work with your C routine (I think you use functions instead of pragma asm - int 13 services are related with biosdisk but don't know what int 25,26 wrappers are).
>You can load the routine I gave with some furnishing to your C routine. I 'guess' with BC++ you'd use a #pragma inline. Load the bin with debug to see the asm you need. You might need to remove push bx, pop bx and retf (FP passes and gets parameters through BX and asm does a far return). But I'm not familiar with BC++, you should check. All it does is to call int 21 (DOS interrupt) with service 0x69 in AH and subfunction 00 for Get, 01 for set serial in AL.
>
>INT 21
>AH = 0x69 Get/Set serial number
>AL = 0x00 Get, 0x01 Set
>BL = drive (unlike Int 13 sequential - 0=default, 1=A, 2=B, 3=C...)
>DS:DX - Disk info
>
>Basically it's :
>mov ax, 6900 ; get
>mov bx, 0003 ; Assuming for C drive
>int 21
>
>On return if there is no error (on error CF is set and AX has error code - ie: 0005 no extended BPB on disk, 0001 doesn't work with networked drives) :
>DS:DX points to bytes 0x27-0x3D of extended BPB.
>Offset,Size,Description
>0x00, Word, Info level (always zero)
>0x02, DWord, disk serial number as binary
>0x06, 11 bytes, volume label (or NO NAME if not present)
>0x11, 8 bytes, (AL=00 only) filesystem type as string (FAT16, FAT32, NTFS ...)
>
>Hope that helps. Honestly I'd go with FP's load/call instead of a C routine. I use ASM routines for many different purposes with FP2.x and they work wonderfully. OTOH I was on ASM side for I didn't have any C compiler when I needed them and ASM was for free with 'debug':)
>Cetin
>
>>Thanks a lot Cetin, it works great. I tried to find out what was actually wrong with my C routine. Like I said the same EXE works well on a w98 and not on my w2k neither NTFS nor FAT32 partitions. I am using BC++31 for the compilation. absread() for reading the disk. What is happening is absread() fails on my machine.
>>
>>Any idea why that may be so or is there a different way to get it done?
>>
>>Can I load you serial.bin for use in the C routine?
>>
>>I am intimidated when I saw the help for biosdisk()
>>
>>Thanks again for a great piece of code.
>>
>>>>The usual, the Disk Serial no. My main aim for the copy protection is casual copy protection. Serious hackers will break any if they want to.
>>>>
>>>>
>>>
>>>You don't need a C routine to check disk format serial number. If C routine is correct it still works under w2K, XP. In FPD2.x you can load and call binary routines.
>>>
>>>
>>>*SerialBinTest.prg
>>>parameters driveletter
>>>set talk off
>>>clear
>>>mp = chr(asc(upper(driveletter))-ASC("A")+1)+chr(0)+;
>>>	space(22) && 24 bytes total
>>>load serial
>>>call serial with mp   && execute binary code
>>>? substr(mp,2+1) && First two bytes are always chr(0)
>>>cSerial1 = substr(mp,1+2,1)
>>>cSerial2 = substr(mp,2+2,1)
>>>cSerial3 = substr(mp,3+2,1)
>>>cSerial4 = substr(mp,4+2,1)
>>>
>>>? asc(cSerial4)  && Disk serial number
>>>? asc(cSerial3)  && is a doubleword
>>>? asc(cSerial2)  && So read in reverse order
>>>? asc(cSerial1)  && as shown in dir
>>>* Now print in hex format just like dir
>>>? "Disk serial number is "
>>>?? padl(dec2hex(asc(cSerial4)),2,"0")
>>>?? padl(dec2hex(asc(cSerial3)),2,"0")
>>>?? ":"
>>>?? padl(dec2hex(asc(cSerial2)),2,"0")
>>>?? padl(dec2hex(asc(cSerial1)),2,"0")
>>>?
>>>
>>>function Dec2Hex
>>>parameters nDecimal
>>>n=0
>>>do while floor(nDecimal/16^n) > 15
>>> n = n+1
>>>enddo
>>>cHEX = ""
>>>for ix=n to 0 step -1
>>> cHEX = cHex + DecDigit2HexDigit(floor(nDecimal/16^ix))
>>> nDecimal = nDecimal % 16
>>>endfor
>>>return cHex
>>>
>>>function DecDigit2HexDigit
>>>parameters nDecimal
>>>return iif(ndecimal>9,chr(asc("A")+nDecimal%10),str(nDecimal,1))
>>>
>>>
>>>
*Create bin - run once
>>>handle=fcreate('Serial.Bin')
>>>=FWRITE(handle,CHR(83)+CHR(184)+;
>>>  CHR(0)+CHR(105)+CHR(139)+CHR(211)+;
>>>  CHR(139)+CHR(31)+CHR(205)+CHR(33)+;
>>>  CHR(91)+CHR(203))
>>>=fclose(handle)
>>>
Cetin
Regards
Bhavbhuti
___________________________________________
Softwares for Indian Businesses at:
http://venussoftop.tripod.com
___________________________________________
venussoftop@gmail.com
___________________________________________
Previous
Reply
Map
View

Click here to load this message in the networking platform