Posted by2 years ago
- Plugy Checking Memory Library Failed Download
- Plugy Checking Memory Library Failed Iphone
- Plugy Checking Memory Library Failed Iphone
Archived
I was playing just fine on my run through a few months ago with zero issues, and now I went to play again and it won't even try to open. I instead get the pop-up error: 'PlugY: Read process memory failed.'
The only thing of note that has changed in this time period is I installed the Windows 10 Creators Update, so I'm guessing it has something to do with that, but running in any kind of compatibility mode does not help.
The game works fine without PlugY, but I find D2 is almost unplayable without PlugY, and most of my good items are in my shared stash. I've tried reinstalling too, but that doesn't seem to affect anything.
Hopefully someone has some insight, because I'm itching to do another D2 LAN run-through! Thanks!
EDIT: Resolved. See comments.
EDIT 2: After the fix, the game was playing super slowly/laggy to the point of being unplayable, and starting it in windowed mode fixed it. But if you find windowed mode annoying, like me, try this glide wrapper that makes it work even better than the original, and in full screen: http://www.svenswrapper.de/english/index.html You'll need to run D2Vidtst.exe in Windows XP SP2 compatibility mode in order to do the install of the wrapper. Cheers!
5 comments
Posted by3 years ago
Archived
Hi everyone.
I asked this sub a while ago about PlugY and I got a few responses but not the answer I was really looking for - I appreciate you guys taking the time to respond to me especially since I am not really contributing to the Slashdiablo community in any way, really.
I just want to play D2 at my own pace on single player without having to worry about ladder resets, limited stash sizes, and ladder-only game content being locked out. I know PlugY will do this for me but I could never get it to work properly.
Can somebody give me an idiot-proof, blow by blow account as to how to get PlugY to work? I'm running D2:LOD on the 1.13c patch with Windows 7.
I will give my most sincere reddit silver/bronze to anybody who can help me out with this.
3 comments
If you've found yourself here, I'm guessing that you're getting PlugY.dll error message and want to find an effective solution to fix this error. You should know for sure that you have to fix this error ASAP, otherwise your machine will be broken sooner or later.
Possible PlugY.dll Error Messages
- The module 'PlugY.dll' was loaded but the entry-point DllRegisterServer was not found. Make sure that 'PlugY.dll' is a valid DLL or OCX file and then try again.
- Windows could not start because PlugY.dll file is missing or corrupt.
- Runtime Error! Program [path]PlugY.dll. An application has made an attempt to load the C runtime library incorrectly. Please contact the application's support team for more information.
- [path]PlugY.dll is either not designed to run on Windows or it contains an error. Try installing the program again using the original installation media.
- Error loading [path]PlugY.dll. The specified module could not be found.
- This application has failed to start because PlugY.dll was not found.
- Can't find PlugY.dll
Information about PlugY.dll File
Filename: PlugY.dll (Free Scan) |
File Description : - |
Latest Known Version: 9.00 |
Product Name : PlugY, The Survival Kit |
Company: - |
File type : dll file |
OS Infected: Windows NT/2000/2003/XP/Vista/2008/7/8 |
MD5: 784b284e0caad0aaa4e0153d6d67aa14 |
Security Level(0-5):5 |
Recommended: Download PlugY.dll Error Free Scan Tool |
General Causes of PlugY.dll Error
This PlugY.dll file stores important information that how the program or a Windows service needs to run. As a result, it will pop up an error message when this file is corrupt or damaged. In such circumstance, you may have a problem running the program or using the computer properly.
Most of the time, you will get an error message when there is a computer error. That error message may give you any hint on what may be wrong. Knowing the root of the problem is half the battle won when it comes to fixing the error.
Usually, PlugY.dll error may be caused by:- The registry key of PlugY.dll is invalid or damaged.
- Computer malware has injected malicious code and modified PlugY.dll file.
- The PlugY.dll file was uninstalled by other software.
- The PlugY.dll file was intentionally or mistakenly deleted by other software.
- The required version of PlugY.dll file is overwritten by other software.
- There is a hardware failure, such as a bad hard disk.
How to Fix PlugY.dll Error?
Attention: It's not advisable to download PlugY.dll file from those 'dll download' websites. The file from those websites are not verified by the official PlugY.dll developer and may be bundled with computer malware or other unwanted things. In case you really need a copy of PlugY.dll file, it's necessary for you to get it directly from its official resource. Now you can use the following solutions to fix PlugY.dll error:
1. Restart the computer
When you receive PlugY.dll error message, you can try to restart your machine to see if this error could be a glitch. Cisco packet tracer crack 7.0 download. If you can't restart it normally, you can force restart it.
2. Recover PlugY.dll file from Recycle Bin
In case you or your family mistakenly deleted this file, you can restore it from the Recycle Bin. But if you have already emptied your Recycle Bin, you can use a free data recovery software to recover PlugY.dllfile. This solution works only if this file worked properly before you deleted it.
3. Fix corrupt or invalid registry entries of PlugY.dll file
The registry is the place where most computer errors like PlugY.dll error come from. When a software was installed or uninstalled incorrectly, sometimes there will be some invalid or corrupt registry entries of some software files like PlugY.dll are left in the registry. That's why it's necessary to regularly clean those invalid and corrupt registry entries and keep the registry compact so that such errors can be reduced and your computer performance can be improved.
Plugy Checking Memory Library Failed Download
Attention: The system registry stores all information that all software and hardware require to run. So it's not suggested that you clean the system registry manually. You should know that a slight mistake may make your software unpredictable or even crash your system.
4. Run a disk defragmentation
When a software is installed, updated and removed, there will be fragments left all over your hard disk, which may lead to computer errors like PlugY.dll error. A disk defragmentation can rearrange the data on your hard disk and make them together in one stream so that computer error could be reduced and your PC can be faster.
5. Install all available Windows updates
Microsoft often releases many service packs and patches to replace and improve some of Windows system files that may be related to PlugY.dll file. Sometimes, your PlugY.dll error may be fixed easily after you install all latest Windows updates.
1). Open Control Panel
For Windows 8 Users
Hold Windows key + X and then click Control panel
For Windows 7 and Vista Users:
Click Start button and click Control Panel
2). Select View by Large Icons and then click Windows Update
3). Click Check for updates
4). Click Install updates after the scan
6. Adjust RAM memory
Some computer errors happen when the RAM memory loose. So sometimes removing RAM memory and then inserting it again could fix the error.
7. Perform a full malware scan for your computer system
It's possible that your PlugY.dll error may be caused by a computer malware in your computer. Those computer malware can damage, modify or even delete your files like PlugY.dll. Moreover, it's also possible that this PlugY.dll error is fabricated by the malware to frighten and coax you into purchasing its fake products. Click and download this powerful Virus Removal Tool to free check your system.
8. Run the sfc /scannow command to repair the system files
The sfc command is also known as System File Checker which is a very helpful utility to verify and replace important system files. When it scans the whole system and finds any missing, corrupt or damaged system files, it will replace the problematic files. This can fix the error if the file is provided by Microsoft.
Video of How to run sfc /scannow command in Windows 7:
Click Here to see the video of How to run sfc /scannow command in Windows 8
9. Examine hardware devices
If you still receive PlugY.dll error message after you perform a clean installation of your Operating System, it's certain that this error should be caused by a bad hardware. You can test each piece of hardware devices and find out and then replace the problematic one.
Recommended Solution:
Still Having PlugY.dll Problem?
In case the above methods could not help you fix your PlugY.dll problem, please contact us via email with the screen shot of your PlugY.dll error pop-up and describe how you got this error and the solutions you've tried if any.
Permalink
Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign up Find file Copy path
Cannot retrieve contributors at this time
/* |
File created by Yohann NICOLAS. |
*/ |
#include<windows.h> |
#include<stdio.h> |
#include<Psapi.h> |
//#using <mscorlib.dll> |
//#using <System.dll> |
//using namespace EnvDTE; |
//using namespace System; |
//using namespace System::Diagnostics; |
//using namespace System::ComponentModel; |
//using namespace System.Diagnostics; |
/* |
0012C458 00000000 |ModuleFileName = NULL |
0012C45C 0012C908 |CommandLine = 'C:JeuxDiablo IIGame.exe' |
0012C460 00000000 |pProcessSecurity = NULL |
0012C464 00000000 |pThreadSecurity = NULL |
0012C468 00000000 |InheritHandles = FALSE |
0012C46C 04000022 |CreationFlags = DEBUG_ONLY_THIS_PROCESS|NORMAL_PRIORITY_CLASS|CREATE_DEFAULT_ERROR_MODE |
0012C470 00000000 |pEnvironment = NULL |
0012C474 0012DF94 |CurrentDir = 'C:JeuxDiablo II' |
0012C478 0012C6BC |pStartupInfo = 0012C6BC |
0012C47C 0012C5CC pProcessInfo = 0012C5CC |
$ > >44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 D........ |
$+10 >1A 13 03 00 08 00 00 00 14 13 04 00 00 00 00 00 001a00130003..001400130004... |
$+20 >01 00 00 00 0C C7 12 00 34 87 D1 77 81 00 00 00 0001..Ç0012.4‡Ñw.. |
$+30 >0A 00 00 00 00 00 00 00 00 00 00 00 89 F6 D4 77 ......‰öÔw |
$+40 >CD AB BA DC 00 00 00 00 Í«ºÜ.. |
//0xE9,0x1C,0xD1,0xA8,0x6F |
*/ |
#defineSUBKEY'SoftwareBlizzard EntertainmentDiablo II' |
#defineGAMEFILE'Game.exe ' |
#defineINIFILE'PlugY.ini' |
#defineLAUNCHING'LAUNCHING' |
#defineLOD_VERSION'LodVersionFolder' |
#definePARAM'Param' |
#defineLIBRARY_NAME'Library' |
BYTE loadDll[]={ |
0xFF,0x74,0x24,0x04, //PUSH DWORD PTR SS:[ESP+4] |
0xFF,0x15,0x40,0xC0,0xA7,0x6F, //CALL DWORD PTR DS:[<&KERNEL32.LoadLibraryA>] ; kernel32.LoadLibraryA |
0x50, //PUSH EAX |
0x68,0x80,0xBE,0xA7,0x6F, //PUSH d2gfx.6FA7BE80 ; ASCII 'PlugY.dll' |
0xFF,0x15,0x40,0xC0,0xA7,0x6F, //CALL DWORD PTR DS:[<&KERNEL32.LoadLibraryA>] ; kernel32.LoadLibraryA |
0xA3,0xFC,0xEF,0xA8,0x6F, //MOV DWORD PTR DS:[6FA8EFFC],EAX |
0x85,0xC0, //TEST EAX,EAX |
0x74,0x2F, //JE SHORT d2gfx.6FA7BE37 |
0x50, //PUSH EAX |
0x68,0x90,0xBE,0xA7,0x6F, //PUSH d2gfx.6FA7BE10 ;Init String |
0x50, //PUSH EAX |
0xFF,0x15,0x3C,0xC0,0xA7,0x6F, //CALL DWORD PTR DS:[<&KERNEL32.GetProcAddress>] ; kernel32.GetProcAddress |
0x85,0xC0, //TEST EAX,EAX |
0x74,0x04, //JE SHORT d2gfx.6FA7BDC1 |
0x6A,0x00, //PUSH 0 |
0xEB,0x13, //JMP SHORT d2gfx.6FA7BDC1 |
0x68,0x10,0x27,0x00,0x00, //PUSH 2710 ;Init Ordinal(10000) |
0xFF,0x74,0x24,0x04, //PUSH DWORD PTR SS:[ESP+4] |
0xFF,0x15,0x3C,0xC0,0xA7,0x6F, //CALL DWORD PTR DS:[<&KERNEL32.GetProcAddress>] ; kernel32.GetProcAddress |
0x85,0xC0, //TEST EAX,EAX |
0x74,0x02, //JE SHORT d2gfx.6FA7BDC1 |
0xFF,0xD0, //CALL EAX |
0x58, //POP EAX |
0x58, //POP EAX |
0xC2,0x04,0x00, //RETN 4 |
0x59, //POP ECX |
0xB9,0x80,0xBE,0xA7,0x6F, //MOV ECX,d2gfx.6FA7BE80 ; ASCII 'PlugY.dll' |
0x83,0x04,0x24,0x10, //ADD DWORD PTR SS:[ESP],10 |
0xC2,0x04,0x00, //RETN 4 |
0x00,0x00,0x00,0x00}; //HANDLE var; |
BYTE freeDll[]={ |
0xFF,0x74,0x24,0x04, //PUSH DWORD PTR SS:[ESP+4] |
0xFF,0x15,0x48,0xC0,0xA7,0x6F, //CALL DWORD PTR DS:[<&KERNEL32.FreeLibrary>] ; kernel32.FreeLibrary |
0x50, //PUSH EAX |
0xA1,0xFC,0xEF,0xA8,0x6F, //MOV EAX,DWORD PTR DS:[6FA8EFFC] |
0x85,0xC0, //TEST EAX,EAX |
0x74,0x2D, //JE SHORT d2gfx.6FA7BE74 |
0x50, //PUSH EAX |
0x68,0xA0,0xBE,0xA7,0x6F, //PUSH d2gfx.6FA7BE20 ;Release String |
0x50, //PUSH EAX |
//0x33,0xC0, //XOR EAX,EAX |
//0xA3,0xFC,0xEF,0xA8,0x6F, //MOV DWORD PTR DS:[6FA8EFFC],EAX |
0xFF,0x15,0x3C,0xC0,0xA7,0x6F, //CALL DWORD PTR DS:[<&KERNEL32.GetProcAdd>; kernel32.GetProcAddress |
0x85,0xC0, //TEST EAX,EAX |
0x75,0x13, //JNZ SHORT d2gfx.6FA7BDEF |
0x68,0x11,0x27,0x00,0x00, //PUSH 2711 ;Release Ordinal(10001) |
0xFF,0x74,0x24,0x04, //PUSH DWORD PTR SS:[ESP+4] |
0xFF,0x15,0x3C,0xC0,0xA7,0x6F, //CALL DWORD PTR DS:[<&KERNEL32.GetProcAdd>; kernel32.GetProcAddress |
0x85,0xC0, //TEST EAX,EAX |
0x74,0x02, //JE SHORT d2gfx.6FA7BDEF |
0xFF,0xD0, //CALL EAX |
0xFF,0x15,0x48,0xC0,0xA7,0x6F, //CALL DWORD PTR DS:[<&KERNEL32.FreeLibrar>; kernel32.FreeLibrary |
0x58, //POP EAX |
0xC2,0x04,0x00}; //RETN 4 |
//LPCSTR dllName = 'PlugY.dll'; |
LPCSTR initFctName = '_Init@4'; |
LPCSTR releaseFctName = '_Release@0'; |
staticbool versionXP; |
typedefint (__stdcall* tDebugActiveProcessStop)(DWORD); |
tDebugActiveProcessStop debugActiveProcessStop; |
voidassertion(LPCSTR msg) |
{ |
MessageBox(0, msg, 'PlugYRun', MB_OK|MB_ICONASTERISK); |
exit(1); |
} |
boolinstallPlugY(HANDLE h, DWORD addr, char* libraryName, int isAdd) |
{ |
BYTE buf[200]; |
DWORD pos=0; |
SIZE_T nb=0; |
DWORD version; |
int res; |
// Get Version and needed addresses. |
res = ReadProcessMemory(h,(LPVOID)(addr+0x110),&version,4,&nb);//0x80 |
if (!res || (nb!=4)) assertion('Read to get current d2gfx version in memory failed'); |
DWORD loadCallerAddr = addr; |
DWORD freeCallerAddr = addr; |
DWORD loadLibraryAddr = addr; |
DWORD freeLibraryAddr = addr; |
DWORD getProcAddressAddr = addr; |
// GET_VERSION(D2gfx, 110, 000054EB, 00001000, 0000C000, 42E6C22A, 43028B19);//110 |
switch (version) |
{ |
case0x000054EB://1.09b 0x00949FA8: |
case0x00001000://1.09d 0x018866A8: |
loadCallerAddr += 0x389B; |
freeCallerAddr += 0x3A8C; |
loadLibraryAddr += 0xC03C; |
freeLibraryAddr += 0xC044; |
getProcAddressAddr += 0xC038; |
break; |
case0x0000C000://1.10 0x401526B2 |
loadCallerAddr += 0x3870; |
freeCallerAddr += 0x3A6D; |
loadLibraryAddr += 0xC040; |
freeLibraryAddr += 0xC048; |
getProcAddressAddr += 0xC03C; |
break; |
case0x42E6C22A://1.11 0x575C8A5E |
loadCallerAddr += 0x8B23; |
freeCallerAddr += 0x8ACA; |
loadLibraryAddr += 0xD11C; |
freeLibraryAddr += 0xD12C; |
getProcAddressAddr += 0xD120; |
break; |
case0x43028B19://1.11b |
loadCallerAddr += 0xB423; |
freeCallerAddr += 0xB3CA; |
loadLibraryAddr += 0xD11C; |
freeLibraryAddr += 0xD12C; |
getProcAddressAddr += 0xD120; |
break; |
case0x0A07010B://1.12a |
loadCallerAddr += 0x8F63; |
freeCallerAddr += 0x8F0A; |
loadLibraryAddr += 0xD11C; |
freeLibraryAddr += 0xD12C; |
getProcAddressAddr += 0xD120; |
break; |
case0x00000000://1.13c |
loadCallerAddr += 0xB423; |
freeCallerAddr += 0xB3CA; |
loadLibraryAddr += 0xD11C; |
freeLibraryAddr += 0xD12C; |
getProcAddressAddr += 0xD120; |
break; |
default: |
assertion('Wrong version of the library D2gfx.dll'); |
} |
//Verify if memory are ok. |
bool alreadyInstalled = false; |
res = ReadProcessMemory(h,(LPVOID)loadCallerAddr,buf,6,&nb); |
if (!res || nb<6 ) assertion('Read memory failed for checking.'); |
if (buf[0]!=0xFF || buf[1]!=0x15 || *(DWORD*)(buf+2) != loadLibraryAddr) |
if (buf[0]!=0xE8/*|| buf[1]!=0xD8 || buf[2]!=0x19*/ || buf[3]!=0x00 || buf[4]!=0x00 || buf[5]!=0x90) |
assertion('Checking library memory check failed.'); |
else |
alreadyInstalled = true; |
res = ReadProcessMemory(h,(LPVOID)freeCallerAddr,buf,6,&nb); |
if (!res || nb<6 ) assertion('Read memory failed for checking.'); |
if (buf[0]!=0xFF || buf[1]!=0x15 || *(DWORD*)(buf+2) != freeLibraryAddr) |
if (buf[0]!=0xE8/*|| buf[1]!=0x75 || buf[2]!=0x1A*/ || buf[3]!=0x00 || buf[4]!=0x00 || buf[5]!=0x90) |
if (!alreadyInstalled) |
assertion('Checking library memory failed.'); |
if (alreadyInstalled) |
returntrue; |
//Alloc custom memory data. |
DWORD memory = (DWORD)VirtualAllocEx(h,NULL,200,MEM_COMMIT,PAGE_EXECUTE_READWRITE); |
DWORD oldProtect=-1; |
if (!memory) |
{ |
// MessageBox(0, 'no memory', 'RunPlugY.n', MB_OK|MB_ICONASTERISK); |
memory = addr + 0xBE00 + isAdd*0x1000; |
if( !VirtualProtectEx(h,(LPVOID)memory, 200, PAGE_EXECUTE_READWRITE, &oldProtect) ) |
assertion('Failed to get memory pool for PlugY loading.'); |
} |
//Make memory data |
int len; |
pos=0; |
//Dll name |
DWORD dllNameAddr = memory+pos; |
len = strlen(libraryName)+1; |
res = WriteProcessMemory(h,(LPVOID)dllNameAddr,libraryName,len,&nb); |
if (!res || (nb!=len)) assertion('Write custom data in memory failed'); |
pos += pos%16 ? len + 16 - pos%16 : len; |
//init name |
DWORD initNameAddr = memory+pos; |
len = strlen(initFctName)+1; |
res = WriteProcessMemory(h,(LPVOID)initNameAddr,initFctName,len,&nb); |
if (!res || (nb!=len)) assertion('Write custom data in memory failed'); |
pos += pos%16 ? len + 16 - pos%16 : len; |
//release name |
DWORD releaseNameAddr = memory+pos; |
len = strlen(releaseFctName)+1; |
res = WriteProcessMemory(h,(LPVOID)releaseNameAddr,releaseFctName,len,&nb); |
if (!res || (nb!=len)) assertion('Write custom data in memory failed'); |
pos += pos%16 ? len + 16 - pos%16 : len; |
//load fct |
DWORD loadDllAddr = memory+pos; |
DWORD handleAddr = loadDllAddr + sizeof(loadDll) - 4; |
*(DWORD*)&loadDll[6] = loadLibraryAddr; |
*(DWORD*)&loadDll[12] = dllNameAddr; |
*(DWORD*)&loadDll[18] = loadLibraryAddr; |
*(DWORD*)&loadDll[23] = handleAddr; |
*(DWORD*)&loadDll[33] = initNameAddr; |
*(DWORD*)&loadDll[40] = getProcAddressAddr; |
*(DWORD*)&loadDll[63] = getProcAddressAddr; |
*(DWORD*)&loadDll[80] = dllNameAddr; |
len = sizeof(loadDll); |
res = WriteProcessMemory(h,(LPVOID)loadDllAddr,loadDll,len,&nb); |
if (!res || (nb!=len)) assertion('Write custom data in memory failed'); |
pos += pos%16 ? len + 16 - pos%16 : len; |
//free fct |
DWORD freeDllAddr = memory+pos; |
*(DWORD*)&freeDll[6] = freeLibraryAddr; |
*(DWORD*)&freeDll[12] = handleAddr; |
*(DWORD*)&freeDll[22] = releaseNameAddr; |
// *(DWORD*)&freeDll[30] = handleAddr; |
*(DWORD*)&freeDll[36-7] = getProcAddressAddr; |
*(DWORD*)&freeDll[55-7] = getProcAddressAddr; |
*(DWORD*)&freeDll[67-7] = freeLibraryAddr; |
len = sizeof(freeDll); |
res = WriteProcessMemory(h,(LPVOID)freeDllAddr,freeDll,len,&nb); |
if (!res || (nb!=len)) assertion('Write custom data in memory failed'); |
pos += pos%16 ? len + 16 - pos%16 : len; |
//Patch load library |
buf[0]=0x90; |
buf[1]=0xE8; |
*(DWORD*)(buf+2) = (DWORD)loadDllAddr - (DWORD)loadCallerAddr-6; |
len = 6; |
res = WriteProcessMemory(h,(LPVOID)loadCallerAddr,buf,len,&nb); |
if (!res || (nb!=len)) assertion('Write load library in memory failed'); |
//Patch free library |
*(DWORD*)(buf+2) = (DWORD)freeDllAddr - (DWORD)freeCallerAddr-6; |
res = WriteProcessMemory(h,(LPVOID)freeCallerAddr,buf,len,&nb); |
if (!res || (nb!=len)) assertion('Write free library in memory failed'); |
// sprintf(tmp,'mem = %08X (read = %d)',buf[0],nbRead); |
// MessageBox(0, tmp, 'RunPlugY.n', MB_OK|MB_ICONASTERISK); |
// if (oldProtect != -1) |
// VirtualProtectEx(h,(LPVOID)memory, 200, oldProtect, &oldProtect); |
returntrue; |
} |
//###########################################################################################// |
/*bool copyLodVersionFiles() |
{ |
BYTE folder[MAX_PATH]; |
if (!GetPrivateProfileString(LAUNCHING,LOD_VERSION,',folder,MAX_PATH,INI_FILE)) |
return true; |
strcat(folder,'*'); |
WIN32_FIND_DATA FindFileData; |
HANDLE hFind = FindFirstFile(folder,&FindFileData); |
if (hFindINVALID_HANDLE_VALUE) |
return true; |
do { |
// CopyFile(); |
} while (FindNextFile(hFind,&FindFileData); |
FindClose(hFind); |
return true; |
}*/ |
#defineBUF_SIZE0x300 |
boolisD2gfx(HANDLE hProcess, LPVOID dllAdr) |
{ |
SIZE_T nbRead; |
BYTE buf[BUF_SIZE]; |
ReadProcessMemory(hProcess,dllAdr,buf,BUF_SIZE, &nbRead); |
if (nbRead < 0x40) returnfalse; |
int offsetPESignature = *(DWORD*)(buf+0x3C); |
if (offsetPESignature+38 >= BUF_SIZE) returnfalse; |
DWORD baseOfCode = *(DWORD*)(buf+offsetPESignature + 0x34); |
if ( ( baseOfCode != 0x6FA80000) && (baseOfCode != 0x6FA70000)) returnfalse; |
returntrue; |
} |
boolgetWinReg(char* buf, DWORD bufsize) |
{ |
HKEY hKey; |
DWORD type; |
int res; |
if (RegOpenKeyEx(HKEY_CURRENT_USER, SUBKEY, 0, KEY_READ, &hKey) ERROR_SUCCESS) { |
res = RegQueryValueEx(hKey,'InstallPath',NULL,&type,(LPBYTE)buf,&bufsize); |
RegCloseKey(hKey); |
if (res!=ERROR_SUCCESS) returnfalse; |
} elseif (RegOpenKeyEx(HKEY_LOCAL_MACHINE, SUBKEY, 0, KEY_READ, &hKey) ERROR_SUCCESS) { |
res = RegQueryValueEx(hKey,'InstallPath',NULL,&type,(LPBYTE)buf,&bufsize); |
RegCloseKey(hKey); |
if (res!=ERROR_SUCCESS) returnfalse; |
} else { |
returnfalse; |
} |
strcat(buf, GAMEFILE); |
if (GetFileAttributes(buf) INVALID_FILE_ATTRIBUTES) |
returnfalse; |
returntrue; |
} |
boollaunchNormal(char* command, char* currentDirectory) |
{ |
STARTUPINFO si; |
PROCESS_INFORMATION pi; |
ZeroMemory( &si, sizeof(si) ); |
si.cb = sizeof(si); |
ZeroMemory( &pi, sizeof(pi) ); |
BOOL success = CreateProcess(0, command, 0, 0, false, 0, 0, currentDirectory, &si, &pi);//DEBUG_ONLY_THIS_PROCESS |
return success?true:false; |
} |
boollaunchGame98(char* command, char* currentDirectory, char* libraryName) |
{ |
// MessageBox(0, 'LAUNCH 98', 'PlugYRun', MB_OK|MB_ICONASTERISK); |
STARTUPINFO si; |
PROCESS_INFORMATION pi; |
ZeroMemory( &si, sizeof(si) ); |
si.cb = sizeof(si); |
ZeroMemory( &pi, sizeof(pi) ); |
BOOL success = CreateProcess(0, command, 0, 0, false, 0, 0, currentDirectory, &si, &pi);//DEBUG_ONLY_THIS_PROCESS |
if (!success) returnfalse; |
DWORD ret; |
// MessageBox(0, 'LAUNCH 98 while', 'PlugYRun', MB_OK|MB_ICONASTERISK); |
Sleep(10); |
while (true) |
{ |
SuspendThread(pi.hThread);// (DWORD)-1) |
//MessageBox(0, 'Thread not suspended', 'PlugYRun', MB_OK|MB_ICONASTERISK); |
if (!GetExitCodeProcess(pi.hProcess,&ret) || (ret != STILL_ACTIVE)) |
exit(0); |
if (isD2gfx(pi.hProcess,(LPVOID)0x6FA80000)) |
{ |
// MessageBox(0, 'INSTALL 98', 'PlugYRun', MB_OK|MB_ICONASTERISK); |
installPlugY(pi.hProcess, 0x6FA80000, libraryName, 1); |
ResumeThread(pi.hThread); |
returntrue; |
} |
if (isD2gfx(pi.hProcess,(LPVOID)0x6FA70000)) |
{ |
// MessageBox(0, 'INSTALL 98', 'PlugYRun', MB_OK|MB_ICONASTERISK); |
installPlugY(pi.hProcess, 0x6FA70000, libraryName, 0); |
ResumeThread(pi.hThread); |
returntrue; |
} |
ResumeThread(pi.hThread); |
// Sleep(10); |
} |
returntrue; |
} |
boollaunchGameXP(char* command, char* currentDirectory, char* libraryName) |
{ |
// MessageBox(0, 'LAUNCH XP', 'PlugYRun', MB_OK|MB_ICONASTERISK); |
STARTUPINFO si; |
PROCESS_INFORMATION pi; |
ZeroMemory( &si, sizeof(si) ); |
si.cb = sizeof(si); |
ZeroMemory( &pi, sizeof(pi) ); |
BOOL success = CreateProcess(0, command, 0, 0, false, DEBUG_PROCESS, 0, currentDirectory, &si, &pi);//DEBUG_ONLY_THIS_PROCESS |
if (!success) returnfalse; |
DEBUG_EVENT DebugEvent; |
DWORD status; |
// MessageBox(0, 'START WAITING', 'PlugYRun', MB_OK|MB_ICONASTERISK); |
while (WaitForDebugEvent(&DebugEvent,INFINITE)) |
{ |
status = DBG_CONTINUE; |
switch(DebugEvent.dwDebugEventCode) |
{ |
case CREATE_THREAD_DEBUG_EVENT: |
CloseHandle(DebugEvent.u.CreateThread.hThread); |
break; |
case CREATE_PROCESS_DEBUG_EVENT: |
break; |
case EXIT_PROCESS_DEBUG_EVENT: |
// MessageBox(0, 'EXIT', 'PlugY', MB_OK|MB_ICONASTERISK); |
exit(0); |
case EXCEPTION_DEBUG_EVENT: |
if (DebugEvent.u.Exception.ExceptionRecord.ExceptionCode EXCEPTION_ACCESS_VIOLATION) |
MessageBox(0, 'EXCEPTION_ACCESS_VIOLATION', 'PlugY', MB_OK|MB_ICONASTERISK); |
// status = DBG_EXCEPTION_NOT_HANDLED; |
break; |
case LOAD_DLL_DEBUG_EVENT: |
// if (!GetModuleBaseName(pi.hProcess,(HMODULE)DebugEvent.u.LoadDll.lpBaseOfDll,buf,100)) |
// MessageBox(0, 'ERROR', 'PlugYRun', MB_OK|MB_ICONASTERISK); |
// sprintf(buf,'%08X : %d',DebugEvent.u.LoadDll.lpBaseOfDll,GetLastError()); |
// MessageBox(0, buf, 'PlugYRun', MB_OK|MB_ICONASTERISK); |
// if (!strcmp(buf,'d2gfx.dll')) |
// if ((LPVOID)GetModuleHandle('D2gfx.dll') DebugEvent.u.LoadDll.lpBaseOfDll)//pi.hProcess,buf,bufSize); |
if(isD2gfx(pi.hProcess, DebugEvent.u.LoadDll.lpBaseOfDll)) |
{ |
// MessageBox(0, 'INSTALL XP', 'PlugYRun', MB_OK|MB_ICONASTERISK); |
installPlugY(pi.hProcess, (DWORD)DebugEvent.u.LoadDll.lpBaseOfDll, libraryName, (DWORD)DebugEvent.u.LoadDll.lpBaseOfDll0x6FA8000); |
CloseHandle(DebugEvent.u.LoadDll.hFile); |
CloseHandle(pi.hProcess); |
CloseHandle(pi.hThread); |
debugActiveProcessStop(DebugEvent.dwProcessId); |
// MessageBox(0, 'INSTALL XP end', 'PlugYRun', MB_OK|MB_ICONASTERISK); |
returntrue; |
} else |
CloseHandle(DebugEvent.u.LoadDll.hFile); |
break; |
} |
ContinueDebugEvent(DebugEvent.dwProcessId,DebugEvent.dwThreadId,status); |
} |
MessageBox(0, 'ERROR : PlugY isn't installed', 'PlugYRun', MB_OK|MB_ICONASTERISK); |
returntrue; |
} |
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) |
{ |
char currrentDirectory[MAX_PATH]; |
char iniFileName[MAX_PATH]; |
char command[MAX_PATH+50]; |
// MessageBox(NULL,'START','PlugYRun',MB_OK); |
//Get Current Directory. |
if (!GetCurrentDirectory(MAX_PATH-1,currrentDirectory)) |
assertion('Current directory not found'); |
int len = strlen(currrentDirectory); |
if (len && currrentDirectory[len-1] != '') |
{ |
currrentDirectory[len+1]=NULL; |
currrentDirectory[len]=''; |
} |
//Get ini full path name. |
strcpy(iniFileName,currrentDirectory); |
strcat(iniFileName,INIFILE); |
//Get current directory. |
strcpy(command,currrentDirectory); |
strcat(command,GAMEFILE); |
if (GetFileAttributes(command) INVALID_FILE_ATTRIBUTES) |
if (!getWinReg(command, MAX_PATH+50)) |
return1; |
//Add params. |
strcat(command,lpCmdLine); |
len = strlen(command); |
GetPrivateProfileString(LAUNCHING,PARAM,'',&command[len],MAX_PATH-len,iniFileName); |
//copyLodVersionFiles(); |
char libraryName[50]; |
if (!GetPrivateProfileString(LAUNCHING,LIBRARY_NAME,'',libraryName,50,iniFileName) || !libraryName[0]) |
return !launchNormal(command, currrentDirectory); |
// MessageBox(NULL,command,'PlugYRun',MB_OK); |
HMODULE module = GetModuleHandle('Kernel32.dll'); |
if (module) |
{ |
debugActiveProcessStop = (tDebugActiveProcessStop) GetProcAddress(module,'DebugActiveProcessStop'); |
if (debugActiveProcessStop) |
return !launchGameXP(command, currrentDirectory, libraryName); |
} |
return !launchGame98(command, currrentDirectory, libraryName); |
} |
/* else if (GetVersion() & 0x80000000) |
{ |
versionXP=false; |
} else { |
versionXP=true; |
}*/ |
//HINSTANCE |
// CreateProcessInternalA |
// HMODULE HPlugY = LoadLibrary('C:JeuxDiablo IIPlugY.dll'); |
// if (!HPlugY) return 0; |
// DuplicateHandle |
// GetCurrentProcess(); |
/* typedef void* (__stdcall* Tinit)(LPSTR IniName); |
Tinit init = (Tinit)GetProcAddress(HPlugY,'_Init@4'); |
if (!init) return 0; |
init(0);*/ |
/* |
6FC2BD50 /$ 81EC 08010000 SUB ESP,108 |
6FC2BD56 |. 53 PUSH EBX |
6FC2BD57 |. 8A9C24 1801000>MOV BL,BYTE PTR SS:[ESP+118] |
6FC2BD5E |. F6C3 10 TEST BL,10 |
6FC2BD61 |. 55 PUSH EBP |
6FC2BD62 |. 56 PUSH ESI |
6FC2BD63 |. C707 00000000 MOV DWORD PTR DS:[EDI],0 |
6FC2BD69 |. C74424 0C 0000>MOV DWORD PTR SS:[ESP+C],0 |
6FC2BD71 |. BE F3030000 MOV ESI,3F3 |
6FC2BD76 |. C64424 10 00 MOV BYTE PTR SS:[ESP+10],0 |
6FC2BD7B |. 75 25 JNZ SHORT storm.6FC2BDA2 |
6FC2BD7D |. F6C3 02 TEST BL,2 |
6FC2BD80 |. 68 04010000 PUSH 104 |
6FC2BD85 |. 74 0C JE SHORT storm.6FC2BD93 |
6FC2BD87 |. 68 146AC36F PUSH storm.6FC36A14 ; ASCII 'SoftwareBattle.net' |
6FC2BD8C |. 8D4424 18 LEA EAX,DWORD PTR SS:[ESP+18] |
6FC2BD90 |. 50 PUSH EAX |
6FC2BD91 |. EB 0A JMP SHORT storm.6FC2BD9D |
6FC2BD93 |> 68 F069C36F PUSH storm.6FC369F0 ; ASCII 'SoftwareBlizzard Entertainment' |
6FC2BD98 |. 8D4C24 18 LEA ECX,DWORD PTR SS:[ESP+18] |
6FC2BD9C |. 51 PUSH ECX |
6FC2BD9D |> E8 EE07FEFF CALL storm.#501 |
6FC2BDA2 |> 8B9424 1801000>MOV EDX,DWORD PTR SS:[ESP+118] |
6FC2BDA9 |. 68 04010000 PUSH 104 |
6FC2BDAE |. 52 PUSH EDX |
6FC2BDAF |. 8D4424 18 LEA EAX,DWORD PTR SS:[ESP+18] |
6FC2BDB3 |. 50 PUSH EAX |
6FC2BDB4 |. E8 6705FEFF CALL storm.#503 |
6FC2BDB9 |. F6C3 04 TEST BL,4 |
6FC2BDBC |. 8B2D 1030C36F MOV EBP,DWORD PTR DS:[<&ADVAPI32.RegQuer>; advapi32.RegQueryValueExA |
6FC2BDC2 |. 75 5D JNZ SHORT storm.6FC2BE21 |
6FC2BDC4 |. 8D4C24 0C LEA ECX,DWORD PTR SS:[ESP+C] |
6FC2BDC8 |. 51 PUSH ECX ; /pHandle |
6FC2BDC9 |. 68 19000200 PUSH 20019 ; |Access = KEY_READ |
6FC2BDCE |. 6A 00 PUSH 0 ; |Reserved = 0 |
6FC2BDD0 |. 8D5424 1C LEA EDX,DWORD PTR SS:[ESP+1C] ; | |
6FC2BDD4 |. 52 PUSH EDX ; |Subkey |
6FC2BDD5 |. 68 01000080 PUSH 80000001 ; |hKey = HKEY_CURRENT_USER |
6FC2BDDA |. FF15 0830C36F CALL DWORD PTR DS:[<&ADVAPI32.RegOpenKey>; RegOpenKeyExA |
002281A4 80000001 |hKey = HKEY_CURRENT_USER |
002281A8 002281C8 |Subkey = 'SoftwareBlizzard EntertainmentDiablo II' |
002281AC 00000000 |Reserved = 0 |
002281B0 00020019 |Access = KEY_READ |
002281B4 002281C4 pHandle = 002281C4 |
6FC2BDE0 |. 8BF0 MOV ESI,EAX |
6FC2BDE2 |. 85F6 TEST ESI,ESI |
6FC2BDE4 |. 75 3B JNZ SHORT storm.6FC2BE21 |
6FC2BDE6 |. 8B8C24 2801000>MOV ECX,DWORD PTR SS:[ESP+128] |
6FC2BDED |. 8B9424 2401000>MOV EDX,DWORD PTR SS:[ESP+124] |
6FC2BDF4 |. 8B8424 2C01000>MOV EAX,DWORD PTR SS:[ESP+12C] |
6FC2BDFB |. 57 PUSH EDI ; /pBufSize |
6FC2BDFC |. 51 PUSH ECX ; |Buffer |
6FC2BDFD |. 8B4C24 14 MOV ECX,DWORD PTR SS:[ESP+14] ; | |
6FC2BE01 |. 52 PUSH EDX ; |pValueType |
6FC2BE02 |. 8907 MOV DWORD PTR DS:[EDI],EAX ; | |
6FC2BE04 |. 8B8424 2801000>MOV EAX,DWORD PTR SS:[ESP+128] ; | |
6FC2BE0B |. 56 PUSH ESI ; |Reserved |
6FC2BE0C |. 50 PUSH EAX ; |ValueName |
6FC2BE0D |. 51 PUSH ECX ; |hKey |
6FC2BE0E |. FFD5 CALL EBP ; RegQueryValueExA |
002281A0 00000124 |hKey = 124 |
002281A4 6FF77B88 |ValueName = 'InstallPath' |
002281A8 00000000 |Reserved = NULL |
002281AC 002282FC |pValueType = 002282FC |
002281B0 00228320 |Buffer = 00228320 |
002281B4 00228300 pBufSize = 00228300 |
6FC2BE10 |. 8B5424 0C MOV EDX,DWORD PTR SS:[ESP+C] |
6FC2BE14 |. 52 PUSH EDX ; /hKey |
6FC2BE15 |. 8BF0 MOV ESI,EAX ; | |
6FC2BE17 |. FF15 1830C36F CALL DWORD PTR DS:[<&ADVAPI32.RegCloseKe>; RegCloseKey |
002281B4 00000124 hKey = 00000124 (window) |
6FC2BE1D |. 85F6 TEST ESI,ESI |
6FC2BE1F |. 74 62 JE SHORT storm.6FC2BE83 |
6FC2BE21 |> F6C3 01 TEST BL,1 |
6FC2BE24 |. 75 59 JNZ SHORT storm.6FC2BE7F |
6FC2BE26 |. 8D4424 0C LEA EAX,DWORD PTR SS:[ESP+C] |
6FC2BE2A |. 50 PUSH EAX ; /pHandle |
6FC2BE2B |. 68 19000200 PUSH 20019 ; |Access = KEY_READ |
6FC2BE30 |. 6A 00 PUSH 0 ; |Reserved = 0 |
6FC2BE32 |. 8D4C24 1C LEA ECX,DWORD PTR SS:[ESP+1C] ; | |
6FC2BE36 |. 51 PUSH ECX ; |Subkey |
6FC2BE37 |. 68 02000080 PUSH 80000002 ; |hKey = HKEY_LOCAL_MACHINE |
6FC2BE3C |. FF15 0830C36F CALL DWORD PTR DS:[<&ADVAPI32.RegOpenKey>; RegOpenKeyExA |
6FC2BE42 |. 8BF0 MOV ESI,EAX |
6FC2BE44 |. 85F6 TEST ESI,ESI |
6FC2BE46 |. 75 4C JNZ SHORT storm.6FC2BE94 |
6FC2BE48 |. 8B8424 2801000>MOV EAX,DWORD PTR SS:[ESP+128] |
6FC2BE4F |. 8B8C24 2401000>MOV ECX,DWORD PTR SS:[ESP+124] |
6FC2BE56 |. 8B9424 2C01000>MOV EDX,DWORD PTR SS:[ESP+12C] |
6FC2BE5D |. 57 PUSH EDI |
6FC2BE5E |. 50 PUSH EAX |
6FC2BE5F |. 8B4424 14 MOV EAX,DWORD PTR SS:[ESP+14] |
6FC2BE63 |. 51 PUSH ECX |
6FC2BE64 |. 8917 MOV DWORD PTR DS:[EDI],EDX |
6FC2BE66 |. 8B9424 2801000>MOV EDX,DWORD PTR SS:[ESP+128] |
6FC2BE6D |. 56 PUSH ESI |
6FC2BE6E |. 52 PUSH EDX |
6FC2BE6F |. 50 PUSH EAX |
6FC2BE70 |. FFD5 CALL EBP |
6FC2BE72 |. 8B4C24 0C MOV ECX,DWORD PTR SS:[ESP+C] |
6FC2BE76 |. 51 PUSH ECX ; /hKey |
6FC2BE77 |. 8BF0 MOV ESI,EAX ; | |
6FC2BE79 |. FF15 1830C36F CALL DWORD PTR DS:[<&ADVAPI32.RegCloseKe>; RegCloseKey |
6FC2BE7F |> 85F6 TEST ESI,ESI |
6FC2BE81 |. 75 11 JNZ SHORT storm.6FC2BE94 |
6FC2BE83 |> 5E POP ESI |
6FC2BE84 |. 5D POP EBP |
6FC2BE85 |. B8 01000000 MOV EAX,1 |
6FC2BE8A |. 5B POP EBX |
6FC2BE8B |. 81C4 08010000 ADD ESP,108 |
6FC2BE91 |. C2 1800 RETN 18 |
6FC2BE94 |> 56 PUSH ESI ; /Error |
6FC2BE95 |. FF15 2832C36F CALL DWORD PTR DS:[<&KERNEL32.SetLastErr>; SetLastError |
6FC2BE9B |. 5E POP ESI |
6FC2BE9C |. 5D POP EBP |
6FC2BE9D |. 33C0 XOR EAX,EAX |
6FC2BE9F |. 5B POP EBX |
6FC2BEA0 |. 81C4 08010000 ADD ESP,108 |
6FC2BEA6 . C2 1800 RETN 18 |
*/ |
///////////////////////// END OF FILE /////////////////////// |
Copy lines Copy permalink
Just recently I switched the language of my project to use C++ from C.With C, I used malloc and after that I check if malloc was successful but with C++, I use 'new' to allocate memory and I would like to know how you would normally check the memory allocation failure.
From my google search, I saw nothrow like the following.
I also saw the following.
But what about the following? I am using some of chrome library routines to use smart pointers.
For instance, I have the code as follows.
It is great to use smart pointers but I am just not sure how I should check if the memory allocation was successful. Do I need to break into two separate statement with nothrow or try/catch?How do you normally do these checks in C++?
Any advice will be appreciated.
gsamaras53.7k27 gold badges113 silver badges202 bronze badges
istudy0istudy08485 gold badges12 silver badges20 bronze badges
4 Answers
Well, you call new that throws
bad_alloc
, so you must catch it:or
What I mean by my answer is that smart pointers propagate exceptions. So if you're allocating memory with ordinary throwing new, you must catch an exception. If you're allocating with a nothrow new, then you must check for
gsamarasnullptr
. In any case, smart pointers don't add anything to this logic53.7k27 gold badges113 silver badges202 bronze badges
Armen TsirunyanArmen Tsirunyan95k45 gold badges280 silver badges392 bronze badges
I hate to say it, but IMO, you're going in the wrong direction (and, unfortunately, the other answers you've gotten haven't really pointed you in the right direction either).
Rather than choosing between different varieties of smart pointer and/or normal vs. nothrow variants of
new
, you should probably take at least two more steps back from what you're doing, and replace your manually-managed dynamic data structures with collections. This may not always be the right choice, but at least in my experience, it's the right way to go a lot more often than not. The standard library has a number of possibilities (vector, deque, list, set, etc.), and chances are pretty good that you can use one of them rather than dealing directly with new
and company at all.By default, those will use an allocator that ends up using the normal (throwing) variant of
new
. You, therefore, normally want to put most code in a try
block at a fairly high level, and have a catch
clause that deals with having run out of memory there.When/if you do need to deal with allocating memory directly, chances are pretty good that you still want to provide an interface similar to that of the standard containers in the library so it'll work with the normal algorithms and iterators. Your initial experience using the existing containers will pay of well when you get to this point, even though it may be a ways down the road.
Jerry CoffinJerry Coffin395k57 gold badges490 silver badges933 bronze badges
In C++ there are 2 primary ways in which
new
allocates memory and each requires different error checking.The standard
new
operator will throw a std::bad_alloc
exception on failure and this can be handled like a normal exceptionOr alternative the
nothrow
version of new
will simply return NULL
on failureI'm curious though as to what you expect to do when the allocation fails? If there is no memory available to allocate your object, there's often very little which can be done in the process.
JaredParJaredPar593k124 gold badges1096 silver badges1362 bronze badges
You'll still need to check for a memory allocation failure.
Plugy Checking Memory Library Failed Iphone
Either
Or
PraetorianPraetorianPlugy Checking Memory Library Failed Iphone
89.5k11 gold badges195 silver badges280 bronze badges