 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
rain-13 Expert Cheater
Reputation: 0
Joined: 18 Mar 2009 Posts: 110
|
Posted: Sat Aug 01, 2015 5:36 am Post subject: Can aonone help me to understand this? |
|
|
Hi
I have found pretty interesting thing that I dont understand why it happens. I am trying to hook GetDiskFreeSpaceW with following code.
Code: | BOOL WINAPI DetourGetDiskFreeSpaceW(
_In_ LPCTSTR lpRootPathName,
_Out_ LPDWORD lpSectorsPerCluster,
_Out_ LPDWORD lpBytesPerSector,
_Out_ LPDWORD lpNumberOfFreeClusters,
_Out_ LPDWORD lpTotalNumberOfClusters
){
printf("DetourGetDiskFreeSpaceW\n&lpNumberOfFreeClusters: %llX\n",&lpNumberOfFreeClusters);
//BOOL ret = fpGetDiskFreeSpaceW(lpRootPathName,lpSectorsPerCluster,lpBytesPerSector,lpNumberOfFreeClusters,lpTotalNumberOfClusters);
printf("before cheating %d \n",*lpNumberOfFreeClusters);
(*lpNumberOfFreeClusters) = (DWORD)99999999;
(*lpTotalNumberOfClusters) = (DWORD)999999999;
(*lpBytesPerSector) = (DWORD)65535;
(*lpSectorsPerCluster) = (DWORD)128;
printf("faked space %d \n",lpNumberOfFreeClusters);
return 1;
} |
Now, when I try to hook my own program, it works correctly.
But when I hook installer then it crashes.
As it can be seen from screenshots it crashes when printf tries to read the variable.
Code: | printf("before cheating %d \n",*lpNumberOfFreeClusters); |
Could anyone help me to understand why this happens and what could fix it?
It looks so strange to me because I dont do anything with variable itself yet. I just try to read it. I dont even try to modify it at first. And even it I do modify it to invalid value, it still shouldn't crash before the caller uses these value, but it crashes when the code execution is still in hook.
I also figured that when I view address that gets printed in CE then with my app it points to address which value contains lpNumberOfFreeClusters's value but with setup if I add this printed address to CE it is 0.
|
|
Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Sat Aug 01, 2015 12:30 pm Post subject: |
|
|
You can't write to the following values like you are:
Code: | (*lpNumberOfFreeClusters) = (DWORD)99999999;
(*lpTotalNumberOfClusters) = (DWORD)999999999;
(*lpBytesPerSector) = (DWORD)65535;
(*lpSectorsPerCluster) = (DWORD)128; |
I showed you how to use them properly in the other thread.
_________________
- Retired. |
|
Back to top |
|
 |
rain-13 Expert Cheater
Reputation: 0
Joined: 18 Mar 2009 Posts: 110
|
Posted: Sat Aug 01, 2015 1:08 pm Post subject: |
|
|
Nope, that's the other thing already. In previous thread I played with GetDiskFreeSpaceExW but now I have GetDiskFreeSpaceW.
And in this thread, it crashes already at printf.
Code: | printf("before cheating %d \n",*lpNumberOfFreeClusters); |
This line doesnt even get printed anymore (as it can be seen from screenshots). And this line is before code you pointed out.
|
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|