View previous topic :: View next topic |
Author |
Message |
rain-13 Expert Cheater
Reputation: 0
Joined: 18 Mar 2009 Posts: 110
|
Posted: Fri Jul 31, 2015 10:34 am Post subject: How to rewrite memcpy using equal sign? |
|
|
Hi.
I was curious to know if there is any better way than memcpy to overwrite lpFreeBytesAvailable with modified?
When I use lpFreeBytesAvailable = modified then it crashes. I also tried to combine these with & and *s but I didn't manage to do that.
Code: | BOOL WINAPI DetourGetDiskFreeSpaceExW(
_In_opt_ LPCTSTR lpDirectoryName,
_Out_opt_ PULARGE_INTEGER lpFreeBytesAvailable,
_Out_opt_ PULARGE_INTEGER lpTotalNumberOfBytes,
_Out_opt_ PULARGE_INTEGER lpTotalNumberOfFreeBytes
){
BOOL ret = fpGetDiskFreeSpaceExW(lpDirectoryName,lpFreeBytesAvailable,lpTotalNumberOfBytes,lpTotalNumberOfFreeBytes);
PULARGE_INTEGER modified = (PULARGE_INTEGER)123; //fake free space
memcpy(lpFreeBytesAvailable, &modified, 8);
//lpFreeBytesAvailable = modified;
wprintf(L"Space2: %s %llX => %I64u\n", lpDirectoryName,lpFreeBytesAvailable, *lpFreeBytesAvailable);
return ret;
} |
The problem is that call to memcpy crashes with some processes so I want to rewrite it using equal sign to see if it fixes the problem.
|
|
Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Fri Jul 31, 2015 11:44 am Post subject: |
|
|
Given that ULARGE_INTEGER is a struct containing a union based on the number parts, you would have to assign each part of the structure. (You can't just use equals to set the value on it.)
Instead you would have to do something like this:
Code: | lpFreeBytesAvailable->QuadPart = 123; |
_________________
- Retired. |
|
Back to top |
|
 |
rain-13 Expert Cheater
Reputation: 0
Joined: 18 Mar 2009 Posts: 110
|
Posted: Fri Jul 31, 2015 1:22 pm Post subject: |
|
|
tnx
|
|
Back to top |
|
 |
|