Thread: get hardcoded hd serial with c++

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    9

    get hardcoded hd serial with c++

    hi all
    new here
    nice forum you have

    saw http://cboard.cprogramming.com/showthread.php?p=427642
    trying to compile it , downloaded disphelper_081.zip, copied the 2 files .c, .h
    and copied the main from the topic 427642 ,
    didnt see spaces in root , added .c to the project , cant compile

    help please if you can
    thanks in advance

  2. #2
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,058
    What compile errors are you getting?

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    9
    sorry i do compile but when i run i get this
    http://rapidshare.com/files/80810223/error.JPG

  4. #4
    Registered User
    Join Date
    Jan 2008
    Posts
    9
    problem is in
    dhGetValue(L"%s", &pszSerial, wmiMediaItem, L".SerialNumber");
    i think

    really weird thing is that the exe does work for a friend
    not for me
    it shows for him the right letters and numbers for the serial,
    but not in the right order
    Last edited by naughtywizard; 01-02-2008 at 05:33 PM.

  5. #5
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Call me lazy, but I'm not going to deal with a download service to look at your error message. You can attach jpegs to messages here, if you want, or cut and paste the error into your message.

  6. #6
    Registered User
    Join Date
    Jan 2008
    Posts
    9
    :\ lol also have probs uploading... :/\
    not my day
    it shows a messagebox with the error

    cant copy and paste , manually write:

    member .serialnumber
    function getvalue
    errorin internalinvokev
    error typemismatch
    code 80020005
    source application

  7. #7
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,058
    I'm assuming that you have one or two physical drives and at least one or more logical drives. Thus, the code is throwing an exception because it cannot query the serial number of the logical drives. To bypass this exception change:

    Code:
    dhToggleExceptions(TRUE);
    to

    Code:
    dhToggleExceptions(FALSE);
    Last edited by BobS0327; 01-02-2008 at 07:24 PM. Reason: Correct type

  8. #8
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    Here is the above error.jpg for those of you who don't want to deal with rapidshare:
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  9. #9
    Registered User
    Join Date
    Jan 2008
    Posts
    9
    hi
    thanks,
    now it doesnt throw exceptions but still dont see the serial
    for a friend it works beside the fact it mix the position of some of the chars and omit a few also

  10. #10
    Registered User
    Join Date
    Jan 2008
    Posts
    9
    i have an allowed list of serial in my prog , and the prog check (with other code atm , that
    cant read scsi (friend has scsi not me and for him id works)) the serial and if it is in the allowed list. it does a check when you press start , and if it didnt find it before in the allowed list it doesnt let you continue,
    two questions about that
    first i see the serials plaintext in the .exe if i edit it , how to hide it the most easy way ?
    (using codegear c++ builder for that prog , not for this code we discuss here , which i use
    vs6 for it atm for tests)
    and second question how to make it harder for hexeditors to just bypass the checks

    thanks in advance

  11. #11
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Encrypting the serial number would be fairly simple. A simple XOR encryption will do. Storing the MD5-sum [or CRC32 or similar] of your built-in list of serial numbers would be a way to make sure they haven't been tampered with.

    To avoid people removing the check itself (by changing the branch conditions, inserting NOP's to the call or some such) that is much harder - there's no real simple answer to that one. Using macros or inline functions that forces the check code to be instantiated many times will make it harder to find and destroy the checks - but only marginally.

    Also consider that if someone really wants to cheat your program, there is always the possibility to patch the "get me the serial number of the hard-disk" kernel code so that it always returns [whatever is allowed by your program]. Someone with a bit of debug & kernel programming skills will be able to do that.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  12. #12
    Registered User
    Join Date
    Jan 2008
    Posts
    9
    thanks for your answer ,

    do you know please simple class i can use to encrypt / md5 the serials ?
    thanks

  13. #13
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    I'm pretty sure a MD5 checksum program can be found via google. Same for a simple XOR encryption [the hard part here will be to have a suitable key - ideally, the key should be as long as the serial number of the hard-disk, to make detecting the key itself harder].

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  14. #14
    Registered User
    Join Date
    Jan 2008
    Posts
    9
    didnt find something straightforward :\

  15. #15
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Try this:
    http://www.gnu.org/software/textutils/textutils.html

    It contains "md5sum" source code, amongst many other things.

    And:
    http://www.cprogramming.com/tutorial/xor.html

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Lame null append cause buffer to crash
    By cmoo in forum C Programming
    Replies: 8
    Last Post: 12-29-2008, 03:27 AM
  2. how to get serial number of HD?
    By tjc in forum C Programming
    Replies: 1
    Last Post: 11-11-2008, 12:18 AM
  3. HD Serial number
    By wallace.oliveir in forum C Programming
    Replies: 16
    Last Post: 07-07-2005, 05:37 AM
  4. HD Serial number
    By groorj in forum C Programming
    Replies: 2
    Last Post: 05-12-2005, 12:12 AM
  5. Please help with serial communication problem - Long
    By spdylude in forum Windows Programming
    Replies: 3
    Last Post: 04-06-2005, 09:41 AM