DBG: added the savedata command to dump memory to disk (related to issue #389).
This commit is contained in:
		
							parent
							
								
									9674967f73
								
							
						
					
					
						commit
						a2082e4586
					
				|  | @ -2292,5 +2292,34 @@ CMDRESULT cbInstrSetMaxFindResult(int argc, char* argv[]) | |||
|         return STATUS_ERROR; | ||||
|     } | ||||
|     maxFindResults = int(num & 0x7FFFFFFF); | ||||
|     return STATUS_CONTINUE; | ||||
| } | ||||
| 
 | ||||
| CMDRESULT cbInstrSavedata(int argc, char* argv[]) | ||||
| { | ||||
|     if (argc < 3) //savedata filename,addr,size
 | ||||
|     { | ||||
|         dputs("Not enough arguments..."); | ||||
|         return STATUS_ERROR; | ||||
|     } | ||||
|     duint addr, size; | ||||
|     if (!valfromstring(argv[2], &addr, false) || !valfromstring(argv[3], &size, false)) | ||||
|         return STATUS_ERROR; | ||||
| 
 | ||||
|     Memory<unsigned char*> data(size); | ||||
|     if (!MemRead(addr, data(), data.size())) | ||||
|     { | ||||
|         dputs("Failed to read memory..."); | ||||
|         return STATUS_ERROR; | ||||
|     } | ||||
| 
 | ||||
|     if(!FileHelper::WriteAllData(argv[1], data(), data.size())) | ||||
|     { | ||||
|         dputs("Failed to write file..."); | ||||
|         return STATUS_ERROR; | ||||
|     } | ||||
| 
 | ||||
|     dprintf("%p[% " fext "X] written to \"%s\" !\n", addr, size, argv[1]); | ||||
| 
 | ||||
|     return STATUS_CONTINUE; | ||||
| } | ||||
|  | @ -77,5 +77,6 @@ CMDRESULT cbInstrCfanalyse(int argc, char* argv[]); | |||
| CMDRESULT cbInstrExanalyse(int argc, char* argv[]); | ||||
| CMDRESULT cbInstrVirtualmod(int argc, char* argv[]); | ||||
| CMDRESULT cbInstrSetMaxFindResult(int argc, char* argv[]); | ||||
| CMDRESULT cbInstrSavedata(int argc, char* argv[]); | ||||
| 
 | ||||
| #endif // _INSTRUCTIONS_H
 | ||||
|  |  | |||
|  | @ -212,6 +212,7 @@ static void registercommands() | |||
|     dbgcmdnew("virtualmod", cbInstrVirtualmod, true); //virtual module
 | ||||
|     dbgcmdnew("findallmem\1findmemall", cbInstrFindMemAll, true); //memory map pattern find
 | ||||
|     dbgcmdnew("setmaxfindresult\1findsetmaxresult", cbInstrSetMaxFindResult, false); //set the maximum number of occurences found
 | ||||
|     dbgcmdnew("savedata", cbInstrSavedata, true); //save data to disk
 | ||||
| } | ||||
| 
 | ||||
| static bool cbCommandProvider(char* cmd, int maxlen) | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue