Commit MetaInfo

Revision3e4961a1aefbbdad9e6503abfb191b9952dbb5c4 (tree)
Time2011-01-27 02:14:27
AuthorFace
CommiterFace

Log Message

OrbiterExtensions: fix for access rights

We don't need all the rights here...

Change Summary

Incremental Difference

diff -r 70500b3279f5 -r 3e4961a1aefb Orbitersdk/samples/AscensionUltra/VirtualDockingTunnel.cpp
--- a/Orbitersdk/samples/AscensionUltra/VirtualDockingTunnel.cpp Mon Jan 24 00:22:25 2011 +0100
+++ b/Orbitersdk/samples/AscensionUltra/VirtualDockingTunnel.cpp Wed Jan 26 18:14:27 2011 +0100
@@ -119,14 +119,15 @@
119119 int WriteCode(void *address, void *code, DWORD len)
120120 {
121121 //Get process information
122- HANDLE hSelf = OpenProcess(PROCESS_ALL_ACCESS, FALSE, ::GetCurrentProcessId());
122+ HANDLE hSelf = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_OPERATION, FALSE, ::GetCurrentProcessId());
123+ if (hSelf==NULL) return -1;
123124 MEMORY_BASIC_INFORMATION mbi;
124125
125- //Open up page of linked address
126- if(VirtualQueryEx(hSelf, (LPVOID)address, &mbi, sizeof(mbi)) != sizeof(mbi)) return -1;
126+ //Open up page of linked address
127+ if(VirtualQueryEx(hSelf, (LPVOID)address, &mbi, sizeof(mbi)) != sizeof(mbi)) return -2;
127128 PVOID pvRgnBaseAddress = mbi.BaseAddress;
128129 DWORD dwOldProtect1, dwOldProtect2, dwFake;
129- if(!::VirtualProtectEx(hSelf, pvRgnBaseAddress, 4, PAGE_EXECUTE_READWRITE, &dwOldProtect1)) return -2;
130+ if(!::VirtualProtectEx(hSelf, pvRgnBaseAddress, 4, PAGE_EXECUTE_READWRITE, &dwOldProtect1)) return -3;
130131 BOOL bStridePage = FALSE;
131132 LPBYTE lpByte = (LPBYTE)pvRgnBaseAddress;
132133 lpByte += 4096;
@@ -136,7 +137,7 @@
136137 if(!::VirtualProtectEx(hSelf, pvRgnBaseAddress2, 4, PAGE_EXECUTE_READWRITE, &dwOldProtect2))
137138 {
138139 ::VirtualProtectEx(hSelf, pvRgnBaseAddress, 4, dwOldProtect1, &dwFake);
139- return -3;
140+ return -4;
140141 }
141142
142143 //Write code
@@ -191,9 +192,8 @@
191192
192193 if (memcmp((void *)g_Original[hook], g_Addresses[hook], 9)!=0) return -2;
193194 for(int i=0;i<4;i++) g_Code[hook][5+i] = p.bytes[i];
194- WriteCode(g_Addresses[hook], (void *)g_Code[hook], 9);
195195
196- return 0;
196+ return WriteCode(g_Addresses[hook], (void *)g_Code[hook], 9)*10;
197197 }
198198 __declspec(dllexport) int __cdecl Init(VESSEL *handle){return InitHook(handle, 0);}
199199
Show on old repository browser