Results 1 to 8 of 8

Thread: Void* x64 to 32bit integer, without loss of precision (last 4 bytes of 64bit offset)

  1. #1

    Void* x64 to 32bit integer, without loss of precision (last 4 bytes of 64bit offset)

    How can I do this? I have 64bit cpu and I need last 4 bytes of this offset to an unsigned long, I tried casting etc but i always get loss of precision in last 2 bytes
    what can i do? thanks pd. my application MUST be x86

    thanks
    I promise that I have read the FAQ and tried to use the Search to answer my question.

  2. #2
    <script>alert(0)</script> disavowed's Avatar
    Join Date
    Apr 2002
    Posts
    1,281
    If you're compiling for x86 then the void* is already 32-bits.

  3. #3
    ^^
    There's that... but if compiling for 64-bit (assuming little endian):

    __int32 foo = * (__int32 *) &x64;

  4. #4
    You're right disawowed, however, i don't know why im getting loss of precision in the void* to long casting :S
    I promise that I have read the FAQ and tried to use the Search to answer my question.

  5. #5
    Just use ULONG_PTR instead of long.
    See here:

    http://msdn.microsoft.com/en-us/library/cc230394(v=prot.10).aspx

    and here:

    http://msdn.microsoft.com/en-us/library/aa384255(v=vs.85).aspx

    Hope that helps

    Regards
    darkelf
    I flout Chuck Norris, Spongebob barbecues underwater!

  6. #6
    Thaks for reply, but i still getting the same result:

    Name:  Sin título.jpg
Views: 169
Size:  19.2 KB

    See how z =/= loadDll_end and zvoid =/=loadDll_end

    Also I've to say that loadDll_end is __declspec(naked) void loadDll_end() { }

    + im in debug mode
    I promise that I have read the FAQ and tried to use the Search to answer my question.

  7. #7
    Would you be so kind as to tell us the error/warning number?

    Additionally try your example with the "PtrToUlong" macro.

    Something like:

    Code:
    ULONG z = PtrToUlong(loadDLL_end);
    Regards
    darkelf
    Last edited by Darkelf; April 12th, 2012 at 17:05.
    I flout Chuck Norris, Spongebob barbecues underwater!

  8. #8
    <script>alert(0)</script> disavowed's Avatar
    Join Date
    Apr 2002
    Posts
    1,281
    You're not losing precision. One of those two addresses is a jmp to the other one (check the disassembly if you don't believe me). Change to release mode and you won't have that problem.

Similar Threads

  1. 64bit and 32bit OS for cracking, using vmware?
    By Gallaxhar in forum The Newbie Forum
    Replies: 1
    Last Post: November 8th, 2012, 08:56
  2. Calling 16bit NE DLL from 32bit PE executable
    By johnny in forum Advanced Reversing and Programming
    Replies: 4
    Last Post: March 3rd, 2010, 14:49
  3. Windows XP 32bit, Service Pack 3
    By Sirmabus in forum Tools of Our Trade (TOT) Messageboard
    Replies: 1
    Last Post: May 20th, 2008, 03:41
  4. flexcv - convert hex or integer value into lm_attr define
    By nblender in forum Tools of Our Trade (TOT) Messageboard
    Replies: 0
    Last Post: May 16th, 2002, 15:07
  5. Reversing a algorithm: 4 bytes read - 8 bytes written
    By DakienDX in forum Advanced Reversing and Programming
    Replies: 9
    Last Post: September 20th, 2001, 13:27

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •