Click here to Skip to main content
16,011,988 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to Sleep a Thread? Pin
BobJanova8-Nov-11 23:19
BobJanova8-Nov-11 23:19 
QuestionWhat am I doing wrong? Pin
Member 83630848-Nov-11 15:33
Member 83630848-Nov-11 15:33 
AnswerRe: What am I doing wrong? Pin
Hum Dum8-Nov-11 17:09
Hum Dum8-Nov-11 17:09 
AnswerRe: What am I doing wrong? Pin
RobCroll8-Nov-11 17:09
RobCroll8-Nov-11 17:09 
QuestionAce OLE driver with Extended Properties Pin
Alaric_8-Nov-11 10:18
professionalAlaric_8-Nov-11 10:18 
AnswerRe: Ace OLE driver with Extended Properties Pin
Dave Kreskowiak8-Nov-11 13:28
mveDave Kreskowiak8-Nov-11 13:28 
GeneralRe: Ace OLE driver with Extended Properties Pin
Alaric_15-Nov-11 9:59
professionalAlaric_15-Nov-11 9:59 
QuestionRemoving Mutex and file lock using DLL injection (Guild Wars) in C# Pin
KairuByte8-Nov-11 8:06
KairuByte8-Nov-11 8:06 
Update 1

CreateFile hooking now works, but only when I suspend the state of the program when it is started, hook the process and then resume the process. I need to be able to do this when a process is opened without interacting with my program. (Meaning I am not able to start it suspended, I need a way to hook the process start or something.) It has been suggested to use Drivers... I'm all ears!

Next issue, when I hook an already running process, I need to be able to determine the file handle linked to gw.dat, and reopen the file to that same handle using ReOpenFile and new share peramaters. Are there any ideas on how to do this? I am not familiar with doing something like this, much less in an unmanaged environment....

Related Questions:
WIN32 API override (Specifically CreateFile) in C# [Solved and very helpful]
How to tell what method opens a file [Solved and not helpful]
Suspend specific process on launch C# [Not Solved, hoping for easier answer...]
Run code inside process with EasyHook
Change a handle in unmanaged code without pre-existing knowledge of process internals [From injected DLL]


Original

Note: I figured I would post this here to get input, and in case anyone tries something similar in the future.

Before you read any further please understand that I do not intend to go any farther then allowing the client to be run more then once. The only advantage will be the same as having two computers next to each other.

I am using C# with EasyHook.

Background: Guild Wars is an MMORPG, for the most part there are mainly only two files. gw.exe which is less then a MB is executed, opens gw.dat (With exclusive rights), checks for updates, loads the rest of the game from gw.dat. gw.dat just holds everything else.

gw.exe makes sure it is not running already when it first starts, and if it is it will just force the prior process to the foreground. If you remove the mutex you cannot properly open a second gw.exe because the first has exclusive rights to the one and only gw.dat.

Yes, it is possible to remove the mutex and run multiple gw.exe processes pointing to different gw.dat files with some registry changes but the gw.dat gets over 4GB and it is just annoying.

Possible Solution: Trough looking around I have put together a DLL, and can successfully inject it into the gw.exe process using EasyHook. I can hook methods of other DLL's, and can interface with the injecting program. Originally it had been suggested I hook CreateFileW and change the call so it does not force exclusivity to the file. It turns out that either I hook the process too late for CreateFileW is not the function used to connect to the file. (Figured this out)

It was also suggested that I could call ReOpenFileW to change current handles to gw.dat to share mode. I can't seem to be able to run anything that isn't inside a hook so I can't call ReOpenFileW. (Though I can hook it)

Intended Result: Basically, what I intend to achieve is injecting a DLL into gw.exe, forcing it to remove a file lock, and remove the mutex (mutex can be done externally but I figure while I'm in there why not?)

Are there any ideas? Alternative solutions?

I have been working on this easyhook solution for a few days now, but in all honesty if it is doomed, or there is an easier way to do this I am all ears!

Quick Note: While doing something like this is against the EULA of the game, there has never been a problem with it in the past and there have been no bannings for this specific type of modification!

Also, if you want to try your hand at doing this or want a first hand look at what is being done by gw.exe (I tried to understand the assembly but I never learned that art....) The gw.exe can be downloaded here, and can be run without an account. You just can't play the game. If needed I can upload my current source! I'll have to clean it up a bit though....

modified 9-Nov-11 22:19pm.

GeneralRe: Removing Mutex and file lock using DLL injection (Guild Wars) in C# Pin
harold aptroot8-Nov-11 8:37
harold aptroot8-Nov-11 8:37 
GeneralRe: Removing Mutex and file lock using DLL injection (Guild Wars) in C# Pin
KairuByte8-Nov-11 8:50
KairuByte8-Nov-11 8:50 
GeneralRe: Removing Mutex and file lock using DLL injection (Guild Wars) in C# Pin
harold aptroot8-Nov-11 9:01
harold aptroot8-Nov-11 9:01 
GeneralRe: Removing Mutex and file lock using DLL injection (Guild Wars) in C# Pin
KairuByte8-Nov-11 9:06
KairuByte8-Nov-11 9:06 
GeneralRe: Removing Mutex and file lock using DLL injection (Guild Wars) in C# Pin
harold aptroot8-Nov-11 9:10
harold aptroot8-Nov-11 9:10 
GeneralRe: Removing Mutex and file lock using DLL injection (Guild Wars) in C# Pin
KairuByte8-Nov-11 9:16
KairuByte8-Nov-11 9:16 
GeneralRe: Removing Mutex and file lock using DLL injection (Guild Wars) in C# Pin
harold aptroot8-Nov-11 9:20
harold aptroot8-Nov-11 9:20 
GeneralRe: Removing Mutex and file lock using DLL injection (Guild Wars) in C# Pin
KairuByte8-Nov-11 9:26
KairuByte8-Nov-11 9:26 
GeneralRe: Removing Mutex and file lock using DLL injection (Guild Wars) in C# Pin
harold aptroot8-Nov-11 9:36
harold aptroot8-Nov-11 9:36 
GeneralRe: Removing Mutex and file lock using DLL injection (Guild Wars) in C# Pin
KairuByte8-Nov-11 9:40
KairuByte8-Nov-11 9:40 
GeneralRe: Removing Mutex and file lock using DLL injection (Guild Wars) in C# Pin
harold aptroot8-Nov-11 9:45
harold aptroot8-Nov-11 9:45 
GeneralRe: Removing Mutex and file lock using DLL injection (Guild Wars) in C# Pin
Dave Kreskowiak8-Nov-11 13:23
mveDave Kreskowiak8-Nov-11 13:23 
GeneralRe: Removing Mutex and file lock using DLL injection (Guild Wars) in C# Pin
KairuByte8-Nov-11 14:20
KairuByte8-Nov-11 14:20 
AnswerRe: Removing Mutex and file lock using DLL injection (Guild Wars) in C# Pin
djdanlib8-Nov-11 9:05
djdanlib8-Nov-11 9:05 
GeneralRe: Removing Mutex and file lock using DLL injection (Guild Wars) in C# Pin
KairuByte8-Nov-11 9:13
KairuByte8-Nov-11 9:13 
GeneralRe: Removing Mutex and file lock using DLL injection (Guild Wars) in C# Pin
jschell8-Nov-11 10:08
jschell8-Nov-11 10:08 
GeneralRe: Removing Mutex and file lock using DLL injection (Guild Wars) in C# Pin
KairuByte8-Nov-11 10:19
KairuByte8-Nov-11 10:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.